mirror of
https://github.com/MapMakersAndProgrammers/alternativa-editor-mod.git
synced 2025-10-26 01:49:05 -07:00
a3d integration done, works from 1st attempt :D
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -793,19 +793,19 @@
|
||||
width="130"/>
|
||||
</mx:ControlBar>
|
||||
|
||||
<mx:HDividedBox percentWidth="100" percentHeight="100" y="26">
|
||||
<mx:HDividedBox percentWidth="100" percentHeight="100" y="26" backgroundAlpha="0">
|
||||
<!-- Left VBox Section -->
|
||||
<mx:VBox id="vbox" percentWidth="100" percentHeight="100">
|
||||
<mx:HDividedBox percentWidth="100" percentHeight="100">
|
||||
<mx:Panel id="workspace" title="Workspace" percentWidth="100" percentHeight="100" layout="absolute" horizontalScrollPolicy="off">
|
||||
<mx:VBox id="vbox" percentWidth="100" percentHeight="100" backgroundAlpha="0">
|
||||
<mx:HDividedBox percentWidth="100" percentHeight="100" backgroundAlpha="0">
|
||||
<mx:Panel id="workspace" title="Workspace" percentWidth="100" percentHeight="100" layout="absolute" horizontalScrollPolicy="off" backgroundAlpha="0">
|
||||
<local1:SceneContainer id="sceneContainer" percentWidth="100" percentHeight="100"/>
|
||||
</mx:Panel>
|
||||
</mx:HDividedBox>
|
||||
</mx:VBox>
|
||||
|
||||
<!-- Right VDividedBox Section -->
|
||||
<mx:VDividedBox width="300" percentHeight="100">
|
||||
<mx:Panel id="previewPanel" title="Preview" percentWidth="100" height="300"/>
|
||||
<mx:VDividedBox width="300" percentHeight="100" backgroundAlpha="0">
|
||||
<mx:Panel id="previewPanel" title="Preview" percentWidth="100" height="300" backgroundAlpha="0"/>
|
||||
|
||||
<mx:VBox percentWidth="100" percentHeight="100">
|
||||
<mx:ComboBox id="cbPropLibNames" change="onComboBoxChange(event);" percentWidth="100"/>
|
||||
|
||||
14
src/alternativa/Alternativa3D.as
Normal file
14
src/alternativa/Alternativa3D.as
Normal file
@@ -0,0 +1,14 @@
|
||||
package alternativa
|
||||
{
|
||||
public class Alternativa3D
|
||||
{
|
||||
|
||||
public static const version:String = "7.11.mod";
|
||||
|
||||
|
||||
public function Alternativa3D()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ package alternativa.editor
|
||||
import alternativa.editor.propslib.PropGroup;
|
||||
import alternativa.editor.propslib.PropLibObject;
|
||||
import alternativa.editor.propslib.PropsLibrary;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Vertex;
|
||||
import alternativa.engine3d.loaders.Parser3DS;
|
||||
@@ -16,6 +16,7 @@ package alternativa.editor
|
||||
import flash.geom.Point;
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.Dictionary;
|
||||
import alternativa.engine3d.primitives.Box;
|
||||
|
||||
public class FunctionalProps
|
||||
{
|
||||
@@ -163,14 +164,14 @@ package alternativa.editor
|
||||
private static function getColoredPropObject(param1:String, param2:ByteArray, param3:uint) : PropLibObject
|
||||
{
|
||||
var loc4:Mesh = parse3DS(param2);
|
||||
loc4.cloneMaterialToAllSurfaces(new TextureMaterial(getMonochromeTexture(param3)));
|
||||
loc4.setMaterialToAllFaces(new TextureMaterial(getMonochromeTexture(param3)));
|
||||
return new PropLibObject(param1,loc4);
|
||||
}
|
||||
|
||||
private static function getTexturedPropObject(param1:String, param2:ByteArray, param3:BitmapData) : PropLibObject
|
||||
{
|
||||
var loc4:Mesh = parse3DS(param2);
|
||||
loc4.cloneMaterialToAllSurfaces(new TextureMaterial(new Texture(param3)));
|
||||
loc4.setMaterialToAllFaces(new TextureMaterial(param3));
|
||||
return new PropLibObject(param1,loc4);
|
||||
}
|
||||
|
||||
@@ -178,19 +179,19 @@ package alternativa.editor
|
||||
{
|
||||
var loc2:Parser3DS = new Parser3DS();
|
||||
loc2.parse(param1);
|
||||
var loc3:Mesh = loc2.content.children.peek() as Mesh;
|
||||
var loc3:Mesh = loc2.objects[0] as Mesh;
|
||||
loc3.x = 0;
|
||||
loc3.y = 0;
|
||||
loc3.z = 0;
|
||||
return loc3;
|
||||
}
|
||||
|
||||
private static function getMonochromeTexture(param1:uint) : Texture
|
||||
private static function getMonochromeTexture(param1:uint) : BitmapData
|
||||
{
|
||||
var loc2:Texture = textures[param1];
|
||||
var loc2:BitmapData = textures[param1];
|
||||
if(loc2 == null)
|
||||
{
|
||||
loc2 = new Texture(new BitmapData(1,1,false,param1));
|
||||
loc2 = new BitmapData(1,1,false,param1);
|
||||
textures[param1] = loc2;
|
||||
}
|
||||
return loc2;
|
||||
@@ -208,7 +209,7 @@ package alternativa.editor
|
||||
|
||||
private static function createDominationPoint() : Object3D
|
||||
{
|
||||
var loc1:Mesh = new Mesh();
|
||||
/*var loc1:Mesh = new Mesh();
|
||||
var loc4:Vertex = loc1.createVertex(-50,-50,0);
|
||||
var loc5:Vertex = loc1.createVertex(50,-50,0);
|
||||
var loc6:Vertex = loc1.createVertex(50,50,0);
|
||||
@@ -223,8 +224,9 @@ package alternativa.editor
|
||||
loc1.setUVsToFace(new Point(0,0),new Point(1,0),new Point(1,1),loc1.createFace([loc5,loc6,loc10,loc9]));
|
||||
loc1.setUVsToFace(new Point(0,0),new Point(1,0),new Point(1,1),loc1.createFace([loc6,loc7,loc11,loc10]));
|
||||
loc1.setUVsToFace(new Point(0,0),new Point(1,0),new Point(1,1),loc1.createFace([loc4,loc8,loc11,loc7]));
|
||||
loc1.moveAllFacesToSurface();
|
||||
loc1.cloneMaterialToAllSurfaces(new TextureMaterial(getMonochromeTexture(16711935)));
|
||||
loc1.moveAllFacesToSurface();*/
|
||||
var loc1:Box = new Box(100,100,400);
|
||||
loc1.setMaterialToAllFaces(new TextureMaterial(getMonochromeTexture(16711935)));
|
||||
return loc1;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ package alternativa.editor
|
||||
import alternativa.editor.propslib.PropLibObject;
|
||||
import alternativa.editor.propslib.PropsLibrary;
|
||||
import alternativa.editor.propslib.events.PropLibProgressEvent;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Sprite3D;
|
||||
import alternativa.engine3d.objects.Sprite3D;
|
||||
import alternativa.types.Map;
|
||||
import alternativa.types.Point3D;
|
||||
import flash.events.ErrorEvent;
|
||||
@@ -59,7 +59,7 @@ package alternativa.editor
|
||||
|
||||
private static function createFunctionalProp(param1:PropLibObject, param2:String) : Prop
|
||||
{
|
||||
var loc3:Object3D = param1.object3d;
|
||||
var loc3:Object3D = param1.mainObject;
|
||||
switch(param2)
|
||||
{
|
||||
case FunctionalProps.GRP_SPAWN_POINTS:
|
||||
@@ -86,9 +86,9 @@ package alternativa.editor
|
||||
case FunctionalProps.DOMINATION_BLUE_SPAWN:
|
||||
case FunctionalProps.DOMINATION_RED_SPAWN:
|
||||
case FunctionalProps.DOMINATION_SPAWN:
|
||||
return new SpawnPoint(param2.object3d,param2.name,FunctionalProps.LIBRARY_NAME,param1);
|
||||
return new SpawnPoint(param2.mainObject,param2.name,FunctionalProps.LIBRARY_NAME,param1);
|
||||
case FunctionalProps.DOMINATION_POINT:
|
||||
return new ControlPoint(param2.object3d,param2.name,FunctionalProps.LIBRARY_NAME,param1);
|
||||
return new ControlPoint(param2.mainObject,param2.name,FunctionalProps.LIBRARY_NAME,param1);
|
||||
default:
|
||||
throw new Error("Unsupported prop type: " + param2.name);
|
||||
}
|
||||
@@ -98,11 +98,11 @@ package alternativa.editor
|
||||
{
|
||||
var loc5:MeshProp = null;
|
||||
var loc6:String = null;
|
||||
var loc4:Object3D = param1.object3d;
|
||||
loc4.coords = new Point3D();
|
||||
var loc4:Object3D = param1.mainObject;
|
||||
loc4.setPositionXYZ(0,0,0);
|
||||
if(loc4 is Mesh)
|
||||
{
|
||||
loc5 = new MeshProp(loc4,param1.name,param2,param3);
|
||||
loc5 = new MeshProp(loc4,param1.objects,param1.name,param2,param3);
|
||||
loc5.bitmaps = (param1 as PropLibMesh).bitmaps;
|
||||
if(loc5.bitmaps != null)
|
||||
{
|
||||
|
||||
@@ -4,9 +4,9 @@ package alternativa.editor
|
||||
import alternativa.editor.prop.Sprite3DProp;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Scene3D;
|
||||
import alternativa.editor.engine3d.Scene3D;
|
||||
import alternativa.engine3d.core.Vertex;
|
||||
import alternativa.engine3d.display.View;
|
||||
import alternativa.engine3d.core.View;
|
||||
import alternativa.types.Map;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.utils.MathUtils;
|
||||
@@ -16,6 +16,7 @@ package alternativa.editor
|
||||
import flash.geom.Matrix;
|
||||
import flash.geom.Point;
|
||||
import mx.core.UIComponent;
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
|
||||
public class Preview extends UIComponent
|
||||
{
|
||||
@@ -27,7 +28,7 @@ package alternativa.editor
|
||||
|
||||
private var camera:Camera3D;
|
||||
|
||||
private var cameraContainer:Object3D;
|
||||
private var cameraContainer:Object3DContainer;
|
||||
|
||||
private var propDistance:Map;
|
||||
|
||||
@@ -50,14 +51,15 @@ package alternativa.editor
|
||||
private function initScene() : void
|
||||
{
|
||||
this.scene = new Scene3D();
|
||||
this.scene.root = new Object3D();
|
||||
this.camera = new Camera3D();
|
||||
this.scene.root = new Object3DContainer();
|
||||
this.camera = this.scene.camera = new Camera3D();
|
||||
this.camera.rotationX = -MathUtils.DEG90 - MathUtils.DEG30;
|
||||
this.cameraContainer = new Object3D();
|
||||
this.cameraContainer = new Object3DContainer();
|
||||
this.cameraContainer.addChild(this.camera);
|
||||
this.camera.coords = new Point3D(0,-100,40);
|
||||
this.camera.setPositionXYZ(0,-100,40);
|
||||
this.scene.root.addChild(this.cameraContainer);
|
||||
this.view = new View(this.camera);
|
||||
this.view = new View(100,100);
|
||||
this.camera.view = this.view;
|
||||
addChild(this.view);
|
||||
this.view.graphics.beginFill(16777215);
|
||||
this.view.graphics.drawRect(0,0,1,1);
|
||||
@@ -73,10 +75,10 @@ package alternativa.editor
|
||||
private function calculateOptimalCameraPosition(param1:Prop) : void
|
||||
{
|
||||
var loc7:BitmapData = null;
|
||||
var loc8:Array = null;
|
||||
var loc8:Vector.<Vertex> = null;
|
||||
var loc9:int = 0;
|
||||
var loc10:int = 0;
|
||||
var loc11:Point3D = null;
|
||||
var loc11:Point3D = new Point3D();
|
||||
var loc12:Number = NaN;
|
||||
var loc13:Number = NaN;
|
||||
var loc14:Number = NaN;
|
||||
@@ -94,12 +96,12 @@ package alternativa.editor
|
||||
}
|
||||
else
|
||||
{
|
||||
loc8 = param1.vertices.toArray(true);
|
||||
loc8 = param1.vertices;
|
||||
loc9 = int(loc8.length);
|
||||
loc10 = 0;
|
||||
while(loc10 < loc9)
|
||||
{
|
||||
loc11 = Vertex(loc8[loc10]).coords;
|
||||
loc11.copyFromVertex(loc8[loc10]);
|
||||
loc12 = loc11.x - param1.x;
|
||||
loc13 = loc11.y - param1.y;
|
||||
loc14 = loc11.z - param1.z;
|
||||
@@ -151,9 +153,9 @@ package alternativa.editor
|
||||
|
||||
private function clearScene() : void
|
||||
{
|
||||
var loc1:* = undefined;
|
||||
var loc1:Object3D;
|
||||
var loc2:Prop = null;
|
||||
for(loc1 in this.scene.root.children)
|
||||
for each(loc1 in this.scene.root.children)
|
||||
{
|
||||
loc2 = loc1 as Prop;
|
||||
if(loc2 != null)
|
||||
|
||||
@@ -9,10 +9,10 @@ package alternativa.editor
|
||||
import alternativa.editor.scene.MainScene;
|
||||
import alternativa.editor.scene.OccupyMap;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Vertex;
|
||||
import alternativa.engine3d.events.MouseEvent3D;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.engine3d.core.MouseEvent3D;
|
||||
import alternativa.types.Matrix4;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.types.Set;
|
||||
import alternativa.utils.KeyboardUtils;
|
||||
@@ -27,6 +27,8 @@ package alternativa.editor
|
||||
import mx.controls.Alert;
|
||||
import mx.core.UIComponent;
|
||||
import mx.events.CloseEvent;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import flash.geom.Vector3D;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
@@ -50,7 +52,7 @@ package alternativa.editor
|
||||
|
||||
private var eventJournal:EventJournal;
|
||||
|
||||
private var cameraTransformation:Matrix3D;
|
||||
private var cameraTransformation:Matrix4;
|
||||
|
||||
private var _snapMode:Boolean;
|
||||
|
||||
@@ -111,13 +113,13 @@ package alternativa.editor
|
||||
|
||||
private static function getMeshBounds(param1:Mesh, param2:Point3D, param3:Point3D) : void
|
||||
{
|
||||
var loc4:Vertex = null;
|
||||
/*var loc4:Vertex = null;
|
||||
var loc5:Point3D = null;
|
||||
param2.reset(10000000000,10000000000,10000000000);
|
||||
param3.reset(-10000000000,-10000000000,-10000000000);
|
||||
for each(loc4 in param1.alternativa3d::_vertices)
|
||||
for each(loc4 in param1.vertices)
|
||||
{
|
||||
loc5 = loc4.alternativa3d::globalCoords;
|
||||
loc5 = loc4.globalCoords;
|
||||
if(loc5.x < param2.x)
|
||||
{
|
||||
param2.x = loc5.x;
|
||||
@@ -142,7 +144,10 @@ package alternativa.editor
|
||||
{
|
||||
param3.z = loc5.z;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
param1.calculateBounds();
|
||||
param2.reset(param1.boundMaxX,param1.boundMaxY,param1.boundMaxZ);
|
||||
param3.reset(param1.boundMinX,param1.boundMinY,param1.boundMinZ);
|
||||
}
|
||||
|
||||
private static function fillBBPoints(param1:Point3D, param2:Point3D, param3:Array) : void
|
||||
@@ -196,7 +201,7 @@ package alternativa.editor
|
||||
{
|
||||
removeEventListener(Event.ADDED_TO_STAGE,this.onAddedToStage);
|
||||
this.keyMapper.startListening(stage);
|
||||
this.cursorScene = new CursorScene(stage);
|
||||
this.cursorScene = new CursorScene(stage,this);
|
||||
this.mainScene = new MainScene();
|
||||
this.cursorScene.occupyMap = this.mainScene.occupyMap;
|
||||
addChild(this.mainScene.view);
|
||||
@@ -209,7 +214,7 @@ package alternativa.editor
|
||||
addChild(this.selectionRectOverlay);
|
||||
this.initListeners();
|
||||
this.eventJournal = new EventJournal();
|
||||
var loc2:Point3D = this.cursorScene.camera.coords;
|
||||
var loc2:Object3D = this.cursorScene.camera;
|
||||
this.cameraDistance = Math.sqrt(loc2.x * loc2.x + loc2.y * loc2.y + loc2.z * loc2.z);
|
||||
}
|
||||
|
||||
@@ -240,7 +245,7 @@ package alternativa.editor
|
||||
{
|
||||
if(this.mainScene.selectedProp != null)
|
||||
{
|
||||
this.startSelectionCoords = this.mainScene.selectedProp.coords;
|
||||
this.startSelectionCoords = new Point3D().copyFromObject3D(this.mainScene.selectedProp);
|
||||
this.cursorScene.visible = false;
|
||||
}
|
||||
}
|
||||
@@ -268,9 +273,9 @@ package alternativa.editor
|
||||
{
|
||||
this.eventJournal.addEvent(EventJournal.COPY,loc3.clone());
|
||||
}
|
||||
else if(!this.startSelectionCoords.equals(loc2.coords))
|
||||
else if(!this.startSelectionCoords.equalsXYZ(loc2.x,loc2.y,loc2.z))
|
||||
{
|
||||
loc5 = loc2.coords;
|
||||
loc5 = new Point3D().copyFromObject3D(loc2);
|
||||
loc5.difference(loc5,this.startSelectionCoords);
|
||||
this.eventJournal.addEvent(EventJournal.MOVE,loc3.clone(),loc5);
|
||||
loc4 = true;
|
||||
@@ -367,7 +372,7 @@ package alternativa.editor
|
||||
var loc6:Set = null;
|
||||
var loc7:Point3D = null;
|
||||
var loc8:Prop = null;
|
||||
var loc9:Matrix3D = null;
|
||||
var loc9:Matrix4 = null;
|
||||
var loc10:Point3D = null;
|
||||
var loc11:Point3D = null;
|
||||
var loc12:Point3D = null;
|
||||
@@ -385,9 +390,9 @@ package alternativa.editor
|
||||
{
|
||||
if(param1.shiftKey && !this.copy)
|
||||
{
|
||||
if(!this.startSelectionCoords.equals(loc4.coords))
|
||||
if(!this.startSelectionCoords.equalsXYZ(loc4.x,loc4.y,loc4.z))
|
||||
{
|
||||
loc7 = loc4.coords;
|
||||
loc7 = new Point3D().copyFromObject3D(loc4);
|
||||
loc7.difference(loc7,this.startSelectionCoords);
|
||||
this.eventJournal.addEvent(EventJournal.MOVE,loc5.clone(),loc7);
|
||||
}
|
||||
@@ -395,7 +400,7 @@ package alternativa.editor
|
||||
for(loc2 in loc5)
|
||||
{
|
||||
loc3 = loc2 as Prop;
|
||||
loc8 = this.mainScene.addProp(loc3,loc3.coords,loc3.rotationZ);
|
||||
loc8 = this.mainScene.addProp(loc3,new Point3D().copyFromObject3D(loc3),loc3.rotationZ);
|
||||
if(loc3 == loc4)
|
||||
{
|
||||
loc4 = loc8;
|
||||
@@ -404,7 +409,7 @@ package alternativa.editor
|
||||
}
|
||||
this.mainScene.selectProps(loc6);
|
||||
this.mainScene.selectedProp = loc4;
|
||||
this.startSelectionCoords = loc4.coords;
|
||||
this.startSelectionCoords = new Point3D().copyFromObject3D(loc4);
|
||||
this.copy = true;
|
||||
}
|
||||
this.mainScene.moveSelectedPropsByMouse(this.verticalMoving);
|
||||
@@ -419,7 +424,7 @@ package alternativa.editor
|
||||
loc12 = new Point3D(loc9.d,loc9.h,loc9.l);
|
||||
loc12.add(loc10);
|
||||
loc12.add(loc11);
|
||||
this.cursorScene.cameraController.coords = this.cursorScene.container.globalToLocal(loc12);
|
||||
this.cursorScene.cameraController.setObjectPos(this.cursorScene.container.globalToLocal(loc12.toVector3D()));
|
||||
}
|
||||
else if(this.mouseDown)
|
||||
{
|
||||
@@ -490,18 +495,23 @@ package alternativa.editor
|
||||
|
||||
private function zoom(param1:int) : void
|
||||
{
|
||||
var loc2:Point3D = !!this.mainScene.selectedProp ? this.mainScene.selectedProp.coords : this.cursorScene.camera.localToGlobal(cameraPoint);
|
||||
var loc3:Point3D = this.cursorScene.container.localToGlobal(this.cursorScene.cameraController.coords);
|
||||
var loc2:Point3D = new Point3D();
|
||||
var cameraPointV3:Vector3D = cameraPoint.toVector3D();
|
||||
if(this.mainScene.selectedProp)
|
||||
loc2.copyFromObject3D(this.mainScene.selectedProp)
|
||||
else
|
||||
loc2.copyFromVector3D(this.cursorScene.camera.localToGlobal(cameraPointV3));
|
||||
var loc3:Point3D = new Point3D().copyFromVector3D(this.cursorScene.container.localToGlobal(this.cursorScene.cameraController.coords3D));
|
||||
var loc4:Point3D = loc3.clone();
|
||||
var loc5:Point3D = Point3D.difference(loc2,loc3);
|
||||
if(loc5.length < 500)
|
||||
{
|
||||
loc5 = Point3D.difference(this.cursorScene.camera.localToGlobal(cameraPoint),loc3);
|
||||
loc5 = Point3D.difference(new Point3D().copyFromVector3D(this.cursorScene.camera.localToGlobal(cameraPointV3)),loc3);
|
||||
}
|
||||
loc5.normalize();
|
||||
loc5.multiply(param1 * 100);
|
||||
loc3.add(loc5);
|
||||
this.cursorScene.cameraController.coords = this.cursorScene.container.globalToLocal(loc3);
|
||||
this.cursorScene.cameraController.setObjectPos(this.cursorScene.container.globalToLocal(loc3.toVector3D()));
|
||||
}
|
||||
|
||||
private function onMouseOut(param1:MouseEvent) : void
|
||||
@@ -543,13 +553,13 @@ package alternativa.editor
|
||||
}
|
||||
else
|
||||
{
|
||||
loc2 = this.cursorScene.camera.localToGlobal(new Point3D(0,0,this.cameraDistance));
|
||||
loc2 = new Point3D().copyFromVector3D(this.cursorScene.camera.localToGlobal(new Vector3D(0,0,this.cameraDistance)));
|
||||
}
|
||||
loc4 = this.cursorScene.containerController.coords.clone();
|
||||
loc4.subtract(loc2);
|
||||
loc5 = this.cursorScene.container.localToGlobal(this.cursorScene.cameraController.coords);
|
||||
loc5 = new Point3D().copyFromVector3D(this.cursorScene.container.localToGlobal(this.cursorScene.cameraController.coords3D));
|
||||
loc5.add(loc4);
|
||||
this.cursorScene.cameraController.coords = this.cursorScene.container.globalToLocal(loc5);
|
||||
this.cursorScene.cameraController.setObjectPos(this.cursorScene.container.globalToLocal(loc5.toVector3D()));
|
||||
this.cursorScene.containerController.coords = loc2;
|
||||
this.cursorScene.containerController.setMouseLook(true);
|
||||
}
|
||||
@@ -596,16 +606,17 @@ package alternativa.editor
|
||||
|
||||
private function drawBoundBoxes() : void
|
||||
{
|
||||
var loc1:* = undefined;
|
||||
var loc2:MeshProp = null;
|
||||
this.boundBoxesOverlay.graphics.clear();
|
||||
for(loc1 in this.mainScene.root.alternativa3d::_children)
|
||||
var loc1:Object3D = this.mainScene.root.childrenList;
|
||||
while(loc1 != null)
|
||||
{
|
||||
loc2 = loc1 as MeshProp;
|
||||
if(loc2 != null && !loc2.hidden)
|
||||
{
|
||||
this.drawPropBoundBox(loc2);
|
||||
}
|
||||
loc1 = loc1.next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,7 +695,7 @@ package alternativa.editor
|
||||
var loc2:Prop = null;
|
||||
var loc3:Point3D = null;
|
||||
var loc4:Point3D = null;
|
||||
var loc5:Point3D = null;
|
||||
var loc5:Object3D = null;
|
||||
var loc6:Prop = null;
|
||||
var loc7:Set = null;
|
||||
switch(param1.keyCode)
|
||||
@@ -694,7 +705,7 @@ package alternativa.editor
|
||||
{
|
||||
this.cursorScene.camera.rotationX = this.cursorScene.camera.rotationX = this.cursorScene.camera.rotationX = -2.0943951023931953;
|
||||
this.cursorScene.cameraController.coords = new Point3D(250,-7800,4670);
|
||||
loc5 = this.cursorScene.camera.coords;
|
||||
loc5 = this.cursorScene.camera;
|
||||
this.cameraDistance = Math.sqrt(loc5.x * loc5.x + loc5.y * loc5.y + loc5.z * loc5.z);
|
||||
}
|
||||
break;
|
||||
@@ -708,9 +719,9 @@ package alternativa.editor
|
||||
break;
|
||||
}
|
||||
loc2 = this.mainScene.selectedProp;
|
||||
loc4 = loc2.coords;
|
||||
loc4 = new Point3D().copyFromObject3D(loc2);
|
||||
this.mainScene.moveByArrows(param1.keyCode);
|
||||
loc3 = loc2.coords;
|
||||
loc3 = new Point3D().copyFromObject3D(loc2);
|
||||
loc3.difference(loc3,loc4);
|
||||
this.eventJournal.addEvent(EventJournal.MOVE,this.mainScene.selectedProps,loc3);
|
||||
break;
|
||||
@@ -727,9 +738,9 @@ package alternativa.editor
|
||||
loc2 = this.mainScene.selectedProp;
|
||||
if(loc2)
|
||||
{
|
||||
loc4 = loc2.coords;
|
||||
loc4 = new Point3D().copyFromObject3D(loc2);
|
||||
this.mainScene.verticalMove(false);
|
||||
loc3 = loc2.coords;
|
||||
loc3 = new Point3D().copyFromObject3D(loc2);
|
||||
loc3.difference(loc3,loc4);
|
||||
this.eventJournal.addEvent(EventJournal.MOVE,this.mainScene.selectedProps,loc3);
|
||||
}
|
||||
@@ -746,9 +757,9 @@ package alternativa.editor
|
||||
loc2 = this.mainScene.selectedProp;
|
||||
if(loc2)
|
||||
{
|
||||
loc4 = loc2.coords;
|
||||
loc4 = new Point3D().copyFromObject3D(loc2);
|
||||
this.mainScene.verticalMove(true);
|
||||
loc3 = loc2.coords;
|
||||
loc3 = new Point3D().copyFromObject3D(loc2);
|
||||
loc3.difference(loc3,loc4);
|
||||
this.eventJournal.addEvent(EventJournal.MOVE,this.mainScene.selectedProps,loc3);
|
||||
}
|
||||
@@ -762,7 +773,7 @@ package alternativa.editor
|
||||
loc6 = this.cursorScene.object;
|
||||
if(loc6)
|
||||
{
|
||||
loc6.coords = loc2.coords;
|
||||
loc6.setPositionXYZ(loc2.x,loc2.y,loc2.z);
|
||||
if(this.snapMode)
|
||||
{
|
||||
loc6.snapToGrid();
|
||||
@@ -799,7 +810,7 @@ package alternativa.editor
|
||||
{
|
||||
if(this.cursorScene.object)
|
||||
{
|
||||
this.cursorScene.object.coords = loc2.coords;
|
||||
this.cursorScene.object.setPositionXYZ(loc2.x,loc2.y,loc2.z);
|
||||
this.cursorScene.object.snapToGrid();
|
||||
}
|
||||
this.mainScene.deselectProps();
|
||||
@@ -872,7 +883,7 @@ package alternativa.editor
|
||||
|
||||
public function addProp(param1:Prop) : void
|
||||
{
|
||||
var loc2:Prop = this.mainScene.addProp(param1,this.cursorScene.object.coords,this.cursorScene.object.rotationZ);
|
||||
var loc2:Prop = this.mainScene.addProp(param1,new Point3D().copyFromObject3D(this.cursorScene.object),this.cursorScene.object.rotationZ);
|
||||
var loc3:Set = new Set();
|
||||
loc3.add(loc2);
|
||||
this.eventJournal.addEvent(EventJournal.ADD,loc3);
|
||||
@@ -886,7 +897,7 @@ package alternativa.editor
|
||||
|
||||
private function onPropMouseDown(param1:MouseEvent3D) : void
|
||||
{
|
||||
this.clickZ = param1.object.z;
|
||||
this.clickZ = param1.relatedObject.z;
|
||||
this.propDown = true;
|
||||
}
|
||||
|
||||
|
||||
44
src/alternativa/editor/engine3d/Scene3D.as
Normal file
44
src/alternativa/editor/engine3d/Scene3D.as
Normal file
@@ -0,0 +1,44 @@
|
||||
package alternativa.editor.engine3d
|
||||
{
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.editor.prop.Prop;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Scene3D
|
||||
{
|
||||
public var camera:Camera3D;
|
||||
|
||||
private var _root:Object3DContainer;
|
||||
|
||||
|
||||
public function get root() : Object3DContainer
|
||||
{
|
||||
return _root;
|
||||
}
|
||||
public function set root(container:Object3DContainer) : void
|
||||
{
|
||||
_root = container;
|
||||
}
|
||||
|
||||
|
||||
public function calculate() : void
|
||||
{
|
||||
var child:Object3D = _root.childrenList;
|
||||
while(child != null)
|
||||
{
|
||||
if(child is Prop)
|
||||
{
|
||||
(child as Prop).calculate();
|
||||
}
|
||||
|
||||
child = child.next;
|
||||
}
|
||||
|
||||
this.camera.render();
|
||||
}
|
||||
}
|
||||
}
|
||||
581
src/alternativa/editor/engine3d/controllers/ObjectController.as
Normal file
581
src/alternativa/editor/engine3d/controllers/ObjectController.as
Normal file
@@ -0,0 +1,581 @@
|
||||
package alternativa.editor.engine3d.controllers
|
||||
{
|
||||
import alternativa.engine3d.*;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
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;
|
||||
import alternativa.engine3d.core.EllipsoidCollider;
|
||||
import flash.geom.Vector3D;
|
||||
|
||||
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 _enabled:Boolean = true;
|
||||
|
||||
protected var keyBindings:Map;
|
||||
|
||||
protected var _mouseSensitivity:Number = 1;
|
||||
|
||||
protected var _keyboardEnabled:Boolean;
|
||||
|
||||
protected var _right:Boolean;
|
||||
|
||||
protected var _speedMultiplier:Number = 2;
|
||||
|
||||
//public var onStopMoving:Function;
|
||||
|
||||
protected var _up:Boolean;
|
||||
|
||||
protected var _coords:Point3D;
|
||||
|
||||
protected var _speed:Number = 100;
|
||||
|
||||
protected var _yawRight:Boolean;
|
||||
|
||||
protected var _collider:EllipsoidCollider;
|
||||
|
||||
protected var _object:Object3D;
|
||||
|
||||
protected var _mouseSensitivityX:Number;
|
||||
|
||||
protected var _mouseSensitivityY:Number;
|
||||
|
||||
protected var startMouseCoords:Point3D;
|
||||
|
||||
protected var _eventsSource:DisplayObject;
|
||||
|
||||
protected var _yawSpeed:Number = 1;
|
||||
|
||||
protected var _accelerate:Boolean;
|
||||
|
||||
protected var _down:Boolean;
|
||||
|
||||
protected var _pitchDown:Boolean;
|
||||
|
||||
protected var _forward:Boolean;
|
||||
|
||||
protected var _mouseCoefficientX:Number;
|
||||
|
||||
protected var _mouseCoefficientY:Number;
|
||||
|
||||
protected var _pitchSpeed:Number = 1;
|
||||
|
||||
//protected var _isMoving:Boolean;
|
||||
|
||||
public var checkCollisions:Boolean;
|
||||
|
||||
protected var _mouseEnabled:Boolean;
|
||||
|
||||
protected var _pitchUp:Boolean;
|
||||
|
||||
protected var _back:Boolean;
|
||||
|
||||
protected var _mouseLookActive:Boolean;
|
||||
|
||||
protected var _yawLeft:Boolean;
|
||||
|
||||
protected var actionBindings:Map;
|
||||
|
||||
protected var _left:Boolean;
|
||||
|
||||
protected var lastFrameTime:uint;
|
||||
|
||||
//public var onStartMoving:Function;
|
||||
|
||||
private var _displacement:Point3D;
|
||||
|
||||
public function ObjectController(eventsSourceObject:DisplayObject)
|
||||
{
|
||||
startMouseCoords = new Point3D();
|
||||
keyBindings = new Map();
|
||||
actionBindings = new Map();
|
||||
_mouseSensitivityY = Math.PI / 360;
|
||||
_mouseSensitivityX = Math.PI / 360;
|
||||
_mouseCoefficientY = _mouseSensitivity * _mouseSensitivityY;
|
||||
_mouseCoefficientX = _mouseSensitivity * _mouseSensitivityX;
|
||||
_coords = new Point3D();
|
||||
_collider = new EllipsoidCollider(50,50,50);
|
||||
_displacement = new Point3D();
|
||||
super();
|
||||
if(eventsSourceObject == null)
|
||||
{
|
||||
throw new ArgumentError(ObjectUtils.getClassName(this) + ": eventsSourceObject is null");
|
||||
}
|
||||
_eventsSource = eventsSourceObject;
|
||||
actionBindings[ACTION_FORWARD] = moveForward;
|
||||
actionBindings[ACTION_BACK] = moveBack;
|
||||
actionBindings[ACTION_LEFT] = moveLeft;
|
||||
actionBindings[ACTION_RIGHT] = moveRight;
|
||||
actionBindings[ACTION_UP] = moveUp;
|
||||
actionBindings[ACTION_DOWN] = moveDown;
|
||||
actionBindings[ACTION_PITCH_UP] = pitchUp;
|
||||
actionBindings[ACTION_PITCH_DOWN] = pitchDown;
|
||||
actionBindings[ACTION_YAW_LEFT] = yawLeft;
|
||||
actionBindings[ACTION_YAW_RIGHT] = yawRight;
|
||||
actionBindings[ACTION_ACCELERATE] = accelerate;
|
||||
actionBindings[ACTION_MOUSE_LOOK] = setMouseLook;
|
||||
keyboardEnabled = true;
|
||||
mouseEnabled = true;
|
||||
}
|
||||
|
||||
public function pitchDown(value:Boolean) : void
|
||||
{
|
||||
_pitchDown = value;
|
||||
}
|
||||
|
||||
public function moveDown(value:Boolean) : void
|
||||
{
|
||||
_down = value;
|
||||
}
|
||||
|
||||
public function yawLeft(value:Boolean) : void
|
||||
{
|
||||
_yawLeft = value;
|
||||
}
|
||||
|
||||
public function get yawSpeed() : Number
|
||||
{
|
||||
return _yawSpeed;
|
||||
}
|
||||
|
||||
public function get coords() : Point3D
|
||||
{
|
||||
return _coords.clone();
|
||||
}
|
||||
public function get coords3D() : Vector3D
|
||||
{
|
||||
return _coords.toVector3D();
|
||||
}
|
||||
|
||||
public function get accelerated() : Boolean
|
||||
{
|
||||
return _accelerate;
|
||||
}
|
||||
|
||||
public function setDefaultBindings() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function set yawSpeed(spd:Number) : void
|
||||
{
|
||||
_yawSpeed = spd;
|
||||
}
|
||||
|
||||
public function unbindKey(keyCode:uint) : void
|
||||
{
|
||||
keyBindings.remove(keyCode);
|
||||
}
|
||||
|
||||
protected function stopMouseLook() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function set coords(value:Point3D) : void
|
||||
{
|
||||
_coords.copy(value);
|
||||
setObjectCoords();
|
||||
}
|
||||
|
||||
public function setObjectPos(pos:Vector3D) : void
|
||||
{
|
||||
_coords.copyFromVector3D(pos);
|
||||
setObjectCoords();
|
||||
}
|
||||
|
||||
public function get object() : Object3D
|
||||
{
|
||||
return _object;
|
||||
}
|
||||
|
||||
protected function unregisterKeyboardListeners() : void
|
||||
{
|
||||
clearCommandFlags();
|
||||
_eventsSource.removeEventListener(KeyboardEvent.KEY_DOWN,onKeyboardEvent);
|
||||
_eventsSource.removeEventListener(KeyboardEvent.KEY_UP,onKeyboardEvent);
|
||||
}
|
||||
|
||||
public function get speed() : Number
|
||||
{
|
||||
return _speed;
|
||||
}
|
||||
|
||||
public function get enabled() : Boolean
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
public function readCoords(point:Point3D) : void
|
||||
{
|
||||
point.copy(_coords);
|
||||
}
|
||||
|
||||
public function moveBack(value:Boolean) : void
|
||||
{
|
||||
_back = value;
|
||||
}
|
||||
|
||||
public function get keyboardEnabled() : Boolean
|
||||
{
|
||||
return _keyboardEnabled;
|
||||
}
|
||||
|
||||
public function moveUp(value:Boolean) : void
|
||||
{
|
||||
_up = value;
|
||||
}
|
||||
|
||||
private function onKeyboardEvent(e:KeyboardEvent) : void
|
||||
{
|
||||
var method:Function = keyBindings[e.keyCode];
|
||||
if(method != null)
|
||||
{
|
||||
method.call(this,e.type == KeyboardEvent.KEY_DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
public function get speedMultiplier() : Number
|
||||
{
|
||||
return _speedMultiplier;
|
||||
}
|
||||
|
||||
public function unbindAll() : void
|
||||
{
|
||||
keyBindings.clear();
|
||||
}
|
||||
|
||||
private function onMouseUp(e:MouseEvent) : void
|
||||
{
|
||||
setMouseLook(false);
|
||||
_eventsSource.stage.removeEventListener(MouseEvent.MOUSE_UP,onMouseUp);
|
||||
}
|
||||
|
||||
public function moveLeft(value:Boolean) : void
|
||||
{
|
||||
_left = value;
|
||||
}
|
||||
|
||||
public function set mouseSensitivity(sensitivity:Number) : void
|
||||
{
|
||||
_mouseSensitivity = sensitivity;
|
||||
_mouseCoefficientY = _mouseSensitivity * _mouseSensitivityY;
|
||||
_mouseCoefficientX = _mouseSensitivity * _mouseSensitivityX;
|
||||
}
|
||||
|
||||
protected function unregisterMouseListeners() : void
|
||||
{
|
||||
_eventsSource.removeEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
|
||||
_eventsSource.stage.removeEventListener(MouseEvent.MOUSE_UP,onMouseUp);
|
||||
}
|
||||
|
||||
public function set object(value:Object3D) : void
|
||||
{
|
||||
_object = value;
|
||||
//_collider.scene = _object == null ? null : _object.scene;
|
||||
setObjectCoords();
|
||||
}
|
||||
|
||||
public function set enabled(value:Boolean) : void
|
||||
{
|
||||
_enabled = value;
|
||||
if(_enabled)
|
||||
{
|
||||
if(_mouseEnabled)
|
||||
{
|
||||
registerMouseListeners();
|
||||
}
|
||||
if(_keyboardEnabled)
|
||||
{
|
||||
registerKeyboardListeners();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_mouseEnabled)
|
||||
{
|
||||
unregisterMouseListeners();
|
||||
setMouseLook(false);
|
||||
}
|
||||
if(_keyboardEnabled)
|
||||
{
|
||||
unregisterKeyboardListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function set speed(value:Number) : void
|
||||
{
|
||||
_speed = value < 0 ? -value : value;
|
||||
}
|
||||
|
||||
protected function rotateObject(frameTime:Number) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function getDisplacement(frameTime:Number, displacement:Point3D) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function processInput() : void
|
||||
{
|
||||
if(!_enabled || _object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var frameTime:Number = getTimer() - lastFrameTime;
|
||||
if(frameTime == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastFrameTime += frameTime;
|
||||
if(frameTime > 100)
|
||||
{
|
||||
frameTime = 100;
|
||||
}
|
||||
frameTime /= 1000;
|
||||
rotateObject(frameTime);
|
||||
getDisplacement(frameTime,_displacement);
|
||||
applyDisplacement(frameTime,_displacement);
|
||||
/*if(Boolean(_object.changeRotationOrScaleOperation.queued) || Boolean(_object.changeCoordsOperation.queued))
|
||||
{
|
||||
if(!_isMoving)
|
||||
{
|
||||
_isMoving = true;
|
||||
if(onStartMoving != null)
|
||||
{
|
||||
onStartMoving.call(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(_isMoving)
|
||||
{
|
||||
_isMoving = false;
|
||||
if(onStopMoving != null)
|
||||
{
|
||||
onStopMoving.call(this);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
protected function registerMouseListeners() : void
|
||||
{
|
||||
_eventsSource.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
|
||||
}
|
||||
|
||||
public function setMouseLook(value:Boolean) : void
|
||||
{
|
||||
if(_mouseLookActive != value)
|
||||
{
|
||||
_mouseLookActive = value;
|
||||
if(_mouseLookActive)
|
||||
{
|
||||
startMouseLook();
|
||||
}
|
||||
else
|
||||
{
|
||||
stopMouseLook();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function applyDisplacement(frameTime:Number, displacement:Point3D) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function startMouseLook() : void
|
||||
{
|
||||
startMouseCoords.x = _eventsSource.stage.mouseX;
|
||||
startMouseCoords.y = _eventsSource.stage.mouseY;
|
||||
}
|
||||
|
||||
public function moveForward(value:Boolean) : void
|
||||
{
|
||||
_forward = value;
|
||||
}
|
||||
|
||||
protected function registerKeyboardListeners() : void
|
||||
{
|
||||
_eventsSource.addEventListener(KeyboardEvent.KEY_DOWN,onKeyboardEvent);
|
||||
_eventsSource.addEventListener(KeyboardEvent.KEY_UP,onKeyboardEvent);
|
||||
}
|
||||
|
||||
public function set mouseEnabled(value:Boolean) : void
|
||||
{
|
||||
if(_mouseEnabled != value)
|
||||
{
|
||||
_mouseEnabled = value;
|
||||
if(_mouseEnabled)
|
||||
{
|
||||
if(_enabled)
|
||||
{
|
||||
registerMouseListeners();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unregisterMouseListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get mouseSensitivity() : Number
|
||||
{
|
||||
return _mouseSensitivity;
|
||||
}
|
||||
|
||||
protected function setObjectCoords() : void
|
||||
{
|
||||
if(_object != null)
|
||||
{
|
||||
_object.setPositionXYZ(_coords.x,_coords.y,_coords.z);
|
||||
}
|
||||
}
|
||||
|
||||
public function set mouseSensitivityY(value:Number) : void
|
||||
{
|
||||
_mouseSensitivityY = value;
|
||||
_mouseCoefficientY = _mouseSensitivity * _mouseSensitivityY;
|
||||
}
|
||||
|
||||
public function set pitchSpeed(spd:Number) : void
|
||||
{
|
||||
_pitchSpeed = spd;
|
||||
}
|
||||
|
||||
public function set speedMultiplier(value:Number) : void
|
||||
{
|
||||
_speedMultiplier = value;
|
||||
}
|
||||
|
||||
public function moveRight(value:Boolean) : void
|
||||
{
|
||||
_right = value;
|
||||
}
|
||||
|
||||
public function set mouseSensitivityX(value:Number) : void
|
||||
{
|
||||
_mouseSensitivityX = value;
|
||||
_mouseCoefficientX = _mouseSensitivity * _mouseSensitivityX;
|
||||
}
|
||||
|
||||
public function set keyboardEnabled(value:Boolean) : void
|
||||
{
|
||||
if(_keyboardEnabled != value)
|
||||
{
|
||||
_keyboardEnabled = value;
|
||||
if(_keyboardEnabled)
|
||||
{
|
||||
if(_enabled)
|
||||
{
|
||||
registerKeyboardListeners();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unregisterKeyboardListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get mouseEnabled() : Boolean
|
||||
{
|
||||
return _mouseEnabled;
|
||||
}
|
||||
|
||||
public function accelerate(value:Boolean) : void
|
||||
{
|
||||
_accelerate = value;
|
||||
}
|
||||
|
||||
public function get mouseSensitivityX() : Number
|
||||
{
|
||||
return _mouseSensitivityX;
|
||||
}
|
||||
|
||||
public function get mouseSensitivityY() : Number
|
||||
{
|
||||
return _mouseSensitivityY;
|
||||
}
|
||||
|
||||
private function onMouseDown(e:MouseEvent) : void
|
||||
{
|
||||
setMouseLook(true);
|
||||
_eventsSource.stage.addEventListener(MouseEvent.MOUSE_UP,onMouseUp);
|
||||
}
|
||||
|
||||
public function get pitchSpeed() : Number
|
||||
{
|
||||
return _pitchSpeed;
|
||||
}
|
||||
|
||||
public function bindKey(keyCode:uint, action:String) : void
|
||||
{
|
||||
var method:Function = actionBindings[action];
|
||||
if(method != null)
|
||||
{
|
||||
keyBindings[keyCode] = method;
|
||||
}
|
||||
}
|
||||
|
||||
public function yawRight(value:Boolean) : void
|
||||
{
|
||||
_yawRight = value;
|
||||
}
|
||||
|
||||
protected function clearCommandFlags() : void
|
||||
{
|
||||
_forward = false;
|
||||
_back = false;
|
||||
_left = false;
|
||||
_right = false;
|
||||
_up = false;
|
||||
_down = false;
|
||||
_pitchUp = false;
|
||||
_pitchDown = false;
|
||||
_yawLeft = false;
|
||||
_yawRight = false;
|
||||
_accelerate = false;
|
||||
_mouseLookActive = false;
|
||||
}
|
||||
|
||||
public function get collider() : EllipsoidCollider
|
||||
{
|
||||
return _collider;
|
||||
}
|
||||
|
||||
public function pitchUp(value:Boolean) : void
|
||||
{
|
||||
_pitchUp = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
477
src/alternativa/editor/engine3d/controllers/WalkController.as
Normal file
477
src/alternativa/editor/engine3d/controllers/WalkController.as
Normal file
@@ -0,0 +1,477 @@
|
||||
package alternativa.editor.engine3d.controllers
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.types.Matrix4;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.utils.KeyboardUtils;
|
||||
import alternativa.utils.MathUtils;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.geom.Vector3D;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class WalkController extends ObjectController
|
||||
{
|
||||
private var _airControlCoefficient:Number = 1;
|
||||
|
||||
private var _objectZPosition:Number = 0.5;
|
||||
|
||||
private var destination:Point3D;
|
||||
|
||||
private var tmpVelocity:Point3D;
|
||||
|
||||
private var _onGround:Boolean;
|
||||
|
||||
private var _currentSpeed:Number = 0;
|
||||
|
||||
public var jumpSpeed:Number = 0;
|
||||
|
||||
//private var _groundMesh:Mesh;
|
||||
|
||||
private const collisionPos:Vector3D = new Vector3D();
|
||||
private const collisionNormal:Vector3D = new Vector3D();
|
||||
|
||||
public var gravity:Number = 0;
|
||||
|
||||
private var minGroundCos:Number;
|
||||
|
||||
private var controlsActive:Boolean;
|
||||
|
||||
private var velocity:Point3D;
|
||||
|
||||
private var startRotX:Number;
|
||||
|
||||
public var speedThreshold:Number = 1;
|
||||
|
||||
private var startRotZ:Number;
|
||||
|
||||
private var currentMouseCoords:Point3D;
|
||||
|
||||
private var prevMouseCoords:Point3D;
|
||||
|
||||
private var inJump:Boolean;
|
||||
|
||||
private var _flyMode:Boolean;
|
||||
|
||||
private var _jumpLocked:Boolean;
|
||||
|
||||
public function WalkController(eventSourceObject:DisplayObject)
|
||||
{
|
||||
minGroundCos = Math.cos(MathUtils.toRadian(70));
|
||||
destination = new Point3D();
|
||||
//collision = new Collision();
|
||||
velocity = new Point3D();
|
||||
tmpVelocity = new Point3D();
|
||||
prevMouseCoords = new Point3D();
|
||||
currentMouseCoords = new Point3D();
|
||||
super(eventSourceObject);
|
||||
}
|
||||
|
||||
public function get airControlCoefficient() : Number
|
||||
{
|
||||
return _airControlCoefficient;
|
||||
}
|
||||
|
||||
public function set airControlCoefficient(value:Number) : void
|
||||
{
|
||||
_airControlCoefficient = value > 0 ? value : -value;
|
||||
}
|
||||
|
||||
public function get maxGroundAngle() : Number
|
||||
{
|
||||
return Math.acos(minGroundCos);
|
||||
}
|
||||
|
||||
override public function set enabled(value:Boolean) : void
|
||||
{
|
||||
super.enabled = value;
|
||||
if(!value)
|
||||
{
|
||||
velocity.reset();
|
||||
_currentSpeed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
override protected function getDisplacement(frameTime:Number, displacement:Point3D) : void
|
||||
{
|
||||
var len:Number = NaN;
|
||||
var x:Number = NaN;
|
||||
var y:Number = NaN;
|
||||
var z:Number = NaN;
|
||||
var matrix:Matrix4 = null;
|
||||
var heading:Number = NaN;
|
||||
var headingCos:Number = NaN;
|
||||
var headingSin:Number = NaN;
|
||||
var spd:Number = NaN;
|
||||
var cos:Number = 0;
|
||||
if(checkCollisions && !_flyMode)
|
||||
{
|
||||
displacement.x = 0;
|
||||
displacement.y = 0;
|
||||
displacement.z = -0.5 * gravity * frameTime * frameTime;
|
||||
if(_collider.getCollision(_coords.toVector3D(),displacement.toVector3D(), collisionPos,collisionNormal, _object))
|
||||
{
|
||||
cos = collisionNormal.z;
|
||||
//_groundMesh = collision.face.alternativa3d::_mesh;
|
||||
}
|
||||
else
|
||||
{
|
||||
//_groundMesh = null;
|
||||
}
|
||||
}
|
||||
_onGround = cos > minGroundCos;
|
||||
if(_onGround && inJump)
|
||||
{
|
||||
inJump = false;
|
||||
if(!_up)
|
||||
{
|
||||
_jumpLocked = false;
|
||||
}
|
||||
}
|
||||
controlsActive = _forward || _back || _right || _left;
|
||||
if(flyMode || gravity == 0)
|
||||
{
|
||||
controlsActive = controlsActive || (_up || _down);
|
||||
}
|
||||
if(controlsActive)
|
||||
{
|
||||
if(_flyMode)
|
||||
{
|
||||
tmpVelocity.x = 0;
|
||||
tmpVelocity.y = 0;
|
||||
tmpVelocity.z = 0;
|
||||
if(_forward)
|
||||
{
|
||||
tmpVelocity.y = 1;
|
||||
}
|
||||
else if(_back)
|
||||
{
|
||||
tmpVelocity.y = -1;
|
||||
}
|
||||
if(_right)
|
||||
{
|
||||
tmpVelocity.x = 1;
|
||||
}
|
||||
else if(_left)
|
||||
{
|
||||
tmpVelocity.x = -1;
|
||||
}
|
||||
if(_up)
|
||||
{
|
||||
tmpVelocity.z = 1;
|
||||
}
|
||||
else if(_down)
|
||||
{
|
||||
tmpVelocity.z = -1;
|
||||
}
|
||||
matrix = _object.transformation;
|
||||
x = tmpVelocity.x;
|
||||
if(_object is Camera3D)
|
||||
{
|
||||
y = -tmpVelocity.z;
|
||||
z = tmpVelocity.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
y = tmpVelocity.y;
|
||||
z = tmpVelocity.z;
|
||||
}
|
||||
velocity.x += (x * matrix.a + y * matrix.b + z * matrix.c) * _speed;
|
||||
velocity.y += (x * matrix.e + y * matrix.f + z * matrix.g) * _speed;
|
||||
velocity.z += (x * matrix.i + y * matrix.j + z * matrix.k) * _speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
heading = _object.rotationZ;
|
||||
headingCos = Math.cos(heading);
|
||||
headingSin = Math.sin(heading);
|
||||
spd = _speed;
|
||||
if(gravity != 0 && !_onGround)
|
||||
{
|
||||
spd *= _airControlCoefficient;
|
||||
}
|
||||
if(_forward)
|
||||
{
|
||||
velocity.x -= spd * headingSin;
|
||||
velocity.y += spd * headingCos;
|
||||
}
|
||||
else if(_back)
|
||||
{
|
||||
velocity.x += spd * headingSin;
|
||||
velocity.y -= spd * headingCos;
|
||||
}
|
||||
if(_right)
|
||||
{
|
||||
velocity.x += spd * headingCos;
|
||||
velocity.y += spd * headingSin;
|
||||
}
|
||||
else if(_left)
|
||||
{
|
||||
velocity.x -= spd * headingCos;
|
||||
velocity.y -= spd * headingSin;
|
||||
}
|
||||
if(gravity == 0)
|
||||
{
|
||||
if(_up)
|
||||
{
|
||||
velocity.z += _speed;
|
||||
}
|
||||
else if(_down)
|
||||
{
|
||||
velocity.z -= _speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
len = 1 / Math.pow(3,frameTime * 10);
|
||||
if(_flyMode || gravity == 0)
|
||||
{
|
||||
velocity.x *= len;
|
||||
velocity.y *= len;
|
||||
velocity.z *= len;
|
||||
}
|
||||
else if(_onGround)
|
||||
{
|
||||
velocity.x *= len;
|
||||
velocity.y *= len;
|
||||
if(velocity.z < 0)
|
||||
{
|
||||
velocity.z *= len;
|
||||
}
|
||||
}
|
||||
else if(cos > 0 && velocity.z > 0)
|
||||
{
|
||||
velocity.z = 0;
|
||||
}
|
||||
}
|
||||
if(_onGround && _up && !inJump && !_jumpLocked)
|
||||
{
|
||||
velocity.z = jumpSpeed;
|
||||
inJump = true;
|
||||
_onGround = false;
|
||||
_jumpLocked = true;
|
||||
cos = 0;
|
||||
}
|
||||
if(!(_flyMode || _onGround))
|
||||
{
|
||||
velocity.z -= gravity * frameTime;
|
||||
}
|
||||
var max:Number = _accelerate ? _speed * _speedMultiplier : _speed;
|
||||
if(_flyMode || gravity == 0)
|
||||
{
|
||||
len = velocity.length;
|
||||
if(len > max)
|
||||
{
|
||||
velocity.length = max;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
len = Math.sqrt(velocity.x * velocity.x + velocity.y * velocity.y);
|
||||
if(len > max)
|
||||
{
|
||||
velocity.x *= max / len;
|
||||
velocity.y *= max / len;
|
||||
}
|
||||
if(cos > 0 && velocity.z > 0)
|
||||
{
|
||||
velocity.z = 0;
|
||||
}
|
||||
}
|
||||
displacement.x = velocity.x * frameTime;
|
||||
displacement.y = velocity.y * frameTime;
|
||||
displacement.z = velocity.z * frameTime;
|
||||
}
|
||||
|
||||
public function set objectZPosition(value:Number) : void
|
||||
{
|
||||
_objectZPosition = value;
|
||||
setObjectCoords();
|
||||
}
|
||||
|
||||
public function set maxGroundAngle(value:Number) : void
|
||||
{
|
||||
minGroundCos = Math.cos(value);
|
||||
}
|
||||
|
||||
/*public function get groundMesh() : Mesh
|
||||
{
|
||||
return _groundMesh;
|
||||
}*/
|
||||
|
||||
override protected function startMouseLook() : void
|
||||
{
|
||||
super.startMouseLook();
|
||||
startRotX = _object is Camera3D ? _object.rotationX + MathUtils.DEG90 : _object.rotationX;
|
||||
startRotZ = _object.rotationZ;
|
||||
}
|
||||
|
||||
override protected function applyDisplacement(frameTime:Number, displacement:Point3D) : void
|
||||
{
|
||||
if(checkCollisions)
|
||||
{
|
||||
var destination3D:Vector3D = _collider.calculateDestination(_coords.toVector3D(),displacement.toVector3D(),_object);
|
||||
destination.copyFromVector3D(destination3D);
|
||||
displacement.x = destination.x - _coords.x;
|
||||
displacement.y = destination.y - _coords.y;
|
||||
displacement.z = destination.z - _coords.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
destination.x = _coords.x + displacement.x;
|
||||
destination.y = _coords.y + displacement.y;
|
||||
destination.z = _coords.z + displacement.z;
|
||||
}
|
||||
velocity.x = displacement.x / frameTime;
|
||||
velocity.y = displacement.y / frameTime;
|
||||
velocity.z = displacement.z / frameTime;
|
||||
_coords.x = destination.x;
|
||||
_coords.y = destination.y;
|
||||
_coords.z = destination.z;
|
||||
setObjectCoords();
|
||||
var len:Number = Math.sqrt(velocity.x * velocity.x + velocity.y * velocity.y + velocity.z * velocity.z);
|
||||
if(len < speedThreshold)
|
||||
{
|
||||
velocity.x = 0;
|
||||
velocity.y = 0;
|
||||
velocity.z = 0;
|
||||
_currentSpeed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentSpeed = len;
|
||||
}
|
||||
}
|
||||
|
||||
public function lookAt(point:Point3D) : void
|
||||
{
|
||||
if(_object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var dx:Number = point.x - _object.x;
|
||||
var dy:Number = point.y - _object.y;
|
||||
var dz:Number = point.z - _object.z;
|
||||
_object.rotationX = Math.atan2(dz,Math.sqrt(dx * dx + dy * dy)) - (_object is Camera3D ? MathUtils.DEG90 : 0);
|
||||
_object.rotationY = 0;
|
||||
_object.rotationZ = -Math.atan2(dx,dy);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public function get flyMode() : Boolean
|
||||
{
|
||||
return _flyMode;
|
||||
}
|
||||
|
||||
override protected function setObjectCoords() : void
|
||||
{
|
||||
if(_object != null)
|
||||
{
|
||||
_object.x = _coords.x;
|
||||
_object.y = _coords.y;
|
||||
_object.z = _coords.z + (2 * _objectZPosition - 1) * _collider.radiusZ;
|
||||
}
|
||||
}
|
||||
|
||||
public function get objectZPosition() : Number
|
||||
{
|
||||
return _objectZPosition;
|
||||
}
|
||||
|
||||
override public function moveUp(value:Boolean) : void
|
||||
{
|
||||
super.moveUp(value);
|
||||
if(!inJump && !value)
|
||||
{
|
||||
_jumpLocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function get onGround() : Boolean
|
||||
{
|
||||
return _onGround;
|
||||
}
|
||||
|
||||
public function set flyMode(value:Boolean) : void
|
||||
{
|
||||
_flyMode = value;
|
||||
}
|
||||
|
||||
override protected function rotateObject(frameTime:Number) : void
|
||||
{
|
||||
var rotX:Number = NaN;
|
||||
if(_mouseLookActive)
|
||||
{
|
||||
prevMouseCoords.copy(currentMouseCoords);
|
||||
currentMouseCoords.x = _eventsSource.stage.mouseX;
|
||||
currentMouseCoords.y = _eventsSource.stage.mouseY;
|
||||
if(!prevMouseCoords.equals(currentMouseCoords))
|
||||
{
|
||||
_object.rotationZ = startRotZ + (startMouseCoords.x - currentMouseCoords.x) * _mouseCoefficientX;
|
||||
rotX = startRotX + (startMouseCoords.y - currentMouseCoords.y) * _mouseCoefficientY;
|
||||
if(_object is Camera3D)
|
||||
{
|
||||
_object.rotationX = rotX > MathUtils.DEG90 ? 0 : (rotX < -MathUtils.DEG90 ? -Math.PI : rotX - MathUtils.DEG90);
|
||||
}
|
||||
else
|
||||
{
|
||||
_object.rotationX = rotX > MathUtils.DEG90 ? MathUtils.DEG90 : (rotX < -MathUtils.DEG90 ? -MathUtils.DEG90 : rotX);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_yawLeft)
|
||||
{
|
||||
_object.rotationZ += _yawSpeed * frameTime;
|
||||
}
|
||||
else if(_yawRight)
|
||||
{
|
||||
_object.rotationZ -= _yawSpeed * frameTime;
|
||||
}
|
||||
rotX = NaN;
|
||||
if(_pitchUp)
|
||||
{
|
||||
rotX = _object.rotationX + _pitchSpeed * frameTime;
|
||||
}
|
||||
else if(_pitchDown)
|
||||
{
|
||||
rotX = _object.rotationX - _pitchSpeed * frameTime;
|
||||
}
|
||||
if(!isNaN(rotX))
|
||||
{
|
||||
if(_object is Camera3D)
|
||||
{
|
||||
_object.rotationX = rotX > 0 ? 0 : (rotX < -Math.PI ? -Math.PI : rotX);
|
||||
}
|
||||
else
|
||||
{
|
||||
_object.rotationX = rotX > MathUtils.DEG90 ? MathUtils.DEG90 : (rotX < -MathUtils.DEG90 ? -MathUtils.DEG90 : rotX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get currentSpeed() : Number
|
||||
{
|
||||
return _currentSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
35
src/alternativa/editor/engine3d/loaders/LoaderEvent.as
Normal file
35
src/alternativa/editor/engine3d/loaders/LoaderEvent.as
Normal file
@@ -0,0 +1,35 @@
|
||||
package alternativa.editor.engine3d.loaders
|
||||
{
|
||||
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(type:String, loadingStage:int)
|
||||
{
|
||||
super(type);
|
||||
this._loadingStage = loadingStage;
|
||||
}
|
||||
|
||||
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 + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package alternativa.editor.engine3d.loaders
|
||||
{
|
||||
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(type:String, loadingStage:int, totalItems:int, currentItem:int, bytesLoaded:uint = 0, bytesTotal:uint = 0)
|
||||
{
|
||||
super(type,false,false,bytesLoaded,bytesTotal);
|
||||
this._loadingStage = loadingStage;
|
||||
this._totalItems = totalItems;
|
||||
this._currentItem = currentItem;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public function get loadingStage() : int
|
||||
{
|
||||
return this._loadingStage;
|
||||
}
|
||||
|
||||
public function get totalItems() : int
|
||||
{
|
||||
return this._totalItems;
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return "[LoaderProgressEvent type=\"" + type + "\", loadingStage=" + this._loadingStage + ", totalItems=" + this._totalItems + ", currentItem=" + this._currentItem + ", bytesTotal=" + bytesTotal + ", bytesLoaded=" + bytesLoaded + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
src/alternativa/editor/engine3d/loaders/LoadingStage.as
Normal file
17
src/alternativa/editor/engine3d/loaders/LoadingStage.as
Normal file
@@ -0,0 +1,17 @@
|
||||
package alternativa.editor.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
package alternativa.editor.engine3d.loaders
|
||||
{
|
||||
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;
|
||||
|
||||
[Event(name="ioError",type="flash.events.IOErrorEvent")]
|
||||
[Event(name="complete",type="flash.events.Event")]
|
||||
[Event(name="loadingComplete",type="alternativa.engine3d.loaders.events.LoaderEvent")]
|
||||
[Event(name="loadingProgress",type="alternativa.engine3d.loaders.events.LoaderProgressEvent")]
|
||||
[Event(name="loadingStart",type="alternativa.engine3d.loaders.events.LoaderEvent")]
|
||||
public class TextureMapsBatchLoader extends EventDispatcher
|
||||
{
|
||||
public static var stubBitmapData:BitmapData;
|
||||
|
||||
private var loader:TextureMapsLoader;
|
||||
|
||||
private var _textures:Map;
|
||||
|
||||
private var totalFiles:int;
|
||||
|
||||
private var loaderContext:LoaderContext;
|
||||
|
||||
private var baseUrl:String;
|
||||
|
||||
private var materialNames:Array;
|
||||
|
||||
private var materialIndex:int;
|
||||
|
||||
private var batch:Map;
|
||||
|
||||
private var currentFileNumber:int;
|
||||
|
||||
public function TextureMapsBatchLoader()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
private function loadNextTextureFile() : void
|
||||
{
|
||||
var info:TextureMapsInfo = this.batch[this.materialNames[this.materialIndex]];
|
||||
this.loader.load(this.baseUrl + info.diffuseMapFileName,info.opacityMapFileName == null ? null : this.baseUrl + info.opacityMapFileName,this.loaderContext);
|
||||
}
|
||||
|
||||
private function clean() : void
|
||||
{
|
||||
this.loaderContext = null;
|
||||
this.batch = null;
|
||||
this.materialNames = null;
|
||||
}
|
||||
|
||||
public function get textures() : Map
|
||||
{
|
||||
return this._textures;
|
||||
}
|
||||
|
||||
private function onTextureLoadingStart(e:Event) : void
|
||||
{
|
||||
dispatchEvent(e);
|
||||
}
|
||||
|
||||
private function onProgress(e:ProgressEvent) : void
|
||||
{
|
||||
dispatchEvent(new LoaderProgressEvent(LoaderProgressEvent.LOADING_PROGRESS,LoadingStage.TEXTURE,this.totalFiles,this.currentFileNumber,e.bytesLoaded,e.bytesTotal));
|
||||
}
|
||||
|
||||
public function load(baseURL:String, batch:Map, loaderContext:LoaderContext) : void
|
||||
{
|
||||
var materialName:String = null;
|
||||
var info:TextureMapsInfo = null;
|
||||
this.baseUrl = baseURL;
|
||||
this.batch = batch;
|
||||
this.loaderContext = loaderContext;
|
||||
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(materialName in batch)
|
||||
{
|
||||
this.materialNames.push(materialName);
|
||||
info = batch[materialName];
|
||||
this.totalFiles += info.opacityMapFileName == null ? 1 : 2;
|
||||
}
|
||||
this.currentFileNumber = 1;
|
||||
this.materialIndex = 0;
|
||||
this._textures = new Map();
|
||||
this.loadNextTextureFile();
|
||||
}
|
||||
|
||||
private function onMaterialTexturesLoadingComplete(e:Event) : void
|
||||
{
|
||||
if(e is IOErrorEvent)
|
||||
{
|
||||
this._textures.add(this.materialNames[this.materialIndex],this.getStubBitmapData());
|
||||
dispatchEvent(e);
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public function close() : void
|
||||
{
|
||||
if(this.loader != null)
|
||||
{
|
||||
this.loader.close();
|
||||
}
|
||||
}
|
||||
|
||||
private function onTextureLoadingComplete(e:Event) : void
|
||||
{
|
||||
dispatchEvent(e);
|
||||
++this.currentFileNumber;
|
||||
}
|
||||
|
||||
private function getStubBitmapData() : BitmapData
|
||||
{
|
||||
var size:uint = 0;
|
||||
var i:uint = 0;
|
||||
var j:uint = 0;
|
||||
if(stubBitmapData == null)
|
||||
{
|
||||
size = 20;
|
||||
stubBitmapData = new BitmapData(size,size,false,0);
|
||||
for(i = 0; i < size; i++)
|
||||
{
|
||||
for(j = 0; j < size; j += 2)
|
||||
{
|
||||
stubBitmapData.setPixel(Boolean(i % 2) ? int(j) : j + 1,i,16711935);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stubBitmapData;
|
||||
}
|
||||
|
||||
public function unload() : void
|
||||
{
|
||||
this._textures = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
src/alternativa/editor/engine3d/loaders/TextureMapsInfo.as
Normal file
17
src/alternativa/editor/engine3d/loaders/TextureMapsInfo.as
Normal file
@@ -0,0 +1,17 @@
|
||||
package alternativa.editor.engine3d.loaders
|
||||
{
|
||||
public class TextureMapsInfo
|
||||
{
|
||||
public var opacityMapFileName:String;
|
||||
|
||||
public var diffuseMapFileName:String;
|
||||
|
||||
public function TextureMapsInfo(diffuseMapFileName:String = null, opacityMapFileName:String = null)
|
||||
{
|
||||
super();
|
||||
this.diffuseMapFileName = diffuseMapFileName;
|
||||
this.opacityMapFileName = opacityMapFileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
187
src/alternativa/editor/engine3d/loaders/TextureMapsLoader.as
Normal file
187
src/alternativa/editor/engine3d/loaders/TextureMapsLoader.as
Normal file
@@ -0,0 +1,187 @@
|
||||
package alternativa.editor.engine3d.loaders
|
||||
{
|
||||
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;
|
||||
import mx.controls.Alert;
|
||||
import flash.filesystem.File;
|
||||
|
||||
[Event(name="progress",type="flash.events.ProgressEvent")]
|
||||
[Event(name="ioError",type="flash.events.IOErrorEvent")]
|
||||
[Event(name="complete",type="flash.events.Event")]
|
||||
[Event(name="loadingComplete",type="alternativa.engine3d.loaders.events.LoaderEvent")]
|
||||
[Event(name="loadingStart",type="alternativa.engine3d.loaders.events.LoaderEvent")]
|
||||
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 bitmapLoader:Loader;
|
||||
|
||||
private var loaderContext:LoaderContext;
|
||||
|
||||
private var alphaTextureUrl:String;
|
||||
|
||||
private var _bitmapData:BitmapData;
|
||||
|
||||
private var loaderState:int = 0;
|
||||
|
||||
private var _triedPNG:Boolean = false;
|
||||
private var _triedUnderscore:Boolean = false;
|
||||
private var _originalUrl:String;
|
||||
|
||||
public function TextureMapsLoader(diffuseTextureUrl:String = null, alphaTextureUrl:String = null, loaderContext:LoaderContext = null)
|
||||
{
|
||||
super();
|
||||
if(diffuseTextureUrl != null)
|
||||
{
|
||||
this.load(diffuseTextureUrl,alphaTextureUrl,loaderContext);
|
||||
}
|
||||
}
|
||||
|
||||
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 load(diffuseTextureUrl:String, alphaTextureUrl:String = null, loaderContext:LoaderContext = null) : void
|
||||
{
|
||||
this.alphaTextureUrl = alphaTextureUrl;
|
||||
this.loaderContext = loaderContext;
|
||||
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();
|
||||
}
|
||||
_originalUrl = diffuseTextureUrl;
|
||||
this.startLoading(STATE_LOADING_DIFFUSE_MAP,diffuseTextureUrl);
|
||||
}
|
||||
|
||||
private function onComplete(e:Event) : void
|
||||
{
|
||||
var tmpBmp:BitmapData = null;
|
||||
var alpha: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)
|
||||
{
|
||||
_originalUrl = this.alphaTextureUrl;
|
||||
this.startLoading(STATE_LOADING_ALPHA_MAP,this.alphaTextureUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.complete();
|
||||
}
|
||||
break;
|
||||
case STATE_LOADING_ALPHA_MAP:
|
||||
tmpBmp = this._bitmapData;
|
||||
this._bitmapData = new BitmapData(this._bitmapData.width,this._bitmapData.height,true,0);
|
||||
this._bitmapData.copyPixels(tmpBmp,tmpBmp.rect,new Point());
|
||||
alpha = Bitmap(this.bitmapLoader.content).bitmapData;
|
||||
if(this._bitmapData.width != alpha.width || this._bitmapData.height != alpha.height)
|
||||
{
|
||||
tmpBmp.draw(alpha,new Matrix(this._bitmapData.width / alpha.width,0,0,this._bitmapData.height / alpha.height),null,BlendMode.NORMAL,null,true);
|
||||
alpha.dispose();
|
||||
alpha = tmpBmp;
|
||||
}
|
||||
this._bitmapData.copyChannel(alpha,alpha.rect,new Point(),BitmapDataChannel.RED,BitmapDataChannel.ALPHA);
|
||||
alpha.dispose();
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
|
||||
private function onOpen(e:Event) : void
|
||||
{
|
||||
dispatchEvent(new LoaderEvent(LoaderEvent.LOADING_START,LoadingStage.TEXTURE));
|
||||
}
|
||||
|
||||
private function onLoadError(e:IOErrorEvent) : void
|
||||
{
|
||||
var split:Array = _originalUrl.split(File.separator);
|
||||
var lastPart:String = split[split.length-1];
|
||||
if(!_triedUnderscore && lastPart.indexOf("_") != -1)
|
||||
{
|
||||
_triedUnderscore = true;
|
||||
var underscoreIndex:int = _originalUrl.lastIndexOf("_");
|
||||
this.bitmapLoader.load(new URLRequest(_originalUrl.slice(0,underscoreIndex)+_originalUrl.slice(underscoreIndex,_originalUrl.length-underscoreIndex)),this.loaderContext);
|
||||
return;
|
||||
}
|
||||
if(!_triedPNG && _originalUrl.indexOf(".jpg") != -1)
|
||||
{
|
||||
_triedPNG = true;
|
||||
this.bitmapLoader.load(new URLRequest(_originalUrl.replace(".jpg",".png")),this.loaderContext);
|
||||
return;
|
||||
}
|
||||
this.loaderState = STATE_IDLE;
|
||||
//dispatchEvent(e);
|
||||
|
||||
this._bitmapData = new BitmapData(1,1,false,0xff00ff);
|
||||
dispatchEvent(new Event(Event.COMPLETE));
|
||||
}
|
||||
|
||||
private function onProgress(e:Event) : void
|
||||
{
|
||||
dispatchEvent(e);
|
||||
}
|
||||
|
||||
public function unload() : void
|
||||
{
|
||||
if(this.loaderState == STATE_IDLE)
|
||||
{
|
||||
if(this.bitmapLoader != null)
|
||||
{
|
||||
this.bitmapLoader.unload();
|
||||
}
|
||||
this.loaderContext = null;
|
||||
this._bitmapData = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function complete() : void
|
||||
{
|
||||
this.loaderState = STATE_IDLE;
|
||||
this.bitmapLoader.unload();
|
||||
dispatchEvent(new Event(Event.COMPLETE));
|
||||
}
|
||||
|
||||
private function startLoading(state:int, url:String) : void
|
||||
{
|
||||
this.loaderState = state;
|
||||
this.bitmapLoader.load(new URLRequest(url),this.loaderContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
74
src/alternativa/editor/engine3d/materials/WireMaterial.as
Normal file
74
src/alternativa/editor/engine3d/materials/WireMaterial.as
Normal file
@@ -0,0 +1,74 @@
|
||||
package alternativa.editor.engine3d.materials
|
||||
{
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import flash.display.BitmapData;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.materials.Material;
|
||||
import flash.display.Shape;
|
||||
import flash.display.Graphics;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class WireMaterial extends TextureMaterial
|
||||
{
|
||||
private static const shape:Shape = new Shape();
|
||||
|
||||
private var _color:uint;
|
||||
private var _thickness:int;
|
||||
private var _width:int;
|
||||
private var _height:int;
|
||||
private var _segments:int;
|
||||
|
||||
public function WireMaterial(thickness:int, width:int, height:int, segments:int = 5, color:uint = 0x0)
|
||||
{
|
||||
_color = color;
|
||||
_thickness = thickness;
|
||||
_width = width;
|
||||
_height = height;
|
||||
_segments = segments;
|
||||
|
||||
_hardwareMipMaps = true;
|
||||
_mipMapping = 1;
|
||||
super(createWireTexture());
|
||||
}
|
||||
|
||||
override public function clone():Material
|
||||
{
|
||||
var _local_1:WireMaterial = new WireMaterial(_color, _thickness, _width, _height, _segments);
|
||||
_local_1.clonePropertiesFrom(this);
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
private function createWireTexture() : BitmapData
|
||||
{
|
||||
var ctx:Graphics = shape.graphics;
|
||||
ctx.clear();
|
||||
shape.width = _width;
|
||||
shape.height = _height;
|
||||
|
||||
var offsetPerNumX:Number = _width / _segments;
|
||||
var offsetPerNumY:Number = _height / _segments;
|
||||
|
||||
ctx.lineStyle(_thickness, _color);
|
||||
|
||||
var num:int;
|
||||
var pos:Number;
|
||||
for(num = 0; num < _segments; num++)
|
||||
{
|
||||
pos = num * offsetPerNumX;
|
||||
ctx.moveTo(pos, 0);
|
||||
ctx.lineTo(pos, _height);
|
||||
}
|
||||
for(num = 0; num < _segments; num++)
|
||||
{
|
||||
pos = num * offsetPerNumY;
|
||||
ctx.moveTo(0, pos);
|
||||
ctx.lineTo(_width, pos);
|
||||
}
|
||||
|
||||
var bitmap:BitmapData = new BitmapData(_width, _height, true, 0x00000000);
|
||||
bitmap.draw(shape);
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package alternativa.editor.mapexport
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Vertex;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.types.Matrix4;
|
||||
import alternativa.types.Point3D;
|
||||
|
||||
public class CollisionBox extends CollisionPrimitive
|
||||
@@ -68,9 +68,9 @@ package alternativa.editor.mapexport
|
||||
transform.l = loc9.z;
|
||||
}
|
||||
|
||||
override public function getXml(param1:Matrix3D) : XML
|
||||
override public function getXml(param1:Matrix4) : XML
|
||||
{
|
||||
var loc2:Matrix3D = null;
|
||||
var loc2:Matrix4 = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
loc2 = transform;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package alternativa.editor.mapexport
|
||||
{
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.types.Matrix4;
|
||||
|
||||
public class CollisionPrimitive
|
||||
{
|
||||
@@ -11,11 +11,11 @@ package alternativa.editor.mapexport
|
||||
|
||||
public var id:int;
|
||||
|
||||
public var transform:Matrix3D;
|
||||
public var transform:Matrix4;
|
||||
|
||||
public function CollisionPrimitive(param1:int, param2:Mesh = null)
|
||||
{
|
||||
this.transform = new Matrix3D();
|
||||
this.transform = new Matrix4();
|
||||
super();
|
||||
this.id = param1;
|
||||
if(param2 != null)
|
||||
@@ -28,7 +28,7 @@ package alternativa.editor.mapexport
|
||||
{
|
||||
}
|
||||
|
||||
public function getXml(param1:Matrix3D) : XML
|
||||
public function getXml(param1:Matrix4) : XML
|
||||
{
|
||||
return new XML();
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package alternativa.editor.mapexport
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Face;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.types.Matrix4;
|
||||
import alternativa.types.Point3D;
|
||||
|
||||
public class CollisionRect extends CollisionPrimitive
|
||||
@@ -59,9 +59,9 @@ package alternativa.editor.mapexport
|
||||
transform.translate(param1.alternativa3d::_coords.x,param1.alternativa3d::_coords.y,param1.alternativa3d::_coords.z);
|
||||
}
|
||||
|
||||
override public function getXml(param1:Matrix3D) : XML
|
||||
override public function getXml(param1:Matrix4) : XML
|
||||
{
|
||||
var loc2:Matrix3D = null;
|
||||
var loc2:Matrix4 = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
loc2 = transform;
|
||||
|
||||
@@ -2,9 +2,9 @@ package alternativa.editor.mapexport
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Face;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Vertex;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.types.Matrix4;
|
||||
import alternativa.types.Point3D;
|
||||
|
||||
public class CollisionTriangle extends CollisionPrimitive
|
||||
@@ -25,10 +25,10 @@ package alternativa.editor.mapexport
|
||||
|
||||
override public function parse(param1:Mesh) : void
|
||||
{
|
||||
var loc2:Array = Face(param1.alternativa3d::_faces.peek()).vertices;
|
||||
this.v0.copy(Vertex(loc2[0]).alternativa3d::_coords);
|
||||
this.v1.copy(Vertex(loc2[1]).alternativa3d::_coords);
|
||||
this.v2.copy(Vertex(loc2[2]).alternativa3d::_coords);
|
||||
var loc2:Vector.<Vertex> = param1.faceList.vertices;
|
||||
this.v0.copy((loc2[0]).alternativa3d::_coords);
|
||||
this.v1.copy((loc2[1]).alternativa3d::_coords);
|
||||
this.v2.copy((loc2[2]).alternativa3d::_coords);
|
||||
var loc3:Point3D = new Point3D();
|
||||
loc3.x = (this.v0.x + this.v1.x + this.v2.x) / 3;
|
||||
loc3.y = (this.v0.y + this.v1.y + this.v2.y) / 3;
|
||||
@@ -59,9 +59,9 @@ package alternativa.editor.mapexport
|
||||
this.v2.y -= loc7;
|
||||
}
|
||||
|
||||
override public function getXml(param1:Matrix3D) : XML
|
||||
override public function getXml(param1:Matrix4) : XML
|
||||
{
|
||||
var loc2:Matrix3D = null;
|
||||
var loc2:Matrix4 = null;
|
||||
if(param1 == null)
|
||||
{
|
||||
loc2 = transform;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package alternativa.editor.mapexport
|
||||
{
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import flash.filesystem.FileStream;
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
|
||||
public class FileExporter
|
||||
{
|
||||
public var sceneRoot:Object3D;
|
||||
public var sceneRoot:Object3DContainer;
|
||||
|
||||
public function FileExporter(param1:Object3D)
|
||||
public function FileExporter(param1:Object3DContainer)
|
||||
{
|
||||
super();
|
||||
this.sceneRoot = param1;
|
||||
|
||||
@@ -10,10 +10,11 @@ package alternativa.editor.mapexport
|
||||
import alternativa.editor.prop.SpawnPoint;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import flash.filesystem.FileStream;
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
|
||||
public class TanksXmlExporterV1Full extends TanksXmlExporterV1Lite
|
||||
{
|
||||
public function TanksXmlExporterV1Full(param1:Object3D)
|
||||
public function TanksXmlExporterV1Full(param1:Object3DContainer)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
@@ -41,7 +42,6 @@ package alternativa.editor.mapexport
|
||||
|
||||
override public function exportToFileStream(param1:FileStream) : void
|
||||
{
|
||||
var loc8:* = undefined;
|
||||
var loc9:Prop = null;
|
||||
var loc10:MeshProp = null;
|
||||
var loc2:XML = new XML("<map version=\"1.0\">\r\n\t\t\t\t\t\t<static-geometry>\r\n\t\t\t\t\t\t</static-geometry>\r\n\t\t\t\t\t\t<collision-geometry>\r\n\t\t\t\t\t\t</collision-geometry>\r\n\t\t\t\t\t\t<spawn-points>\r\n\t\t\t\t\t\t</spawn-points>\r\n\t\t\t\t\t\t<bonus-regions>\r\n\t\t\t\t\t\t</bonus-regions>\r\n\t\t\t\t\t\t" + ("<" + FunctionalProps.KILL_GEOMETRY + "/>") + "\r\n\t\t\t\t\t</map>");
|
||||
@@ -50,7 +50,7 @@ package alternativa.editor.mapexport
|
||||
var loc5:XML = loc2.child("bonus-regions")[0];
|
||||
var loc6:XML = loc2.child("spawn-points")[0];
|
||||
var loc7:XML = loc2.child(FunctionalProps.KILL_GEOMETRY)[0];
|
||||
for(loc8 in sceneRoot.children)
|
||||
for each(var loc8:Object3D in sceneRoot.children)
|
||||
{
|
||||
loc9 = loc8 as Prop;
|
||||
if(!loc9)
|
||||
|
||||
@@ -8,9 +8,10 @@ package alternativa.editor.mapexport
|
||||
import alternativa.editor.prop.Prop;
|
||||
import alternativa.editor.prop.SpawnPoint;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import flash.filesystem.FileStream;
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
|
||||
public class TanksXmlExporterV1Lite extends FileExporter
|
||||
{
|
||||
@@ -18,7 +19,7 @@ package alternativa.editor.mapexport
|
||||
|
||||
private var collPrimCache:CollisionPrimitivesCache;
|
||||
|
||||
public function TanksXmlExporterV1Lite(param1:Object3D)
|
||||
public function TanksXmlExporterV1Lite(param1:Object3DContainer)
|
||||
{
|
||||
super(param1);
|
||||
this.collPrimCache = new CollisionPrimitivesCache();
|
||||
@@ -183,7 +184,6 @@ package alternativa.editor.mapexport
|
||||
|
||||
override public function exportToFileStream(param1:FileStream) : void
|
||||
{
|
||||
var loc7:* = undefined;
|
||||
var loc8:Prop = null;
|
||||
var loc9:MeshProp = null;
|
||||
var loc2:XML = <map version="1.0.Light">
|
||||
@@ -200,7 +200,7 @@ package alternativa.editor.mapexport
|
||||
var loc4:XML = loc2.child("collision-geometry")[0];
|
||||
var loc5:XML = loc2.child("bonus-regions")[0];
|
||||
var loc6:XML = loc2.child("spawn-points")[0];
|
||||
for(loc7 in sceneRoot.children)
|
||||
for each(var loc7:Object3D in sceneRoot.children)
|
||||
{
|
||||
loc8 = loc7 as Prop;
|
||||
if(!loc8)
|
||||
|
||||
@@ -7,9 +7,10 @@ package alternativa.editor.mapexport
|
||||
import alternativa.editor.prop.SpawnPoint;
|
||||
import alternativa.editor.prop.Sprite3DProp;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import flash.filesystem.FileStream;
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
@@ -39,14 +40,13 @@ package alternativa.editor.mapexport
|
||||
|
||||
private var spritesXML:XML;
|
||||
|
||||
public function TanksXmlExporterV3(param1:Object3D)
|
||||
public function TanksXmlExporterV3(param1:Object3DContainer)
|
||||
{
|
||||
super(param1);
|
||||
}
|
||||
|
||||
override public function exportToFileStream(param1:FileStream) : void
|
||||
{
|
||||
var loc6:* = undefined;
|
||||
var loc7:XML = null;
|
||||
var loc8:PropRegistryData = null;
|
||||
var loc9:Prop = null;
|
||||
@@ -63,7 +63,7 @@ package alternativa.editor.mapexport
|
||||
var loc3:XML = <x/>;
|
||||
var loc4:XML = <x/>;
|
||||
var loc5:XML = <ctf-flags/>;
|
||||
for(loc6 in sceneRoot.children)
|
||||
for each(var loc6:Object3D in sceneRoot.children)
|
||||
{
|
||||
loc9 = loc6 as Prop;
|
||||
if(!loc9)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package alternativa.editor.prop
|
||||
{
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import alternativa.types.Set;
|
||||
@@ -37,7 +37,7 @@ package alternativa.editor.prop
|
||||
{
|
||||
var loc2:BonusRegion = null;
|
||||
var loc1:Mesh = _object.clone() as Mesh;
|
||||
loc1.cloneMaterialToAllSurfaces(_material as TextureMaterial);
|
||||
loc1.setMaterialToAllFaces(_material as TextureMaterial);
|
||||
loc2 = new BonusRegion(loc1,name,_libraryName,_groupName,false);
|
||||
loc2.distancesX = distancesX.clone();
|
||||
loc2.distancesY = distancesY.clone();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package alternativa.editor.prop
|
||||
{
|
||||
import alternativa.editor.scene.EditorScene;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import flash.geom.Point;
|
||||
@@ -25,7 +25,7 @@ package alternativa.editor.prop
|
||||
override public function clone() : Object3D
|
||||
{
|
||||
var loc1:Mesh = _object.clone() as Mesh;
|
||||
loc1.cloneMaterialToAllSurfaces(_material as TextureMaterial);
|
||||
loc1.setMaterialToAllFaces(_material as TextureMaterial);
|
||||
var loc2:CTFFlagBase = new CTFFlagBase(loc1,name,_libraryName,_groupName,false);
|
||||
loc2.distancesX = distancesX.clone();
|
||||
loc2.distancesY = distancesY.clone();
|
||||
|
||||
@@ -2,9 +2,9 @@ package alternativa.editor.prop
|
||||
{
|
||||
import alternativa.editor.events.DominationSpawnLinkEndEvent;
|
||||
import alternativa.editor.scene.EditorScene;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.events.MouseEvent3D;
|
||||
import alternativa.engine3d.core.MouseEvent3D;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.Dictionary;
|
||||
@@ -68,7 +68,7 @@ package alternativa.editor.prop
|
||||
override public function clone() : Object3D
|
||||
{
|
||||
var loc1:Mesh = _object.clone() as Mesh;
|
||||
loc1.cloneMaterialToAllSurfaces(_material as TextureMaterial);
|
||||
loc1.setMaterialToAllFaces(_material as TextureMaterial);
|
||||
var loc2:ControlPoint = new ControlPoint(loc1,name,_libraryName,_groupName,false);
|
||||
loc2.distancesX = distancesX.clone();
|
||||
loc2.distancesY = distancesY.clone();
|
||||
|
||||
@@ -2,8 +2,6 @@ package alternativa.editor.prop
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.core.PolyPrimitive;
|
||||
import alternativa.engine3d.display.Skin;
|
||||
import alternativa.engine3d.materials.FillMaterial;
|
||||
import alternativa.engine3d.materials.Material;
|
||||
import alternativa.types.Point3D;
|
||||
@@ -19,16 +17,20 @@ package alternativa.editor.prop
|
||||
|
||||
private var normal:Point3D;
|
||||
|
||||
private var blendMode:String;
|
||||
|
||||
public function CustomFillMaterial(param1:Point3D, param2:uint, param3:Number = 1, param4:String = "normal", param5:Number = -1, param6:uint = 0)
|
||||
{
|
||||
this.center = new Point3D();
|
||||
this.lightPoint = new Point3D();
|
||||
this.normal = new Point3D();
|
||||
super(param2,param3,param4,param5,param6);
|
||||
//super(param2,param3,param4,param5,param6);
|
||||
super(param2, param3, param5, param6);
|
||||
this.lightPoint.copy(param1);
|
||||
this.blendMode = param4;
|
||||
}
|
||||
|
||||
override alternativa3d function draw(param1:Camera3D, param2:Skin, param3:uint, param4:Array) : void
|
||||
/*override alternativa3d function draw(param1:Camera3D, param2:Skin, param3:uint, param4:Array) : void
|
||||
{
|
||||
var loc5:PolyPrimitive = param2.alternativa3d::primitive;
|
||||
this.center.reset();
|
||||
@@ -46,11 +48,11 @@ package alternativa.editor.prop
|
||||
alternativa3d::_color = ColorUtils.multiply(alternativa3d::_color,loc8);
|
||||
super.alternativa3d::draw(param1,param2,param3,param4);
|
||||
alternativa3d::_color = loc7;
|
||||
}
|
||||
}*/
|
||||
|
||||
override public function clone() : Material
|
||||
{
|
||||
return new CustomFillMaterial(this.lightPoint,color,alpha,blendMode,wireThickness,wireColor);
|
||||
return new CustomFillMaterial(this.lightPoint,color,alpha,blendMode,lineThickness,lineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
package alternativa.editor.prop
|
||||
{
|
||||
import alternativa.editor.scene.MainScene;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.materials.Material;
|
||||
import alternativa.engine3d.materials.SurfaceMaterial;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import alternativa.engine3d.primitives.Box;
|
||||
import alternativa.engine3d.primitives.Plane;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.types.Set;
|
||||
import alternativa.types.Texture;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.BlendMode;
|
||||
import flash.geom.Vector3D;
|
||||
|
||||
public class FreeBonusRegion extends Prop
|
||||
{
|
||||
private static const tmpVec:Vector3D = new Vector3D();
|
||||
|
||||
private static const BASE_WIDTH:Number = 500;
|
||||
|
||||
private static const BASE_LENGTH:Number = 500;
|
||||
|
||||
private static const BASE_HEIGHT:Number = 300;
|
||||
|
||||
private static const texture:Texture = new Texture(new BitmapData(1,1,false,16756224));
|
||||
private static const texture:BitmapData = new BitmapData(1,1,false,16756224);
|
||||
|
||||
private var _typeNames:Set;
|
||||
|
||||
@@ -47,8 +48,9 @@ package alternativa.editor.prop
|
||||
loc5.x = BASE_WIDTH / 2;
|
||||
loc5.y = BASE_LENGTH / 2;
|
||||
loc5.z = BASE_HEIGHT / 2;
|
||||
_material = new TextureMaterial(texture,0.5,true,false,BlendMode.MULTIPLY);
|
||||
loc5.cloneMaterialToAllSurfaces(SurfaceMaterial(_material));
|
||||
//_material = new TextureMaterial(texture,0.5,true,false,BlendMode.MULTIPLY);
|
||||
_material = new TextureMaterial(texture);
|
||||
loc5.setMaterialToAllFaces(_material);
|
||||
_object = loc5;
|
||||
super(object,param1,param2,param3,param4);
|
||||
type = Prop.BONUS;
|
||||
@@ -68,7 +70,7 @@ package alternativa.editor.prop
|
||||
override public function clone() : Object3D
|
||||
{
|
||||
var loc1:Mesh = _object.clone() as Mesh;
|
||||
loc1.cloneMaterialToAllSurfaces(_material as TextureMaterial);
|
||||
loc1.setMaterialToAllFaces(_material as TextureMaterial);
|
||||
var loc2:FreeBonusRegion = new FreeBonusRegion(name,_libraryName,_groupName,false);
|
||||
loc2.scaleX = scaleX;
|
||||
loc2.scaleY = scaleY;
|
||||
@@ -86,19 +88,20 @@ package alternativa.editor.prop
|
||||
|
||||
public function showDestinationArea() : void
|
||||
{
|
||||
if(Boolean(this.shadow) && children.has(this.shadow))
|
||||
if(Boolean(this.shadow) && contains(this.shadow))
|
||||
{
|
||||
removeChild(this.shadow);
|
||||
}
|
||||
var loc1:Point3D = MainScene.getProjectedPoint(new Point3D(x + scaleX * BASE_WIDTH / 2,y + scaleY * BASE_LENGTH / 2,z - 50));
|
||||
globalToLocal(loc1,loc1);
|
||||
var loc1:Vector3D = MainScene.getProjectedPoint(new Vector3D(x + scaleX * BASE_WIDTH / 2,y + scaleY * BASE_LENGTH / 2,z - 50));
|
||||
loc1 = globalToLocal(loc1);
|
||||
var loc2:Number = BASE_WIDTH * scaleX + this.BOX_SIZE;
|
||||
var loc3:Number = BASE_LENGTH * scaleY + this.BOX_SIZE;
|
||||
this.shadow = new Plane(loc2,loc3);
|
||||
this.shadow.mouseEnabled = false;
|
||||
var loc4:TextureMaterial = new TextureMaterial(texture);
|
||||
loc4.alpha = 0.5;
|
||||
this.shadow.cloneMaterialToAllSurfaces(loc4);
|
||||
//loc4.alpha = 0.5;
|
||||
this.shadow.alpha = 0.5;
|
||||
this.shadow.setMaterialToAllFaces(loc4);
|
||||
this.shadow.scaleX /= scaleX;
|
||||
this.shadow.scaleY /= scaleY;
|
||||
this.shadow.x = BASE_WIDTH / 2;
|
||||
@@ -109,9 +112,10 @@ package alternativa.editor.prop
|
||||
|
||||
override public function setMaterial(param1:Material) : void
|
||||
{
|
||||
var loc2:SurfaceMaterial = param1 as SurfaceMaterial;
|
||||
(_object as Mesh).cloneMaterialToAllSurfaces(loc2);
|
||||
(this.shadow as Mesh).cloneMaterialToAllSurfaces(loc2);
|
||||
//var loc2:SurfaceMaterial = param1 as SurfaceMaterial;
|
||||
var loc2:Material = param1; //TODO check maybe FillMaterial is not Surface
|
||||
(_object as Mesh).setMaterialToAllFaces(loc2);
|
||||
(this.shadow as Mesh).setMaterialToAllFaces(loc2);
|
||||
}
|
||||
|
||||
override public function get rotationX() : Number
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package alternativa.editor.prop
|
||||
{
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import alternativa.engine3d.primitives.Box;
|
||||
import alternativa.types.Texture;
|
||||
import flash.display.BitmapData;
|
||||
import mx.collections.ArrayCollection;
|
||||
|
||||
@@ -22,7 +21,7 @@ package alternativa.editor.prop
|
||||
|
||||
private static const BASE_HEIGHT:Number = 300;
|
||||
|
||||
private static const texture:Texture = new Texture(new BitmapData(1,1,false,15732981));
|
||||
private static const texture:BitmapData = new BitmapData(1,1,false,15732981);
|
||||
|
||||
public static const typesProvider:ArrayCollection = new ArrayCollection([KICK,KILL,BLOCK]);
|
||||
|
||||
@@ -36,8 +35,9 @@ package alternativa.editor.prop
|
||||
loc5.z = BASE_HEIGHT / 2;
|
||||
_object = loc5;
|
||||
var loc6:TextureMaterial = new TextureMaterial(texture);
|
||||
loc6.alpha = 0.5;
|
||||
loc5.cloneMaterialToAllSurfaces(loc6);
|
||||
//loc6.alpha = 0.5;
|
||||
loc5.alpha = 0.5;
|
||||
loc5.setMaterialToAllFaces(loc6);
|
||||
super(object,param1,param2,param3,param4);
|
||||
type = Prop.KILL_GEOMETRY;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ package alternativa.editor.prop
|
||||
override public function clone() : Object3D
|
||||
{
|
||||
var loc1:Mesh = _object.clone() as Mesh;
|
||||
loc1.cloneMaterialToAllSurfaces(_material as TextureMaterial);
|
||||
loc1.setMaterialToAllFaces(_material as TextureMaterial);
|
||||
var loc2:KillBox = new KillBox(name,_libraryName,_groupName,false);
|
||||
loc2.action = this.action;
|
||||
loc2.scaleX = scaleX;
|
||||
|
||||
@@ -2,19 +2,19 @@ package alternativa.editor.prop
|
||||
{
|
||||
import alternativa.editor.InvisibleTexture;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Surface;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import alternativa.engine3d.materials.WireMaterial;
|
||||
import alternativa.types.Map;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.types.Matrix4;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.types.Set;
|
||||
import alternativa.types.Texture;
|
||||
import flash.display.BitmapData;
|
||||
import flash.geom.Matrix;
|
||||
import mx.controls.Alert;
|
||||
import alternativa.engine3d.core.Face;
|
||||
import alternativa.editor.engine3d.materials.WireMaterial;
|
||||
import alternativa.engine3d.core.Vertex;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
@@ -32,11 +32,14 @@ package alternativa.editor.prop
|
||||
|
||||
private var bound:Mesh;
|
||||
|
||||
public function MeshProp(param1:Object3D, param2:String, param3:String, param4:String, param5:Boolean = true)
|
||||
private var _objects:Vector.<Object3D>;
|
||||
|
||||
public function MeshProp(mainObject:Object3D, objects:Vector.<Object3D>, param2:String, param3:String, param4:String, param5:Boolean = true)
|
||||
{
|
||||
super(param1,param2,param3,param4,param5);
|
||||
super(mainObject,param2,param3,param4,param5);
|
||||
_objects = objects;
|
||||
type = Prop.TILE;
|
||||
this.parseCollisionData(param1);
|
||||
this.parseCollisionData(mainObject, objects);
|
||||
}
|
||||
|
||||
private static function getMirrorBitmapData(param1:BitmapData) : BitmapData
|
||||
@@ -46,17 +49,17 @@ package alternativa.editor.prop
|
||||
return loc2;
|
||||
}
|
||||
|
||||
private function parseCollisionData(param1:Object3D) : void
|
||||
private function parseCollisionData(mainObject:Object3D, objects:Vector.<Object3D>) : void
|
||||
{
|
||||
var loc2:* = undefined;
|
||||
var loc2:Object3D;
|
||||
var loc3:Mesh = null;
|
||||
this.collisionBoxes = new Set();
|
||||
for(loc2 in param1.children)
|
||||
for each(loc2 in objects)
|
||||
{
|
||||
loc3 = loc2 as Mesh;
|
||||
if(loc3)
|
||||
{
|
||||
loc3.cloneMaterialToAllSurfaces(null);
|
||||
loc3.setMaterialToAllFaces(null);
|
||||
if(loc3.name.substr(0,3) != "occ")
|
||||
{
|
||||
this.collisionBoxes.add(loc3);
|
||||
@@ -64,7 +67,7 @@ package alternativa.editor.prop
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.show(param1.name + " include invalid collision mesh " + Object3D(loc2).name);
|
||||
Alert.show(mainObject.name + " include invalid collision mesh " + Object3D(loc2).name);
|
||||
}
|
||||
}
|
||||
this.collisionMaterial = new CustomFillMaterial(new Point3D(-10000000000,-7000000000,4000000000),16744319);
|
||||
@@ -77,7 +80,7 @@ package alternativa.editor.prop
|
||||
for(loc1 in this.collisionBoxes)
|
||||
{
|
||||
loc2 = loc1 as Mesh;
|
||||
loc2.cloneMaterialToAllSurfaces(this.collisionMaterial);
|
||||
loc2.setMaterialToAllFaces(this.collisionMaterial);
|
||||
}
|
||||
setMaterial(null);
|
||||
}
|
||||
@@ -89,7 +92,7 @@ package alternativa.editor.prop
|
||||
for(loc1 in this.collisionBoxes)
|
||||
{
|
||||
loc2 = loc1 as Mesh;
|
||||
loc2.cloneMaterialToAllSurfaces(null);
|
||||
loc2.setMaterialToAllFaces(null);
|
||||
}
|
||||
setMaterial(_material);
|
||||
}
|
||||
@@ -115,7 +118,7 @@ package alternativa.editor.prop
|
||||
{
|
||||
bitmapData = this._isMirror ? getMirrorBitmapData(this.bitmaps[param1]) : this.bitmaps[param1];
|
||||
}
|
||||
_material = new TextureMaterial(new Texture(bitmapData));
|
||||
_material = new TextureMaterial(bitmapData);
|
||||
if(_selected)
|
||||
{
|
||||
_selectBitmapData.dispose();
|
||||
@@ -135,7 +138,7 @@ package alternativa.editor.prop
|
||||
{
|
||||
this._isMirror = !this._isMirror;
|
||||
bitmapData = getMirrorBitmapData(bitmapData);
|
||||
(_material as TextureMaterial).texture = new Texture(bitmapData);
|
||||
(_material as TextureMaterial).texture = bitmapData;
|
||||
if(selected)
|
||||
{
|
||||
_selectBitmapData.dispose();
|
||||
@@ -150,8 +153,15 @@ package alternativa.editor.prop
|
||||
override public function clone() : Object3D
|
||||
{
|
||||
var loc1:Mesh = _object.clone() as Mesh;
|
||||
loc1.cloneMaterialToAllSurfaces(_material as TextureMaterial);
|
||||
var loc2:MeshProp = new MeshProp(loc1,name,_libraryName,_groupName,false);
|
||||
loc1.setMaterialToAllFaces(_material as TextureMaterial);
|
||||
|
||||
var objectsCopy:Vector.<Object3D> = new Vector.<Object3D>();
|
||||
for each(var obj:Object3D in _objects)
|
||||
{
|
||||
objectsCopy.push(obj.clone());
|
||||
}
|
||||
|
||||
var loc2:MeshProp = new MeshProp(loc1,objectsCopy,name,_libraryName,_groupName,false);
|
||||
loc2.distancesX = distancesX.clone();
|
||||
loc2.distancesY = distancesY.clone();
|
||||
loc2.distancesZ = distancesZ.clone();
|
||||
@@ -165,12 +175,12 @@ package alternativa.editor.prop
|
||||
|
||||
public function showBound() : void
|
||||
{
|
||||
var loc1:Matrix3D = null;
|
||||
var loc1:Matrix4 = null;
|
||||
var loc2:Point3D = null;
|
||||
var loc3:Point3D = null;
|
||||
var loc4:Point3D = null;
|
||||
var loc5:Point3D = null;
|
||||
var loc6:Surface = null;
|
||||
var loc6:Face = null;
|
||||
if(!this.bound)
|
||||
{
|
||||
this.bound = new Mesh();
|
||||
@@ -184,12 +194,13 @@ package alternativa.editor.prop
|
||||
loc4.transform(loc1);
|
||||
loc3.transform(loc1);
|
||||
loc2.transform(loc1);
|
||||
this.bound.createFace([this.bound.createVertex(loc2.x,loc2.y,loc2.z,3),this.bound.createVertex(loc3.x,loc3.y,loc3.z,2),this.bound.createVertex(loc4.x,loc4.y,loc4.z,1),this.bound.createVertex(loc5.x,loc5.y,loc5.z,0)],0);
|
||||
loc6 = this.bound.createSurface([0],0);
|
||||
loc6.material = new WireMaterial(4,255);
|
||||
this.bound.addFace(Vector.<Vertex>([this.bound.addVertex(loc2.x,loc2.y,loc2.z,3),this.bound.addVertex(loc3.x,loc3.y,loc3.z,2),this.bound.addVertex(loc4.x,loc4.y,loc4.z,1),this.bound.addVertex(loc5.x,loc5.y,loc5.z,0)]));
|
||||
//loc6 = this.bound.createSurface([0],0);
|
||||
//loc6.material = new WireMaterial(4,255);
|
||||
this.bound.setMaterialToAllFaces(new WireMaterial(4,128,128,5,255));
|
||||
addChild(this.bound);
|
||||
this.bound.z = 0.1;
|
||||
this.bound.mobility = -100;
|
||||
//this.bound.mobility = -100;
|
||||
this.bound.mouseEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
package alternativa.editor.prop
|
||||
{
|
||||
import alternativa.editor.scene.EditorScene;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.events.MouseEvent3D;
|
||||
import alternativa.engine3d.core.MouseEvent3D;
|
||||
import alternativa.engine3d.materials.Material;
|
||||
import alternativa.engine3d.materials.SurfaceMaterial;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import alternativa.types.Map;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.types.Texture;
|
||||
import alternativa.utils.MathUtils;
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.BlendMode;
|
||||
import flash.geom.Matrix;
|
||||
import flash.geom.Point;
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
import alternativa.engine3d.core.Vertex;
|
||||
import flash.geom.Vector3D;
|
||||
|
||||
public class Prop extends Object3D
|
||||
public class Prop extends Object3DContainer
|
||||
{
|
||||
public static const TILE:int = 1;
|
||||
|
||||
@@ -31,12 +30,15 @@ package alternativa.editor.prop
|
||||
|
||||
public static const KILL_GEOMETRY:int = 6;
|
||||
|
||||
private static const matrix:Matrix = new Matrix();
|
||||
private static const _matrix:Matrix = new Matrix();
|
||||
|
||||
private static var redClass:Class = Prop_redClass;
|
||||
|
||||
private static const redBmp:BitmapData = new redClass().bitmapData;
|
||||
|
||||
private static const v1:Vector3D = new Vector3D();
|
||||
private static const v2:Vector3D = new Vector3D();
|
||||
|
||||
public var type:int = 3;
|
||||
|
||||
protected var _object:Object3D;
|
||||
@@ -73,7 +75,8 @@ package alternativa.editor.prop
|
||||
|
||||
public function Prop(param1:Object3D, param2:String, param3:String, param4:String, param5:Boolean = true)
|
||||
{
|
||||
super(param2);
|
||||
super();
|
||||
this.name = param2;
|
||||
addChild(param1);
|
||||
this._object = param1;
|
||||
this._object.addEventListener(MouseEvent3D.MOUSE_DOWN,this.onMouseDown);
|
||||
@@ -144,30 +147,30 @@ package alternativa.editor.prop
|
||||
|
||||
private function onMouseDown(param1:MouseEvent3D) : void
|
||||
{
|
||||
param1.object = this;
|
||||
param1.relatedObject = this;
|
||||
}
|
||||
|
||||
protected function initBitmapData() : void
|
||||
{
|
||||
this._material = Mesh(this._object).surfaces.peek().material;
|
||||
this._material = Mesh(this._object).faceList.material;
|
||||
if(_material is TextureMaterial)
|
||||
{
|
||||
this.bitmapData = TextureMaterial(this._material).texture.bitmapData;
|
||||
this.bitmapData = TextureMaterial(this._material).texture;
|
||||
}
|
||||
}
|
||||
|
||||
public function calculate() : void
|
||||
{
|
||||
var loc13:Point3D = null;
|
||||
var loc13:Vector3D = null;
|
||||
var loc14:int = 0;
|
||||
var loc15:Point3D = null;
|
||||
var loc15:Vector3D = null;
|
||||
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 loc1:Array = (this._object as Mesh).vertices.toArray(true);
|
||||
var loc1:Vector.<Vertex> = (this._object as Mesh).vertices;
|
||||
var loc2:Number = 0;
|
||||
var loc3:Number = 0;
|
||||
var loc4:Number = 0;
|
||||
@@ -181,16 +184,16 @@ package alternativa.editor.prop
|
||||
var loc12:int = 0;
|
||||
while(loc12 < loc11)
|
||||
{
|
||||
loc13 = loc1[loc12].coords;
|
||||
if(scene)
|
||||
loc13 = loc1[loc12].copyToVector3D(v1);
|
||||
if(parent)
|
||||
{
|
||||
loc13 = localToGlobal(loc13);
|
||||
}
|
||||
loc14 = loc12 + 1;
|
||||
while(loc14 < loc11)
|
||||
{
|
||||
loc15 = loc1[loc14].coords;
|
||||
if(scene)
|
||||
loc15 = loc1[loc14].copyToVector3D(v2);
|
||||
if(parent)
|
||||
{
|
||||
loc15 = localToGlobal(loc15);
|
||||
}
|
||||
@@ -230,7 +233,7 @@ package alternativa.editor.prop
|
||||
{
|
||||
this._multi = true;
|
||||
}
|
||||
if(!scene)
|
||||
if(!parent)
|
||||
{
|
||||
if(this._multi)
|
||||
{
|
||||
@@ -278,9 +281,9 @@ package alternativa.editor.prop
|
||||
public function select() : void
|
||||
{
|
||||
this._selectBitmapData = this.bitmapData.clone();
|
||||
matrix.a = this.bitmapData.width / redBmp.width;
|
||||
matrix.d = matrix.a;
|
||||
this._selectBitmapData.draw(redBmp,matrix,null,BlendMode.MULTIPLY);
|
||||
_matrix.a = this.bitmapData.width / redBmp.width;
|
||||
_matrix.d = _matrix.a;
|
||||
this._selectBitmapData.draw(redBmp,_matrix,null,BlendMode.MULTIPLY);
|
||||
this.setMaterial(this.newSelectedMaterial);
|
||||
this._selected = true;
|
||||
}
|
||||
@@ -301,13 +304,14 @@ package alternativa.editor.prop
|
||||
|
||||
protected function get newSelectedMaterial() : Material
|
||||
{
|
||||
return new TextureMaterial(new Texture(this._selectBitmapData));
|
||||
return new TextureMaterial(this._selectBitmapData);
|
||||
}
|
||||
|
||||
public function setMaterial(param1:Material) : void
|
||||
{
|
||||
var loc2:SurfaceMaterial = param1 as SurfaceMaterial;
|
||||
(this._object as Mesh).cloneMaterialToAllSurfaces(loc2);
|
||||
//var loc2:SurfaceMaterial = param1 as SurfaceMaterial;
|
||||
var loc2:Material = param1; //TODO
|
||||
(this._object as Mesh).setMaterialToAllFaces(loc2);
|
||||
}
|
||||
|
||||
public function hide() : void
|
||||
@@ -347,7 +351,7 @@ package alternativa.editor.prop
|
||||
return this._groupName;
|
||||
}
|
||||
|
||||
public function get vertices() : Map
|
||||
public function get vertices() : Vector.<Vertex>
|
||||
{
|
||||
return (this._object as Mesh).vertices;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package alternativa.editor.prop
|
||||
import alternativa.editor.FunctionalProps;
|
||||
import alternativa.editor.events.DominationSpawnLinkStartEvent;
|
||||
import alternativa.editor.scene.EditorScene;
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.events.MouseEvent3D;
|
||||
import alternativa.engine3d.core.MouseEvent3D;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import alternativa.utils.MathUtils;
|
||||
import flash.geom.Point;
|
||||
@@ -40,7 +40,7 @@ package alternativa.editor.prop
|
||||
{
|
||||
var loc2:SpawnPoint = null;
|
||||
var loc1:Mesh = _object.clone() as Mesh;
|
||||
loc1.cloneMaterialToAllSurfaces(_material as TextureMaterial);
|
||||
loc1.setMaterialToAllFaces(_material as TextureMaterial);
|
||||
loc2 = new SpawnPoint(loc1,name,_libraryName,_groupName,false);
|
||||
loc2.distancesX = distancesX.clone();
|
||||
loc2.distancesY = distancesY.clone();
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package alternativa.editor.prop
|
||||
{
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Sprite3D;
|
||||
import alternativa.engine3d.objects.Sprite3D;
|
||||
import alternativa.engine3d.core.Vertex;
|
||||
import alternativa.engine3d.materials.Material;
|
||||
import alternativa.engine3d.materials.SpriteTextureMaterial;
|
||||
import alternativa.types.Map;
|
||||
import alternativa.types.Texture;
|
||||
import flash.geom.Point;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
|
||||
public class Sprite3DProp extends MeshProp
|
||||
{
|
||||
private var spriteTextureMaterial:SpriteTextureMaterial;
|
||||
private static const EMPTY_OBJECTS:Vector.<Object3D> = new Vector.<Object3D>();
|
||||
|
||||
private var spriteTextureMaterial:TextureMaterial;
|
||||
|
||||
public function Sprite3DProp(param1:Sprite3D, param2:String, param3:String, param4:String, param5:Boolean = true)
|
||||
{
|
||||
super(param1,param2,param3,param4,param5);
|
||||
super(param1,EMPTY_OBJECTS,param2,param3,param4,param5);
|
||||
}
|
||||
|
||||
public function get scale() : Number
|
||||
@@ -34,11 +34,11 @@ package alternativa.editor.prop
|
||||
|
||||
override public function setMaterial(param1:Material) : void
|
||||
{
|
||||
var loc2:SpriteTextureMaterial = param1 as SpriteTextureMaterial;
|
||||
var loc2:TextureMaterial = param1 as TextureMaterial;
|
||||
if(loc2)
|
||||
{
|
||||
loc2.originX = this.spriteTextureMaterial.originX;
|
||||
loc2.originY = this.spriteTextureMaterial.originY;
|
||||
//loc2.originX = this.spriteTextureMaterial.originX;
|
||||
//loc2.originY = this.spriteTextureMaterial.originY;
|
||||
}
|
||||
(_object as Sprite3D).material = loc2;
|
||||
}
|
||||
@@ -46,27 +46,28 @@ package alternativa.editor.prop
|
||||
override protected function initBitmapData() : void
|
||||
{
|
||||
_material = (_object as Sprite3D).material;
|
||||
this.spriteTextureMaterial = _material as SpriteTextureMaterial;
|
||||
bitmapData = this.spriteTextureMaterial.texture.bitmapData;
|
||||
this.spriteTextureMaterial = _material as TextureMaterial;
|
||||
bitmapData = this.spriteTextureMaterial.texture;
|
||||
}
|
||||
|
||||
override public function get vertices() : Map
|
||||
override public function get vertices() : Vector.<Vertex>
|
||||
{
|
||||
var loc1:Vertex = new Vertex(0,0,0);
|
||||
/*var loc1:Vertex = new Vertex(0,0,0);
|
||||
var loc2:Map = new Map();
|
||||
loc2.add("1",loc1);
|
||||
return loc2;
|
||||
return loc2;*/
|
||||
return Vector.<Vertex>([new Vertex()]);
|
||||
}
|
||||
|
||||
override protected function get newSelectedMaterial() : Material
|
||||
{
|
||||
return new SpriteTextureMaterial(new Texture(_selectBitmapData));
|
||||
return new TextureMaterial(_selectBitmapData);
|
||||
}
|
||||
|
||||
override public function clone() : Object3D
|
||||
{
|
||||
var loc1:Sprite3D = _object.clone() as Sprite3D;
|
||||
loc1.material = _material.clone() as SpriteTextureMaterial;
|
||||
loc1.material = _material.clone() as TextureMaterial;
|
||||
var loc2:Sprite3DProp = new Sprite3DProp(loc1,name,_libraryName,_groupName,false);
|
||||
loc2.distancesX = distancesX.clone();
|
||||
loc2.distancesY = distancesY.clone();
|
||||
|
||||
@@ -15,7 +15,7 @@ package alternativa.editor.propslib
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "[PropMesh object3d=" + object3d + ", bitmaps=" + this.bitmaps + "]";
|
||||
return "[PropMesh object3d=" + mainObject + ", bitmaps=" + this.bitmaps + (objects != null ? ", objectsLen="+objects.length : "") + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,16 @@ package alternativa.editor.propslib
|
||||
{
|
||||
public var name:String;
|
||||
|
||||
public var object3d:Object3D;
|
||||
public var mainObject:Object3D;
|
||||
|
||||
public function PropLibObject(param1:String, param2:Object3D = null)
|
||||
public var objects:Vector.<Object3D>;
|
||||
|
||||
public function PropLibObject(param1:String, param2:Object3D = null, objects:Vector.<Object3D> = null)
|
||||
{
|
||||
super();
|
||||
this.name = param1;
|
||||
this.object3d = param2;
|
||||
this.mainObject = param2;
|
||||
this.objects = objects;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package alternativa.editor.propslib
|
||||
import alternativa.editor.propslib.events.PropLibProgressEvent;
|
||||
import alternativa.editor.propslib.loaders.MeshLoader;
|
||||
import alternativa.editor.propslib.loaders.SpriteLoader;
|
||||
import alternativa.engine3d.loaders.TextureMapsInfo;
|
||||
import alternativa.editor.engine3d.loaders.TextureMapsInfo;
|
||||
import alternativa.types.Map;
|
||||
import flash.events.ErrorEvent;
|
||||
import flash.events.Event;
|
||||
@@ -117,12 +117,13 @@ package alternativa.editor.propslib
|
||||
{
|
||||
loc2 = this.currLoader.propObject as PropLibMesh;
|
||||
loc3 = this.currLoader.loader as MeshLoader;
|
||||
loc2.object3d = loc3.object;
|
||||
loc2.mainObject = loc3.object;
|
||||
loc2.bitmaps = loc3.bitmaps;
|
||||
loc2.objects = loc3.objects;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currLoader.propObject.object3d = (this.currLoader.loader as SpriteLoader).sprite;
|
||||
this.currLoader.propObject.mainObject = (this.currLoader.loader as SpriteLoader).sprite;
|
||||
}
|
||||
++this.propsLoaded;
|
||||
if(hasEventListener(PropLibProgressEvent.PROGRESS))
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
package alternativa.editor.propslib.loaders
|
||||
{
|
||||
import alternativa.engine3d.core.Mesh;
|
||||
import alternativa.engine3d.core.Surface;
|
||||
import alternativa.engine3d.loaders.Loader3DS;
|
||||
import alternativa.engine3d.loaders.TextureMapsBatchLoader;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import alternativa.types.Map;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
import flash.system.LoaderContext;
|
||||
import flash.net.URLLoader;
|
||||
import alternativa.engine3d.loaders.Parser3DS;
|
||||
import flash.net.URLRequest;
|
||||
import flash.net.URLLoaderDataFormat;
|
||||
import alternativa.engine3d.core.Face;
|
||||
import alternativa.editor.engine3d.loaders.TextureMapsBatchLoader;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
|
||||
public class MeshLoader extends ObjectLoader
|
||||
{
|
||||
public var object:Mesh;
|
||||
public var objects:Vector.<Object3D>;
|
||||
|
||||
public var bitmaps:Map;
|
||||
|
||||
@@ -23,7 +28,8 @@ package alternativa.editor.propslib.loaders
|
||||
|
||||
private var textures:Map;
|
||||
|
||||
private var loader3DS:Loader3DS;
|
||||
private var loader3DS:URLLoader;
|
||||
private const parser3DS:Parser3DS = new Parser3DS();
|
||||
|
||||
private var texturesLoader:TextureMapsBatchLoader;
|
||||
|
||||
@@ -40,25 +46,33 @@ package alternativa.editor.propslib.loaders
|
||||
override public function load(param1:LoaderContext) : void
|
||||
{
|
||||
this.loaderContext = param1;
|
||||
this.loader3DS = new Loader3DS();
|
||||
this.loader3DS = new URLLoader();
|
||||
this.loader3DS.dataFormat = URLLoaderDataFormat.BINARY;
|
||||
this.loader3DS.addEventListener(Event.COMPLETE,this.on3DSLoadingComplete);
|
||||
this.loader3DS.addEventListener(IOErrorEvent.IO_ERROR,onErrorEvent);
|
||||
this.loader3DS.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onErrorEvent);
|
||||
this.loader3DS.smooth = true;
|
||||
this.loader3DS.repeat = false;
|
||||
this.loader3DS.load(this.url,param1);
|
||||
//this.loader3DS.smooth = true;
|
||||
//this.loader3DS.repeat = false;
|
||||
//this.loader3DS.load(this.url,param1);
|
||||
this.loader3DS.load(new URLRequest(this.url));
|
||||
}
|
||||
|
||||
private function on3DSLoadingComplete(param1:Event) : void
|
||||
{
|
||||
this.parser3DS.parse(this.loader3DS.data);
|
||||
if(this.objectName != null)
|
||||
{
|
||||
this.object = this.loader3DS.content.getChildByName(this.objectName,true) as Mesh;
|
||||
this.object = this.parser3DS.getObjectByName(this.objectName) as Mesh;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.object = this.loader3DS.content.children.peek() as Mesh;
|
||||
this.object = this.parser3DS.objects[0] as Mesh;
|
||||
}
|
||||
|
||||
//'child' objects for old engine
|
||||
this.objects = this.parser3DS.objects.concat();
|
||||
this.objects.removeAt(this.objects.indexOf(this.object));
|
||||
|
||||
this.loader3DS.removeEventListener(Event.COMPLETE,this.on3DSLoadingComplete);
|
||||
this.loader3DS.removeEventListener(IOErrorEvent.IO_ERROR,onErrorEvent);
|
||||
this.loader3DS.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onErrorEvent);
|
||||
@@ -80,12 +94,12 @@ package alternativa.editor.propslib.loaders
|
||||
private function initDefaultTexture() : void
|
||||
{
|
||||
var loc1:Mesh = Mesh(this.object);
|
||||
var loc2:Surface = loc1.surfaces.peek();
|
||||
var loc2:Face = loc1.faceList;
|
||||
var loc3:TextureMaterial = loc2.material as TextureMaterial;
|
||||
if(loc3 != null)
|
||||
{
|
||||
this.bitmaps = new Map();
|
||||
this.bitmaps.add("DEFAULT",loc3.texture.bitmapData);
|
||||
this.bitmaps.add("DEFAULT",loc3.texture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package alternativa.editor.propslib.loaders
|
||||
{
|
||||
import alternativa.engine3d.core.Sprite3D;
|
||||
import alternativa.engine3d.loaders.TextureMapsLoader;
|
||||
import alternativa.engine3d.materials.SpriteTextureMaterial;
|
||||
import alternativa.engine3d.objects.Sprite3D;
|
||||
import alternativa.editor.engine3d.loaders.TextureMapsLoader;
|
||||
import alternativa.types.Texture;
|
||||
import flash.display.BlendMode;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.system.LoaderContext;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
|
||||
public class SpriteLoader extends ObjectLoader
|
||||
{
|
||||
@@ -44,8 +44,12 @@ package alternativa.editor.propslib.loaders
|
||||
|
||||
private function onLoadingComplete(param1:Event) : void
|
||||
{
|
||||
this.sprite = new Sprite3D();
|
||||
this.sprite.material = new SpriteTextureMaterial(new Texture(this.loader.bitmapData),1,true,BlendMode.NORMAL,this.originX,this.originY);
|
||||
this.sprite = new Sprite3D(100,150);
|
||||
//this.sprite.material = new SpriteTextureMaterial(new Texture(this.loader.bitmapData),1,true,BlendMode.NORMAL,this.originX,this.originY);
|
||||
this.sprite.material = new TextureMaterial(this.loader.bitmapData);
|
||||
this.sprite.originX = this.originX;
|
||||
this.sprite.originY = this.originY;
|
||||
|
||||
this.sprite.scaleX = this.scale;
|
||||
this.sprite.scaleY = this.scale;
|
||||
this.sprite.scaleZ = this.scale;
|
||||
|
||||
@@ -4,13 +4,12 @@ package alternativa.editor.scene
|
||||
import alternativa.editor.prop.MeshProp;
|
||||
import alternativa.editor.prop.Prop;
|
||||
import alternativa.editor.prop.Sprite3DProp;
|
||||
import alternativa.engine3d.controllers.WalkController;
|
||||
import alternativa.editor.engine3d.controllers.WalkController;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.display.View;
|
||||
import alternativa.engine3d.core.View;
|
||||
import alternativa.engine3d.materials.Material;
|
||||
import alternativa.engine3d.materials.SpriteTextureMaterial;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.types.Matrix4;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.types.Set;
|
||||
import alternativa.types.Texture;
|
||||
@@ -22,6 +21,10 @@ package alternativa.editor.scene
|
||||
import flash.display.Shape;
|
||||
import flash.geom.Matrix;
|
||||
import flash.geom.Point;
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
import flash.geom.Vector3D;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import flash.display.Sprite;
|
||||
|
||||
public class CursorScene extends EditorScene
|
||||
{
|
||||
@@ -47,7 +50,7 @@ package alternativa.editor.scene
|
||||
|
||||
public var containerController:WalkController;
|
||||
|
||||
public var container:Object3D;
|
||||
public var container:Object3DContainer;
|
||||
|
||||
private var eventSourceObject:DisplayObject;
|
||||
|
||||
@@ -59,12 +62,12 @@ package alternativa.editor.scene
|
||||
|
||||
private var _visible:Boolean = false;
|
||||
|
||||
public function CursorScene(param1:DisplayObject)
|
||||
public function CursorScene(param1:DisplayObject, container:Sprite)
|
||||
{
|
||||
super();
|
||||
this.eventSourceObject = param1;
|
||||
this.initControllers();
|
||||
view.addChild(this.axisIndicatorOverlay = new Shape());
|
||||
container.addChild(this.axisIndicatorOverlay = new Shape());
|
||||
}
|
||||
|
||||
private function initControllers() : void
|
||||
@@ -75,7 +78,7 @@ package alternativa.editor.scene
|
||||
this.cameraController.speedThreshold = 1;
|
||||
this.cameraController.mouseEnabled = false;
|
||||
this.cameraController.coords = new Point3D(250,-7800,4670);
|
||||
this.container = new Object3D();
|
||||
this.container = new Object3DContainer();
|
||||
root.addChild(this.container);
|
||||
this.containerController = new WalkController(this.eventSourceObject);
|
||||
this.containerController.object = this.container;
|
||||
@@ -85,10 +88,10 @@ package alternativa.editor.scene
|
||||
|
||||
public function set object(param1:Prop) : void
|
||||
{
|
||||
var loc2:Point3D = null;
|
||||
var loc2:Vector3D = null;
|
||||
if(this._object)
|
||||
{
|
||||
loc2 = this._object.coords;
|
||||
loc2 = new Vector3D(this._object.x,this._object.y,this._object.z);
|
||||
if(this._visible)
|
||||
{
|
||||
root.removeChild(this._object);
|
||||
@@ -96,10 +99,11 @@ package alternativa.editor.scene
|
||||
}
|
||||
this._object = param1;
|
||||
this.material = this._object.material.clone();
|
||||
this.material.alpha = 0.5;
|
||||
//this.material.alpha = 0.5;
|
||||
this._object.alpha = 0.5;
|
||||
if(loc2)
|
||||
{
|
||||
this._object.coords = loc2;
|
||||
this._object.setPositionFromVector3(loc2);
|
||||
}
|
||||
if(this._visible)
|
||||
{
|
||||
@@ -150,24 +154,25 @@ package alternativa.editor.scene
|
||||
loc2.draw(greenBmp,loc3,null,BlendMode.HARDLIGHT);
|
||||
if(this._object is Sprite3DProp)
|
||||
{
|
||||
this.greenMaterial = new SpriteTextureMaterial(new Texture(loc2));
|
||||
this.redMaterial = new SpriteTextureMaterial(new Texture(loc1));
|
||||
this.greenMaterial = new TextureMaterial(loc2);
|
||||
this.redMaterial = new TextureMaterial(loc1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.greenMaterial = new CustomFillMaterial(new Point3D(-10000000000,-7000000000,4000000000),65280);
|
||||
this.redMaterial = new CustomFillMaterial(new Point3D(-10000000000,-7000000000,4000000000),16711680);
|
||||
}
|
||||
this.greenMaterial.alpha = 0.8;
|
||||
this.redMaterial.alpha = 0.8;
|
||||
//this.greenMaterial.alpha = 0.8;
|
||||
//this.redMaterial.alpha = 0.8;
|
||||
this._object.alpha = 0.8;
|
||||
}
|
||||
|
||||
public function moveCursorByMouse() : void
|
||||
{
|
||||
var loc1:Point3D = null;
|
||||
var loc1:Vector3D = null;
|
||||
if(this._object)
|
||||
{
|
||||
loc1 = view.projectViewPointToPlane(new Point(view.mouseX,view.mouseY),znormal,this._object.z);
|
||||
loc1 = camera.projectGlobal(new Vector3D(view.mouseX,view.mouseY,this._object.z));
|
||||
this._object.x = loc1.x;
|
||||
this._object.y = loc1.y;
|
||||
if(this._snapMode || this._object is MeshProp && !(this._object is Sprite3DProp))
|
||||
@@ -185,11 +190,12 @@ package alternativa.editor.scene
|
||||
|
||||
override protected function initScene() : void
|
||||
{
|
||||
root = new Object3D();
|
||||
root = new Object3DContainer();
|
||||
camera = new Camera3D();
|
||||
camera.rotationX = -MathUtils.DEG90 - MathUtils.DEG30;
|
||||
view = new View(camera);
|
||||
view.interactive = false;
|
||||
view = new View(100,100);
|
||||
camera.view = view;
|
||||
//view.interactive = false;
|
||||
view.mouseEnabled = false;
|
||||
view.mouseChildren = false;
|
||||
view.graphics.beginFill(16777215);
|
||||
@@ -234,7 +240,7 @@ package alternativa.editor.scene
|
||||
}
|
||||
}
|
||||
|
||||
public function drawAxis(param1:Matrix3D) : void
|
||||
public function drawAxis(param1:Matrix4) : void
|
||||
{
|
||||
var loc2:Graphics = this.axisIndicatorOverlay.graphics;
|
||||
var loc3:Number = this.axisIndicatorSize;
|
||||
|
||||
@@ -3,14 +3,15 @@ package alternativa.editor.scene
|
||||
import alternativa.editor.prop.Prop;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Scene3D;
|
||||
import alternativa.engine3d.display.View;
|
||||
import alternativa.types.Matrix3D;
|
||||
import alternativa.editor.engine3d.Scene3D;
|
||||
import alternativa.engine3d.core.View;
|
||||
import alternativa.types.Matrix4;
|
||||
import alternativa.types.Point3D;
|
||||
import alternativa.types.Set;
|
||||
import alternativa.utils.KeyboardUtils;
|
||||
import alternativa.utils.MathUtils;
|
||||
import flash.geom.Point;
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
|
||||
public class EditorScene extends Scene3D
|
||||
{
|
||||
@@ -30,8 +31,6 @@ package alternativa.editor.scene
|
||||
|
||||
public static var vBase:Number = 300;
|
||||
|
||||
public var camera:Camera3D;
|
||||
|
||||
public var view:View;
|
||||
|
||||
public var occupyMap:OccupyMap;
|
||||
@@ -65,13 +64,14 @@ package alternativa.editor.scene
|
||||
|
||||
protected function initScene() : void
|
||||
{
|
||||
root = new Object3D();
|
||||
root = new Object3DContainer();
|
||||
this.camera = new Camera3D();
|
||||
this.camera.rotationX = -MathUtils.DEG90 - MathUtils.DEG30;
|
||||
this.camera.coords = new Point3D(250,-7800,4670);
|
||||
this.camera.setPositionXYZ(250,-7800,4670);
|
||||
root.addChild(this.camera);
|
||||
this.view = new View(this.camera);
|
||||
this.view.interactive = true;
|
||||
this.view = new View(100,100);
|
||||
this.camera.view = view;
|
||||
//this.view.interactive = true;
|
||||
this.view.buttonMode = true;
|
||||
this.view.useHandCursor = false;
|
||||
this.view.graphics.beginFill(16777215);
|
||||
@@ -81,7 +81,7 @@ package alternativa.editor.scene
|
||||
|
||||
protected function getCameraFacing() : CameraFacing
|
||||
{
|
||||
var loc1:Matrix3D = this.camera.transformation;
|
||||
var loc1:Matrix4 = this.camera.transformation;
|
||||
if(loc1.a > 1 / Math.SQRT2)
|
||||
{
|
||||
return CameraFacing.Y;
|
||||
|
||||
@@ -26,9 +26,8 @@ package alternativa.editor.scene
|
||||
import alternativa.editor.prop.SpawnPoint;
|
||||
import alternativa.editor.prop.Sprite3DProp;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.events.MouseEvent3D;
|
||||
import alternativa.engine3d.materials.WireMaterial;
|
||||
import alternativa.engine3d.physics.EllipsoidCollider;
|
||||
import alternativa.engine3d.core.MouseEvent3D;
|
||||
import alternativa.editor.engine3d.materials.WireMaterial;
|
||||
import alternativa.engine3d.primitives.Plane;
|
||||
import alternativa.types.Map;
|
||||
import alternativa.types.Point3D;
|
||||
@@ -41,10 +40,14 @@ package alternativa.editor.scene
|
||||
import flash.utils.getQualifiedClassName;
|
||||
import gui.events.PropListEvent;
|
||||
import mx.containers.Panel;
|
||||
import alternativa.engine3d.core.EllipsoidCollider;
|
||||
import flash.geom.Vector3D;
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
|
||||
public class MainScene extends EditorScene
|
||||
{
|
||||
public static var collider:EllipsoidCollider;
|
||||
private static var __root:Object3DContainer;
|
||||
|
||||
public var selectedProp:Prop;
|
||||
|
||||
@@ -97,7 +100,7 @@ package alternativa.editor.scene
|
||||
this.selectablePropTypes = AlternativaEditor.DEFAULT_SELECTABLE_TYPES;
|
||||
var loc2:Number = 15 * hBase2;
|
||||
this.grid = new Plane(loc2,loc2,15,15);
|
||||
this.grid.cloneMaterialToAllSurfaces(new WireMaterial(1,9474192));
|
||||
this.grid.setMaterialToAllFaces(new WireMaterial(1,loc2,loc2,15,9474192));
|
||||
root.addChild(this.grid);
|
||||
this.grid.x = hBase;
|
||||
this.grid.y = hBase;
|
||||
@@ -106,18 +109,17 @@ package alternativa.editor.scene
|
||||
this.exporters[FileType.MAP_XML_VERSION_1_FULL] = new TanksXmlExporterV1Full(root);
|
||||
this.exporters[FileType.MAP_XML_VERSION_3] = new TanksXmlExporterV3(root);
|
||||
this.createControlPointNameTextField();
|
||||
collider = new EllipsoidCollider(this,30,30,30);
|
||||
collider = new EllipsoidCollider(30,30,30);
|
||||
__root = root;
|
||||
GlobalEventDispatcher.addListener(LayerVisibilityChangeEvent.VISIBILITY_CHANGED,this.onLayerVisibilityChange);
|
||||
GlobalEventDispatcher.addListener(LayerContentChangeEvent.LAYER_CONTENT_CHANGED,this.onLayerContentChange);
|
||||
GlobalEventDispatcher.addListener(DominationSpawnLinkStartEvent.DOMINATION_SPAWN_LINK_START,this.onDominationLinkStart);
|
||||
GlobalEventDispatcher.addListener(DominationSpawnLinkEndEvent.DOMINATION_SPAWN_LINK_END,this.onDominationLinkEnd);
|
||||
}
|
||||
|
||||
public static function getProjectedPoint(param1:Point3D) : Point3D
|
||||
public static function getProjectedPoint(param1:Vector3D) : Vector3D
|
||||
{
|
||||
var loc2:Point3D = new Point3D();
|
||||
collider.calculateDestination(param1,new Point3D(0,0,-10000),loc2);
|
||||
return loc2;
|
||||
return collider.calculateDestination(param1,new Vector3D(0,0,-10000),__root);
|
||||
}
|
||||
|
||||
private static function snapPropsToGrid(param1:Set) : void
|
||||
@@ -163,7 +165,7 @@ package alternativa.editor.scene
|
||||
}
|
||||
}
|
||||
|
||||
override public function set root(param1:Object3D) : void
|
||||
override public function set root(param1:Object3DContainer) : void
|
||||
{
|
||||
var loc2:FileExporter = null;
|
||||
super.root = param1;
|
||||
@@ -216,7 +218,7 @@ package alternativa.editor.scene
|
||||
{
|
||||
loc4 = loc3;
|
||||
loc4.deselect();
|
||||
this.addProp(loc4,loc4.coords,loc4.rotationZ,false);
|
||||
this.addProp(loc4,new Point3D(loc4.x,loc4.y,loc4.z),loc4.rotationZ,false);
|
||||
}
|
||||
break;
|
||||
case EventJournal.MOVE:
|
||||
@@ -247,13 +249,13 @@ package alternativa.editor.scene
|
||||
{
|
||||
case EventJournal.ADD:
|
||||
loc3 = loc2.peek();
|
||||
this.addProp(loc3,loc3.coords,loc3.rotationZ,false);
|
||||
this.addProp(loc3,new Point3D(loc3.x,loc3.y,loc3.z),loc3.rotationZ,false);
|
||||
break;
|
||||
case EventJournal.COPY:
|
||||
for(loc4 in loc2)
|
||||
{
|
||||
loc3 = loc4;
|
||||
this.addProp(loc3,loc3.coords,loc3.rotationZ,false);
|
||||
this.addProp(loc3,new Point3D(loc3.x,loc3.y,loc3.z),loc3.rotationZ,false);
|
||||
}
|
||||
break;
|
||||
case EventJournal.DELETE:
|
||||
@@ -280,7 +282,7 @@ package alternativa.editor.scene
|
||||
|
||||
public function setCameraPosition(param1:Point3D, param2:Number, param3:Number, param4:Number) : void
|
||||
{
|
||||
camera.coords = param1;
|
||||
camera.setPositionXYZ(param1.x,param1.y,param1.z);
|
||||
camera.rotationX = param2;
|
||||
camera.rotationY = param3;
|
||||
camera.rotationZ = param4;
|
||||
@@ -288,9 +290,9 @@ package alternativa.editor.scene
|
||||
|
||||
public function showCollisionBoxes() : void
|
||||
{
|
||||
var loc1:* = undefined;
|
||||
var loc1:Object3D;
|
||||
var loc2:MeshProp = null;
|
||||
for(loc1 in root.children)
|
||||
for each(loc1 in root.children)
|
||||
{
|
||||
loc2 = loc1 as MeshProp;
|
||||
if(loc2)
|
||||
@@ -302,9 +304,9 @@ package alternativa.editor.scene
|
||||
|
||||
public function hideCollisionBoxes() : void
|
||||
{
|
||||
var loc1:* = undefined;
|
||||
var loc1:Object3D;
|
||||
var loc2:MeshProp = null;
|
||||
for(loc1 in root.children)
|
||||
for each(loc1 in root.children)
|
||||
{
|
||||
loc2 = loc1 as MeshProp;
|
||||
if(loc2)
|
||||
@@ -326,9 +328,9 @@ package alternativa.editor.scene
|
||||
|
||||
public function showPlaneBounds() : void
|
||||
{
|
||||
var loc1:* = undefined;
|
||||
var loc1:Object3D;
|
||||
var loc2:MeshProp = null;
|
||||
for(loc1 in root.children)
|
||||
for each(loc1 in root.children)
|
||||
{
|
||||
loc2 = loc1 as MeshProp;
|
||||
if(Boolean(loc2) && loc2.height == 0)
|
||||
@@ -340,9 +342,9 @@ package alternativa.editor.scene
|
||||
|
||||
public function hidePlaneBounds() : void
|
||||
{
|
||||
var loc1:* = undefined;
|
||||
var loc1:Object3D;
|
||||
var loc2:MeshProp = null;
|
||||
for(loc1 in root.children)
|
||||
for each(loc1 in root.children)
|
||||
{
|
||||
loc2 = loc1 as MeshProp;
|
||||
if(Boolean(loc2) && loc2.height == 0)
|
||||
@@ -354,9 +356,9 @@ package alternativa.editor.scene
|
||||
|
||||
public function set selectablePropTypes(param1:Array) : void
|
||||
{
|
||||
var loc4:* = undefined;
|
||||
var loc4:Object3D;
|
||||
var loc5:Prop = null;
|
||||
var loc6:* = undefined;
|
||||
var loc6:Object3D;
|
||||
var loc7:Object3D = null;
|
||||
this._selectablePropTypes.clear();
|
||||
var loc2:int = int(param1.length);
|
||||
@@ -366,13 +368,13 @@ package alternativa.editor.scene
|
||||
this._selectablePropTypes.add(getQualifiedClassName(param1[loc3]));
|
||||
loc3++;
|
||||
}
|
||||
for(loc4 in root.children)
|
||||
for each(loc4 in root.children)
|
||||
{
|
||||
loc5 = loc4 as Prop;
|
||||
if(loc5)
|
||||
{
|
||||
loc5.mouseEnabled = this.isSelectableProp(loc5);
|
||||
for(loc6 in loc5.children)
|
||||
for each(loc6 in loc5.children)
|
||||
{
|
||||
loc7 = loc6 as Object3D;
|
||||
loc7.mouseEnabled = loc5.mouseEnabled;
|
||||
@@ -406,7 +408,7 @@ package alternativa.editor.scene
|
||||
public function moveSelectedPropsByMouse(param1:Boolean) : void
|
||||
{
|
||||
var loc2:Point = null;
|
||||
var loc3:Point3D = null;
|
||||
var loc3:Vector3D = null;
|
||||
var loc4:* = undefined;
|
||||
var loc5:Number = NaN;
|
||||
var loc6:Number = NaN;
|
||||
@@ -428,13 +430,13 @@ package alternativa.editor.scene
|
||||
loc8 = getCameraFacing();
|
||||
if(loc8 == CameraFacing.Y || loc8 == CameraFacing.NEGATIVE_Y)
|
||||
{
|
||||
loc3 = view.projectViewPointToPlane(loc2,ynormal,this.selectedProp.y);
|
||||
loc3 = camera.projectGlobal(new Vector3D(loc2.x,loc2.y,this.selectedProp.y));
|
||||
loc5 = loc3.x - this.selectedProp.x;
|
||||
this.selectedProp.x = loc3.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
loc3 = view.projectViewPointToPlane(loc2,xnormal,this.selectedProp.x);
|
||||
loc3 = camera.projectGlobal(new Vector3D(loc2.x,loc2.y,this.selectedProp.x));
|
||||
loc6 = loc3.y - this.selectedProp.y;
|
||||
this.selectedProp.y = loc3.y;
|
||||
}
|
||||
@@ -443,7 +445,7 @@ package alternativa.editor.scene
|
||||
}
|
||||
else
|
||||
{
|
||||
loc3 = view.projectViewPointToPlane(loc2,znormal,this.selectedProp.z);
|
||||
loc3 = camera.projectGlobal(new Vector3D(loc2.x,loc2.y,this.selectedProp.z));
|
||||
loc5 = loc3.x - this.selectedProp.x;
|
||||
loc6 = loc3.y - this.selectedProp.y;
|
||||
this.selectedProp.x = loc3.x;
|
||||
@@ -510,7 +512,7 @@ package alternativa.editor.scene
|
||||
var loc3:Boolean = false;
|
||||
if(!param1.ctrlKey)
|
||||
{
|
||||
loc2 = param1.object as Prop;
|
||||
loc2 = param1.relatedObject as Prop;
|
||||
if(this.isSelectableProp(loc2))
|
||||
{
|
||||
loc3 = loc2.selected;
|
||||
@@ -621,16 +623,16 @@ package alternativa.editor.scene
|
||||
|
||||
public function getPropsUnderRect(param1:Point, param2:Number, param3:Number, param4:Boolean) : Set
|
||||
{
|
||||
var loc6:* = undefined;
|
||||
var loc6:Object3D;
|
||||
var loc7:Prop = null;
|
||||
var loc8:Point3D = null;
|
||||
var loc8:Vector3D = null;
|
||||
var loc5:Set = new Set();
|
||||
for(loc6 in root.children)
|
||||
for each(loc6 in root.children)
|
||||
{
|
||||
loc7 = loc6 as Prop;
|
||||
if((Boolean(loc7)) && this.isSelectableProp(loc7))
|
||||
{
|
||||
loc8 = view.projectPoint(loc7.coords);
|
||||
loc8 = camera.projectGlobal(new Vector3D(loc7.x,loc7.y,loc7.z));
|
||||
if(loc8.x >= param1.x && loc8.x <= param1.x + param2 && loc8.y >= param1.y && loc8.y <= param1.y + param3)
|
||||
{
|
||||
if(param4)
|
||||
@@ -654,7 +656,7 @@ package alternativa.editor.scene
|
||||
public function addProp(param1:Prop, param2:Point3D, param3:Number, param4:Boolean = true, param5:Boolean = true) : Prop
|
||||
{
|
||||
var loc6:Prop = null;
|
||||
var loc7:* = undefined;
|
||||
var loc7:Object3D;
|
||||
var loc8:Object3D = null;
|
||||
if(param4)
|
||||
{
|
||||
@@ -687,7 +689,7 @@ package alternativa.editor.scene
|
||||
occupyMap.occupy(loc6);
|
||||
}
|
||||
loc6.mouseEnabled = this.isSelectableProp(loc6);
|
||||
for(loc7 in loc6.children)
|
||||
for each(loc7 in loc6.children)
|
||||
{
|
||||
loc8 = loc7 as Object3D;
|
||||
loc8.mouseEnabled = loc6.mouseEnabled;
|
||||
@@ -821,9 +823,9 @@ package alternativa.editor.scene
|
||||
|
||||
public function clear() : void
|
||||
{
|
||||
var loc1:* = undefined;
|
||||
var loc1:Object3D;
|
||||
var loc2:Prop = null;
|
||||
for(loc1 in root.children)
|
||||
for each(loc1 in root.children)
|
||||
{
|
||||
loc2 = loc1 as Prop;
|
||||
if(loc2)
|
||||
@@ -835,7 +837,7 @@ package alternativa.editor.scene
|
||||
this.selectedProps.clear();
|
||||
occupyMap.clear();
|
||||
this.layers.clear();
|
||||
view.interactive = true;
|
||||
//view.interactive = true;
|
||||
this.dominationPoints = new Dictionary();
|
||||
}
|
||||
|
||||
@@ -1108,12 +1110,12 @@ package alternativa.editor.scene
|
||||
private function drawDominationPointLinks(param1:Graphics, param2:ControlPoint) : void
|
||||
{
|
||||
var loc4:SpawnPoint = null;
|
||||
var loc5:Point3D = null;
|
||||
var loc5:Point3D = new Point3D();
|
||||
param1.lineStyle(0,65280);
|
||||
var loc3:Point3D = view.projectPoint(param2.coords);
|
||||
var loc3:Point3D = new Point3D().copyFromVector3D(camera.projectGlobal(new Vector3D(param2.x,param2.y,param2.z)));
|
||||
for each(loc4 in param2.getSpawnPoints())
|
||||
{
|
||||
loc5 = view.projectPoint(loc4.coords);
|
||||
loc5.copyFromVector3D(camera.projectGlobal(new Vector3D(loc4.x,loc4.y,loc4.z)));
|
||||
GraphicUtils.drawLine(param1,loc3,loc5);
|
||||
}
|
||||
}
|
||||
|
||||
4
src/alternativa/engine3d/alternativa3d.as
Normal file
4
src/alternativa/engine3d/alternativa3d.as
Normal file
@@ -0,0 +1,4 @@
|
||||
package alternativa.engine3d
|
||||
{
|
||||
public namespace alternativa3d = "http://alternativaplatform.com/en/alternativa3d";
|
||||
}
|
||||
424
src/alternativa/engine3d/animation/AnimationClip.as
Normal file
424
src/alternativa/engine3d/animation/AnimationClip.as
Normal file
@@ -0,0 +1,424 @@
|
||||
package alternativa.engine3d.animation
|
||||
{
|
||||
import __AS3__.vec.Vector;
|
||||
import alternativa.engine3d.animation.keys.Track;
|
||||
import alternativa.engine3d.objects.Joint;
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
import alternativa.engine3d.objects.Skin;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class AnimationClip extends AnimationNode
|
||||
{
|
||||
|
||||
alternativa3d var _objects:Array;
|
||||
public var name:String;
|
||||
public var loop:Boolean = true;
|
||||
public var length:Number = 0;
|
||||
public var animated:Boolean = true;
|
||||
private var _time:Number = 0;
|
||||
private var _numTracks:int = 0;
|
||||
private var _tracks:Vector.<Track> = new Vector.<Track>();
|
||||
private var _notifiersList:AnimationNotify;
|
||||
|
||||
public function AnimationClip(_arg_1:String=null)
|
||||
{
|
||||
this.name = _arg_1;
|
||||
}
|
||||
|
||||
public function get objects():Array
|
||||
{
|
||||
return ((this._objects == null) ? null : [].concat(this._objects));
|
||||
}
|
||||
|
||||
public function set objects(_arg_1:Array):void
|
||||
{
|
||||
this.updateObjects(this._objects, controller, _arg_1, controller);
|
||||
this._objects = ((_arg_1 == null) ? null : [].concat(_arg_1));
|
||||
}
|
||||
|
||||
override alternativa3d function setController(_arg_1:AnimationController):void
|
||||
{
|
||||
this.updateObjects(this._objects, controller, this._objects, _arg_1);
|
||||
this.controller = _arg_1;
|
||||
}
|
||||
|
||||
private function addObject(_arg_1:Object):void
|
||||
{
|
||||
if (this._objects == null)
|
||||
{
|
||||
this._objects = [_arg_1];
|
||||
} else
|
||||
{
|
||||
this._objects.push(_arg_1);
|
||||
};
|
||||
if (controller != null)
|
||||
{
|
||||
controller.addObject(_arg_1);
|
||||
};
|
||||
}
|
||||
|
||||
private function updateObjects(_arg_1:Array, _arg_2:AnimationController, _arg_3:Array, _arg_4:AnimationController):void
|
||||
{
|
||||
var _local_5:int;
|
||||
var _local_6:int;
|
||||
if (((!(_arg_2 == null)) && (!(_arg_1 == null))))
|
||||
{
|
||||
_local_5 = 0;
|
||||
_local_6 = this._objects.length;
|
||||
while (_local_5 < _local_6)
|
||||
{
|
||||
_arg_2.removeObject(_arg_1[_local_5]);
|
||||
_local_5++;
|
||||
};
|
||||
};
|
||||
if (((!(_arg_4 == null)) && (!(_arg_3 == null))))
|
||||
{
|
||||
_local_5 = 0;
|
||||
_local_6 = _arg_3.length;
|
||||
while (_local_5 < _local_6)
|
||||
{
|
||||
_arg_4.addObject(_arg_3[_local_5]);
|
||||
_local_5++;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public function updateLength():void
|
||||
{
|
||||
var _local_2:Track;
|
||||
var _local_3:Number;
|
||||
var _local_1:int;
|
||||
while (_local_1 < this._numTracks)
|
||||
{
|
||||
_local_2 = this._tracks[_local_1];
|
||||
_local_3 = _local_2.length;
|
||||
if (_local_3 > this.length)
|
||||
{
|
||||
this.length = _local_3;
|
||||
};
|
||||
_local_1++;
|
||||
};
|
||||
}
|
||||
|
||||
public function addTrack(_arg_1:Track):Track
|
||||
{
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new Error("Track can not be null"));
|
||||
};
|
||||
var _local_2:* = this._numTracks++;
|
||||
this._tracks[_local_2] = _arg_1;
|
||||
if (_arg_1.length > this.length)
|
||||
{
|
||||
this.length = _arg_1.length;
|
||||
};
|
||||
return (_arg_1);
|
||||
}
|
||||
|
||||
public function removeTrack(_arg_1:Track):Track
|
||||
{
|
||||
var _local_5:Track;
|
||||
var _local_2:int = this._tracks.indexOf(_arg_1);
|
||||
if (_local_2 < 0)
|
||||
{
|
||||
throw (new ArgumentError("Track not found"));
|
||||
};
|
||||
this._numTracks--;
|
||||
var _local_3:int = (_local_2 + 1);
|
||||
while (_local_2 < this._numTracks)
|
||||
{
|
||||
this._tracks[_local_2] = this._tracks[_local_3];
|
||||
_local_2++;
|
||||
_local_3++;
|
||||
};
|
||||
this._tracks.length = this._numTracks;
|
||||
this.length = 0;
|
||||
var _local_4:int;
|
||||
while (_local_4 < this._numTracks)
|
||||
{
|
||||
_local_5 = this._tracks[_local_4];
|
||||
if (_local_5.length > this.length)
|
||||
{
|
||||
this.length = _local_5.length;
|
||||
};
|
||||
_local_4++;
|
||||
};
|
||||
return (_arg_1);
|
||||
}
|
||||
|
||||
public function getTrackAt(_arg_1:int):Track
|
||||
{
|
||||
return (this._tracks[_arg_1]);
|
||||
}
|
||||
|
||||
public function get numTracks():int
|
||||
{
|
||||
return (this._numTracks);
|
||||
}
|
||||
|
||||
override alternativa3d function update(_arg_1:Number, _arg_2:Number):void
|
||||
{
|
||||
var _local_4:int;
|
||||
var _local_5:Track;
|
||||
var _local_6:AnimationState;
|
||||
var _local_3:Number = this._time;
|
||||
if (this.animated)
|
||||
{
|
||||
this._time = (this._time + (_arg_1 * speed));
|
||||
if (this.loop)
|
||||
{
|
||||
if (this._time < 0)
|
||||
{
|
||||
this._time = 0;
|
||||
} else
|
||||
{
|
||||
if (this._time >= this.length)
|
||||
{
|
||||
this.collectNotifiers(_local_3, this.length);
|
||||
this._time = ((this.length <= 0) ? 0 : (this._time % this.length));
|
||||
this.collectNotifiers(0, this._time);
|
||||
} else
|
||||
{
|
||||
this.collectNotifiers(_local_3, this._time);
|
||||
};
|
||||
};
|
||||
} else
|
||||
{
|
||||
if (this._time < 0)
|
||||
{
|
||||
this._time = 0;
|
||||
} else
|
||||
{
|
||||
if (this._time >= this.length)
|
||||
{
|
||||
this._time = this.length;
|
||||
};
|
||||
};
|
||||
this.collectNotifiers(_local_3, this._time);
|
||||
};
|
||||
};
|
||||
if (_arg_2 > 0)
|
||||
{
|
||||
_local_4 = 0;
|
||||
while (_local_4 < this._numTracks)
|
||||
{
|
||||
_local_5 = this._tracks[_local_4];
|
||||
if (_local_5.object != null)
|
||||
{
|
||||
_local_6 = controller.getState(_local_5.object);
|
||||
if (_local_6 != null)
|
||||
{
|
||||
_local_5.blend(this._time, _arg_2, _local_6);
|
||||
};
|
||||
};
|
||||
_local_4++;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public function get time():Number
|
||||
{
|
||||
return (this._time);
|
||||
}
|
||||
|
||||
public function set time(_arg_1:Number):void
|
||||
{
|
||||
this._time = _arg_1;
|
||||
}
|
||||
|
||||
public function get normalizedTime():Number
|
||||
{
|
||||
return ((this.length == 0) ? 0 : (this._time / this.length));
|
||||
}
|
||||
|
||||
public function set normalizedTime(_arg_1:Number):void
|
||||
{
|
||||
this._time = (_arg_1 * this.length);
|
||||
}
|
||||
|
||||
private function getNumChildren(_arg_1:Object):int
|
||||
{
|
||||
if ((_arg_1 is Joint))
|
||||
{
|
||||
return (Joint(_arg_1).numChildren);
|
||||
};
|
||||
if ((_arg_1 is Object3DContainer))
|
||||
{
|
||||
return (Object3DContainer(_arg_1).numChildren);
|
||||
};
|
||||
if ((_arg_1 is Skin))
|
||||
{
|
||||
return (Skin(_arg_1).numJoints);
|
||||
};
|
||||
return (0);
|
||||
}
|
||||
|
||||
private function getChildAt(_arg_1:Object, _arg_2:int):Object
|
||||
{
|
||||
if ((_arg_1 is Joint))
|
||||
{
|
||||
return (Joint(_arg_1).getChildAt(_arg_2));
|
||||
};
|
||||
if ((_arg_1 is Object3DContainer))
|
||||
{
|
||||
return (Object3DContainer(_arg_1).getChildAt(_arg_2));
|
||||
};
|
||||
if ((_arg_1 is Skin))
|
||||
{
|
||||
return (Skin(_arg_1).getJointAt(_arg_2));
|
||||
};
|
||||
return (null);
|
||||
}
|
||||
|
||||
private function addChildren(_arg_1:Object):void
|
||||
{
|
||||
var _local_4:Object;
|
||||
var _local_2:int;
|
||||
var _local_3:int = this.getNumChildren(_arg_1);
|
||||
while (_local_2 < _local_3)
|
||||
{
|
||||
_local_4 = this.getChildAt(_arg_1, _local_2);
|
||||
this.addObject(_local_4);
|
||||
this.addChildren(_local_4);
|
||||
_local_2++;
|
||||
};
|
||||
}
|
||||
|
||||
public function attach(_arg_1:Object, _arg_2:Boolean):void
|
||||
{
|
||||
this.updateObjects(this._objects, controller, null, controller);
|
||||
this._objects = null;
|
||||
this.addObject(_arg_1);
|
||||
if (_arg_2)
|
||||
{
|
||||
this.addChildren(_arg_1);
|
||||
};
|
||||
}
|
||||
|
||||
alternativa3d function collectNotifiers(_arg_1:Number, _arg_2:Number):void
|
||||
{
|
||||
var _local_3:AnimationNotify = this._notifiersList;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
if (_local_3._time > _arg_1)
|
||||
{
|
||||
if (_local_3._time > _arg_2)
|
||||
{
|
||||
return;
|
||||
};
|
||||
_local_3.processNext = controller.nearestNotifyers;
|
||||
controller.nearestNotifyers = _local_3;
|
||||
};
|
||||
_local_3 = _local_3.next;
|
||||
};
|
||||
}
|
||||
|
||||
public function addNotify(_arg_1:Number, _arg_2:String=null):AnimationNotify
|
||||
{
|
||||
var _local_4:AnimationNotify;
|
||||
_arg_1 = ((_arg_1 <= 0) ? 0 : ((_arg_1 >= this.length) ? this.length : _arg_1));
|
||||
var _local_3:AnimationNotify = new AnimationNotify(_arg_2);
|
||||
_local_3._time = _arg_1;
|
||||
if (this._notifiersList == null)
|
||||
{
|
||||
this._notifiersList = _local_3;
|
||||
return (_local_3);
|
||||
};
|
||||
if (this._notifiersList._time > _arg_1)
|
||||
{
|
||||
_local_3.next = this._notifiersList;
|
||||
this._notifiersList = _local_3;
|
||||
return (_local_3);
|
||||
};
|
||||
_local_4 = this._notifiersList;
|
||||
while (((!(_local_4.next == null)) && (_local_4.next._time <= _arg_1)))
|
||||
{
|
||||
_local_4 = _local_4.next;
|
||||
};
|
||||
if (_local_4.next == null)
|
||||
{
|
||||
_local_4.next = _local_3;
|
||||
} else
|
||||
{
|
||||
_local_3.next = _local_4.next;
|
||||
_local_4.next = _local_3;
|
||||
};
|
||||
return (_local_3);
|
||||
}
|
||||
|
||||
public function addNotifyAtEnd(_arg_1:Number=0, _arg_2:String=null):AnimationNotify
|
||||
{
|
||||
return (this.addNotify((this.length - _arg_1), _arg_2));
|
||||
}
|
||||
|
||||
public function removeNotify(_arg_1:AnimationNotify):AnimationNotify
|
||||
{
|
||||
var _local_2:AnimationNotify;
|
||||
if (this._notifiersList != null)
|
||||
{
|
||||
if (this._notifiersList == _arg_1)
|
||||
{
|
||||
this._notifiersList = this._notifiersList.next;
|
||||
return (_arg_1);
|
||||
};
|
||||
_local_2 = this._notifiersList;
|
||||
while (((!(_local_2.next == null)) && (!(_local_2.next == _arg_1))))
|
||||
{
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (_local_2.next == _arg_1)
|
||||
{
|
||||
_local_2.next = _arg_1.next;
|
||||
return (_arg_1);
|
||||
};
|
||||
};
|
||||
throw (new Error("Notify not found"));
|
||||
}
|
||||
|
||||
public function get notifiers():Vector.<AnimationNotify>
|
||||
{
|
||||
var _local_1:Vector.<AnimationNotify> = new Vector.<AnimationNotify>();
|
||||
var _local_2:int;
|
||||
var _local_3:AnimationNotify = this._notifiersList;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
_local_1[_local_2] = _local_3;
|
||||
_local_2++;
|
||||
_local_3 = _local_3.next;
|
||||
};
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
public function slice(_arg_1:Number, _arg_2:Number=1.79769313486232E308):AnimationClip
|
||||
{
|
||||
var _local_3:AnimationClip = new AnimationClip(this.name);
|
||||
_local_3._objects = ((this._objects == null) ? null : [].concat(this._objects));
|
||||
var _local_4:int;
|
||||
while (_local_4 < this._numTracks)
|
||||
{
|
||||
_local_3.addTrack(this._tracks[_local_4].slice(_arg_1, _arg_2));
|
||||
_local_4++;
|
||||
};
|
||||
return (_local_3);
|
||||
}
|
||||
|
||||
public function clone():AnimationClip
|
||||
{
|
||||
var _local_1:AnimationClip = new AnimationClip(this.name);
|
||||
_local_1._objects = ((this._objects == null) ? null : [].concat(this._objects));
|
||||
var _local_2:int;
|
||||
while (_local_2 < this._numTracks)
|
||||
{
|
||||
_local_1.addTrack(this._tracks[_local_2]);
|
||||
_local_2++;
|
||||
};
|
||||
_local_1.length = this.length;
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation
|
||||
176
src/alternativa/engine3d/animation/AnimationController.as
Normal file
176
src/alternativa/engine3d/animation/AnimationController.as
Normal file
@@ -0,0 +1,176 @@
|
||||
package alternativa.engine3d.animation
|
||||
{
|
||||
import __AS3__.vec.Vector;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import flash.utils.Dictionary;
|
||||
import flash.utils.getTimer;
|
||||
import alternativa.engine3d.animation.events.NotifyEvent;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class AnimationController
|
||||
{
|
||||
|
||||
private var _root:AnimationNode;
|
||||
private var _objects:Vector.<Object>;
|
||||
private var _object3ds:Vector.<Object3D> = new Vector.<Object3D>();
|
||||
private var objectsUsedCount:Dictionary = new Dictionary();
|
||||
private var states:Object = new Object();
|
||||
private var lastTime:int = -1;
|
||||
alternativa3d var nearestNotifyers:AnimationNotify;
|
||||
|
||||
|
||||
public function get root():AnimationNode
|
||||
{
|
||||
return (this._root);
|
||||
}
|
||||
|
||||
public function set root(_arg_1:AnimationNode):void
|
||||
{
|
||||
if (this._root != _arg_1)
|
||||
{
|
||||
if (this._root != null)
|
||||
{
|
||||
this._root.setController(null);
|
||||
this._root._isActive = false;
|
||||
};
|
||||
if (_arg_1 != null)
|
||||
{
|
||||
_arg_1.setController(this);
|
||||
_arg_1._isActive = true;
|
||||
};
|
||||
this._root = _arg_1;
|
||||
};
|
||||
}
|
||||
|
||||
public function update():void
|
||||
{
|
||||
var _local_1:Number;
|
||||
var _local_2:AnimationState;
|
||||
var _local_3:int;
|
||||
var _local_4:int;
|
||||
var _local_6:int;
|
||||
var _local_7:Object3D;
|
||||
if (this.lastTime < 0)
|
||||
{
|
||||
this.lastTime = getTimer();
|
||||
_local_1 = 0;
|
||||
} else
|
||||
{
|
||||
_local_6 = getTimer();
|
||||
_local_1 = (0.001 * (_local_6 - this.lastTime));
|
||||
this.lastTime = _local_6;
|
||||
};
|
||||
if (this._root == null)
|
||||
{
|
||||
return;
|
||||
};
|
||||
for each (_local_2 in this.states)
|
||||
{
|
||||
_local_2.reset();
|
||||
};
|
||||
this._root.update(_local_1, 1);
|
||||
_local_3 = 0;
|
||||
_local_4 = this._object3ds.length;
|
||||
while (_local_3 < _local_4)
|
||||
{
|
||||
_local_7 = this._object3ds[_local_3];
|
||||
_local_2 = this.states[_local_7.name];
|
||||
if (_local_2 != null)
|
||||
{
|
||||
_local_2.apply(_local_7);
|
||||
};
|
||||
_local_3++;
|
||||
};
|
||||
var _local_5:AnimationNotify = this.nearestNotifyers;
|
||||
while (_local_5 != null)
|
||||
{
|
||||
if (_local_5.willTrigger(NotifyEvent.NOTIFY))
|
||||
{
|
||||
_local_5.dispatchEvent(new NotifyEvent(_local_5));
|
||||
};
|
||||
_local_5 = _local_5.processNext;
|
||||
};
|
||||
this.nearestNotifyers = null;
|
||||
}
|
||||
|
||||
alternativa3d function addObject(_arg_1:Object):void
|
||||
{
|
||||
if ((_arg_1 in this.objectsUsedCount))
|
||||
{
|
||||
this.objectsUsedCount[_arg_1]++;
|
||||
} else
|
||||
{
|
||||
if ((_arg_1 is Object3D))
|
||||
{
|
||||
this._object3ds.push(_arg_1);
|
||||
} else
|
||||
{
|
||||
this._objects.push(_arg_1);
|
||||
};
|
||||
this.objectsUsedCount[_arg_1] = 1;
|
||||
};
|
||||
}
|
||||
|
||||
alternativa3d function removeObject(_arg_1:Object):void
|
||||
{
|
||||
var _local_3:int;
|
||||
var _local_4:int;
|
||||
var _local_5:int;
|
||||
var _local_2:int = this.objectsUsedCount[_arg_1];
|
||||
_local_2--;
|
||||
if (_local_2 <= 0)
|
||||
{
|
||||
if ((_arg_1 is Object3D))
|
||||
{
|
||||
_local_3 = this._object3ds.indexOf(_arg_1);
|
||||
_local_5 = (this._object3ds.length - 1);
|
||||
_local_4 = (_local_3 + 1);
|
||||
while (_local_3 < _local_5)
|
||||
{
|
||||
this._object3ds[_local_3] = this._object3ds[_local_4];
|
||||
_local_3++;
|
||||
_local_4++;
|
||||
};
|
||||
this._object3ds.length = _local_5;
|
||||
} else
|
||||
{
|
||||
_local_3 = this._objects.indexOf(_arg_1);
|
||||
_local_5 = (this._objects.length - 1);
|
||||
_local_4 = (_local_3 + 1);
|
||||
while (_local_3 < _local_5)
|
||||
{
|
||||
this._objects[_local_3] = this._objects[_local_4];
|
||||
_local_3++;
|
||||
_local_4++;
|
||||
};
|
||||
this._objects.length = _local_5;
|
||||
};
|
||||
delete this.objectsUsedCount[_arg_1];
|
||||
} else
|
||||
{
|
||||
this.objectsUsedCount[_arg_1] = _local_2;
|
||||
};
|
||||
}
|
||||
|
||||
alternativa3d function getState(_arg_1:String):AnimationState
|
||||
{
|
||||
var _local_2:AnimationState = this.states[_arg_1];
|
||||
if (_local_2 == null)
|
||||
{
|
||||
_local_2 = new AnimationState();
|
||||
this.states[_arg_1] = _local_2;
|
||||
};
|
||||
return (_local_2);
|
||||
}
|
||||
|
||||
public function freeze():void
|
||||
{
|
||||
this.lastTime = -1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation
|
||||
117
src/alternativa/engine3d/animation/AnimationCouple.as
Normal file
117
src/alternativa/engine3d/animation/AnimationCouple.as
Normal file
@@ -0,0 +1,117 @@
|
||||
package alternativa.engine3d.animation
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class AnimationCouple extends AnimationNode
|
||||
{
|
||||
|
||||
private var _left:AnimationNode;
|
||||
private var _right:AnimationNode;
|
||||
public var balance:Number = 0.5;
|
||||
|
||||
|
||||
override alternativa3d function update(_arg_1:Number, _arg_2:Number):void
|
||||
{
|
||||
var _local_3:Number = ((this.balance <= 0) ? 0 : ((this.balance >= 1) ? 1 : this.balance));
|
||||
if (this._left == null)
|
||||
{
|
||||
this._right.update((_arg_1 * speed), _arg_2);
|
||||
} else
|
||||
{
|
||||
if (this._right == null)
|
||||
{
|
||||
this._left.update((_arg_1 * speed), _arg_2);
|
||||
} else
|
||||
{
|
||||
this._left.update((_arg_1 * speed), ((1 - _local_3) * _arg_2));
|
||||
this._right.update((_arg_1 * speed), (_local_3 * _arg_2));
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
override alternativa3d function setController(_arg_1:AnimationController):void
|
||||
{
|
||||
this.controller = _arg_1;
|
||||
if (this._left != null)
|
||||
{
|
||||
this._left.setController(_arg_1);
|
||||
};
|
||||
if (this._right != null)
|
||||
{
|
||||
this._right.setController(_arg_1);
|
||||
};
|
||||
}
|
||||
|
||||
override alternativa3d function addNode(_arg_1:AnimationNode):void
|
||||
{
|
||||
super.addNode(_arg_1);
|
||||
_arg_1._isActive = true;
|
||||
}
|
||||
|
||||
override alternativa3d function removeNode(_arg_1:AnimationNode):void
|
||||
{
|
||||
if (this._left == _arg_1)
|
||||
{
|
||||
this._left = null;
|
||||
} else
|
||||
{
|
||||
this._right = null;
|
||||
};
|
||||
super.removeNode(_arg_1);
|
||||
}
|
||||
|
||||
public function get left():AnimationNode
|
||||
{
|
||||
return (this._left);
|
||||
}
|
||||
|
||||
public function set left(_arg_1:AnimationNode):void
|
||||
{
|
||||
if (_arg_1 != this._left)
|
||||
{
|
||||
if (_arg_1._parent == this)
|
||||
{
|
||||
throw (new Error("Animation already exist in blender"));
|
||||
};
|
||||
if (this._left != null)
|
||||
{
|
||||
this.removeNode(this._left);
|
||||
};
|
||||
this._left = _arg_1;
|
||||
if (_arg_1 != null)
|
||||
{
|
||||
this.addNode(_arg_1);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public function get right():AnimationNode
|
||||
{
|
||||
return (this._right);
|
||||
}
|
||||
|
||||
public function set right(_arg_1:AnimationNode):void
|
||||
{
|
||||
if (_arg_1 != this._right)
|
||||
{
|
||||
if (_arg_1._parent == this)
|
||||
{
|
||||
throw (new Error("Animation already exist in blender"));
|
||||
};
|
||||
if (this._right != null)
|
||||
{
|
||||
this.removeNode(this._right);
|
||||
};
|
||||
this._right = _arg_1;
|
||||
if (_arg_1 != null)
|
||||
{
|
||||
this.addNode(_arg_1);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation
|
||||
54
src/alternativa/engine3d/animation/AnimationNode.as
Normal file
54
src/alternativa/engine3d/animation/AnimationNode.as
Normal file
@@ -0,0 +1,54 @@
|
||||
package alternativa.engine3d.animation
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class AnimationNode
|
||||
{
|
||||
|
||||
alternativa3d var _isActive:Boolean = false;
|
||||
alternativa3d var _parent:AnimationNode;
|
||||
alternativa3d var controller:AnimationController;
|
||||
public var speed:Number = 1;
|
||||
|
||||
|
||||
public function get isActive():Boolean
|
||||
{
|
||||
return ((this._isActive) && (!(this.controller == null)));
|
||||
}
|
||||
|
||||
public function get parent():AnimationNode
|
||||
{
|
||||
return (this._parent);
|
||||
}
|
||||
|
||||
alternativa3d function update(_arg_1:Number, _arg_2:Number):void
|
||||
{
|
||||
}
|
||||
|
||||
alternativa3d function setController(_arg_1:AnimationController):void
|
||||
{
|
||||
this.controller = _arg_1;
|
||||
}
|
||||
|
||||
alternativa3d function addNode(_arg_1:AnimationNode):void
|
||||
{
|
||||
if (_arg_1._parent != null)
|
||||
{
|
||||
_arg_1._parent.removeNode(_arg_1);
|
||||
};
|
||||
_arg_1._parent = this;
|
||||
_arg_1.setController(this.controller);
|
||||
}
|
||||
|
||||
alternativa3d function removeNode(_arg_1:AnimationNode):void
|
||||
{
|
||||
_arg_1.setController(null);
|
||||
_arg_1._isActive = false;
|
||||
_arg_1._parent = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation
|
||||
29
src/alternativa/engine3d/animation/AnimationNotify.as
Normal file
29
src/alternativa/engine3d/animation/AnimationNotify.as
Normal file
@@ -0,0 +1,29 @@
|
||||
package alternativa.engine3d.animation
|
||||
{
|
||||
import flash.events.EventDispatcher;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class AnimationNotify extends EventDispatcher
|
||||
{
|
||||
|
||||
public var name:String;
|
||||
alternativa3d var _time:Number = 0;
|
||||
alternativa3d var next:AnimationNotify;
|
||||
alternativa3d var updateTime:Number;
|
||||
alternativa3d var processNext:AnimationNotify;
|
||||
|
||||
public function AnimationNotify(_arg_1:String)
|
||||
{
|
||||
this.name = _arg_1;
|
||||
}
|
||||
|
||||
public function get time():Number
|
||||
{
|
||||
return (this._time);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation
|
||||
261
src/alternativa/engine3d/animation/AnimationState.as
Normal file
261
src/alternativa/engine3d/animation/AnimationState.as
Normal file
@@ -0,0 +1,261 @@
|
||||
package alternativa.engine3d.animation
|
||||
{
|
||||
import alternativa.engine3d.animation.keys.TransformKey;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import flash.geom.Vector3D;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class AnimationState
|
||||
{
|
||||
|
||||
public var useCount:int = 0;
|
||||
public var transform:TransformKey = new TransformKey();
|
||||
public var transformWeightSum:Number = 0;
|
||||
public var numbers:Object = new Object();
|
||||
public var numberWeightSums:Object = new Object();
|
||||
|
||||
|
||||
public function reset():void
|
||||
{
|
||||
var _local_1:String;
|
||||
this.transformWeightSum = 0;
|
||||
for (_local_1 in this.numbers)
|
||||
{
|
||||
delete this.numbers[_local_1];
|
||||
delete this.numberWeightSums[_local_1];
|
||||
};
|
||||
}
|
||||
|
||||
public function addWeightedTransform(_arg_1:TransformKey, _arg_2:Number):void
|
||||
{
|
||||
this.transformWeightSum = (this.transformWeightSum + _arg_2);
|
||||
this.transform.interpolate(this.transform, _arg_1, (_arg_2 / this.transformWeightSum));
|
||||
}
|
||||
|
||||
public function addWeightedNumber(_arg_1:String, _arg_2:Number, _arg_3:Number):void
|
||||
{
|
||||
var _local_5:Number;
|
||||
var _local_4:Number = this.numberWeightSums[_arg_1];
|
||||
if (_local_4 == _local_4)
|
||||
{
|
||||
_local_4 = (_local_4 + _arg_3);
|
||||
_arg_3 = (_arg_3 / _local_4);
|
||||
_local_5 = this.numbers[_arg_1];
|
||||
this.numbers[_arg_1] = (((1 - _arg_3) * _local_5) + (_arg_3 * _arg_2));
|
||||
this.numberWeightSums[_arg_1] = _local_4;
|
||||
} else
|
||||
{
|
||||
this.numbers[_arg_1] = _arg_2;
|
||||
this.numberWeightSums[_arg_1] = _arg_3;
|
||||
};
|
||||
}
|
||||
|
||||
public function apply(_arg_1:Object3D):void
|
||||
{
|
||||
var _local_2:Number;
|
||||
var _local_3:Number;
|
||||
var _local_4:String;
|
||||
if (this.transformWeightSum > 0)
|
||||
{
|
||||
_arg_1.x = this.transform.x;
|
||||
_arg_1.y = this.transform.y;
|
||||
_arg_1.z = this.transform.z;
|
||||
this.setEulerAngles(this.transform.rotation, _arg_1);
|
||||
_arg_1.scaleX = this.transform.scaleX;
|
||||
_arg_1.scaleY = this.transform.scaleY;
|
||||
_arg_1.scaleZ = this.transform.scaleZ;
|
||||
};
|
||||
for (_local_4 in this.numbers)
|
||||
{
|
||||
switch (_local_4)
|
||||
{
|
||||
case "x":
|
||||
_local_2 = this.numberWeightSums["x"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.x = (((1 - _local_3) * _arg_1.x) + (_local_3 * this.numbers["x"]));
|
||||
break;
|
||||
case "y":
|
||||
_local_2 = this.numberWeightSums["y"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.y = (((1 - _local_3) * _arg_1.y) + (_local_3 * this.numbers["y"]));
|
||||
break;
|
||||
case "z":
|
||||
_local_2 = this.numberWeightSums["z"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.z = (((1 - _local_3) * _arg_1.z) + (_local_3 * this.numbers["z"]));
|
||||
break;
|
||||
case "rotationX":
|
||||
_local_2 = this.numberWeightSums["rotationX"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.rotationX = (((1 - _local_3) * _arg_1.rotationX) + (_local_3 * this.numbers["rotationX"]));
|
||||
break;
|
||||
case "rotationY":
|
||||
_local_2 = this.numberWeightSums["rotationY"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.rotationY = (((1 - _local_3) * _arg_1.rotationY) + (_local_3 * this.numbers["rotationY"]));
|
||||
break;
|
||||
case "rotationZ":
|
||||
_local_2 = this.numberWeightSums["rotationZ"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.rotationZ = (((1 - _local_3) * _arg_1.rotationZ) + (_local_3 * this.numbers["rotationZ"]));
|
||||
break;
|
||||
case "scaleX":
|
||||
_local_2 = this.numberWeightSums["scaleX"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.scaleX = (((1 - _local_3) * _arg_1.scaleX) + (_local_3 * this.numbers["scaleX"]));
|
||||
break;
|
||||
case "scaleY":
|
||||
_local_2 = this.numberWeightSums["scaleY"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.scaleY = (((1 - _local_3) * _arg_1.scaleY) + (_local_3 * this.numbers["scaleY"]));
|
||||
break;
|
||||
case "scaleZ":
|
||||
_local_2 = this.numberWeightSums["scaleZ"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.scaleZ = (((1 - _local_3) * _arg_1.scaleZ) + (_local_3 * this.numbers["scaleZ"]));
|
||||
break;
|
||||
default:
|
||||
_arg_1[_local_4] = this.numbers[_local_4];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public function applyObject(_arg_1:Object):void
|
||||
{
|
||||
var _local_2:Number;
|
||||
var _local_3:Number;
|
||||
var _local_4:String;
|
||||
if (this.transformWeightSum > 0)
|
||||
{
|
||||
_arg_1.x = this.transform.x;
|
||||
_arg_1.y = this.transform.y;
|
||||
_arg_1.z = this.transform.z;
|
||||
this.setEulerAnglesObject(this.transform.rotation, _arg_1);
|
||||
_arg_1.scaleX = this.transform.scaleX;
|
||||
_arg_1.scaleY = this.transform.scaleY;
|
||||
_arg_1.scaleZ = this.transform.scaleZ;
|
||||
};
|
||||
for (_local_4 in this.numbers)
|
||||
{
|
||||
switch (_local_4)
|
||||
{
|
||||
case "x":
|
||||
_local_2 = this.numberWeightSums["x"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.x = (((1 - _local_3) * _arg_1.x) + (_local_3 * this.numbers["x"]));
|
||||
break;
|
||||
case "y":
|
||||
_local_2 = this.numberWeightSums["y"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.y = (((1 - _local_3) * _arg_1.y) + (_local_3 * this.numbers["y"]));
|
||||
break;
|
||||
case "z":
|
||||
_local_2 = this.numberWeightSums["z"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.z = (((1 - _local_3) * _arg_1.z) + (_local_3 * this.numbers["z"]));
|
||||
break;
|
||||
case "rotationX":
|
||||
_local_2 = this.numberWeightSums["rotationX"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.rotationX = (((1 - _local_3) * _arg_1.rotationX) + (_local_3 * this.numbers["rotationX"]));
|
||||
break;
|
||||
case "rotationY":
|
||||
_local_2 = this.numberWeightSums["rotationY"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.rotationY = (((1 - _local_3) * _arg_1.rotationY) + (_local_3 * this.numbers["rotationY"]));
|
||||
break;
|
||||
case "rotationZ":
|
||||
_local_2 = this.numberWeightSums["rotationZ"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.rotationZ = (((1 - _local_3) * _arg_1.rotationZ) + (_local_3 * this.numbers["rotationZ"]));
|
||||
break;
|
||||
case "scaleX":
|
||||
_local_2 = this.numberWeightSums["scaleX"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.scaleX = (((1 - _local_3) * _arg_1.scaleX) + (_local_3 * this.numbers["scaleX"]));
|
||||
break;
|
||||
case "scaleY":
|
||||
_local_2 = this.numberWeightSums["scaleY"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.scaleY = (((1 - _local_3) * _arg_1.scaleY) + (_local_3 * this.numbers["scaleY"]));
|
||||
break;
|
||||
case "scaleZ":
|
||||
_local_2 = this.numberWeightSums["scaleZ"];
|
||||
_local_3 = (_local_2 / (_local_2 + this.transformWeightSum));
|
||||
_arg_1.scaleZ = (((1 - _local_3) * _arg_1.scaleZ) + (_local_3 * this.numbers["scaleZ"]));
|
||||
break;
|
||||
default:
|
||||
_arg_1[_local_4] = this.numbers[_local_4];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
private function setEulerAngles(_arg_1:Vector3D, _arg_2:Object3D):void
|
||||
{
|
||||
var _local_3:Number = ((2 * _arg_1.x) * _arg_1.x);
|
||||
var _local_4:Number = ((2 * _arg_1.y) * _arg_1.y);
|
||||
var _local_5:Number = ((2 * _arg_1.z) * _arg_1.z);
|
||||
var _local_6:Number = ((2 * _arg_1.x) * _arg_1.y);
|
||||
var _local_7:Number = ((2 * _arg_1.y) * _arg_1.z);
|
||||
var _local_8:Number = ((2 * _arg_1.z) * _arg_1.x);
|
||||
var _local_9:Number = ((2 * _arg_1.w) * _arg_1.x);
|
||||
var _local_10:Number = ((2 * _arg_1.w) * _arg_1.y);
|
||||
var _local_11:Number = ((2 * _arg_1.w) * _arg_1.z);
|
||||
var _local_12:Number = ((1 - _local_4) - _local_5);
|
||||
var _local_13:Number = (_local_6 - _local_11);
|
||||
var _local_14:Number = (_local_6 + _local_11);
|
||||
var _local_15:Number = ((1 - _local_3) - _local_5);
|
||||
var _local_16:Number = (_local_8 - _local_10);
|
||||
var _local_17:Number = (_local_7 + _local_9);
|
||||
var _local_18:Number = ((1 - _local_3) - _local_4);
|
||||
if (((-1 < _local_16) && (_local_16 < 1)))
|
||||
{
|
||||
_arg_2.rotationX = Math.atan2(_local_17, _local_18);
|
||||
_arg_2.rotationY = -(Math.asin(_local_16));
|
||||
_arg_2.rotationZ = Math.atan2(_local_14, _local_12);
|
||||
} else
|
||||
{
|
||||
_arg_2.rotationX = 0;
|
||||
_arg_2.rotationY = ((_local_16 <= -1) ? Math.PI : -(Math.PI));
|
||||
_arg_2.rotationY = (_arg_2.rotationY * 0.5);
|
||||
_arg_2.rotationZ = Math.atan2(-(_local_13), _local_15);
|
||||
};
|
||||
}
|
||||
|
||||
private function setEulerAnglesObject(_arg_1:Vector3D, _arg_2:Object):void
|
||||
{
|
||||
var _local_3:Number = ((2 * _arg_1.x) * _arg_1.x);
|
||||
var _local_4:Number = ((2 * _arg_1.y) * _arg_1.y);
|
||||
var _local_5:Number = ((2 * _arg_1.z) * _arg_1.z);
|
||||
var _local_6:Number = ((2 * _arg_1.x) * _arg_1.y);
|
||||
var _local_7:Number = ((2 * _arg_1.y) * _arg_1.z);
|
||||
var _local_8:Number = ((2 * _arg_1.z) * _arg_1.x);
|
||||
var _local_9:Number = ((2 * _arg_1.w) * _arg_1.x);
|
||||
var _local_10:Number = ((2 * _arg_1.w) * _arg_1.y);
|
||||
var _local_11:Number = ((2 * _arg_1.w) * _arg_1.z);
|
||||
var _local_12:Number = ((1 - _local_4) - _local_5);
|
||||
var _local_13:Number = (_local_6 - _local_11);
|
||||
var _local_14:Number = (_local_6 + _local_11);
|
||||
var _local_15:Number = ((1 - _local_3) - _local_5);
|
||||
var _local_16:Number = (_local_8 - _local_10);
|
||||
var _local_17:Number = (_local_7 + _local_9);
|
||||
var _local_18:Number = ((1 - _local_3) - _local_4);
|
||||
if (((-1 < _local_16) && (_local_16 < 1)))
|
||||
{
|
||||
_arg_2.rotationX = Math.atan2(_local_17, _local_18);
|
||||
_arg_2.rotationY = -(Math.asin(_local_16));
|
||||
_arg_2.rotationZ = Math.atan2(_local_14, _local_12);
|
||||
} else
|
||||
{
|
||||
_arg_2.rotationX = 0;
|
||||
_arg_2.rotationY = ((_local_16 <= -1) ? Math.PI : -(Math.PI));
|
||||
_arg_2.rotationY = (_arg_2.rotationY * 0.5);
|
||||
_arg_2.rotationZ = Math.atan2(-(_local_13), _local_15);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation
|
||||
176
src/alternativa/engine3d/animation/AnimationSwitcher.as
Normal file
176
src/alternativa/engine3d/animation/AnimationSwitcher.as
Normal file
@@ -0,0 +1,176 @@
|
||||
package alternativa.engine3d.animation
|
||||
{
|
||||
import __AS3__.vec.Vector;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class AnimationSwitcher extends AnimationNode
|
||||
{
|
||||
|
||||
private var _numAnimations:int = 0;
|
||||
private var _animations:Vector.<AnimationNode> = new Vector.<AnimationNode>();
|
||||
private var _weights:Vector.<Number> = new Vector.<Number>();
|
||||
private var _active:AnimationNode;
|
||||
private var fadingSpeed:Number = 0;
|
||||
|
||||
|
||||
override alternativa3d function update(_arg_1:Number, _arg_2:Number):void
|
||||
{
|
||||
var _local_6:AnimationNode;
|
||||
var _local_7:Number;
|
||||
var _local_3:Number = (speed * _arg_1);
|
||||
var _local_4:Number = (this.fadingSpeed * _local_3);
|
||||
var _local_5:int;
|
||||
while (_local_5 < this._numAnimations)
|
||||
{
|
||||
_local_6 = this._animations[_local_5];
|
||||
_local_7 = this._weights[_local_5];
|
||||
if (_local_6 == this._active)
|
||||
{
|
||||
_local_7 = (_local_7 + _local_4);
|
||||
_local_7 = ((_local_7 >= 1) ? 1 : _local_7);
|
||||
_local_6.update(_local_3, (_arg_2 * _local_7));
|
||||
this._weights[_local_5] = _local_7;
|
||||
} else
|
||||
{
|
||||
_local_7 = (_local_7 - _local_4);
|
||||
if (_local_7 > 0)
|
||||
{
|
||||
_local_6.update(_local_3, (_arg_2 * _local_7));
|
||||
this._weights[_local_5] = _local_7;
|
||||
} else
|
||||
{
|
||||
_local_6._isActive = false;
|
||||
this._weights[_local_5] = 0;
|
||||
};
|
||||
};
|
||||
_local_5++;
|
||||
};
|
||||
}
|
||||
|
||||
public function get active():AnimationNode
|
||||
{
|
||||
return (this._active);
|
||||
}
|
||||
|
||||
public function activate(_arg_1:AnimationNode, _arg_2:Number=0):void
|
||||
{
|
||||
var _local_3:int;
|
||||
if (_arg_1._parent != this)
|
||||
{
|
||||
throw (new Error("Animation is not child of this blender"));
|
||||
};
|
||||
this._active = _arg_1;
|
||||
_arg_1._isActive = true;
|
||||
if (_arg_2 <= 0)
|
||||
{
|
||||
_local_3 = 0;
|
||||
while (_local_3 < this._numAnimations)
|
||||
{
|
||||
if (this._animations[_local_3] == _arg_1)
|
||||
{
|
||||
this._weights[_local_3] = 1;
|
||||
} else
|
||||
{
|
||||
this._weights[_local_3] = 0;
|
||||
this._animations[_local_3]._isActive = false;
|
||||
};
|
||||
_local_3++;
|
||||
};
|
||||
this.fadingSpeed = 0;
|
||||
} else
|
||||
{
|
||||
this.fadingSpeed = (1 / _arg_2);
|
||||
};
|
||||
}
|
||||
|
||||
override alternativa3d function setController(_arg_1:AnimationController):void
|
||||
{
|
||||
var _local_3:AnimationNode;
|
||||
this.controller = _arg_1;
|
||||
var _local_2:int;
|
||||
while (_local_2 < this._numAnimations)
|
||||
{
|
||||
_local_3 = this._animations[_local_2];
|
||||
_local_3.setController(controller);
|
||||
_local_2++;
|
||||
};
|
||||
}
|
||||
|
||||
override alternativa3d function removeNode(_arg_1:AnimationNode):void
|
||||
{
|
||||
this.removeAnimation(_arg_1);
|
||||
}
|
||||
|
||||
public function addAnimation(_arg_1:AnimationNode):AnimationNode
|
||||
{
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new Error("Animation cannot be null"));
|
||||
};
|
||||
if (_arg_1._parent == this)
|
||||
{
|
||||
throw (new Error("Animation already exist in blender"));
|
||||
};
|
||||
this._animations[this._numAnimations] = _arg_1;
|
||||
if (this._numAnimations == 0)
|
||||
{
|
||||
this._active = _arg_1;
|
||||
_arg_1._isActive = true;
|
||||
this._weights[this._numAnimations] = 1;
|
||||
} else
|
||||
{
|
||||
this._weights[this._numAnimations] = 0;
|
||||
};
|
||||
this._numAnimations++;
|
||||
addNode(_arg_1);
|
||||
return (_arg_1);
|
||||
}
|
||||
|
||||
public function removeAnimation(_arg_1:AnimationNode):AnimationNode
|
||||
{
|
||||
var _local_2:int = this._animations.indexOf(_arg_1);
|
||||
if (_local_2 < 0)
|
||||
{
|
||||
throw (new ArgumentError("Animation not found"));
|
||||
};
|
||||
this._numAnimations--;
|
||||
var _local_3:int = (_local_2 + 1);
|
||||
while (_local_2 < this._numAnimations)
|
||||
{
|
||||
this._animations[_local_2] = this._animations[_local_3];
|
||||
_local_2++;
|
||||
_local_3++;
|
||||
};
|
||||
this._animations.length = this._numAnimations;
|
||||
this._weights.length = this._numAnimations;
|
||||
if (this._active == _arg_1)
|
||||
{
|
||||
if (this._numAnimations > 0)
|
||||
{
|
||||
this._active = this._animations[int((this._numAnimations - 1))];
|
||||
this._weights[int((this._numAnimations - 1))] = 1;
|
||||
} else
|
||||
{
|
||||
this._active = null;
|
||||
};
|
||||
};
|
||||
super.removeNode(_arg_1);
|
||||
return (_arg_1);
|
||||
}
|
||||
|
||||
public function getAnimationAt(_arg_1:int):AnimationNode
|
||||
{
|
||||
return (this._animations[_arg_1]);
|
||||
}
|
||||
|
||||
public function numAnimations():int
|
||||
{
|
||||
return (this._numAnimations);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation
|
||||
23
src/alternativa/engine3d/animation/events/NotifyEvent.as
Normal file
23
src/alternativa/engine3d/animation/events/NotifyEvent.as
Normal file
@@ -0,0 +1,23 @@
|
||||
package alternativa.engine3d.animation.events
|
||||
{
|
||||
import flash.events.Event;
|
||||
import alternativa.engine3d.animation.AnimationNotify;
|
||||
|
||||
public class NotifyEvent extends Event
|
||||
{
|
||||
|
||||
public static const NOTIFY:String = "notify";
|
||||
|
||||
public function NotifyEvent(_arg_1:AnimationNotify)
|
||||
{
|
||||
super(NOTIFY);
|
||||
}
|
||||
|
||||
public function get notify():AnimationNotify
|
||||
{
|
||||
return (AnimationNotify(target));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation.events
|
||||
43
src/alternativa/engine3d/animation/keys/Keyframe.as
Normal file
43
src/alternativa/engine3d/animation/keys/Keyframe.as
Normal file
@@ -0,0 +1,43 @@
|
||||
package alternativa.engine3d.animation.keys
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Keyframe
|
||||
{
|
||||
|
||||
alternativa3d var _time:Number = 0;
|
||||
|
||||
|
||||
public function get time():Number
|
||||
{
|
||||
return (this._time);
|
||||
}
|
||||
|
||||
public function get value():Object
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
|
||||
public function set value(_arg_1:Object):void
|
||||
{
|
||||
}
|
||||
|
||||
alternativa3d function get nextKeyFrame():Keyframe
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
|
||||
alternativa3d function set nextKeyFrame(_arg_1:Keyframe):void
|
||||
{
|
||||
}
|
||||
|
||||
public function toString():String
|
||||
{
|
||||
return (((("[Keyframe time = " + this._time.toFixed(2)) + " value = ") + this.value) + "]");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation.keys
|
||||
41
src/alternativa/engine3d/animation/keys/NumberKey.as
Normal file
41
src/alternativa/engine3d/animation/keys/NumberKey.as
Normal file
@@ -0,0 +1,41 @@
|
||||
package alternativa.engine3d.animation.keys
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class NumberKey extends Keyframe
|
||||
{
|
||||
|
||||
alternativa3d var _value:Number = 0;
|
||||
alternativa3d var next:NumberKey;
|
||||
|
||||
|
||||
public function interpolate(_arg_1:NumberKey, _arg_2:NumberKey, _arg_3:Number):void
|
||||
{
|
||||
this._value = (((1 - _arg_3) * _arg_1._value) + (_arg_3 * _arg_2._value));
|
||||
}
|
||||
|
||||
override public function get value():Object
|
||||
{
|
||||
return (this._value);
|
||||
}
|
||||
|
||||
override public function set value(_arg_1:Object):void
|
||||
{
|
||||
this._value = Number(_arg_1);
|
||||
}
|
||||
|
||||
override alternativa3d function get nextKeyFrame():Keyframe
|
||||
{
|
||||
return (this.next);
|
||||
}
|
||||
|
||||
override alternativa3d function set nextKeyFrame(_arg_1:Keyframe):void
|
||||
{
|
||||
this.next = NumberKey(_arg_1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation.keys
|
||||
92
src/alternativa/engine3d/animation/keys/NumberTrack.as
Normal file
92
src/alternativa/engine3d/animation/keys/NumberTrack.as
Normal file
@@ -0,0 +1,92 @@
|
||||
package alternativa.engine3d.animation.keys
|
||||
{
|
||||
import alternativa.engine3d.animation.AnimationState;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class NumberTrack extends Track
|
||||
{
|
||||
|
||||
private static var temp:NumberKey = new NumberKey();
|
||||
|
||||
alternativa3d var keyList:NumberKey;
|
||||
public var property:String;
|
||||
|
||||
public function NumberTrack(_arg_1:String, _arg_2:String)
|
||||
{
|
||||
this.property = _arg_2;
|
||||
this.object = _arg_1;
|
||||
}
|
||||
|
||||
override alternativa3d function get keyFramesList():Keyframe
|
||||
{
|
||||
return (this.keyList);
|
||||
}
|
||||
|
||||
override alternativa3d function set keyFramesList(_arg_1:Keyframe):void
|
||||
{
|
||||
this.keyList = NumberKey(_arg_1);
|
||||
}
|
||||
|
||||
public function addKey(_arg_1:Number, _arg_2:Number=0):Keyframe
|
||||
{
|
||||
var _local_3:NumberKey = new NumberKey();
|
||||
_local_3._time = _arg_1;
|
||||
_local_3.value = _arg_2;
|
||||
addKeyToList(_local_3);
|
||||
return (_local_3);
|
||||
}
|
||||
|
||||
override alternativa3d function blend(_arg_1:Number, _arg_2:Number, _arg_3:AnimationState):void
|
||||
{
|
||||
var _local_4:NumberKey;
|
||||
if (this.property == null)
|
||||
{
|
||||
return;
|
||||
};
|
||||
var _local_5:NumberKey = this.keyList;
|
||||
while (((!(_local_5 == null)) && (_local_5._time < _arg_1)))
|
||||
{
|
||||
_local_4 = _local_5;
|
||||
_local_5 = _local_5.next;
|
||||
};
|
||||
if (_local_4 != null)
|
||||
{
|
||||
if (_local_5 != null)
|
||||
{
|
||||
temp.interpolate(_local_4, _local_5, ((_arg_1 - _local_4._time) / (_local_5._time - _local_4._time)));
|
||||
_arg_3.addWeightedNumber(this.property, temp._value, _arg_2);
|
||||
} else
|
||||
{
|
||||
_arg_3.addWeightedNumber(this.property, _local_4._value, _arg_2);
|
||||
};
|
||||
} else
|
||||
{
|
||||
if (_local_5 != null)
|
||||
{
|
||||
_arg_3.addWeightedNumber(this.property, _local_5._value, _arg_2);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
override alternativa3d function createKeyFrame():Keyframe
|
||||
{
|
||||
return (new NumberKey());
|
||||
}
|
||||
|
||||
override alternativa3d function interpolateKeyFrame(_arg_1:Keyframe, _arg_2:Keyframe, _arg_3:Keyframe, _arg_4:Number):void
|
||||
{
|
||||
NumberKey(_arg_1).interpolate(NumberKey(_arg_2), NumberKey(_arg_3), _arg_4);
|
||||
}
|
||||
|
||||
override public function slice(_arg_1:Number, _arg_2:Number=1.79769313486232E308):Track
|
||||
{
|
||||
var _local_3:NumberTrack = new NumberTrack(object, this.property);
|
||||
sliceImplementation(_local_3, _arg_1, _arg_2);
|
||||
return (_local_3);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation.keys
|
||||
193
src/alternativa/engine3d/animation/keys/Track.as
Normal file
193
src/alternativa/engine3d/animation/keys/Track.as
Normal file
@@ -0,0 +1,193 @@
|
||||
package alternativa.engine3d.animation.keys
|
||||
{
|
||||
import __AS3__.vec.Vector;
|
||||
import alternativa.engine3d.animation.AnimationState;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Track
|
||||
{
|
||||
|
||||
public var object:String;
|
||||
alternativa3d var _length:Number = 0;
|
||||
|
||||
|
||||
public function get length():Number
|
||||
{
|
||||
return (this._length);
|
||||
}
|
||||
|
||||
alternativa3d function get keyFramesList():Keyframe
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
|
||||
alternativa3d function set keyFramesList(_arg_1:Keyframe):void
|
||||
{
|
||||
}
|
||||
|
||||
alternativa3d function addKeyToList(_arg_1:Keyframe):void
|
||||
{
|
||||
var _local_3:Keyframe;
|
||||
var _local_2:Number = _arg_1._time;
|
||||
if (this.keyFramesList == null)
|
||||
{
|
||||
this.keyFramesList = _arg_1;
|
||||
this._length = ((_local_2 <= 0) ? 0 : _local_2);
|
||||
return;
|
||||
};
|
||||
if (this.keyFramesList._time > _local_2)
|
||||
{
|
||||
_arg_1.nextKeyFrame = this.keyFramesList;
|
||||
this.keyFramesList = _arg_1;
|
||||
return;
|
||||
};
|
||||
_local_3 = this.keyFramesList;
|
||||
while (((!(_local_3.nextKeyFrame == null)) && (_local_3.nextKeyFrame._time <= _local_2)))
|
||||
{
|
||||
_local_3 = _local_3.nextKeyFrame;
|
||||
};
|
||||
if (_local_3.nextKeyFrame == null)
|
||||
{
|
||||
_local_3.nextKeyFrame = _arg_1;
|
||||
this._length = ((_local_2 <= 0) ? 0 : _local_2);
|
||||
} else
|
||||
{
|
||||
_arg_1.nextKeyFrame = _local_3.nextKeyFrame;
|
||||
_local_3.nextKeyFrame = _arg_1;
|
||||
};
|
||||
}
|
||||
|
||||
public function removeKey(_arg_1:Keyframe):Keyframe
|
||||
{
|
||||
var _local_2:Keyframe;
|
||||
if (this.keyFramesList != null)
|
||||
{
|
||||
if (this.keyFramesList == _arg_1)
|
||||
{
|
||||
this.keyFramesList = this.keyFramesList.nextKeyFrame;
|
||||
if (this.keyFramesList == null)
|
||||
{
|
||||
this._length = 0;
|
||||
};
|
||||
return (_arg_1);
|
||||
};
|
||||
_local_2 = this.keyFramesList;
|
||||
while (((!(_local_2.nextKeyFrame == null)) && (!(_local_2.nextKeyFrame == _arg_1))))
|
||||
{
|
||||
_local_2 = _local_2.nextKeyFrame;
|
||||
};
|
||||
if (_local_2.nextKeyFrame == _arg_1)
|
||||
{
|
||||
if (_arg_1.nextKeyFrame == null)
|
||||
{
|
||||
this._length = ((_local_2._time <= 0) ? 0 : _local_2._time);
|
||||
};
|
||||
_local_2.nextKeyFrame = _arg_1.nextKeyFrame;
|
||||
return (_arg_1);
|
||||
};
|
||||
};
|
||||
throw (new Error("Key not found"));
|
||||
}
|
||||
|
||||
public function get keys():Vector.<Keyframe>
|
||||
{
|
||||
var _local_1:Vector.<Keyframe> = new Vector.<Keyframe>();
|
||||
var _local_2:int;
|
||||
var _local_3:Keyframe = this.keyFramesList;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
_local_1[_local_2] = _local_3;
|
||||
_local_2++;
|
||||
_local_3 = _local_3.nextKeyFrame;
|
||||
};
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
alternativa3d function blend(_arg_1:Number, _arg_2:Number, _arg_3:AnimationState):void
|
||||
{
|
||||
}
|
||||
|
||||
public function slice(_arg_1:Number, _arg_2:Number=1.79769313486232E308):Track
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
|
||||
alternativa3d function createKeyFrame():Keyframe
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
|
||||
alternativa3d function interpolateKeyFrame(_arg_1:Keyframe, _arg_2:Keyframe, _arg_3:Keyframe, _arg_4:Number):void
|
||||
{
|
||||
}
|
||||
|
||||
alternativa3d function sliceImplementation(_arg_1:Track, _arg_2:Number, _arg_3:Number):void
|
||||
{
|
||||
var _local_5:Keyframe;
|
||||
var _local_8:Keyframe;
|
||||
var _local_4:Number = ((_arg_2 > 0) ? _arg_2 : 0);
|
||||
var _local_6:Keyframe = this.keyFramesList;
|
||||
var _local_7:Keyframe = this.createKeyFrame();
|
||||
while (((!(_local_6 == null)) && (_local_6._time <= _arg_2)))
|
||||
{
|
||||
_local_5 = _local_6;
|
||||
_local_6 = _local_6.nextKeyFrame;
|
||||
};
|
||||
if (_local_5 != null)
|
||||
{
|
||||
if (_local_6 != null)
|
||||
{
|
||||
this.interpolateKeyFrame(_local_7, _local_5, _local_6, ((_arg_2 - _local_5._time) / (_local_6._time - _local_5._time)));
|
||||
_local_7._time = (_arg_2 - _local_4);
|
||||
} else
|
||||
{
|
||||
this.interpolateKeyFrame(_local_7, _local_7, _local_5, 1);
|
||||
};
|
||||
} else
|
||||
{
|
||||
if (_local_6 != null)
|
||||
{
|
||||
this.interpolateKeyFrame(_local_7, _local_7, _local_6, 1);
|
||||
_local_7._time = (_local_6._time - _local_4);
|
||||
_local_5 = _local_6;
|
||||
_local_6 = _local_6.nextKeyFrame;
|
||||
} else
|
||||
{
|
||||
return;
|
||||
};
|
||||
};
|
||||
_arg_1.keyFramesList = _local_7;
|
||||
if (((_local_6 == null) || (_arg_3 <= _arg_2)))
|
||||
{
|
||||
_arg_1._length = ((_local_7._time <= 0) ? 0 : _local_7._time);
|
||||
return;
|
||||
};
|
||||
while (((!(_local_6 == null)) && (_local_6._time <= _arg_3)))
|
||||
{
|
||||
_local_8 = this.createKeyFrame();
|
||||
this.interpolateKeyFrame(_local_8, _local_8, _local_6, 1);
|
||||
_local_8._time = (_local_6._time - _local_4);
|
||||
_local_7.nextKeyFrame = _local_8;
|
||||
_local_7 = _local_8;
|
||||
_local_5 = _local_6;
|
||||
_local_6 = _local_6.nextKeyFrame;
|
||||
};
|
||||
if (_local_6 != null)
|
||||
{
|
||||
_local_8 = this.createKeyFrame();
|
||||
this.interpolateKeyFrame(_local_8, _local_5, _local_6, ((_arg_3 - _local_5._time) / (_local_6._time - _local_5._time)));
|
||||
_local_8._time = (_arg_3 - _local_4);
|
||||
_local_7.nextKeyFrame = _local_8;
|
||||
};
|
||||
if (_local_8 != null)
|
||||
{
|
||||
_arg_1._length = ((_local_8._time <= 0) ? 0 : _local_8._time);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation.keys
|
||||
114
src/alternativa/engine3d/animation/keys/TransformKey.as
Normal file
114
src/alternativa/engine3d/animation/keys/TransformKey.as
Normal file
@@ -0,0 +1,114 @@
|
||||
package alternativa.engine3d.animation.keys
|
||||
{
|
||||
import flash.geom.Vector3D;
|
||||
import flash.geom.Matrix3D;
|
||||
import flash.geom.Orientation3D;
|
||||
import __AS3__.vec.Vector;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class TransformKey extends Keyframe
|
||||
{
|
||||
|
||||
alternativa3d var x:Number = 0;
|
||||
alternativa3d var y:Number = 0;
|
||||
alternativa3d var z:Number = 0;
|
||||
alternativa3d var rotation:Vector3D = new Vector3D(0, 0, 0, 1);
|
||||
alternativa3d var scaleX:Number = 1;
|
||||
alternativa3d var scaleY:Number = 1;
|
||||
alternativa3d var scaleZ:Number = 1;
|
||||
alternativa3d var next:TransformKey;
|
||||
|
||||
|
||||
override public function get value():Object
|
||||
{
|
||||
var _local_1:Matrix3D = new Matrix3D();
|
||||
_local_1.recompose(Vector.<Vector3D>([new Vector3D(this.x, this.y, this.z), this.rotation, new Vector3D(this.scaleX, this.scaleY, this.scaleZ)]), Orientation3D.QUATERNION);
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
override public function set value(_arg_1:Object):void
|
||||
{
|
||||
var _local_2:Matrix3D = Matrix3D(_arg_1);
|
||||
var _local_3:Vector.<Vector3D> = _local_2.decompose(Orientation3D.QUATERNION);
|
||||
this.x = _local_3[0].x;
|
||||
this.y = _local_3[0].y;
|
||||
this.z = _local_3[0].z;
|
||||
this.rotation = _local_3[1];
|
||||
this.scaleX = _local_3[2].x;
|
||||
this.scaleY = _local_3[2].y;
|
||||
this.scaleZ = _local_3[2].z;
|
||||
}
|
||||
|
||||
public function interpolate(_arg_1:TransformKey, _arg_2:TransformKey, _arg_3:Number):void
|
||||
{
|
||||
var _local_4:Number = (1 - _arg_3);
|
||||
this.x = ((_local_4 * _arg_1.x) + (_arg_3 * _arg_2.x));
|
||||
this.y = ((_local_4 * _arg_1.y) + (_arg_3 * _arg_2.y));
|
||||
this.z = ((_local_4 * _arg_1.z) + (_arg_3 * _arg_2.z));
|
||||
this.slerp(_arg_1.rotation, _arg_2.rotation, _arg_3, this.rotation);
|
||||
this.scaleX = ((_local_4 * _arg_1.scaleX) + (_arg_3 * _arg_2.scaleX));
|
||||
this.scaleY = ((_local_4 * _arg_1.scaleY) + (_arg_3 * _arg_2.scaleY));
|
||||
this.scaleZ = ((_local_4 * _arg_1.scaleZ) + (_arg_3 * _arg_2.scaleZ));
|
||||
}
|
||||
|
||||
private function slerp(_arg_1:Vector3D, _arg_2:Vector3D, _arg_3:Number, _arg_4:Vector3D):void
|
||||
{
|
||||
var _local_7:Number;
|
||||
var _local_8:Number;
|
||||
var _local_9:Number;
|
||||
var _local_10:Number;
|
||||
var _local_11:Number;
|
||||
var _local_12:Number;
|
||||
var _local_13:Number;
|
||||
var _local_5:Number = 1;
|
||||
var _local_6:Number = ((((_arg_1.w * _arg_2.w) + (_arg_1.x * _arg_2.x)) + (_arg_1.y * _arg_2.y)) + (_arg_1.z * _arg_2.z));
|
||||
if (_local_6 < 0)
|
||||
{
|
||||
_local_6 = -(_local_6);
|
||||
_local_5 = -1;
|
||||
};
|
||||
if ((1 - _local_6) < 0.001)
|
||||
{
|
||||
_local_7 = (1 - _arg_3);
|
||||
_local_8 = (_arg_3 * _local_5);
|
||||
_arg_4.w = ((_arg_1.w * _local_7) + (_arg_2.w * _local_8));
|
||||
_arg_4.x = ((_arg_1.x * _local_7) + (_arg_2.x * _local_8));
|
||||
_arg_4.y = ((_arg_1.y * _local_7) + (_arg_2.y * _local_8));
|
||||
_arg_4.z = ((_arg_1.z * _local_7) + (_arg_2.z * _local_8));
|
||||
_local_9 = ((((_arg_4.w * _arg_4.w) + (_arg_4.x * _arg_4.x)) + (_arg_4.y * _arg_4.y)) + (_arg_4.z * _arg_4.z));
|
||||
if (_local_9 == 0)
|
||||
{
|
||||
_arg_4.w = 1;
|
||||
} else
|
||||
{
|
||||
_arg_4.scaleBy((1 / Math.sqrt(_local_9)));
|
||||
};
|
||||
} else
|
||||
{
|
||||
_local_10 = Math.acos(_local_6);
|
||||
_local_11 = Math.sin(_local_10);
|
||||
_local_12 = (Math.sin(((1 - _arg_3) * _local_10)) / _local_11);
|
||||
_local_13 = ((Math.sin((_arg_3 * _local_10)) / _local_11) * _local_5);
|
||||
_arg_4.w = ((_arg_1.w * _local_12) + (_arg_2.w * _local_13));
|
||||
_arg_4.x = ((_arg_1.x * _local_12) + (_arg_2.x * _local_13));
|
||||
_arg_4.y = ((_arg_1.y * _local_12) + (_arg_2.y * _local_13));
|
||||
_arg_4.z = ((_arg_1.z * _local_12) + (_arg_2.z * _local_13));
|
||||
};
|
||||
}
|
||||
|
||||
override alternativa3d function get nextKeyFrame():Keyframe
|
||||
{
|
||||
return (this.next);
|
||||
}
|
||||
|
||||
override alternativa3d function set nextKeyFrame(_arg_1:Keyframe):void
|
||||
{
|
||||
this.next = TransformKey(_arg_1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation.keys
|
||||
164
src/alternativa/engine3d/animation/keys/TransformTrack.as
Normal file
164
src/alternativa/engine3d/animation/keys/TransformTrack.as
Normal file
@@ -0,0 +1,164 @@
|
||||
package alternativa.engine3d.animation.keys
|
||||
{
|
||||
import flash.geom.Vector3D;
|
||||
import flash.geom.Orientation3D;
|
||||
import __AS3__.vec.Vector;
|
||||
import flash.geom.Matrix3D;
|
||||
import alternativa.engine3d.animation.AnimationState;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class TransformTrack extends Track
|
||||
{
|
||||
|
||||
private static var tempQuat:Vector3D = new Vector3D();
|
||||
private static var temp:TransformKey = new TransformKey();
|
||||
|
||||
private var keyList:TransformKey;
|
||||
|
||||
public function TransformTrack(_arg_1:String)
|
||||
{
|
||||
this.object = _arg_1;
|
||||
}
|
||||
|
||||
override alternativa3d function get keyFramesList():Keyframe
|
||||
{
|
||||
return (this.keyList);
|
||||
}
|
||||
|
||||
override alternativa3d function set keyFramesList(_arg_1:Keyframe):void
|
||||
{
|
||||
this.keyList = TransformKey(_arg_1);
|
||||
}
|
||||
|
||||
public function addKey(_arg_1:Number, _arg_2:Matrix3D):TransformKey
|
||||
{
|
||||
var _local_3:TransformKey;
|
||||
_local_3 = new TransformKey();
|
||||
_local_3._time = _arg_1;
|
||||
var _local_4:Vector.<Vector3D> = _arg_2.decompose(Orientation3D.QUATERNION);
|
||||
_local_3.x = _local_4[0].x;
|
||||
_local_3.y = _local_4[0].y;
|
||||
_local_3.z = _local_4[0].z;
|
||||
_local_3.rotation = _local_4[1];
|
||||
_local_3.scaleX = _local_4[2].x;
|
||||
_local_3.scaleY = _local_4[2].y;
|
||||
_local_3.scaleZ = _local_4[2].z;
|
||||
addKeyToList(_local_3);
|
||||
return (_local_3);
|
||||
}
|
||||
|
||||
public function addKeyComponents(_arg_1:Number, _arg_2:Number=0, _arg_3:Number=0, _arg_4:Number=0, _arg_5:Number=0, _arg_6:Number=0, _arg_7:Number=0, _arg_8:Number=1, _arg_9:Number=1, _arg_10:Number=1):TransformKey
|
||||
{
|
||||
var _local_11:TransformKey = new TransformKey();
|
||||
_local_11._time = _arg_1;
|
||||
_local_11.x = _arg_2;
|
||||
_local_11.y = _arg_3;
|
||||
_local_11.z = _arg_4;
|
||||
_local_11.rotation = this.createQuatFromEuler(_arg_5, _arg_6, _arg_7);
|
||||
_local_11.scaleX = _arg_8;
|
||||
_local_11.scaleY = _arg_9;
|
||||
_local_11.scaleZ = _arg_10;
|
||||
addKeyToList(_local_11);
|
||||
return (_local_11);
|
||||
}
|
||||
|
||||
private function appendQuat(_arg_1:Vector3D, _arg_2:Vector3D):void
|
||||
{
|
||||
var _local_3:Number = ((((_arg_2.w * _arg_1.w) - (_arg_2.x * _arg_1.x)) - (_arg_2.y * _arg_1.y)) - (_arg_2.z * _arg_1.z));
|
||||
var _local_4:Number = ((((_arg_2.w * _arg_1.x) + (_arg_2.x * _arg_1.w)) + (_arg_2.y * _arg_1.z)) - (_arg_2.z * _arg_1.y));
|
||||
var _local_5:Number = ((((_arg_2.w * _arg_1.y) + (_arg_2.y * _arg_1.w)) + (_arg_2.z * _arg_1.x)) - (_arg_2.x * _arg_1.z));
|
||||
var _local_6:Number = ((((_arg_2.w * _arg_1.z) + (_arg_2.z * _arg_1.w)) + (_arg_2.x * _arg_1.y)) - (_arg_2.y * _arg_1.x));
|
||||
_arg_1.w = _local_3;
|
||||
_arg_1.x = _local_4;
|
||||
_arg_1.y = _local_5;
|
||||
_arg_1.z = _local_6;
|
||||
}
|
||||
|
||||
private function normalizeQuat(_arg_1:Vector3D):void
|
||||
{
|
||||
var _local_2:Number = ((((_arg_1.w * _arg_1.w) + (_arg_1.x * _arg_1.x)) + (_arg_1.y * _arg_1.y)) + (_arg_1.z * _arg_1.z));
|
||||
if (_local_2 == 0)
|
||||
{
|
||||
_arg_1.w = 1;
|
||||
} else
|
||||
{
|
||||
_local_2 = (1 / Math.sqrt(_local_2));
|
||||
_arg_1.w = (_arg_1.w * _local_2);
|
||||
_arg_1.x = (_arg_1.x * _local_2);
|
||||
_arg_1.y = (_arg_1.y * _local_2);
|
||||
_arg_1.z = (_arg_1.z * _local_2);
|
||||
};
|
||||
}
|
||||
|
||||
private function setQuatFromAxisAngle(_arg_1:Vector3D, _arg_2:Number, _arg_3:Number, _arg_4:Number, _arg_5:Number):void
|
||||
{
|
||||
_arg_1.w = Math.cos((0.5 * _arg_5));
|
||||
var _local_6:Number = (Math.sin((0.5 * _arg_5)) / Math.sqrt((((_arg_2 * _arg_2) + (_arg_3 * _arg_3)) + (_arg_4 * _arg_4))));
|
||||
_arg_1.x = (_arg_2 * _local_6);
|
||||
_arg_1.y = (_arg_3 * _local_6);
|
||||
_arg_1.z = (_arg_4 * _local_6);
|
||||
}
|
||||
|
||||
private function createQuatFromEuler(_arg_1:Number, _arg_2:Number, _arg_3:Number):Vector3D
|
||||
{
|
||||
var _local_4:Vector3D = new Vector3D();
|
||||
this.setQuatFromAxisAngle(_local_4, 1, 0, 0, _arg_1);
|
||||
this.setQuatFromAxisAngle(tempQuat, 0, 1, 0, _arg_2);
|
||||
this.appendQuat(_local_4, tempQuat);
|
||||
this.normalizeQuat(_local_4);
|
||||
this.setQuatFromAxisAngle(tempQuat, 0, 0, 1, _arg_3);
|
||||
this.appendQuat(_local_4, tempQuat);
|
||||
this.normalizeQuat(_local_4);
|
||||
return (_local_4);
|
||||
}
|
||||
|
||||
override alternativa3d function blend(_arg_1:Number, _arg_2:Number, _arg_3:AnimationState):void
|
||||
{
|
||||
var _local_4:TransformKey;
|
||||
var _local_5:TransformKey = this.keyList;
|
||||
while (((!(_local_5 == null)) && (_local_5._time < _arg_1)))
|
||||
{
|
||||
_local_4 = _local_5;
|
||||
_local_5 = _local_5.next;
|
||||
};
|
||||
if (_local_4 != null)
|
||||
{
|
||||
if (_local_5 != null)
|
||||
{
|
||||
temp.interpolate(_local_4, _local_5, ((_arg_1 - _local_4._time) / (_local_5._time - _local_4._time)));
|
||||
_arg_3.addWeightedTransform(temp, _arg_2);
|
||||
} else
|
||||
{
|
||||
_arg_3.addWeightedTransform(_local_4, _arg_2);
|
||||
};
|
||||
} else
|
||||
{
|
||||
if (_local_5 != null)
|
||||
{
|
||||
_arg_3.addWeightedTransform(_local_5, _arg_2);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
override alternativa3d function createKeyFrame():Keyframe
|
||||
{
|
||||
return (new TransformKey());
|
||||
}
|
||||
|
||||
override alternativa3d function interpolateKeyFrame(_arg_1:Keyframe, _arg_2:Keyframe, _arg_3:Keyframe, _arg_4:Number):void
|
||||
{
|
||||
TransformKey(_arg_1).interpolate(TransformKey(_arg_2), TransformKey(_arg_3), _arg_4);
|
||||
}
|
||||
|
||||
override public function slice(_arg_1:Number, _arg_2:Number=1.79769313486232E308):Track
|
||||
{
|
||||
var _local_3:TransformTrack = new TransformTrack(object);
|
||||
sliceImplementation(_local_3, _arg_1, _arg_2);
|
||||
return (_local_3);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.animation.keys
|
||||
3429
src/alternativa/engine3d/containers/BSPContainer.as
Normal file
3429
src/alternativa/engine3d/containers/BSPContainer.as
Normal file
File diff suppressed because it is too large
Load Diff
1263
src/alternativa/engine3d/containers/ConflictContainer.as
Normal file
1263
src/alternativa/engine3d/containers/ConflictContainer.as
Normal file
File diff suppressed because it is too large
Load Diff
161
src/alternativa/engine3d/containers/DistanceSortContainer.as
Normal file
161
src/alternativa/engine3d/containers/DistanceSortContainer.as
Normal file
@@ -0,0 +1,161 @@
|
||||
package alternativa.engine3d.containers
|
||||
{
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
import __AS3__.vec.Vector;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class DistanceSortContainer extends Object3DContainer
|
||||
{
|
||||
|
||||
private static const sortingStack:Vector.<int> = new Vector.<int>();
|
||||
|
||||
public var sortByZ:Boolean = false;
|
||||
|
||||
|
||||
override public function clone():Object3D
|
||||
{
|
||||
var _local_1:DistanceSortContainer = new DistanceSortContainer();
|
||||
_local_1.clonePropertiesFrom(this);
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
override protected function clonePropertiesFrom(_arg_1:Object3D):void
|
||||
{
|
||||
super.clonePropertiesFrom(_arg_1);
|
||||
var _local_2:DistanceSortContainer = (_arg_1 as DistanceSortContainer);
|
||||
this.sortByZ = _local_2.sortByZ;
|
||||
}
|
||||
|
||||
override alternativa3d function drawVisibleChildren(_arg_1:Camera3D):void
|
||||
{
|
||||
var _local_2:int;
|
||||
var _local_3:int;
|
||||
var _local_4:Object3D;
|
||||
var _local_7:int;
|
||||
var _local_8:Number;
|
||||
var _local_9:Number;
|
||||
var _local_10:Number;
|
||||
var _local_11:Number;
|
||||
var _local_12:Number;
|
||||
var _local_5:int;
|
||||
var _local_6:int = (numVisibleChildren - 1);
|
||||
sortingStack[0] = _local_5;
|
||||
sortingStack[1] = _local_6;
|
||||
_local_7 = 2;
|
||||
if (this.sortByZ)
|
||||
{
|
||||
while (_local_7 > 0)
|
||||
{
|
||||
_local_6 = sortingStack[--_local_7];
|
||||
_local_5 = sortingStack[--_local_7];
|
||||
_local_3 = _local_6;
|
||||
_local_2 = _local_5;
|
||||
_local_4 = visibleChildren[((_local_6 + _local_5) >> 1)];
|
||||
_local_9 = _local_4.ml;
|
||||
do
|
||||
{
|
||||
while ((_local_8 = (visibleChildren[_local_2] as Object3D).ml) > _local_9)
|
||||
{
|
||||
_local_2++;
|
||||
};
|
||||
while ((_local_10 = (visibleChildren[_local_3] as Object3D).ml) < _local_9)
|
||||
{
|
||||
_local_3--;
|
||||
};
|
||||
if (_local_2 <= _local_3)
|
||||
{
|
||||
_local_4 = visibleChildren[_local_2];
|
||||
var _local_13:* = _local_2++;
|
||||
visibleChildren[_local_13] = visibleChildren[_local_3];
|
||||
var _local_14:* = _local_3--;
|
||||
visibleChildren[_local_14] = _local_4;
|
||||
};
|
||||
} while (_local_2 <= _local_3);
|
||||
if (_local_5 < _local_3)
|
||||
{
|
||||
_local_13 = _local_7++;
|
||||
sortingStack[_local_13] = _local_5;
|
||||
_local_14 = _local_7++;
|
||||
sortingStack[_local_14] = _local_3;
|
||||
};
|
||||
if (_local_2 < _local_6)
|
||||
{
|
||||
_local_13 = _local_7++;
|
||||
sortingStack[_local_13] = _local_2;
|
||||
_local_14 = _local_7++;
|
||||
sortingStack[_local_14] = _local_6;
|
||||
};
|
||||
};
|
||||
} else
|
||||
{
|
||||
_local_2 = 0;
|
||||
while (_local_2 < numVisibleChildren)
|
||||
{
|
||||
_local_4 = visibleChildren[_local_2];
|
||||
_local_11 = ((_local_4.md * _arg_1.viewSizeX) / _arg_1.focalLength);
|
||||
_local_12 = ((_local_4.mh * _arg_1.viewSizeY) / _arg_1.focalLength);
|
||||
_local_4.distance = (((_local_11 * _local_11) + (_local_12 * _local_12)) + (_local_4.ml * _local_4.ml));
|
||||
_local_2++;
|
||||
};
|
||||
while (_local_7 > 0)
|
||||
{
|
||||
_local_6 = sortingStack[--_local_7];
|
||||
_local_5 = sortingStack[--_local_7];
|
||||
_local_3 = _local_6;
|
||||
_local_2 = _local_5;
|
||||
_local_4 = visibleChildren[((_local_6 + _local_5) >> 1)];
|
||||
_local_9 = _local_4.distance;
|
||||
do
|
||||
{
|
||||
while ((_local_8 = (visibleChildren[_local_2] as Object3D).distance) > _local_9)
|
||||
{
|
||||
_local_2++;
|
||||
};
|
||||
while ((_local_10 = (visibleChildren[_local_3] as Object3D).distance) < _local_9)
|
||||
{
|
||||
_local_3--;
|
||||
};
|
||||
if (_local_2 <= _local_3)
|
||||
{
|
||||
_local_4 = visibleChildren[_local_2];
|
||||
_local_13 = _local_2++;
|
||||
visibleChildren[_local_13] = visibleChildren[_local_3];
|
||||
_local_14 = _local_3--;
|
||||
visibleChildren[_local_14] = _local_4;
|
||||
};
|
||||
} while (_local_2 <= _local_3);
|
||||
if (_local_5 < _local_3)
|
||||
{
|
||||
_local_13 = _local_7++;
|
||||
sortingStack[_local_13] = _local_5;
|
||||
_local_14 = _local_7++;
|
||||
sortingStack[_local_14] = _local_3;
|
||||
};
|
||||
if (_local_2 < _local_6)
|
||||
{
|
||||
_local_13 = _local_7++;
|
||||
sortingStack[_local_13] = _local_2;
|
||||
_local_14 = _local_7++;
|
||||
sortingStack[_local_14] = _local_6;
|
||||
};
|
||||
};
|
||||
};
|
||||
_local_2 = (numVisibleChildren - 1);
|
||||
while (_local_2 >= 0)
|
||||
{
|
||||
_local_4 = visibleChildren[_local_2];
|
||||
_local_4.concat(this);
|
||||
_local_4.draw(_arg_1);
|
||||
visibleChildren[_local_2] = null;
|
||||
_local_2--;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.containers
|
||||
4012
src/alternativa/engine3d/containers/KDContainer.as
Normal file
4012
src/alternativa/engine3d/containers/KDContainer.as
Normal file
File diff suppressed because it is too large
Load Diff
262
src/alternativa/engine3d/containers/LODContainer.as
Normal file
262
src/alternativa/engine3d/containers/LODContainer.as
Normal file
@@ -0,0 +1,262 @@
|
||||
package alternativa.engine3d.containers
|
||||
{
|
||||
import alternativa.engine3d.core.Object3DContainer;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import flash.geom.Vector3D;
|
||||
import flash.utils.Dictionary;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import alternativa.engine3d.core.RayIntersectionData;
|
||||
import __AS3__.vec.Vector;
|
||||
import alternativa.engine3d.core.Face;
|
||||
import alternativa.engine3d.core.Debug;
|
||||
import alternativa.engine3d.core.VG;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class LODContainer extends Object3DContainer
|
||||
{
|
||||
|
||||
|
||||
public function getChildDistance(_arg_1:Object3D):Number
|
||||
{
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new TypeError("Parameter child must be non-null."));
|
||||
};
|
||||
if (_arg_1._parent != this)
|
||||
{
|
||||
throw (new ArgumentError("The supplied Object3D must be a child of the caller."));
|
||||
};
|
||||
return (_arg_1.distance);
|
||||
}
|
||||
|
||||
public function setChildDistance(_arg_1:Object3D, _arg_2:Number):void
|
||||
{
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new TypeError("Parameter child must be non-null."));
|
||||
};
|
||||
if (_arg_1._parent != this)
|
||||
{
|
||||
throw (new ArgumentError("The supplied Object3D must be a child of the caller."));
|
||||
};
|
||||
_arg_1.distance = _arg_2;
|
||||
}
|
||||
|
||||
public function addLOD(_arg_1:Object3D, _arg_2:Number):Object3D
|
||||
{
|
||||
this.addChild(_arg_1);
|
||||
_arg_1.distance = _arg_2;
|
||||
return (_arg_1);
|
||||
}
|
||||
|
||||
override public function addChild(_arg_1:Object3D):Object3D
|
||||
{
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new TypeError("Parameter child must be non-null."));
|
||||
};
|
||||
if (_arg_1 == this)
|
||||
{
|
||||
throw (new ArgumentError("An object cannot be added as a child of itself."));
|
||||
};
|
||||
var _local_2:Object3DContainer = _parent;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (_local_2 == _arg_1)
|
||||
{
|
||||
throw (new ArgumentError("An object cannot be added as a child to one of it's children (or children's children, etc.)."));
|
||||
};
|
||||
_local_2 = _local_2._parent;
|
||||
};
|
||||
if (_arg_1._parent != this)
|
||||
{
|
||||
_arg_1.distance = 0;
|
||||
};
|
||||
if (_arg_1._parent != null)
|
||||
{
|
||||
_arg_1._parent.removeChild(_arg_1);
|
||||
};
|
||||
addToList(_arg_1);
|
||||
return (_arg_1);
|
||||
}
|
||||
|
||||
override public function addChildAt(_arg_1:Object3D, _arg_2:int):Object3D
|
||||
{
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new TypeError("Parameter child must be non-null."));
|
||||
};
|
||||
if (_arg_1 == this)
|
||||
{
|
||||
throw (new ArgumentError("An object cannot be added as a child of itself."));
|
||||
};
|
||||
if (_arg_2 < 0)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
var _local_3:Object3DContainer = _parent;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
if (_local_3 == _arg_1)
|
||||
{
|
||||
throw (new ArgumentError("An object cannot be added as a child to one of it's children (or children's children, etc.)."));
|
||||
};
|
||||
_local_3 = _local_3._parent;
|
||||
};
|
||||
var _local_4:Object3D = childrenList;
|
||||
var _local_5:int;
|
||||
while (_local_5 < _arg_2)
|
||||
{
|
||||
if (_local_4 == null)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
_local_4 = _local_4.next;
|
||||
_local_5++;
|
||||
};
|
||||
if (_arg_1._parent != this)
|
||||
{
|
||||
_arg_1.distance = 0;
|
||||
};
|
||||
if (_arg_1._parent != null)
|
||||
{
|
||||
_arg_1._parent.removeChild(_arg_1);
|
||||
};
|
||||
addToList(_arg_1, _local_4);
|
||||
return (_arg_1);
|
||||
}
|
||||
|
||||
override public function intersectRay(_arg_1:Vector3D, _arg_2:Vector3D, _arg_3:Dictionary=null, _arg_4:Camera3D=null):RayIntersectionData
|
||||
{
|
||||
if (((!(_arg_3 == null)) && (_arg_3[this])))
|
||||
{
|
||||
return (null);
|
||||
};
|
||||
if ((!(boundIntersectRay(_arg_1, _arg_2, boundMinX, boundMinY, boundMinZ, boundMaxX, boundMaxY, boundMaxZ))))
|
||||
{
|
||||
return (null);
|
||||
};
|
||||
var _local_5:Object3D = childrenList;
|
||||
_local_5.composeMatrix();
|
||||
_local_5.invertMatrix();
|
||||
var _local_6:Vector3D = new Vector3D();
|
||||
var _local_7:Vector3D = new Vector3D();
|
||||
_local_6.x = ((((_local_5.ma * _arg_1.x) + (_local_5.mb * _arg_1.y)) + (_local_5.mc * _arg_1.z)) + _local_5.md);
|
||||
_local_6.y = ((((_local_5.me * _arg_1.x) + (_local_5.mf * _arg_1.y)) + (_local_5.mg * _arg_1.z)) + _local_5.mh);
|
||||
_local_6.z = ((((_local_5.mi * _arg_1.x) + (_local_5.mj * _arg_1.y)) + (_local_5.mk * _arg_1.z)) + _local_5.ml);
|
||||
_local_7.x = (((_local_5.ma * _arg_2.x) + (_local_5.mb * _arg_2.y)) + (_local_5.mc * _arg_2.z));
|
||||
_local_7.y = (((_local_5.me * _arg_2.x) + (_local_5.mf * _arg_2.y)) + (_local_5.mg * _arg_2.z));
|
||||
_local_7.z = (((_local_5.mi * _arg_2.x) + (_local_5.mj * _arg_2.y)) + (_local_5.mk * _arg_2.z));
|
||||
return (_local_5.intersectRay(_local_6, _local_7, _arg_3, _arg_4));
|
||||
}
|
||||
|
||||
override alternativa3d function checkIntersection(_arg_1:Number, _arg_2:Number, _arg_3:Number, _arg_4:Number, _arg_5:Number, _arg_6:Number, _arg_7:Number, _arg_8:Dictionary):Boolean
|
||||
{
|
||||
var _local_10:Number;
|
||||
var _local_11:Number;
|
||||
var _local_12:Number;
|
||||
var _local_13:Number;
|
||||
var _local_14:Number;
|
||||
var _local_15:Number;
|
||||
var _local_9:Object3D = childrenList;
|
||||
if (((!(_arg_8 == null)) && (!(_arg_8[_local_9]))))
|
||||
{
|
||||
_local_9.composeMatrix();
|
||||
_local_9.invertMatrix();
|
||||
_local_10 = ((((_local_9.ma * _arg_1) + (_local_9.mb * _arg_2)) + (_local_9.mc * _arg_3)) + _local_9.md);
|
||||
_local_11 = ((((_local_9.me * _arg_1) + (_local_9.mf * _arg_2)) + (_local_9.mg * _arg_3)) + _local_9.mh);
|
||||
_local_12 = ((((_local_9.mi * _arg_1) + (_local_9.mj * _arg_2)) + (_local_9.mk * _arg_3)) + _local_9.ml);
|
||||
_local_13 = (((_local_9.ma * _arg_4) + (_local_9.mb * _arg_5)) + (_local_9.mc * _arg_6));
|
||||
_local_14 = (((_local_9.me * _arg_4) + (_local_9.mf * _arg_5)) + (_local_9.mg * _arg_6));
|
||||
_local_15 = (((_local_9.mi * _arg_4) + (_local_9.mj * _arg_5)) + (_local_9.mk * _arg_6));
|
||||
return ((boundCheckIntersection(_local_10, _local_11, _local_12, _local_13, _local_14, _local_15, _arg_7, _local_9.boundMinX, _local_9.boundMinY, _local_9.boundMinZ, _local_9.boundMaxX, _local_9.boundMaxY, _local_9.boundMaxZ)) && (_local_9.checkIntersection(_local_10, _local_11, _local_12, _local_13, _local_14, _local_15, _arg_7, _arg_8)));
|
||||
};
|
||||
return (false);
|
||||
}
|
||||
|
||||
override alternativa3d function collectPlanes(_arg_1:Vector3D, _arg_2:Vector3D, _arg_3:Vector3D, _arg_4:Vector3D, _arg_5:Vector3D, _arg_6:Vector.<Face>, _arg_7:Dictionary=null):void
|
||||
{
|
||||
if (((!(_arg_7 == null)) && (_arg_7[this])))
|
||||
{
|
||||
return;
|
||||
};
|
||||
var _local_8:Vector3D = calculateSphere(_arg_1, _arg_2, _arg_3, _arg_4, _arg_5);
|
||||
if ((!(boundIntersectSphere(_local_8, boundMinX, boundMinY, boundMinZ, boundMaxX, boundMaxY, boundMaxZ))))
|
||||
{
|
||||
return;
|
||||
};
|
||||
var _local_9:Object3D = childrenList;
|
||||
_local_9.composeAndAppend(this);
|
||||
_local_9.collectPlanes(_arg_1, _arg_2, _arg_3, _arg_4, _arg_5, _arg_6, _arg_7);
|
||||
}
|
||||
|
||||
override public function clone():Object3D
|
||||
{
|
||||
var _local_1:LODContainer = new LODContainer();
|
||||
_local_1.clonePropertiesFrom(this);
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
override alternativa3d function draw(_arg_1:Camera3D):void
|
||||
{
|
||||
var _local_3:int;
|
||||
var _local_2:Object3D = this.getLODObject(_arg_1);
|
||||
if (((!(_local_2 == null)) && (_local_2.visible)))
|
||||
{
|
||||
_local_2.composeAndAppend(this);
|
||||
if (_local_2.cullingInCamera(_arg_1, culling) >= 0)
|
||||
{
|
||||
if (((_arg_1.debug) && ((_local_3 = _arg_1.checkInDebug(this)) > 0)))
|
||||
{
|
||||
if ((_local_3 & Debug.BOUNDS))
|
||||
{
|
||||
Debug.drawBounds(_arg_1, this, boundMinX, boundMinY, boundMinZ, boundMaxX, boundMaxY, boundMaxZ);
|
||||
};
|
||||
};
|
||||
_local_2.draw(_arg_1);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
override alternativa3d function getVG(_arg_1:Camera3D):VG
|
||||
{
|
||||
var _local_2:Object3D = this.getLODObject(_arg_1);
|
||||
if (((!(_local_2 == null)) && (_local_2.visible)))
|
||||
{
|
||||
_local_2.composeAndAppend(this);
|
||||
if (_local_2.cullingInCamera(_arg_1, culling) >= 0)
|
||||
{
|
||||
_local_2.concat(this);
|
||||
return (_local_2.getVG(_arg_1));
|
||||
};
|
||||
};
|
||||
return (null);
|
||||
}
|
||||
|
||||
private function getLODObject(_arg_1:Camera3D):Object3D
|
||||
{
|
||||
var _local_6:Object3D;
|
||||
var _local_8:Number;
|
||||
var _local_2:Number = ((md * _arg_1.viewSizeX) / _arg_1.focalLength);
|
||||
var _local_3:Number = ((mh * _arg_1.viewSizeY) / _arg_1.focalLength);
|
||||
var _local_4:Number = Math.sqrt((((_local_2 * _local_2) + (_local_3 * _local_3)) + (ml * ml)));
|
||||
var _local_5:Number = 1E22;
|
||||
var _local_7:Object3D = childrenList;
|
||||
while (_local_7 != null)
|
||||
{
|
||||
_local_8 = (_local_7.distance - _local_4);
|
||||
if (((_local_8 > 0) && (_local_8 < _local_5)))
|
||||
{
|
||||
_local_5 = _local_8;
|
||||
_local_6 = _local_7;
|
||||
};
|
||||
_local_7 = _local_7.next;
|
||||
};
|
||||
return (_local_6);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.containers
|
||||
358
src/alternativa/engine3d/controllers/SimpleObjectController.as
Normal file
358
src/alternativa/engine3d/controllers/SimpleObjectController.as
Normal file
@@ -0,0 +1,358 @@
|
||||
package alternativa.engine3d.controllers
|
||||
{
|
||||
import flash.display.InteractiveObject;
|
||||
import alternativa.engine3d.core.Object3D;
|
||||
import flash.geom.Vector3D;
|
||||
import flash.geom.Point;
|
||||
import __AS3__.vec.Vector;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Matrix3D;
|
||||
import flash.utils.getTimer;
|
||||
import alternativa.engine3d.core.Camera3D;
|
||||
import flash.ui.Keyboard;
|
||||
import __AS3__.vec.*;
|
||||
|
||||
public class SimpleObjectController
|
||||
{
|
||||
|
||||
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";
|
||||
|
||||
public var speed:Number;
|
||||
public var speedMultiplier:Number;
|
||||
public var mouseSensitivity:Number;
|
||||
public var maxPitch:Number = 1E22;
|
||||
public var minPitch:Number = -1E22;
|
||||
private var eventSource:InteractiveObject;
|
||||
private var _object:Object3D;
|
||||
private var _up:Boolean;
|
||||
private var _down:Boolean;
|
||||
private var _forward:Boolean;
|
||||
private var _back:Boolean;
|
||||
private var _left:Boolean;
|
||||
private var _right:Boolean;
|
||||
private var _accelerate:Boolean;
|
||||
private var displacement:Vector3D = new Vector3D();
|
||||
private var mousePoint:Point = new Point();
|
||||
private var mouseLook:Boolean;
|
||||
private var objectTransform:Vector.<Vector3D>;
|
||||
private var time:int;
|
||||
private var actionBindings:Object = {};
|
||||
protected var keyBindings:Object = {};
|
||||
private var _vin:Vector.<Number> = new Vector.<Number>(3);
|
||||
private var _vout:Vector.<Number> = new Vector.<Number>(3);
|
||||
|
||||
public function SimpleObjectController(_arg_1:InteractiveObject, _arg_2:Object3D, _arg_3:Number, _arg_4:Number=3, _arg_5:Number=1)
|
||||
{
|
||||
this.eventSource = _arg_1;
|
||||
this.object = _arg_2;
|
||||
this.speed = _arg_3;
|
||||
this.speedMultiplier = _arg_4;
|
||||
this.mouseSensitivity = _arg_5;
|
||||
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_ACCELERATE] = this.accelerate;
|
||||
this.setDefaultBindings();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
public function enable():void
|
||||
{
|
||||
this.eventSource.addEventListener(KeyboardEvent.KEY_DOWN, this.onKey);
|
||||
this.eventSource.addEventListener(KeyboardEvent.KEY_UP, this.onKey);
|
||||
this.eventSource.addEventListener(MouseEvent.MOUSE_DOWN, this.onMouseDown);
|
||||
this.eventSource.addEventListener(MouseEvent.MOUSE_UP, this.onMouseUp);
|
||||
}
|
||||
|
||||
public function disable():void
|
||||
{
|
||||
this.eventSource.removeEventListener(KeyboardEvent.KEY_DOWN, this.onKey);
|
||||
this.eventSource.removeEventListener(KeyboardEvent.KEY_UP, this.onKey);
|
||||
this.eventSource.removeEventListener(MouseEvent.MOUSE_DOWN, this.onMouseDown);
|
||||
this.eventSource.removeEventListener(MouseEvent.MOUSE_UP, this.onMouseUp);
|
||||
this.stopMouseLook();
|
||||
}
|
||||
|
||||
private function onMouseDown(_arg_1:MouseEvent):void
|
||||
{
|
||||
this.startMouseLook();
|
||||
}
|
||||
|
||||
private function onMouseUp(_arg_1:MouseEvent):void
|
||||
{
|
||||
this.stopMouseLook();
|
||||
}
|
||||
|
||||
public function startMouseLook():void
|
||||
{
|
||||
this.mousePoint.x = this.eventSource.mouseX;
|
||||
this.mousePoint.y = this.eventSource.mouseY;
|
||||
this.mouseLook = true;
|
||||
}
|
||||
|
||||
public function stopMouseLook():void
|
||||
{
|
||||
this.mouseLook = false;
|
||||
}
|
||||
|
||||
private function onKey(_arg_1:KeyboardEvent):void
|
||||
{
|
||||
var _local_2:Function = this.keyBindings[_arg_1.keyCode];
|
||||
if (_local_2 != null)
|
||||
{
|
||||
_local_2.call(this, (_arg_1.type == KeyboardEvent.KEY_DOWN));
|
||||
};
|
||||
}
|
||||
|
||||
public function get object():Object3D
|
||||
{
|
||||
return (this._object);
|
||||
}
|
||||
|
||||
public function set object(_arg_1:Object3D):void
|
||||
{
|
||||
this._object = _arg_1;
|
||||
this.updateObjectTransform();
|
||||
}
|
||||
|
||||
public function updateObjectTransform():void
|
||||
{
|
||||
if (this._object != null)
|
||||
{
|
||||
this.objectTransform = this._object.matrix.decompose();
|
||||
};
|
||||
}
|
||||
|
||||
public function update():void
|
||||
{
|
||||
var _local_3:Number;
|
||||
var _local_4:Number;
|
||||
var _local_5:Vector3D;
|
||||
var _local_6:Number;
|
||||
var _local_7:Matrix3D;
|
||||
if (this._object == null)
|
||||
{
|
||||
return;
|
||||
};
|
||||
var _local_1:Number = this.time;
|
||||
this.time = getTimer();
|
||||
_local_1 = (0.001 * (this.time - _local_1));
|
||||
if (_local_1 > 0.1)
|
||||
{
|
||||
_local_1 = 0.1;
|
||||
};
|
||||
var _local_2:Boolean;
|
||||
if (this.mouseLook)
|
||||
{
|
||||
_local_3 = (this.eventSource.mouseX - this.mousePoint.x);
|
||||
_local_4 = (this.eventSource.mouseY - this.mousePoint.y);
|
||||
this.mousePoint.x = this.eventSource.mouseX;
|
||||
this.mousePoint.y = this.eventSource.mouseY;
|
||||
_local_5 = this.objectTransform[1];
|
||||
_local_5.x = (_local_5.x - (((_local_4 * Math.PI) / 180) * this.mouseSensitivity));
|
||||
if (_local_5.x > this.maxPitch)
|
||||
{
|
||||
_local_5.x = this.maxPitch;
|
||||
};
|
||||
if (_local_5.x < this.minPitch)
|
||||
{
|
||||
_local_5.x = this.minPitch;
|
||||
};
|
||||
_local_5.z = (_local_5.z - (((_local_3 * Math.PI) / 180) * this.mouseSensitivity));
|
||||
_local_2 = true;
|
||||
};
|
||||
this.displacement.x = ((this._right) ? 1 : ((this._left) ? -1 : 0));
|
||||
this.displacement.y = ((this._forward) ? 1 : ((this._back) ? -1 : 0));
|
||||
this.displacement.z = ((this._up) ? 1 : ((this._down) ? -1 : 0));
|
||||
if (this.displacement.lengthSquared > 0)
|
||||
{
|
||||
if ((this._object is Camera3D))
|
||||
{
|
||||
_local_6 = this.displacement.z;
|
||||
this.displacement.z = this.displacement.y;
|
||||
this.displacement.y = -(_local_6);
|
||||
};
|
||||
this.deltaTransformVector(this.displacement);
|
||||
if (this._accelerate)
|
||||
{
|
||||
this.displacement.scaleBy((((this.speedMultiplier * this.speed) * _local_1) / this.displacement.length));
|
||||
} else
|
||||
{
|
||||
this.displacement.scaleBy(((this.speed * _local_1) / this.displacement.length));
|
||||
};
|
||||
(this.objectTransform[0] as Vector3D).incrementBy(this.displacement);
|
||||
_local_2 = true;
|
||||
};
|
||||
if (_local_2)
|
||||
{
|
||||
_local_7 = new Matrix3D();
|
||||
_local_7.recompose(this.objectTransform);
|
||||
this._object.matrix = _local_7;
|
||||
};
|
||||
}
|
||||
|
||||
public function setObjectPos(_arg_1:Vector3D):void
|
||||
{
|
||||
var _local_2:Vector3D;
|
||||
if (this._object != null)
|
||||
{
|
||||
_local_2 = this.objectTransform[0];
|
||||
_local_2.x = _arg_1.x;
|
||||
_local_2.y = _arg_1.y;
|
||||
_local_2.z = _arg_1.z;
|
||||
};
|
||||
}
|
||||
|
||||
public function setObjectPosXYZ(_arg_1:Number, _arg_2:Number, _arg_3:Number):void
|
||||
{
|
||||
var _local_4:Vector3D;
|
||||
if (this._object != null)
|
||||
{
|
||||
_local_4 = this.objectTransform[0];
|
||||
_local_4.x = _arg_1;
|
||||
_local_4.y = _arg_2;
|
||||
_local_4.z = _arg_3;
|
||||
};
|
||||
}
|
||||
|
||||
public function lookAt(_arg_1:Vector3D):void
|
||||
{
|
||||
this.lookAtXYZ(_arg_1.x, _arg_1.y, _arg_1.z);
|
||||
}
|
||||
|
||||
public function lookAtXYZ(_arg_1:Number, _arg_2:Number, _arg_3:Number):void
|
||||
{
|
||||
if (this._object == null)
|
||||
{
|
||||
return;
|
||||
};
|
||||
var _local_4:Vector3D = this.objectTransform[0];
|
||||
var _local_5:Number = (_arg_1 - _local_4.x);
|
||||
var _local_6:Number = (_arg_2 - _local_4.y);
|
||||
var _local_7:Number = (_arg_3 - _local_4.z);
|
||||
_local_4 = this.objectTransform[1];
|
||||
_local_4.x = Math.atan2(_local_7, Math.sqrt(((_local_5 * _local_5) + (_local_6 * _local_6))));
|
||||
if ((this._object is Camera3D))
|
||||
{
|
||||
_local_4.x = (_local_4.x - (0.5 * Math.PI));
|
||||
};
|
||||
_local_4.y = 0;
|
||||
_local_4.z = -(Math.atan2(_local_5, _local_6));
|
||||
var _local_8:Matrix3D = this._object.matrix;
|
||||
_local_8.recompose(this.objectTransform);
|
||||
this._object.matrix = _local_8;
|
||||
}
|
||||
|
||||
private function deltaTransformVector(_arg_1:Vector3D):void
|
||||
{
|
||||
this._vin[0] = _arg_1.x;
|
||||
this._vin[1] = _arg_1.y;
|
||||
this._vin[2] = _arg_1.z;
|
||||
this._object.matrix.transformVectors(this._vin, this._vout);
|
||||
var _local_2:Vector3D = this.objectTransform[0];
|
||||
_arg_1.x = (this._vout[0] - _local_2.x);
|
||||
_arg_1.y = (this._vout[1] - _local_2.y);
|
||||
_arg_1.z = (this._vout[2] - _local_2.z);
|
||||
}
|
||||
|
||||
public function moveForward(_arg_1:Boolean):void
|
||||
{
|
||||
this._forward = _arg_1;
|
||||
}
|
||||
|
||||
public function moveBack(_arg_1:Boolean):void
|
||||
{
|
||||
this._back = _arg_1;
|
||||
}
|
||||
|
||||
public function moveLeft(_arg_1:Boolean):void
|
||||
{
|
||||
this._left = _arg_1;
|
||||
}
|
||||
|
||||
public function moveRight(_arg_1:Boolean):void
|
||||
{
|
||||
this._right = _arg_1;
|
||||
}
|
||||
|
||||
public function moveUp(_arg_1:Boolean):void
|
||||
{
|
||||
this._up = _arg_1;
|
||||
}
|
||||
|
||||
public function moveDown(_arg_1:Boolean):void
|
||||
{
|
||||
this._down = _arg_1;
|
||||
}
|
||||
|
||||
public function accelerate(_arg_1:Boolean):void
|
||||
{
|
||||
this._accelerate = _arg_1;
|
||||
}
|
||||
|
||||
public function bindKey(_arg_1:uint, _arg_2:String):void
|
||||
{
|
||||
var _local_3:Function = this.actionBindings[_arg_2];
|
||||
if (_local_3 != null)
|
||||
{
|
||||
this.keyBindings[_arg_1] = _local_3;
|
||||
};
|
||||
}
|
||||
|
||||
public function bindKeys(_arg_1:Array):void
|
||||
{
|
||||
var _local_2:int;
|
||||
while (_local_2 < _arg_1.length)
|
||||
{
|
||||
this.bindKey(_arg_1[_local_2], _arg_1[(_local_2 + 1)]);
|
||||
_local_2 = (_local_2 + 2);
|
||||
};
|
||||
}
|
||||
|
||||
public function unbindKey(_arg_1:uint):void
|
||||
{
|
||||
delete this.keyBindings[_arg_1];
|
||||
}
|
||||
|
||||
public function unbindAll():void
|
||||
{
|
||||
var _local_1:String;
|
||||
for (_local_1 in this.keyBindings)
|
||||
{
|
||||
delete this.keyBindings[_local_1];
|
||||
};
|
||||
}
|
||||
|
||||
public function setDefaultBindings():void
|
||||
{
|
||||
this.bindKey(87, ACTION_FORWARD);
|
||||
this.bindKey(83, ACTION_BACK);
|
||||
this.bindKey(65, ACTION_LEFT);
|
||||
this.bindKey(68, ACTION_RIGHT);
|
||||
this.bindKey(69, ACTION_UP);
|
||||
this.bindKey(67, ACTION_DOWN);
|
||||
this.bindKey(Keyboard.SHIFT, ACTION_ACCELERATE);
|
||||
this.bindKey(Keyboard.UP, ACTION_FORWARD);
|
||||
this.bindKey(Keyboard.DOWN, ACTION_BACK);
|
||||
this.bindKey(Keyboard.LEFT, ACTION_LEFT);
|
||||
this.bindKey(Keyboard.RIGHT, ACTION_RIGHT);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.controllers
|
||||
103
src/alternativa/engine3d/core/BoundBox.as
Normal file
103
src/alternativa/engine3d/core/BoundBox.as
Normal file
@@ -0,0 +1,103 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
public class BoundBox
|
||||
{
|
||||
|
||||
|
||||
public var minX:Number = 1.7976931348623157E308;
|
||||
|
||||
public var minY:Number = 1.7976931348623157E308;
|
||||
|
||||
public var minZ:Number = 1.7976931348623157E308;
|
||||
|
||||
public var maxX:Number;
|
||||
|
||||
public var maxY:Number;
|
||||
|
||||
public var maxZ:Number;
|
||||
|
||||
public function BoundBox()
|
||||
{
|
||||
this.maxX = -Number.MAX_VALUE;
|
||||
this.maxY = -Number.MAX_VALUE;
|
||||
this.maxZ = -Number.MAX_VALUE;
|
||||
super();
|
||||
}
|
||||
|
||||
public function setSize(param1:Number, param2:Number, param3:Number, param4:Number, param5:Number, param6:Number) : void
|
||||
{
|
||||
this.minX = param1;
|
||||
this.minY = param2;
|
||||
this.minZ = param3;
|
||||
this.maxX = param4;
|
||||
this.maxY = param5;
|
||||
this.maxZ = param6;
|
||||
}
|
||||
|
||||
public function clone() : BoundBox
|
||||
{
|
||||
var _loc1_:BoundBox = new BoundBox();
|
||||
_loc1_.copyFrom(this);
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function infinity() : void
|
||||
{
|
||||
this.minX = this.minY = this.minZ = Number.MAX_VALUE;
|
||||
this.maxX = this.maxY = this.maxZ = -Number.MAX_VALUE;
|
||||
}
|
||||
|
||||
public function toString() : String
|
||||
{
|
||||
return "BoundBox [" + this.minX.toFixed(2) + ", " + this.minY.toFixed(2) + ", " + this.minZ.toFixed(2) + " - " + this.maxX.toFixed(2) + ", " + this.maxY.toFixed(2) + ", " + this.maxZ.toFixed(2) + "]";
|
||||
}
|
||||
|
||||
public function addBoundBox(param1:BoundBox) : void
|
||||
{
|
||||
this.minX = param1.minX < this.minX ? Number(param1.minX) : Number(this.minX);
|
||||
this.minY = param1.minY < this.minY ? Number(param1.minY) : Number(this.minY);
|
||||
this.minZ = param1.minZ < this.minZ ? Number(param1.minZ) : Number(this.minZ);
|
||||
this.maxX = param1.maxX > this.maxX ? Number(param1.maxX) : Number(this.maxX);
|
||||
this.maxY = param1.maxY > this.maxY ? Number(param1.maxY) : Number(this.maxY);
|
||||
this.maxZ = param1.maxZ > this.maxZ ? Number(param1.maxZ) : Number(this.maxZ);
|
||||
}
|
||||
|
||||
public function addPoint(param1:Number, param2:Number, param3:Number) : void
|
||||
{
|
||||
if(param1 < this.minX)
|
||||
{
|
||||
this.minX = param1;
|
||||
}
|
||||
if(param1 > this.maxX)
|
||||
{
|
||||
this.maxX = param1;
|
||||
}
|
||||
if(param2 < this.minY)
|
||||
{
|
||||
this.minY = param2;
|
||||
}
|
||||
if(param2 > this.maxY)
|
||||
{
|
||||
this.maxY = param2;
|
||||
}
|
||||
if(param3 < this.minZ)
|
||||
{
|
||||
this.minZ = param3;
|
||||
}
|
||||
if(param3 > this.maxZ)
|
||||
{
|
||||
this.maxZ = param3;
|
||||
}
|
||||
}
|
||||
|
||||
public function copyFrom(param1:BoundBox) : void
|
||||
{
|
||||
this.minX = param1.minX;
|
||||
this.minY = param1.minY;
|
||||
this.minZ = param1.minZ;
|
||||
this.maxX = param1.maxX;
|
||||
this.maxY = param1.maxY;
|
||||
this.maxZ = param1.maxZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
2975
src/alternativa/engine3d/core/Camera3D.as
Normal file
2975
src/alternativa/engine3d/core/Camera3D.as
Normal file
File diff suppressed because it is too large
Load Diff
14
src/alternativa/engine3d/core/Canvas.as
Normal file
14
src/alternativa/engine3d/core/Canvas.as
Normal file
@@ -0,0 +1,14 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import flash.display.Sprite;
|
||||
|
||||
public class Canvas extends Sprite
|
||||
{
|
||||
|
||||
|
||||
public function Canvas()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
18
src/alternativa/engine3d/core/Clipping.as
Normal file
18
src/alternativa/engine3d/core/Clipping.as
Normal file
@@ -0,0 +1,18 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
public class Clipping
|
||||
{
|
||||
|
||||
public static const BOUND_CULLING:int = 0;
|
||||
|
||||
public static const FACE_CULLING:int = 1;
|
||||
|
||||
public static const FACE_CLIPPING:int = 2;
|
||||
|
||||
|
||||
public function Clipping()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
257
src/alternativa/engine3d/core/Debug.as
Normal file
257
src/alternativa/engine3d/core/Debug.as
Normal file
@@ -0,0 +1,257 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import flash.display.Sprite;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa.engine3d.alternativa3d;
|
||||
|
||||
public class Debug
|
||||
{
|
||||
|
||||
public static const BOUNDS:int = 8;
|
||||
public static const EDGES:int = 16;
|
||||
public static const NODES:int = 128;
|
||||
public static const LIGHTS:int = 0x0100;
|
||||
public static const BONES:int = 0x0200;
|
||||
private static const boundVertexList:Vertex = Vertex.createList(8);
|
||||
private static const nodeVertexList:Vertex = Vertex.createList(4);
|
||||
|
||||
|
||||
alternativa3d static function drawEdges(_arg_1:Camera3D, _arg_2:Face, _arg_3:int):void
|
||||
{
|
||||
var _local_6:Number;
|
||||
var _local_9:Wrapper;
|
||||
var _local_10:Vertex;
|
||||
var _local_11:Number;
|
||||
var _local_12:Number;
|
||||
var _local_4:Number = _arg_1.viewSizeX;
|
||||
var _local_5:Number = _arg_1.viewSizeY;
|
||||
var _local_7:Sprite = _arg_1.view.canvas;
|
||||
_local_7.graphics.lineStyle(0, _arg_3);
|
||||
var _local_8:Face = _arg_2;
|
||||
while (_local_8 != null)
|
||||
{
|
||||
_local_9 = _local_8.wrapper;
|
||||
_local_10 = _local_9.vertex;
|
||||
_local_6 = (1 / _local_10.cameraZ);
|
||||
_local_11 = ((_local_10.cameraX * _local_4) * _local_6);
|
||||
_local_12 = ((_local_10.cameraY * _local_5) * _local_6);
|
||||
_local_7.graphics.moveTo(_local_11, _local_12);
|
||||
_local_9 = _local_9.next;
|
||||
while (_local_9 != null)
|
||||
{
|
||||
_local_10 = _local_9.vertex;
|
||||
_local_6 = (1 / _local_10.cameraZ);
|
||||
_local_7.graphics.lineTo(((_local_10.cameraX * _local_4) * _local_6), ((_local_10.cameraY * _local_5) * _local_6));
|
||||
_local_9 = _local_9.next;
|
||||
};
|
||||
_local_7.graphics.lineTo(_local_11, _local_12);
|
||||
_local_8 = _local_8.processNext;
|
||||
};
|
||||
}
|
||||
|
||||
alternativa3d static function drawBounds(_arg_1:Camera3D, _arg_2:Object3D, _arg_3:Number, _arg_4:Number, _arg_5:Number, _arg_6:Number, _arg_7:Number, _arg_8:Number, _arg_9:int=-1, _arg_10:Number=1):void
|
||||
{
|
||||
var _local_11:Vertex;
|
||||
var _local_23:Number;
|
||||
var _local_12:Vertex = boundVertexList;
|
||||
_local_12.x = _arg_3;
|
||||
_local_12.y = _arg_4;
|
||||
_local_12.z = _arg_5;
|
||||
var _local_13:Vertex = _local_12.next;
|
||||
_local_13.x = _arg_6;
|
||||
_local_13.y = _arg_4;
|
||||
_local_13.z = _arg_5;
|
||||
var _local_14:Vertex = _local_13.next;
|
||||
_local_14.x = _arg_3;
|
||||
_local_14.y = _arg_7;
|
||||
_local_14.z = _arg_5;
|
||||
var _local_15:Vertex = _local_14.next;
|
||||
_local_15.x = _arg_6;
|
||||
_local_15.y = _arg_7;
|
||||
_local_15.z = _arg_5;
|
||||
var _local_16:Vertex = _local_15.next;
|
||||
_local_16.x = _arg_3;
|
||||
_local_16.y = _arg_4;
|
||||
_local_16.z = _arg_8;
|
||||
var _local_17:Vertex = _local_16.next;
|
||||
_local_17.x = _arg_6;
|
||||
_local_17.y = _arg_4;
|
||||
_local_17.z = _arg_8;
|
||||
var _local_18:Vertex = _local_17.next;
|
||||
_local_18.x = _arg_3;
|
||||
_local_18.y = _arg_7;
|
||||
_local_18.z = _arg_8;
|
||||
var _local_19:Vertex = _local_18.next;
|
||||
_local_19.x = _arg_6;
|
||||
_local_19.y = _arg_7;
|
||||
_local_19.z = _arg_8;
|
||||
_local_11 = _local_12;
|
||||
while (_local_11 != null)
|
||||
{
|
||||
_local_11.cameraX = ((((_arg_2.ma * _local_11.x) + (_arg_2.mb * _local_11.y)) + (_arg_2.mc * _local_11.z)) + _arg_2.md);
|
||||
_local_11.cameraY = ((((_arg_2.me * _local_11.x) + (_arg_2.mf * _local_11.y)) + (_arg_2.mg * _local_11.z)) + _arg_2.mh);
|
||||
_local_11.cameraZ = ((((_arg_2.mi * _local_11.x) + (_arg_2.mj * _local_11.y)) + (_arg_2.mk * _local_11.z)) + _arg_2.ml);
|
||||
if (_local_11.cameraZ <= 0)
|
||||
{
|
||||
return;
|
||||
};
|
||||
_local_11 = _local_11.next;
|
||||
};
|
||||
var _local_20:Number = _arg_1.viewSizeX;
|
||||
var _local_21:Number = _arg_1.viewSizeY;
|
||||
_local_11 = _local_12;
|
||||
while (_local_11 != null)
|
||||
{
|
||||
_local_23 = (1 / _local_11.cameraZ);
|
||||
_local_11.cameraX = ((_local_11.cameraX * _local_20) * _local_23);
|
||||
_local_11.cameraY = ((_local_11.cameraY * _local_21) * _local_23);
|
||||
_local_11 = _local_11.next;
|
||||
};
|
||||
var _local_22:Sprite = _arg_1.view.canvas;
|
||||
_local_22.graphics.lineStyle(0, ((_arg_9 < 0) ? ((_arg_2.culling > 0) ? 0xFFFF00 : 0xFF00) : _arg_9), _arg_10);
|
||||
_local_22.graphics.moveTo(_local_12.cameraX, _local_12.cameraY);
|
||||
_local_22.graphics.lineTo(_local_13.cameraX, _local_13.cameraY);
|
||||
_local_22.graphics.lineTo(_local_15.cameraX, _local_15.cameraY);
|
||||
_local_22.graphics.lineTo(_local_14.cameraX, _local_14.cameraY);
|
||||
_local_22.graphics.lineTo(_local_12.cameraX, _local_12.cameraY);
|
||||
_local_22.graphics.moveTo(_local_16.cameraX, _local_16.cameraY);
|
||||
_local_22.graphics.lineTo(_local_17.cameraX, _local_17.cameraY);
|
||||
_local_22.graphics.lineTo(_local_19.cameraX, _local_19.cameraY);
|
||||
_local_22.graphics.lineTo(_local_18.cameraX, _local_18.cameraY);
|
||||
_local_22.graphics.lineTo(_local_16.cameraX, _local_16.cameraY);
|
||||
_local_22.graphics.moveTo(_local_12.cameraX, _local_12.cameraY);
|
||||
_local_22.graphics.lineTo(_local_16.cameraX, _local_16.cameraY);
|
||||
_local_22.graphics.moveTo(_local_13.cameraX, _local_13.cameraY);
|
||||
_local_22.graphics.lineTo(_local_17.cameraX, _local_17.cameraY);
|
||||
_local_22.graphics.moveTo(_local_15.cameraX, _local_15.cameraY);
|
||||
_local_22.graphics.lineTo(_local_19.cameraX, _local_19.cameraY);
|
||||
_local_22.graphics.moveTo(_local_14.cameraX, _local_14.cameraY);
|
||||
_local_22.graphics.lineTo(_local_18.cameraX, _local_18.cameraY);
|
||||
}
|
||||
|
||||
alternativa3d static function drawKDNode(_arg_1:Camera3D, _arg_2:Object3D, _arg_3:int, _arg_4:Number, _arg_5:Number, _arg_6:Number, _arg_7:Number, _arg_8:Number, _arg_9:Number, _arg_10:Number, _arg_11:Number):void
|
||||
{
|
||||
var _local_12:Vertex;
|
||||
var _local_20:Number;
|
||||
var _local_13:Vertex = nodeVertexList;
|
||||
var _local_14:Vertex = _local_13.next;
|
||||
var _local_15:Vertex = _local_14.next;
|
||||
var _local_16:Vertex = _local_15.next;
|
||||
if (_arg_3 == 0)
|
||||
{
|
||||
_local_13.x = _arg_4;
|
||||
_local_13.y = _arg_6;
|
||||
_local_13.z = _arg_10;
|
||||
_local_14.x = _arg_4;
|
||||
_local_14.y = _arg_9;
|
||||
_local_14.z = _arg_10;
|
||||
_local_15.x = _arg_4;
|
||||
_local_15.y = _arg_9;
|
||||
_local_15.z = _arg_7;
|
||||
_local_16.x = _arg_4;
|
||||
_local_16.y = _arg_6;
|
||||
_local_16.z = _arg_7;
|
||||
} else
|
||||
{
|
||||
if (_arg_3 == 1)
|
||||
{
|
||||
_local_13.x = _arg_8;
|
||||
_local_13.y = _arg_4;
|
||||
_local_13.z = _arg_10;
|
||||
_local_14.x = _arg_5;
|
||||
_local_14.y = _arg_4;
|
||||
_local_14.z = _arg_10;
|
||||
_local_15.x = _arg_5;
|
||||
_local_15.y = _arg_4;
|
||||
_local_15.z = _arg_7;
|
||||
_local_16.x = _arg_8;
|
||||
_local_16.y = _arg_4;
|
||||
_local_16.z = _arg_7;
|
||||
} else
|
||||
{
|
||||
_local_13.x = _arg_5;
|
||||
_local_13.y = _arg_6;
|
||||
_local_13.z = _arg_4;
|
||||
_local_14.x = _arg_8;
|
||||
_local_14.y = _arg_6;
|
||||
_local_14.z = _arg_4;
|
||||
_local_15.x = _arg_8;
|
||||
_local_15.y = _arg_9;
|
||||
_local_15.z = _arg_4;
|
||||
_local_16.x = _arg_5;
|
||||
_local_16.y = _arg_9;
|
||||
_local_16.z = _arg_4;
|
||||
};
|
||||
};
|
||||
_local_12 = _local_13;
|
||||
while (_local_12 != null)
|
||||
{
|
||||
_local_12.cameraX = ((((_arg_2.ma * _local_12.x) + (_arg_2.mb * _local_12.y)) + (_arg_2.mc * _local_12.z)) + _arg_2.md);
|
||||
_local_12.cameraY = ((((_arg_2.me * _local_12.x) + (_arg_2.mf * _local_12.y)) + (_arg_2.mg * _local_12.z)) + _arg_2.mh);
|
||||
_local_12.cameraZ = ((((_arg_2.mi * _local_12.x) + (_arg_2.mj * _local_12.y)) + (_arg_2.mk * _local_12.z)) + _arg_2.ml);
|
||||
if (_local_12.cameraZ <= 0)
|
||||
{
|
||||
return;
|
||||
};
|
||||
_local_12 = _local_12.next;
|
||||
};
|
||||
var _local_17:Number = _arg_1.viewSizeX;
|
||||
var _local_18:Number = _arg_1.viewSizeY;
|
||||
_local_12 = _local_13;
|
||||
while (_local_12 != null)
|
||||
{
|
||||
_local_20 = (1 / _local_12.cameraZ);
|
||||
_local_12.cameraX = ((_local_12.cameraX * _local_17) * _local_20);
|
||||
_local_12.cameraY = ((_local_12.cameraY * _local_18) * _local_20);
|
||||
_local_12 = _local_12.next;
|
||||
};
|
||||
var _local_19:Sprite = _arg_1.view.canvas;
|
||||
_local_19.graphics.lineStyle(0, ((_arg_3 == 0) ? 0xFF0000 : ((_arg_3 == 1) ? 0xFF00 : 0xFF)), _arg_11);
|
||||
_local_19.graphics.moveTo(_local_13.cameraX, _local_13.cameraY);
|
||||
_local_19.graphics.lineTo(_local_14.cameraX, _local_14.cameraY);
|
||||
_local_19.graphics.lineTo(_local_15.cameraX, _local_15.cameraY);
|
||||
_local_19.graphics.lineTo(_local_16.cameraX, _local_16.cameraY);
|
||||
_local_19.graphics.lineTo(_local_13.cameraX, _local_13.cameraY);
|
||||
}
|
||||
|
||||
alternativa3d static function drawBone(_arg_1:Camera3D, _arg_2:Number, _arg_3:Number, _arg_4:Number, _arg_5:Number, _arg_6:Number, _arg_7:int):void
|
||||
{
|
||||
var _local_11:Number;
|
||||
var _local_12:Number;
|
||||
var _local_13:Number;
|
||||
var _local_14:Number;
|
||||
var _local_15:Sprite;
|
||||
var _local_8:Number = (_arg_4 - _arg_2);
|
||||
var _local_9:Number = (_arg_5 - _arg_3);
|
||||
var _local_10:Number = Math.sqrt(((_local_8 * _local_8) + (_local_9 * _local_9)));
|
||||
if (_local_10 > 0.001)
|
||||
{
|
||||
_local_8 = (_local_8 / _local_10);
|
||||
_local_9 = (_local_9 / _local_10);
|
||||
_local_11 = (_local_9 * _arg_6);
|
||||
_local_12 = (-(_local_8) * _arg_6);
|
||||
_local_13 = (-(_local_9) * _arg_6);
|
||||
_local_14 = (_local_8 * _arg_6);
|
||||
if (_local_10 > (_arg_6 * 2))
|
||||
{
|
||||
_local_10 = _arg_6;
|
||||
} else
|
||||
{
|
||||
_local_10 = (_local_10 / 2);
|
||||
};
|
||||
_local_15 = _arg_1.view.canvas;
|
||||
_local_15.graphics.lineStyle(1, _arg_7);
|
||||
_local_15.graphics.beginFill(_arg_7, 0.6);
|
||||
_local_15.graphics.moveTo(_arg_2, _arg_3);
|
||||
_local_15.graphics.lineTo(((_arg_2 + (_local_8 * _local_10)) + _local_11), ((_arg_3 + (_local_9 * _local_10)) + _local_12));
|
||||
_local_15.graphics.lineTo(_arg_4, _arg_5);
|
||||
_local_15.graphics.lineTo(((_arg_2 + (_local_8 * _local_10)) + _local_13), ((_arg_3 + (_local_9 * _local_10)) + _local_14));
|
||||
_local_15.graphics.lineTo(_arg_2, _arg_3);
|
||||
_local_15.graphics.endFill();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
770
src/alternativa/engine3d/core/DepthRenderer.as
Normal file
770
src/alternativa/engine3d/core/DepthRenderer.as
Normal file
@@ -0,0 +1,770 @@
|
||||
package alternativa.engine3d.core{
|
||||
import __AS3__.vec.Vector;
|
||||
import alternativa.gfx.core.ProgramResource;
|
||||
import alternativa.gfx.core.VertexBufferResource;
|
||||
import alternativa.gfx.core.IndexBufferResource;
|
||||
import alternativa.gfx.core.RenderTargetTextureResource;
|
||||
import flash.geom.Rectangle;
|
||||
import alternativa.gfx.core.BitmapTextureResource;
|
||||
import flash.display.BitmapData;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.objects.BSP;
|
||||
import alternativa.engine3d.lights.OmniLight;
|
||||
import alternativa.engine3d.lights.SpotLight;
|
||||
import alternativa.engine3d.lights.TubeLight;
|
||||
import alternativa.gfx.core.Device;
|
||||
import flash.display3D.Context3DProgramType;
|
||||
import flash.display3D.Context3DVertexBufferFormat;
|
||||
import flash.display3D.Context3DBlendFactor;
|
||||
import flash.utils.ByteArray;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class DepthRenderer {
|
||||
|
||||
private static const limit2const:int = 62;
|
||||
private static const limit5const:int = 24;
|
||||
|
||||
private var depthPrograms:Array = new Array();
|
||||
private var correction:Vector.<Number> = Vector.<Number>([0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0.5]);
|
||||
private var depthFragment:Vector.<Number> = Vector.<Number>([(1 / 0xFF), 0, 0, 1, 0.5, 0.5, 0, 1]);
|
||||
private var alphaTestConst:Vector.<Number> = Vector.<Number>([0, 0, 0, 1]);
|
||||
private var ssaoProgram:ProgramResource;
|
||||
private var ssaoVertexBuffer:VertexBufferResource = new VertexBufferResource(Vector.<Number>([-1, 1, 0, 0, 0, -1, -1, 0, 0, 1, 1, -1, 0, 1, 1, 1, 1, 0, 1, 0]), 5);
|
||||
private var ssaoIndexBuffer:IndexBufferResource = new IndexBufferResource(Vector.<uint>([0, 1, 3, 2, 3, 1]));
|
||||
private var ssaoVertex:Vector.<Number> = Vector.<Number>([0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1]);
|
||||
private var ssaoFragment:Vector.<Number> = Vector.<Number>([0, 0, 0, (Math.PI * 2), 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, (Math.PI * 2), (Math.PI * 2)]);
|
||||
private var blurProgram:ProgramResource;
|
||||
private var blurFragment:Vector.<Number> = Vector.<Number>([0, 0, 0, 1, 0, 0, 0, 1]);
|
||||
private var omniProgram:ProgramResource;
|
||||
private var spotProgram:ProgramResource;
|
||||
private var tubeProgram:ProgramResource;
|
||||
private var lightConst:Vector.<Number> = new Vector.<Number>();
|
||||
private var lightVertexBuffer:VertexBufferResource;
|
||||
private var lightIndexBuffer:IndexBufferResource;
|
||||
alternativa3d var depthBuffer:RenderTargetTextureResource;
|
||||
alternativa3d var lightBuffer:RenderTargetTextureResource;
|
||||
private var temporaryBuffer:RenderTargetTextureResource;
|
||||
private var scissor:Rectangle = new Rectangle();
|
||||
private var table:BitmapTextureResource;
|
||||
private var noise:BitmapTextureResource;
|
||||
private var bias:Number = 0.1;
|
||||
private var tableSize:int = 128;
|
||||
private var noiseSize:int = 4;
|
||||
private var blurSamples:int = 16;
|
||||
private var intensity:Number = 2.5;
|
||||
private var noiseRandom:Number = 0.2;
|
||||
private var samples:int = 6;
|
||||
private var noiseAngle:Number = ((Math.PI * 2) / samples);
|
||||
alternativa3d var correctionX:Number;
|
||||
alternativa3d var correctionY:Number;
|
||||
|
||||
public function DepthRenderer(){
|
||||
var _local_1:int;
|
||||
var _local_2:int;
|
||||
var _local_11:int;
|
||||
var _local_12:int;
|
||||
var _local_13:int;
|
||||
var _local_14:int;
|
||||
var _local_15:int;
|
||||
var _local_16:int;
|
||||
var _local_17:int;
|
||||
var _local_18:int;
|
||||
var _local_19:int;
|
||||
var _local_20:int;
|
||||
var _local_21:Number;
|
||||
var _local_22:Number;
|
||||
var _local_23:Number;
|
||||
var _local_24:Number;
|
||||
var _local_25:int;
|
||||
var _local_26:int;
|
||||
var _local_27:int;
|
||||
super();
|
||||
var _local_3:int;
|
||||
var _local_4:int;
|
||||
var _local_5:Vector.<Number> = new Vector.<Number>();
|
||||
var _local_6:Vector.<uint> = new Vector.<uint>();
|
||||
_local_1 = 0;
|
||||
while (_local_1 < limit2const)
|
||||
{
|
||||
_local_11 = (4 + (_local_1 * 2));
|
||||
_local_12 = (4 + (_local_1 * 5));
|
||||
_local_13 = (_local_1 * 8);
|
||||
_local_5[_local_3] = -1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = 1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = -1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_11;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_12;
|
||||
_local_3++;
|
||||
_local_14 = (_local_13 + 1);
|
||||
_local_5[_local_3] = 1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = 1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = -1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_11;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_12;
|
||||
_local_3++;
|
||||
_local_15 = (_local_14 + 1);
|
||||
_local_5[_local_3] = 1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = 1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = 1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_11;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_12;
|
||||
_local_3++;
|
||||
_local_16 = (_local_15 + 1);
|
||||
_local_5[_local_3] = -1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = 1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = 1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_11;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_12;
|
||||
_local_3++;
|
||||
_local_17 = (_local_16 + 1);
|
||||
_local_5[_local_3] = -1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = -1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = -1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_11;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_12;
|
||||
_local_3++;
|
||||
_local_18 = (_local_17 + 1);
|
||||
_local_5[_local_3] = 1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = -1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = -1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_11;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_12;
|
||||
_local_3++;
|
||||
_local_19 = (_local_18 + 1);
|
||||
_local_5[_local_3] = 1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = -1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = 1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_11;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_12;
|
||||
_local_3++;
|
||||
_local_20 = (_local_19 + 1);
|
||||
_local_5[_local_3] = -1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = -1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = 1;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_11;
|
||||
_local_3++;
|
||||
_local_5[_local_3] = _local_12;
|
||||
_local_3++;
|
||||
_local_6[_local_4] = _local_13;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_17;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_14;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_14;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_17;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_18;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_14;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_18;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_19;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_14;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_19;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_15;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_17;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_19;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_18;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_17;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_20;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_19;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_15;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_19;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_20;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_15;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_20;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_16;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_13;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_16;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_20;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_13;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_20;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_17;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_13;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_14;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_15;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_13;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_15;
|
||||
_local_4++;
|
||||
_local_6[_local_4] = _local_16;
|
||||
_local_4++;
|
||||
_local_1++;
|
||||
};
|
||||
this.lightVertexBuffer = new VertexBufferResource(_local_5, 5);
|
||||
this.lightIndexBuffer = new IndexBufferResource(_local_6);
|
||||
var _local_7:Vector.<uint> = new Vector.<uint>();
|
||||
var _local_8:int;
|
||||
var _local_9:Number = (Math.PI * 2);
|
||||
var _local_10:int = (this.tableSize - 1);
|
||||
_local_1 = 0;
|
||||
while (_local_1 < this.tableSize)
|
||||
{
|
||||
_local_21 = (((_local_1 / _local_10) - 0.5) * 2);
|
||||
_local_2 = 0;
|
||||
while (_local_2 < this.tableSize)
|
||||
{
|
||||
_local_22 = (((_local_2 / _local_10) - 0.5) * 2);
|
||||
_local_23 = Math.atan2(_local_21, _local_22);
|
||||
if (_local_23 < 0)
|
||||
{
|
||||
_local_23 = (_local_23 + _local_9);
|
||||
};
|
||||
_local_7[_local_8] = Math.round(((0xFF * _local_23) / _local_9));
|
||||
_local_8++;
|
||||
_local_2++;
|
||||
};
|
||||
_local_1++;
|
||||
};
|
||||
this.table = new BitmapTextureResource(new BitmapData(this.tableSize, this.tableSize, false, 0), false);
|
||||
this.table.bitmapData.setVector(this.table.bitmapData.rect, _local_7);
|
||||
_local_7 = new Vector.<uint>();
|
||||
_local_8 = 0;
|
||||
_local_1 = 0;
|
||||
while (_local_1 < this.noiseSize)
|
||||
{
|
||||
_local_2 = 0;
|
||||
while (_local_2 < this.noiseSize)
|
||||
{
|
||||
_local_24 = (Math.random() * this.noiseAngle);
|
||||
_local_25 = (Math.sin(_local_24) * 0xFF);
|
||||
_local_26 = (Math.cos(_local_24) * 0xFF);
|
||||
_local_27 = ((this.noiseRandom + (Math.random() * (1 - this.noiseRandom))) * 0xFF);
|
||||
_local_7[_local_8] = (((_local_25 << 16) | (_local_26 << 8)) | _local_27);
|
||||
_local_8++;
|
||||
_local_2++;
|
||||
};
|
||||
_local_1++;
|
||||
};
|
||||
this.noise = new BitmapTextureResource(new BitmapData(this.noiseSize, this.noiseSize, false, 0), false);
|
||||
this.noise.bitmapData.setVector(this.noise.bitmapData.rect, _local_7);
|
||||
this.depthBuffer = new RenderTargetTextureResource(1, 1);
|
||||
this.temporaryBuffer = new RenderTargetTextureResource(1, 1);
|
||||
this.lightBuffer = new RenderTargetTextureResource(1, 1);
|
||||
}
|
||||
|
||||
alternativa3d function render(_arg_1:Camera3D, _arg_2:Number, _arg_3:Number, _arg_4:Number, _arg_5:Boolean, _arg_6:Boolean, _arg_7:Number, _arg_8:Vector.<Object3D>, _arg_9:int):void{
|
||||
var _local_10:int;
|
||||
var _local_14:Object3D;
|
||||
var _local_15:VertexBufferResource;
|
||||
var _local_16:IndexBufferResource;
|
||||
var _local_17:int;
|
||||
var _local_18:TextureMaterial;
|
||||
var _local_19:Mesh;
|
||||
var _local_20:BSP;
|
||||
var _local_21:int;
|
||||
var _local_22:int;
|
||||
var _local_23:OmniLight;
|
||||
var _local_24:SpotLight;
|
||||
var _local_25:Number;
|
||||
var _local_26:Number;
|
||||
var _local_27:TubeLight;
|
||||
var _local_11:Device = _arg_1.device;
|
||||
if (_arg_2 > 0x0800)
|
||||
{
|
||||
_arg_2 = 0x0800;
|
||||
};
|
||||
if (_arg_3 > 0x0800)
|
||||
{
|
||||
_arg_3 = 0x0800;
|
||||
};
|
||||
if (_arg_4 > 1)
|
||||
{
|
||||
_arg_4 = 1;
|
||||
};
|
||||
_arg_2 = Math.round((_arg_2 * _arg_4));
|
||||
_arg_3 = Math.round((_arg_3 * _arg_4));
|
||||
if (_arg_2 < 1)
|
||||
{
|
||||
_arg_2 = 1;
|
||||
};
|
||||
if (_arg_3 < 1)
|
||||
{
|
||||
_arg_3 = 1;
|
||||
};
|
||||
this.scissor.width = _arg_2;
|
||||
this.scissor.height = _arg_3;
|
||||
var _local_12:int = int((1 << Math.ceil((Math.log(_arg_2) / Math.LN2))));
|
||||
var _local_13:int = int((1 << Math.ceil((Math.log(_arg_3) / Math.LN2))));
|
||||
if (((!(_local_12 == this.depthBuffer.width)) || (!(_local_13 == this.depthBuffer.height))))
|
||||
{
|
||||
this.depthBuffer.dispose();
|
||||
this.depthBuffer = new RenderTargetTextureResource(_local_12, _local_13);
|
||||
this.temporaryBuffer.dispose();
|
||||
this.temporaryBuffer = new RenderTargetTextureResource(_local_12, _local_13);
|
||||
this.lightBuffer.dispose();
|
||||
this.lightBuffer = new RenderTargetTextureResource(_local_12, _local_13);
|
||||
};
|
||||
if ((!(_arg_5)))
|
||||
{
|
||||
this.noise.reset();
|
||||
this.temporaryBuffer.reset();
|
||||
this.ssaoVertexBuffer.reset();
|
||||
this.ssaoIndexBuffer.reset();
|
||||
};
|
||||
if ((!(_arg_6)))
|
||||
{
|
||||
this.lightBuffer.reset();
|
||||
this.lightVertexBuffer.reset();
|
||||
this.lightIndexBuffer.reset();
|
||||
};
|
||||
if (((!(_arg_5)) && (!(_arg_6))))
|
||||
{
|
||||
this.table.reset();
|
||||
};
|
||||
this.correctionX = (_arg_2 / this.depthBuffer.width);
|
||||
this.correctionY = (_arg_3 / this.depthBuffer.height);
|
||||
_local_11.setRenderToTexture(this.depthBuffer, true);
|
||||
_local_11.clear(1, 0, 0.25, 1);
|
||||
_local_11.setScissorRectangle(this.scissor);
|
||||
this.correction[0] = this.correctionX;
|
||||
this.correction[1] = this.correctionY;
|
||||
this.correction[2] = (0xFF / _arg_1.farClipping);
|
||||
this.correction[4] = (1 - this.correctionX);
|
||||
this.correction[5] = (1 - this.correctionY);
|
||||
this.correction[8] = _arg_1.correctionX;
|
||||
this.correction[9] = _arg_1.correctionY;
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 3, _arg_1.projection, 1, false);
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 4, this.correction, 3, false);
|
||||
if (((_arg_5) || (_arg_6)))
|
||||
{
|
||||
_local_11.setTextureAt(0, this.table);
|
||||
};
|
||||
_local_10 = 0;
|
||||
while (_local_10 < _arg_9)
|
||||
{
|
||||
_local_14 = _arg_8[_local_10];
|
||||
if ((_local_14 is Mesh))
|
||||
{
|
||||
_local_19 = Mesh(_local_14);
|
||||
_local_15 = _local_19.vertexBuffer;
|
||||
_local_16 = _local_19.indexBuffer;
|
||||
_local_17 = _local_19.numTriangles;
|
||||
_local_18 = (_local_19.faceList.material as TextureMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((_local_14 is BSP))
|
||||
{
|
||||
_local_20 = BSP(_local_14);
|
||||
_local_15 = _local_20.vertexBuffer;
|
||||
_local_16 = _local_20.indexBuffer;
|
||||
_local_17 = _local_20.numTriangles;
|
||||
_local_18 = (_local_20.faces[0].material as TextureMaterial);
|
||||
};
|
||||
};
|
||||
if ((((!(_local_18 == null)) && (_local_18.alphaTestThreshold > 0)) && (_local_18.transparent)))
|
||||
{
|
||||
_local_11.setProgram(this.getDepthProgram(((_arg_5) || (_arg_6)), true, _arg_1.view.quality, _local_18.repeat, (_local_18._mipMapping > 0), false, false));
|
||||
_local_11.setVertexBufferAt(2, _local_15, 3, Context3DVertexBufferFormat.FLOAT_2);
|
||||
_local_11.setTextureAt(1, _local_18.textureResource);
|
||||
this.alphaTestConst[0] = _local_18.textureResource.correctionU;
|
||||
this.alphaTestConst[1] = _local_18.textureResource.correctionV;
|
||||
this.alphaTestConst[3] = _local_18.alphaTestThreshold;
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 7, this.alphaTestConst, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_11.setProgram(this.getDepthProgram(((_arg_5) || (_arg_6)), false));
|
||||
};
|
||||
_local_11.setVertexBufferAt(0, _local_15, 0, Context3DVertexBufferFormat.FLOAT_3);
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 0, _local_14.transformConst, 3, false);
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, this.depthFragment, 2);
|
||||
if (((_arg_5) || (_arg_6)))
|
||||
{
|
||||
_local_11.setVertexBufferAt(1, _local_15, 5, Context3DVertexBufferFormat.FLOAT_3);
|
||||
};
|
||||
_local_11.drawTriangles(_local_16, 0, _local_17);
|
||||
_local_11.setTextureAt(1, null);
|
||||
_local_11.setVertexBufferAt(2, null);
|
||||
_local_10++;
|
||||
};
|
||||
if (_arg_6)
|
||||
{
|
||||
_local_11.setRenderToTexture(this.lightBuffer, false);
|
||||
_local_11.clear(_arg_7, _arg_7, _arg_7, 0);
|
||||
_local_11.setBlendFactors(Context3DBlendFactor.ONE, Context3DBlendFactor.ONE);
|
||||
_local_11.setTextureAt(0, this.depthBuffer);
|
||||
_local_11.setVertexBufferAt(0, this.lightVertexBuffer, 0, Context3DVertexBufferFormat.FLOAT_3);
|
||||
_local_11.setVertexBufferAt(1, this.lightVertexBuffer, 3, Context3DVertexBufferFormat.FLOAT_2);
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 0, _arg_1.projection, 1, false);
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 1, this.correction, 3, false);
|
||||
this.ssaoFragment[0] = _arg_1.farClipping;
|
||||
this.ssaoFragment[1] = (_arg_1.farClipping / 0xFF);
|
||||
this.ssaoFragment[4] = (2 / this.correctionX);
|
||||
this.ssaoFragment[5] = (2 / this.correctionY);
|
||||
this.ssaoFragment[6] = 0;
|
||||
this.ssaoFragment[8] = 1;
|
||||
this.ssaoFragment[9] = 1;
|
||||
this.ssaoFragment[10] = 0.5;
|
||||
this.ssaoFragment[12] = _arg_1.correctionX;
|
||||
this.ssaoFragment[13] = _arg_1.correctionY;
|
||||
this.ssaoFragment[16] = 0.5;
|
||||
this.ssaoFragment[17] = 0.5;
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, this.ssaoFragment, 7, false);
|
||||
_local_11.setProgram(this.getOmniProgram());
|
||||
_local_21 = 0;
|
||||
_local_22 = 0;
|
||||
_local_10 = 0;
|
||||
while (_local_10 < _arg_1.omniesCount)
|
||||
{
|
||||
_local_23 = _arg_1.omnies[_local_10];
|
||||
this.lightConst[_local_21] = (_local_23.cmd * _arg_1.correctionX);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (_local_23.cmh * _arg_1.correctionY);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_23.cml;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_23.attenuationEnd;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (((_local_23.intensity * _arg_1.deferredLightingStrength) * ((_local_23.color >> 16) & 0xFF)) / 0xFF);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (((_local_23.intensity * _arg_1.deferredLightingStrength) * ((_local_23.color >> 8) & 0xFF)) / 0xFF);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (((_local_23.intensity * _arg_1.deferredLightingStrength) * (_local_23.color & 0xFF)) / 0xFF);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (1 / (_local_23.attenuationEnd - _local_23.attenuationBegin));
|
||||
_local_21++;
|
||||
_local_22++;
|
||||
if (((_local_22 == limit2const) || (_local_10 == (_arg_1.omniesCount - 1))))
|
||||
{
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 4, this.lightConst, (_local_22 * 2), false);
|
||||
_local_11.drawTriangles(this.lightIndexBuffer, 0, ((_local_22 * 6) * 2));
|
||||
_local_22 = 0;
|
||||
_local_21 = 0;
|
||||
};
|
||||
_local_10++;
|
||||
};
|
||||
_local_11.setProgram(this.getSpotProgram());
|
||||
_local_21 = 0;
|
||||
_local_22 = 0;
|
||||
_local_10 = 0;
|
||||
while (_local_10 < _arg_1.spotsCount)
|
||||
{
|
||||
_local_24 = _arg_1.spots[_local_10];
|
||||
_local_25 = Math.cos((_local_24.hotspot * 0.5));
|
||||
_local_26 = Math.cos((_local_24.falloff * 0.5));
|
||||
this.lightConst[_local_21] = _local_24.cma;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_24.cmb;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_24.cmc;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_24.cmd;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_24.cme;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_24.cmf;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_24.cmg;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_24.cmh;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_24.cmi;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_24.cmj;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_24.cmk;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_24.cml;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_24.attenuationEnd;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (1 / (_local_24.attenuationEnd - _local_24.attenuationBegin));
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_26;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (1 / (_local_25 - _local_26));
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (((_local_24.intensity * _arg_1.deferredLightingStrength) * ((_local_24.color >> 16) & 0xFF)) / 0xFF);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (((_local_24.intensity * _arg_1.deferredLightingStrength) * ((_local_24.color >> 8) & 0xFF)) / 0xFF);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (((_local_24.intensity * _arg_1.deferredLightingStrength) * (_local_24.color & 0xFF)) / 0xFF);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (Math.sin((_local_24.falloff * 0.5)) * _local_24.attenuationEnd);
|
||||
_local_21++;
|
||||
_local_22++;
|
||||
if (((_local_22 == limit5const) || (_local_10 == (_arg_1.spotsCount - 1))))
|
||||
{
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 4, this.lightConst, (_local_22 * 5), false);
|
||||
_local_11.drawTriangles(this.lightIndexBuffer, 0, ((_local_22 * 6) * 2));
|
||||
_local_22 = 0;
|
||||
_local_21 = 0;
|
||||
};
|
||||
_local_10++;
|
||||
};
|
||||
_local_11.setProgram(this.getTubeProgram());
|
||||
_local_21 = 0;
|
||||
_local_22 = 0;
|
||||
_local_10 = 0;
|
||||
while (_local_10 < _arg_1.tubesCount)
|
||||
{
|
||||
_local_27 = _arg_1.tubes[_local_10];
|
||||
this.lightConst[_local_21] = _local_27.cma;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_27.cmb;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_27.cmc;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_27.cmd;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_27.cme;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_27.cmf;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_27.cmg;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_27.cmh;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_27.cmi;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_27.cmj;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_27.cmk;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_27.cml;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = _local_27.attenuationEnd;
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (1 / (_local_27.attenuationEnd - _local_27.attenuationBegin));
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = ((_local_27.length * 0.5) + _local_27.falloff);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (1 / _local_27.falloff);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (((_local_27.intensity * _arg_1.deferredLightingStrength) * ((_local_27.color >> 16) & 0xFF)) / 0xFF);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (((_local_27.intensity * _arg_1.deferredLightingStrength) * ((_local_27.color >> 8) & 0xFF)) / 0xFF);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (((_local_27.intensity * _arg_1.deferredLightingStrength) * (_local_27.color & 0xFF)) / 0xFF);
|
||||
_local_21++;
|
||||
this.lightConst[_local_21] = (_local_27.length * 0.5);
|
||||
_local_21++;
|
||||
_local_22++;
|
||||
if (((_local_22 == limit5const) || (_local_10 == (_arg_1.tubesCount - 1))))
|
||||
{
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 4, this.lightConst, (_local_22 * 5), false);
|
||||
_local_11.drawTriangles(this.lightIndexBuffer, 0, ((_local_22 * 6) * 2));
|
||||
_local_22 = 0;
|
||||
_local_21 = 0;
|
||||
};
|
||||
_local_10++;
|
||||
};
|
||||
_local_11.setBlendFactors(Context3DBlendFactor.ONE, Context3DBlendFactor.ZERO);
|
||||
};
|
||||
if (_arg_5)
|
||||
{
|
||||
_local_11.setRenderToTexture(this.temporaryBuffer, false);
|
||||
_local_11.clear(0, 0, 0, 0);
|
||||
_local_11.setProgram(this.getSSAOProgram());
|
||||
_local_11.setTextureAt(0, this.depthBuffer);
|
||||
_local_11.setTextureAt(1, this.noise);
|
||||
_local_11.setVertexBufferAt(0, this.ssaoVertexBuffer, 0, Context3DVertexBufferFormat.FLOAT_3);
|
||||
_local_11.setVertexBufferAt(1, this.ssaoVertexBuffer, 3, Context3DVertexBufferFormat.FLOAT_2);
|
||||
this.ssaoVertex[0] = (_local_12 / this.noiseSize);
|
||||
this.ssaoVertex[1] = (_local_13 / this.noiseSize);
|
||||
this.ssaoVertex[4] = (2 / this.correctionX);
|
||||
this.ssaoVertex[5] = (2 / this.correctionY);
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 0, this.ssaoVertex, 3, false);
|
||||
this.ssaoFragment[0] = _arg_1.farClipping;
|
||||
this.ssaoFragment[1] = (_arg_1.farClipping / 0xFF);
|
||||
this.ssaoFragment[4] = (2 / this.correctionX);
|
||||
this.ssaoFragment[5] = (2 / this.correctionY);
|
||||
this.ssaoFragment[6] = _arg_1.ssaoRadius;
|
||||
this.ssaoFragment[8] = 1;
|
||||
this.ssaoFragment[9] = 1;
|
||||
this.ssaoFragment[10] = this.bias;
|
||||
this.ssaoFragment[11] = ((this.intensity * 1) / this.samples);
|
||||
this.ssaoFragment[12] = _arg_1.correctionX;
|
||||
this.ssaoFragment[13] = _arg_1.correctionY;
|
||||
this.ssaoFragment[15] = (1 / _arg_1.ssaoRange);
|
||||
this.ssaoFragment[16] = Math.cos(this.noiseAngle);
|
||||
this.ssaoFragment[17] = Math.sin(this.noiseAngle);
|
||||
this.ssaoFragment[20] = -(Math.sin(this.noiseAngle));
|
||||
this.ssaoFragment[21] = Math.cos(this.noiseAngle);
|
||||
this.ssaoFragment[24] = (this.correctionX - (1 / _local_12));
|
||||
this.ssaoFragment[25] = (this.correctionY - (1 / _local_13));
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, this.ssaoFragment, 7, false);
|
||||
_local_11.drawTriangles(this.ssaoIndexBuffer, 0, 2);
|
||||
_local_11.setTextureAt(1, null);
|
||||
_local_11.setRenderToTexture(this.depthBuffer, false);
|
||||
_local_11.clear(0, 0, 0, 0);
|
||||
_local_11.setProgram(this.getBlurProgram());
|
||||
_local_11.setTextureAt(0, this.temporaryBuffer);
|
||||
this.blurFragment[0] = (1 / _local_12);
|
||||
this.blurFragment[1] = (1 / _local_13);
|
||||
this.blurFragment[3] = (1 / this.blurSamples);
|
||||
this.blurFragment[4] = (this.correctionX - (1 / _local_12));
|
||||
this.blurFragment[5] = (this.correctionY - (1 / _local_13));
|
||||
_local_11.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, this.blurFragment, 2, false);
|
||||
_local_11.drawTriangles(this.ssaoIndexBuffer, 0, 2);
|
||||
};
|
||||
_local_11.setVertexBufferAt(1, null);
|
||||
_local_11.setTextureAt(0, null);
|
||||
_local_11.setScissorRectangle(null);
|
||||
}
|
||||
|
||||
alternativa3d function resetResources():void{
|
||||
this.noise.reset();
|
||||
this.table.reset();
|
||||
this.depthBuffer.reset();
|
||||
this.temporaryBuffer.reset();
|
||||
this.lightBuffer.reset();
|
||||
this.ssaoVertexBuffer.reset();
|
||||
this.ssaoIndexBuffer.reset();
|
||||
this.lightVertexBuffer.reset();
|
||||
this.lightIndexBuffer.reset();
|
||||
}
|
||||
|
||||
private function getDepthProgram(_arg_1:Boolean, _arg_2:Boolean, _arg_3:Boolean=false, _arg_4:Boolean=false, _arg_5:Boolean=false, _arg_6:Boolean=false, _arg_7:Boolean=false):ProgramResource{
|
||||
var _local_10:ByteArray;
|
||||
var _local_11:ByteArray;
|
||||
var _local_8:int = ((((((int(_arg_1) | (int(_arg_2) << 1)) | (int(_arg_3) << 2)) | (int(_arg_4) << 3)) | (int(_arg_5) << 4)) | (int(_arg_6) << 5)) | (int(_arg_7) << 6));
|
||||
var _local_9:ProgramResource = this.depthPrograms[_local_8];
|
||||
if (_local_9 == null)
|
||||
{
|
||||
_local_10 = new DepthRendererDepthVertexShader(_arg_1, _arg_2).agalcode;
|
||||
_local_11 = new DepthRendererDepthFragmentShader(_arg_1, _arg_2, _arg_3, _arg_4, _arg_5).agalcode;
|
||||
_local_9 = new ProgramResource(_local_10, _local_11);
|
||||
this.depthPrograms[_local_8] = _local_9;
|
||||
};
|
||||
return (_local_9);
|
||||
}
|
||||
|
||||
private function getSSAOProgram():ProgramResource{
|
||||
var _local_2:ByteArray;
|
||||
var _local_3:ByteArray;
|
||||
var _local_1:ProgramResource = this.ssaoProgram;
|
||||
if (_local_1 == null)
|
||||
{
|
||||
_local_2 = new DepthRendererSSAOVertexShader().agalcode;
|
||||
_local_3 = new DepthRendererSSAOFragmentShader(this.samples).agalcode;
|
||||
_local_1 = new ProgramResource(_local_2, _local_3);
|
||||
this.ssaoProgram = _local_1;
|
||||
};
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
private function getBlurProgram():ProgramResource{
|
||||
var _local_2:ByteArray;
|
||||
var _local_3:ByteArray;
|
||||
var _local_1:ProgramResource = this.blurProgram;
|
||||
if (_local_1 == null)
|
||||
{
|
||||
_local_2 = new DepthRendererBlurVertexShader().agalcode;
|
||||
_local_3 = new DepthRendererBlurFragmentShader().agalcode;
|
||||
_local_1 = new ProgramResource(_local_2, _local_3);
|
||||
this.blurProgram = _local_1;
|
||||
};
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
private function getOmniProgram():ProgramResource{
|
||||
var _local_2:ByteArray;
|
||||
var _local_3:ByteArray;
|
||||
var _local_1:ProgramResource = this.omniProgram;
|
||||
if (_local_1 == null)
|
||||
{
|
||||
_local_2 = new DepthRendererLightVertexShader(0).agalcode;
|
||||
_local_3 = new DepthRendererLightFragmentShader(0).agalcode;
|
||||
_local_1 = new ProgramResource(_local_2, _local_3);
|
||||
this.omniProgram = _local_1;
|
||||
};
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
private function getSpotProgram():ProgramResource{
|
||||
var _local_2:ByteArray;
|
||||
var _local_3:ByteArray;
|
||||
var _local_1:ProgramResource = this.spotProgram;
|
||||
if (_local_1 == null)
|
||||
{
|
||||
_local_2 = new DepthRendererLightVertexShader(1).agalcode;
|
||||
_local_3 = new DepthRendererLightFragmentShader(1).agalcode;
|
||||
_local_1 = new ProgramResource(_local_2, _local_3);
|
||||
this.spotProgram = _local_1;
|
||||
};
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
private function getTubeProgram():ProgramResource{
|
||||
var _local_2:ByteArray;
|
||||
var _local_3:ByteArray;
|
||||
var _local_1:ProgramResource = this.tubeProgram;
|
||||
if (_local_1 == null)
|
||||
{
|
||||
_local_2 = new DepthRendererLightVertexShader(2).agalcode;
|
||||
_local_3 = new DepthRendererLightFragmentShader(2).agalcode;
|
||||
_local_1 = new ProgramResource(_local_2, _local_3);
|
||||
this.tubeProgram = _local_1;
|
||||
};
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
@@ -0,0 +1,81 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.gfx.agal.FragmentShader;
|
||||
import alternativa.gfx.agal.SamplerDim;
|
||||
import alternativa.gfx.agal.SamplerRepeat;
|
||||
import alternativa.gfx.agal.SamplerFilter;
|
||||
import alternativa.gfx.agal.SamplerMipMap;
|
||||
|
||||
public class DepthRendererBlurFragmentShader extends FragmentShader
|
||||
{
|
||||
|
||||
public function DepthRendererBlurFragmentShader()
|
||||
{
|
||||
mov(ft1, v0);
|
||||
tex(ft0, ft1, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
sub(ft1.y, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
sub(ft1.x, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
add(ft1.y, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
add(ft1.y, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
add(ft1.y, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
add(ft1.x, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
add(ft1.x, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
add(ft1.x, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
sub(ft1.y, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
sub(ft1.y, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
sub(ft1.y, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
sub(ft1.x, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
add(ft1.y, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
add(ft1.y, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
sub(ft1.x, ft1, fc[0]);
|
||||
min(ft2, ft1, fc[1]);
|
||||
tex(ft2, ft2, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft0.w, ft0, ft2);
|
||||
mul(ft0.w, ft0, fc[0]);
|
||||
mov(oc, ft0);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
@@ -0,0 +1,15 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.gfx.agal.VertexShader;
|
||||
|
||||
public class DepthRendererBlurVertexShader extends VertexShader
|
||||
{
|
||||
|
||||
public function DepthRendererBlurVertexShader()
|
||||
{
|
||||
mov(op, va0);
|
||||
mov(v0, va1);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
@@ -0,0 +1,55 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.gfx.agal.FragmentShader;
|
||||
import alternativa.gfx.agal.SamplerRepeat;
|
||||
import alternativa.gfx.agal.SamplerFilter;
|
||||
import alternativa.gfx.agal.SamplerMipMap;
|
||||
import alternativa.gfx.agal.SamplerType;
|
||||
import alternativa.gfx.agal.SamplerDim;
|
||||
|
||||
public class DepthRendererDepthFragmentShader extends FragmentShader
|
||||
{
|
||||
|
||||
public function DepthRendererDepthFragmentShader(_arg_1:Boolean, _arg_2:Boolean, _arg_3:Boolean, _arg_4:Boolean, _arg_5:Boolean)
|
||||
{
|
||||
var _local_6:SamplerRepeat;
|
||||
var _local_7:SamplerFilter;
|
||||
var _local_8:SamplerMipMap;
|
||||
var _local_9:SamplerType;
|
||||
super();
|
||||
if (_arg_2)
|
||||
{
|
||||
_local_6 = ((_arg_4) ? SamplerRepeat.WRAP : SamplerRepeat.CLAMP);
|
||||
_local_7 = ((_arg_3) ? SamplerFilter.LINEAR : SamplerFilter.NEAREST);
|
||||
_local_8 = ((_arg_5) ? ((_arg_3) ? SamplerMipMap.LINEAR : SamplerMipMap.NEAREST) : SamplerMipMap.NONE);
|
||||
_local_9 = SamplerType.RGBA;
|
||||
tex(ft0, v1, fs1.dim(SamplerDim.D2).repeat(_local_6).filter(_local_7).mipmap(_local_8).type(_local_9));
|
||||
sub(ft0.w, ft0, v1);
|
||||
kil(ft0.w);
|
||||
};
|
||||
frc(ft0, v0.z);
|
||||
sub(ft0.x, v0.z, ft0);
|
||||
mul(ft0.x, ft0, fc[0]);
|
||||
if (_arg_1)
|
||||
{
|
||||
mov(ft1.zw, fc[0]);
|
||||
mov(ft1.xy, v0);
|
||||
nrm(ft1.xyz, ft1.xyz);
|
||||
mul(ft1.xy, ft1, fc[1]);
|
||||
add(ft1.xy, ft1, fc[1]);
|
||||
tex(ft2, ft1, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
mov(ft0.w, ft2.z);
|
||||
mul(ft1.xy, v0, v0);
|
||||
add(ft1.x, ft1, ft1.y);
|
||||
sqt(ft1.x, ft1);
|
||||
neg(ft1.y, v0.w);
|
||||
mul(ft1.xy, ft1, fc[1]);
|
||||
add(ft1.xy, ft1, fc[1]);
|
||||
tex(ft2, ft1, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
mov(ft0.z, ft2.z);
|
||||
};
|
||||
mov(oc, ft0);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
@@ -0,0 +1,36 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.gfx.agal.VertexShader;
|
||||
|
||||
public class DepthRendererDepthVertexShader extends VertexShader
|
||||
{
|
||||
|
||||
public function DepthRendererDepthVertexShader(_arg_1:Boolean, _arg_2:Boolean)
|
||||
{
|
||||
mov(vt0, vc[0]);
|
||||
dp4(vt0.x, va0, vc[0]);
|
||||
dp4(vt0.y, va0, vc[1]);
|
||||
dp4(vt0.z, va0, vc[2]);
|
||||
mul(vt0.xy, vt0, vc[4]);
|
||||
mul(vt1, vc[5], vt0.z);
|
||||
sub(vt0.xy, vt0, vt1);
|
||||
mul(v0, vt0, vc[4]);
|
||||
if (_arg_1)
|
||||
{
|
||||
dp3(vt1, va1, vc[0]);
|
||||
dp3(vt1.y, va1, vc[1]);
|
||||
mul(v0.xy, vt1, vc[6]);
|
||||
dp3(v0.w, va1, vc[2]);
|
||||
};
|
||||
mov(op.xw, vt0.xz);
|
||||
neg(op.y, vt0);
|
||||
mul(vt0.z, vt0, vc[3]);
|
||||
add(op.z, vt0, vc[3].w);
|
||||
if (_arg_2)
|
||||
{
|
||||
mul(v1, va2, vc[7]);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
@@ -0,0 +1,95 @@
|
||||
package alternativa.engine3d.core{
|
||||
import alternativa.gfx.agal.FragmentShader;
|
||||
import alternativa.gfx.agal.SamplerDim;
|
||||
import alternativa.gfx.agal.SamplerRepeat;
|
||||
import alternativa.gfx.agal.SamplerFilter;
|
||||
import alternativa.gfx.agal.SamplerMipMap;
|
||||
|
||||
public class DepthRendererLightFragmentShader extends FragmentShader {
|
||||
|
||||
public function DepthRendererLightFragmentShader(_arg_1:int){
|
||||
div(ft4, v0, v0.z);
|
||||
mul(ft4, ft4, fc[4]);
|
||||
add(ft4, ft4, fc[4]);
|
||||
tex(ft0, ft4, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
mul(ft0.zw, ft0, fc[6]);
|
||||
cos(ft1, ft0);
|
||||
sin(ft2, ft0);
|
||||
mul(ft1.x, ft1.w, ft1.z);
|
||||
mul(ft1.y, ft2.w, ft1.z);
|
||||
neg(ft1.z, ft2);
|
||||
dp3(ft2.z, ft0, fc[0]);
|
||||
mul(ft2.xy, ft4, fc[1]);
|
||||
sub(ft2.xy, ft2, fc[2]);
|
||||
mul(ft2.xy, ft2, ft2.z);
|
||||
mul(ft2.xy, ft2, fc[3]);
|
||||
if (_arg_1 == 0)
|
||||
{
|
||||
sub(ft3, v1, ft2);
|
||||
dp3(ft3.w, ft3, ft3);
|
||||
sqt(ft3.w, ft3);
|
||||
div(ft3.xyz, ft3, ft3.w);
|
||||
sub(ft3.w, v1, ft3);
|
||||
mul(ft3.w, ft3, v2);
|
||||
sat(ft3.w, ft3);
|
||||
mul(ft3.w, ft3, ft3);
|
||||
dp3(ft2.w, ft3, ft1);
|
||||
max(ft2.w, ft2, fc[4]);
|
||||
mul(ft3.w, ft3, ft2);
|
||||
mul(ft0.xyz, v2, ft3.w);
|
||||
} else
|
||||
{
|
||||
if (_arg_1 == 1)
|
||||
{
|
||||
sub(ft3, v1, ft2);
|
||||
dp3(ft3.w, ft3, ft3);
|
||||
sqt(ft3.w, ft3);
|
||||
div(ft3.xyz, ft3, ft3.w);
|
||||
sub(ft3.w, v3.x, ft3);
|
||||
mul(ft3.w, ft3, v3.y);
|
||||
sat(ft3.w, ft3);
|
||||
mul(ft3.w, ft3, ft3);
|
||||
dp3(ft4.w, ft3, ft1);
|
||||
max(ft4.w, ft4, fc[4]);
|
||||
mul(ft3.w, ft3, ft4);
|
||||
dp3(ft4.w, ft3, v2);
|
||||
neg(ft4.w, ft4);
|
||||
sub(ft4.w, ft4, v3.z);
|
||||
mul(ft4.w, ft4, v3);
|
||||
sat(ft4.w, ft4);
|
||||
mul(ft4.w, ft4, ft4);
|
||||
mul(ft3.w, ft3, ft4);
|
||||
} else
|
||||
{
|
||||
if (_arg_1 == 2)
|
||||
{
|
||||
sub(ft4, ft2, v1);
|
||||
dp3(ft4.w, ft4, v2);
|
||||
mul(ft4.xyz, v2, ft4.w);
|
||||
add(ft4.xyz, v1, ft4);
|
||||
abs(ft4.w, ft4);
|
||||
sub(ft4.w, v3.z, ft4);
|
||||
mul(ft4.w, ft4, v3);
|
||||
sat(ft4.w, ft4);
|
||||
mul(ft4.w, ft4, ft4);
|
||||
sub(ft3, ft4, ft2);
|
||||
dp3(ft3.w, ft3, ft3);
|
||||
sqt(ft3.w, ft3);
|
||||
div(ft3.xyz, ft3, ft3.w);
|
||||
sub(ft3.w, v3.x, ft3);
|
||||
mul(ft3.w, ft3, v3.y);
|
||||
sat(ft3.w, ft3);
|
||||
mul(ft3.w, ft3, ft3);
|
||||
mul(ft3.w, ft3, ft4);
|
||||
dp3(ft4.w, ft3, ft1);
|
||||
max(ft4.w, ft4, fc[4]);
|
||||
mul(ft3.w, ft3, ft4);
|
||||
};
|
||||
};
|
||||
mul(ft0.xyz, v4, ft3.w);
|
||||
};
|
||||
mov(oc, ft0);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
@@ -0,0 +1,73 @@
|
||||
package alternativa.engine3d.core{
|
||||
import alternativa.gfx.agal.VertexShader;
|
||||
|
||||
public class DepthRendererLightVertexShader extends VertexShader {
|
||||
|
||||
public function DepthRendererLightVertexShader(_arg_1:int){
|
||||
if (_arg_1 == 0)
|
||||
{
|
||||
mov(vt1, cc.rel(va1.x, 0));
|
||||
mov(v1, vt1);
|
||||
mov(v2, cc.rel(va1.x, 1));
|
||||
mul(vt0, va0, vt1.w);
|
||||
add(vt0, vt0, vt1);
|
||||
div(vt0.xy, vt0, vc[3]);
|
||||
} else
|
||||
{
|
||||
mov(vt2, cc.rel(va1.y, 0));
|
||||
mov(vt3, cc.rel(va1.y, 1));
|
||||
mov(vt4, cc.rel(va1.y, 2));
|
||||
mov(vt5, cc.rel(va1.y, 3));
|
||||
mov(vt6, cc.rel(va1.y, 4));
|
||||
if (_arg_1 == 1)
|
||||
{
|
||||
mul(v1.x, vt2.w, vc[3]);
|
||||
mul(v1.y, vt3.w, vc[3]);
|
||||
mov(v1.zw, vt4.w);
|
||||
mul(v2.x, vt2.z, vc[3]);
|
||||
mul(v2.y, vt3.z, vc[3]);
|
||||
mov(v2.zw, vt4.z);
|
||||
mov(v3, vt5);
|
||||
mov(v4, vt6);
|
||||
mul(vt0, va0, vt6.w);
|
||||
mul(vt0.z, va0, vt5.x);
|
||||
add(vt0.z, vt0, vt5.x);
|
||||
mul(vt0.z, vt0, vc[3].w);
|
||||
} else
|
||||
{
|
||||
if (_arg_1 == 2)
|
||||
{
|
||||
mul(vt0.x, vt2.z, vc[3]);
|
||||
mul(vt0.y, vt3.z, vc[3]);
|
||||
mov(vt0.zw, vt4.z);
|
||||
mov(v2, vt0);
|
||||
mul(vt1.x, vt2.w, vc[3]);
|
||||
mul(vt1.y, vt3.w, vc[3]);
|
||||
mov(vt1.zw, vt4.w);
|
||||
mul(vt0, vt0, vt6.w);
|
||||
add(v1, vt1, vt0);
|
||||
mov(v3, vt5);
|
||||
mov(v4, vt6);
|
||||
mul(vt0.xy, va0, vt5.x);
|
||||
mul(vt0.z, va0, vt5);
|
||||
add(vt0.z, vt0, vt6.w);
|
||||
};
|
||||
};
|
||||
mov(vt0.w, vc[1]);
|
||||
dp4(vt1.x, vt0, vt2);
|
||||
dp4(vt1.y, vt0, vt3);
|
||||
dp4(vt1.z, vt0, vt4);
|
||||
mov(vt0.xyz, vt1.xyz);
|
||||
};
|
||||
mul(vt0.xy, vt0, vc[1]);
|
||||
mul(vt1, vc[2], vt0.z);
|
||||
sub(vt0.xy, vt0, vt1);
|
||||
mov(v0, vt0);
|
||||
mov(op.xw, vt0.xz);
|
||||
neg(op.y, vt0);
|
||||
mul(vt0.z, vt0, vc[0]);
|
||||
add(op.z, vt0, vc[0].w);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
@@ -0,0 +1,80 @@
|
||||
package alternativa.engine3d.core{
|
||||
import alternativa.gfx.agal.FragmentShader;
|
||||
import alternativa.gfx.agal.SamplerDim;
|
||||
import alternativa.gfx.agal.SamplerRepeat;
|
||||
import alternativa.gfx.agal.SamplerFilter;
|
||||
import alternativa.gfx.agal.SamplerMipMap;
|
||||
|
||||
public class DepthRendererSSAOFragmentShader extends FragmentShader {
|
||||
|
||||
public function DepthRendererSSAOFragmentShader(_arg_1:int){
|
||||
tex(ft0, v0, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
mul(ft0.zw, ft0, fc[6]);
|
||||
cos(ft1, ft0);
|
||||
sin(ft2, ft0);
|
||||
mul(ft1.x, ft1.w, ft1.z);
|
||||
mul(ft1.y, ft2.w, ft1.z);
|
||||
neg(ft1.z, ft2);
|
||||
dp3(ft2.z, ft0, fc[0]);
|
||||
mul(ft2.xy, v2, ft2.z);
|
||||
tex(ft3, v1, fs1.dim(SamplerDim.D2).repeat(SamplerRepeat.WRAP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
mul(ft3.z, ft3, fc[1]);
|
||||
mul(ft3, ft3.z, ft3);
|
||||
var _local_2:int;
|
||||
while (_local_2 < _arg_1)
|
||||
{
|
||||
if (_local_2 > 0)
|
||||
{
|
||||
if ((_local_2 % 2) > 0)
|
||||
{
|
||||
dp3(ft6, ft3, fc[4]);
|
||||
dp3(ft6.y, ft3, fc[5]);
|
||||
} else
|
||||
{
|
||||
dp3(ft3.x, ft6, fc[4]);
|
||||
dp3(ft3.y, ft6, fc[5]);
|
||||
};
|
||||
};
|
||||
if ((_local_2 % 2) > 0)
|
||||
{
|
||||
div(ft4, ft6, fc[3]);
|
||||
} else
|
||||
{
|
||||
div(ft4, ft3, fc[3]);
|
||||
};
|
||||
div(ft4, ft4, ft2.z);
|
||||
div(ft4, ft4, fc[1]);
|
||||
add(ft4, v0, ft4);
|
||||
min(ft5, ft4, fc[6]);
|
||||
tex(ft5, ft5, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
dp3(ft5.z, ft5, fc[0]);
|
||||
mul(ft5.xy, ft4, fc[1]);
|
||||
sub(ft5.xy, ft5, fc[2]);
|
||||
mul(ft5.xy, ft5, ft5.z);
|
||||
sub(ft5, ft5, ft2);
|
||||
mul(ft5, ft5, fc[3]);
|
||||
dp3(ft5.w, ft5, ft5);
|
||||
sqt(ft5.w, ft5);
|
||||
div(ft5.xyz, ft5, ft5.w);
|
||||
mul(ft5.w, ft5, fc[3]);
|
||||
sub(ft5.w, fc[1], ft5);
|
||||
max(ft5.w, ft5, fc[4]);
|
||||
dp3(ft5.z, ft5, ft1);
|
||||
sub(ft5.z, ft5, fc[2]);
|
||||
max(ft5.z, ft5, fc[0]);
|
||||
mul(ft5.w, ft5, ft5.z);
|
||||
if (_local_2 == 0)
|
||||
{
|
||||
mov(ft0.w, ft5);
|
||||
} else
|
||||
{
|
||||
add(ft0.w, ft0, ft5);
|
||||
};
|
||||
_local_2++;
|
||||
};
|
||||
mul(ft0.w, ft0, fc[2]);
|
||||
mov(oc, ft0);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
@@ -0,0 +1,15 @@
|
||||
package alternativa.engine3d.core{
|
||||
import alternativa.gfx.agal.VertexShader;
|
||||
|
||||
public class DepthRendererSSAOVertexShader extends VertexShader {
|
||||
|
||||
public function DepthRendererSSAOVertexShader(){
|
||||
mov(op, va0);
|
||||
mov(v0, va1);
|
||||
mul(v1, va1, vc[0]);
|
||||
mul(vt1, va1, vc[1]);
|
||||
sub(v2, vt1, vc[2]);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
426
src/alternativa/engine3d/core/EllipsoidCollider.as
Normal file
426
src/alternativa/engine3d/core/EllipsoidCollider.as
Normal file
@@ -0,0 +1,426 @@
|
||||
package alternativa.engine3d.core{
|
||||
import __AS3__.vec.Vector;
|
||||
import flash.geom.Vector3D;
|
||||
import flash.utils.Dictionary;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class EllipsoidCollider {
|
||||
|
||||
public var radiusX:Number;
|
||||
public var radiusY:Number;
|
||||
public var radiusZ:Number;
|
||||
public var threshold:Number = 0.001;
|
||||
private var matrix:Object3D = new Object3D();
|
||||
private var faces:Vector.<Face> = new Vector.<Face>();
|
||||
private var facesLength:int;
|
||||
private var radius:Number;
|
||||
private var src:Vector3D = new Vector3D();
|
||||
private var displ:Vector3D = new Vector3D();
|
||||
private var dest:Vector3D = new Vector3D();
|
||||
private var collisionPoint:Vector3D = new Vector3D();
|
||||
private var collisionPlane:Vector3D = new Vector3D();
|
||||
private var vCenter:Vector3D = new Vector3D();
|
||||
private var vA:Vector3D = new Vector3D();
|
||||
private var vB:Vector3D = new Vector3D();
|
||||
private var vC:Vector3D = new Vector3D();
|
||||
private var vD:Vector3D = new Vector3D();
|
||||
|
||||
public function EllipsoidCollider(_arg_1:Number, _arg_2:Number, _arg_3:Number){
|
||||
this.radiusX = _arg_1;
|
||||
this.radiusY = _arg_2;
|
||||
this.radiusZ = _arg_3;
|
||||
}
|
||||
|
||||
private function prepare(_arg_1:Vector3D, _arg_2:Vector3D, _arg_3:Object3D, _arg_4:Dictionary, _arg_5:Boolean):void{
|
||||
var _local_6:Number;
|
||||
this.radius = this.radiusX;
|
||||
if (this.radiusY > this.radius)
|
||||
{
|
||||
this.radius = this.radiusY;
|
||||
};
|
||||
if (this.radiusZ > this.radius)
|
||||
{
|
||||
this.radius = this.radiusZ;
|
||||
};
|
||||
this.matrix.scaleX = (this.radiusX / this.radius);
|
||||
this.matrix.scaleY = (this.radiusY / this.radius);
|
||||
this.matrix.scaleZ = (this.radiusZ / this.radius);
|
||||
this.matrix.x = _arg_1.x;
|
||||
this.matrix.y = _arg_1.y;
|
||||
this.matrix.z = _arg_1.z;
|
||||
this.matrix.composeMatrix();
|
||||
this.matrix.invertMatrix();
|
||||
this.src.x = 0;
|
||||
this.src.y = 0;
|
||||
this.src.z = 0;
|
||||
this.displ.x = (((this.matrix.ma * _arg_2.x) + (this.matrix.mb * _arg_2.y)) + (this.matrix.mc * _arg_2.z));
|
||||
this.displ.y = (((this.matrix.me * _arg_2.x) + (this.matrix.mf * _arg_2.y)) + (this.matrix.mg * _arg_2.z));
|
||||
this.displ.z = (((this.matrix.mi * _arg_2.x) + (this.matrix.mj * _arg_2.y)) + (this.matrix.mk * _arg_2.z));
|
||||
this.dest.x = (this.src.x + this.displ.x);
|
||||
this.dest.y = (this.src.y + this.displ.y);
|
||||
this.dest.z = (this.src.z + this.displ.z);
|
||||
if (_arg_5)
|
||||
{
|
||||
this.vCenter.x = (this.displ.x / 2);
|
||||
this.vCenter.y = (this.displ.y / 2);
|
||||
this.vCenter.z = (this.displ.z / 2);
|
||||
_local_6 = (this.radius + (this.displ.length / 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.vCenter.x = 0;
|
||||
this.vCenter.y = 0;
|
||||
this.vCenter.z = 0;
|
||||
_local_6 = (this.radius + this.displ.length);
|
||||
};
|
||||
this.vA.x = -(_local_6);
|
||||
this.vA.y = -(_local_6);
|
||||
this.vA.z = -(_local_6);
|
||||
this.vB.x = _local_6;
|
||||
this.vB.y = -(_local_6);
|
||||
this.vB.z = -(_local_6);
|
||||
this.vC.x = _local_6;
|
||||
this.vC.y = _local_6;
|
||||
this.vC.z = -(_local_6);
|
||||
this.vD.x = -(_local_6);
|
||||
this.vD.y = _local_6;
|
||||
this.vD.z = -(_local_6);
|
||||
_arg_3.composeAndAppend(this.matrix);
|
||||
_arg_3.collectPlanes(this.vCenter, this.vA, this.vB, this.vC, this.vD, this.faces, _arg_4);
|
||||
this.facesLength = this.faces.length;
|
||||
}
|
||||
|
||||
public function calculateDestination(_arg_1:Vector3D, _arg_2:Vector3D, _arg_3:Object3D, _arg_4:Dictionary=null):Vector3D{
|
||||
var _local_5:int;
|
||||
var _local_6:int;
|
||||
var _local_7:Number;
|
||||
if (_arg_2.length <= this.threshold)
|
||||
{
|
||||
return (_arg_1.clone());
|
||||
};
|
||||
this.prepare(_arg_1, _arg_2, _arg_3, _arg_4, false);
|
||||
if (this.facesLength > 0)
|
||||
{
|
||||
_local_5 = 50;
|
||||
_local_6 = 0;
|
||||
while (_local_6 < _local_5)
|
||||
{
|
||||
if (this.checkCollision())
|
||||
{
|
||||
_local_7 = (((((this.radius + this.threshold) + this.collisionPlane.w) - (this.dest.x * this.collisionPlane.x)) - (this.dest.y * this.collisionPlane.y)) - (this.dest.z * this.collisionPlane.z));
|
||||
this.dest.x = (this.dest.x + (this.collisionPlane.x * _local_7));
|
||||
this.dest.y = (this.dest.y + (this.collisionPlane.y * _local_7));
|
||||
this.dest.z = (this.dest.z + (this.collisionPlane.z * _local_7));
|
||||
this.src.x = (this.collisionPoint.x + (this.collisionPlane.x * (this.radius + this.threshold)));
|
||||
this.src.y = (this.collisionPoint.y + (this.collisionPlane.y * (this.radius + this.threshold)));
|
||||
this.src.z = (this.collisionPoint.z + (this.collisionPlane.z * (this.radius + this.threshold)));
|
||||
this.displ.x = (this.dest.x - this.src.x);
|
||||
this.displ.y = (this.dest.y - this.src.y);
|
||||
this.displ.z = (this.dest.z - this.src.z);
|
||||
if (this.displ.length < this.threshold) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
};
|
||||
_local_6++;
|
||||
};
|
||||
this.faces.length = 0;
|
||||
this.matrix.composeMatrix();
|
||||
return (new Vector3D(((((this.matrix.ma * this.dest.x) + (this.matrix.mb * this.dest.y)) + (this.matrix.mc * this.dest.z)) + this.matrix.md), ((((this.matrix.me * this.dest.x) + (this.matrix.mf * this.dest.y)) + (this.matrix.mg * this.dest.z)) + this.matrix.mh), ((((this.matrix.mi * this.dest.x) + (this.matrix.mj * this.dest.y)) + (this.matrix.mk * this.dest.z)) + this.matrix.ml)));
|
||||
};
|
||||
return (new Vector3D((_arg_1.x + _arg_2.x), (_arg_1.y + _arg_2.y), (_arg_1.z + _arg_2.z)));
|
||||
}
|
||||
|
||||
public function getCollision(_arg_1:Vector3D, _arg_2:Vector3D, _arg_3:Vector3D, _arg_4:Vector3D, _arg_5:Object3D, _arg_6:Dictionary=null):Boolean{
|
||||
var _local_7:Number;
|
||||
var _local_8:Number;
|
||||
var _local_9:Number;
|
||||
var _local_10:Number;
|
||||
var _local_11:Number;
|
||||
var _local_12:Number;
|
||||
var _local_13:Number;
|
||||
var _local_14:Number;
|
||||
var _local_15:Number;
|
||||
var _local_16:Number;
|
||||
var _local_17:Number;
|
||||
var _local_18:Number;
|
||||
if (_arg_2.length <= this.threshold)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
this.prepare(_arg_1, _arg_2, _arg_5, _arg_6, true);
|
||||
if (this.facesLength > 0)
|
||||
{
|
||||
if (this.checkCollision())
|
||||
{
|
||||
this.matrix.composeMatrix();
|
||||
_arg_3.x = ((((this.matrix.ma * this.collisionPoint.x) + (this.matrix.mb * this.collisionPoint.y)) + (this.matrix.mc * this.collisionPoint.z)) + this.matrix.md);
|
||||
_arg_3.y = ((((this.matrix.me * this.collisionPoint.x) + (this.matrix.mf * this.collisionPoint.y)) + (this.matrix.mg * this.collisionPoint.z)) + this.matrix.mh);
|
||||
_arg_3.z = ((((this.matrix.mi * this.collisionPoint.x) + (this.matrix.mj * this.collisionPoint.y)) + (this.matrix.mk * this.collisionPoint.z)) + this.matrix.ml);
|
||||
if (this.collisionPlane.x < this.collisionPlane.y)
|
||||
{
|
||||
if (this.collisionPlane.x < this.collisionPlane.z)
|
||||
{
|
||||
_local_7 = 0;
|
||||
_local_8 = -(this.collisionPlane.z);
|
||||
_local_9 = this.collisionPlane.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_7 = -(this.collisionPlane.y);
|
||||
_local_8 = this.collisionPlane.x;
|
||||
_local_9 = 0;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.collisionPlane.y < this.collisionPlane.z)
|
||||
{
|
||||
_local_7 = this.collisionPlane.z;
|
||||
_local_8 = 0;
|
||||
_local_9 = -(this.collisionPlane.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_7 = -(this.collisionPlane.y);
|
||||
_local_8 = this.collisionPlane.x;
|
||||
_local_9 = 0;
|
||||
};
|
||||
};
|
||||
_local_10 = ((this.collisionPlane.z * _local_8) - (this.collisionPlane.y * _local_9));
|
||||
_local_11 = ((this.collisionPlane.x * _local_9) - (this.collisionPlane.z * _local_7));
|
||||
_local_12 = ((this.collisionPlane.y * _local_7) - (this.collisionPlane.x * _local_8));
|
||||
_local_13 = (((this.matrix.ma * _local_7) + (this.matrix.mb * _local_8)) + (this.matrix.mc * _local_9));
|
||||
_local_14 = (((this.matrix.me * _local_7) + (this.matrix.mf * _local_8)) + (this.matrix.mg * _local_9));
|
||||
_local_15 = (((this.matrix.mi * _local_7) + (this.matrix.mj * _local_8)) + (this.matrix.mk * _local_9));
|
||||
_local_16 = (((this.matrix.ma * _local_10) + (this.matrix.mb * _local_11)) + (this.matrix.mc * _local_12));
|
||||
_local_17 = (((this.matrix.me * _local_10) + (this.matrix.mf * _local_11)) + (this.matrix.mg * _local_12));
|
||||
_local_18 = (((this.matrix.mi * _local_10) + (this.matrix.mj * _local_11)) + (this.matrix.mk * _local_12));
|
||||
_arg_4.x = ((_local_15 * _local_17) - (_local_14 * _local_18));
|
||||
_arg_4.y = ((_local_13 * _local_18) - (_local_15 * _local_16));
|
||||
_arg_4.z = ((_local_14 * _local_16) - (_local_13 * _local_17));
|
||||
_arg_4.normalize();
|
||||
_arg_4.w = (((_arg_3.x * _arg_4.x) + (_arg_3.y * _arg_4.y)) + (_arg_3.z * _arg_4.z));
|
||||
this.faces.length = 0;
|
||||
return (true);
|
||||
};
|
||||
this.faces.length = 0;
|
||||
return (false);
|
||||
};
|
||||
return (false);
|
||||
}
|
||||
|
||||
private function checkCollision():Boolean{
|
||||
var _local_4:Face;
|
||||
var _local_5:Wrapper;
|
||||
var _local_6:Vertex;
|
||||
var _local_7:Vertex;
|
||||
var _local_8:Vertex;
|
||||
var _local_9:Number;
|
||||
var _local_10:Number;
|
||||
var _local_11:Number;
|
||||
var _local_12:Number;
|
||||
var _local_13:Number;
|
||||
var _local_14:Number;
|
||||
var _local_15:Number;
|
||||
var _local_16:Number;
|
||||
var _local_17:Number;
|
||||
var _local_18:Number;
|
||||
var _local_19:Number;
|
||||
var _local_20:Number;
|
||||
var _local_21:Number;
|
||||
var _local_22:Number;
|
||||
var _local_23:Number;
|
||||
var _local_24:Number;
|
||||
var _local_25:Number;
|
||||
var _local_26:Number;
|
||||
var _local_27:Number;
|
||||
var _local_28:Boolean;
|
||||
var _local_29:Wrapper;
|
||||
var _local_30:Number;
|
||||
var _local_31:Number;
|
||||
var _local_32:Number;
|
||||
var _local_33:Number;
|
||||
var _local_34:Number;
|
||||
var _local_35:Number;
|
||||
var _local_36:Number;
|
||||
var _local_37:Number;
|
||||
var _local_38:Number;
|
||||
var _local_39:Number;
|
||||
var _local_40:Number;
|
||||
var _local_41:Number;
|
||||
var _local_42:Number;
|
||||
var _local_43:Number;
|
||||
var _local_44:Number;
|
||||
var _local_45:Number;
|
||||
var _local_46:Number;
|
||||
var _local_1:Number = 1;
|
||||
var _local_2:Number = this.displ.length;
|
||||
var _local_3:int;
|
||||
for (;_local_3 < this.facesLength;_local_3++)
|
||||
{
|
||||
_local_4 = this.faces[_local_3];
|
||||
_local_5 = _local_4.wrapper;
|
||||
_local_6 = _local_5.vertex;
|
||||
_local_5 = _local_5.next;
|
||||
_local_7 = _local_5.vertex;
|
||||
_local_5 = _local_5.next;
|
||||
_local_8 = _local_5.vertex;
|
||||
_local_9 = (_local_7.cameraX - _local_6.cameraX);
|
||||
_local_10 = (_local_7.cameraY - _local_6.cameraY);
|
||||
_local_11 = (_local_7.cameraZ - _local_6.cameraZ);
|
||||
_local_12 = (_local_8.cameraX - _local_6.cameraX);
|
||||
_local_13 = (_local_8.cameraY - _local_6.cameraY);
|
||||
_local_14 = (_local_8.cameraZ - _local_6.cameraZ);
|
||||
_local_15 = ((_local_14 * _local_10) - (_local_13 * _local_11));
|
||||
_local_16 = ((_local_12 * _local_11) - (_local_14 * _local_9));
|
||||
_local_17 = ((_local_13 * _local_9) - (_local_12 * _local_10));
|
||||
_local_18 = (((_local_15 * _local_15) + (_local_16 * _local_16)) + (_local_17 * _local_17));
|
||||
if (_local_18 > 0.001)
|
||||
{
|
||||
_local_18 = (1 / Math.sqrt(_local_18));
|
||||
_local_15 = (_local_15 * _local_18);
|
||||
_local_16 = (_local_16 * _local_18);
|
||||
_local_17 = (_local_17 * _local_18);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
};
|
||||
_local_19 = (((_local_6.cameraX * _local_15) + (_local_6.cameraY * _local_16)) + (_local_6.cameraZ * _local_17));
|
||||
_local_20 = ((((this.src.x * _local_15) + (this.src.y * _local_16)) + (this.src.z * _local_17)) - _local_19);
|
||||
if (_local_20 < this.radius)
|
||||
{
|
||||
_local_21 = (this.src.x - (_local_15 * _local_20));
|
||||
_local_22 = (this.src.y - (_local_16 * _local_20));
|
||||
_local_23 = (this.src.z - (_local_17 * _local_20));
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_33 = ((_local_20 - this.radius) / ((((_local_20 - (this.dest.x * _local_15)) - (this.dest.y * _local_16)) - (this.dest.z * _local_17)) + _local_19));
|
||||
_local_21 = ((this.src.x + (this.displ.x * _local_33)) - (_local_15 * this.radius));
|
||||
_local_22 = ((this.src.y + (this.displ.y * _local_33)) - (_local_16 * this.radius));
|
||||
_local_23 = ((this.src.z + (this.displ.z * _local_33)) - (_local_17 * this.radius));
|
||||
};
|
||||
_local_27 = 1E22;
|
||||
_local_28 = true;
|
||||
_local_29 = _local_4.wrapper;
|
||||
while (_local_29 != null)
|
||||
{
|
||||
_local_6 = _local_29.vertex;
|
||||
_local_7 = ((_local_29.next != null) ? _local_29.next.vertex : _local_4.wrapper.vertex);
|
||||
_local_9 = (_local_7.cameraX - _local_6.cameraX);
|
||||
_local_10 = (_local_7.cameraY - _local_6.cameraY);
|
||||
_local_11 = (_local_7.cameraZ - _local_6.cameraZ);
|
||||
_local_12 = (_local_21 - _local_6.cameraX);
|
||||
_local_13 = (_local_22 - _local_6.cameraY);
|
||||
_local_14 = (_local_23 - _local_6.cameraZ);
|
||||
_local_34 = ((_local_14 * _local_10) - (_local_13 * _local_11));
|
||||
_local_35 = ((_local_12 * _local_11) - (_local_14 * _local_9));
|
||||
_local_36 = ((_local_13 * _local_9) - (_local_12 * _local_10));
|
||||
if ((((_local_34 * _local_15) + (_local_35 * _local_16)) + (_local_36 * _local_17)) < 0)
|
||||
{
|
||||
_local_37 = (((_local_9 * _local_9) + (_local_10 * _local_10)) + (_local_11 * _local_11));
|
||||
_local_38 = ((((_local_34 * _local_34) + (_local_35 * _local_35)) + (_local_36 * _local_36)) / _local_37);
|
||||
if (_local_38 < _local_27)
|
||||
{
|
||||
_local_37 = Math.sqrt(_local_37);
|
||||
_local_9 = (_local_9 / _local_37);
|
||||
_local_10 = (_local_10 / _local_37);
|
||||
_local_11 = (_local_11 / _local_37);
|
||||
_local_33 = (((_local_9 * _local_12) + (_local_10 * _local_13)) + (_local_11 * _local_14));
|
||||
if (_local_33 < 0)
|
||||
{
|
||||
_local_39 = (((_local_12 * _local_12) + (_local_13 * _local_13)) + (_local_14 * _local_14));
|
||||
if (_local_39 < _local_27)
|
||||
{
|
||||
_local_27 = _local_39;
|
||||
_local_24 = _local_6.cameraX;
|
||||
_local_25 = _local_6.cameraY;
|
||||
_local_26 = _local_6.cameraZ;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_local_33 > _local_37)
|
||||
{
|
||||
_local_12 = (_local_21 - _local_7.cameraX);
|
||||
_local_13 = (_local_22 - _local_7.cameraY);
|
||||
_local_14 = (_local_23 - _local_7.cameraZ);
|
||||
_local_39 = (((_local_12 * _local_12) + (_local_13 * _local_13)) + (_local_14 * _local_14));
|
||||
if (_local_39 < _local_27)
|
||||
{
|
||||
_local_27 = _local_39;
|
||||
_local_24 = _local_7.cameraX;
|
||||
_local_25 = _local_7.cameraY;
|
||||
_local_26 = _local_7.cameraZ;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_27 = _local_38;
|
||||
_local_24 = (_local_6.cameraX + (_local_9 * _local_33));
|
||||
_local_25 = (_local_6.cameraY + (_local_10 * _local_33));
|
||||
_local_26 = (_local_6.cameraZ + (_local_11 * _local_33));
|
||||
};
|
||||
};
|
||||
};
|
||||
_local_28 = false;
|
||||
};
|
||||
_local_29 = _local_29.next;
|
||||
};
|
||||
if (_local_28)
|
||||
{
|
||||
_local_24 = _local_21;
|
||||
_local_25 = _local_22;
|
||||
_local_26 = _local_23;
|
||||
};
|
||||
_local_30 = (this.src.x - _local_24);
|
||||
_local_31 = (this.src.y - _local_25);
|
||||
_local_32 = (this.src.z - _local_26);
|
||||
if ((((_local_30 * this.displ.x) + (_local_31 * this.displ.y)) + (_local_32 * this.displ.z)) <= 0)
|
||||
{
|
||||
_local_40 = (-(this.displ.x) / _local_2);
|
||||
_local_41 = (-(this.displ.y) / _local_2);
|
||||
_local_42 = (-(this.displ.z) / _local_2);
|
||||
_local_43 = (((_local_30 * _local_30) + (_local_31 * _local_31)) + (_local_32 * _local_32));
|
||||
_local_44 = (((_local_30 * _local_40) + (_local_31 * _local_41)) + (_local_32 * _local_42));
|
||||
_local_45 = (((this.radius * this.radius) - _local_43) + (_local_44 * _local_44));
|
||||
if (_local_45 > 0)
|
||||
{
|
||||
_local_46 = ((_local_44 - Math.sqrt(_local_45)) / _local_2);
|
||||
if (_local_46 < _local_1)
|
||||
{
|
||||
_local_1 = _local_46;
|
||||
this.collisionPoint.x = _local_24;
|
||||
this.collisionPoint.y = _local_25;
|
||||
this.collisionPoint.z = _local_26;
|
||||
if (_local_28)
|
||||
{
|
||||
this.collisionPlane.x = _local_15;
|
||||
this.collisionPlane.y = _local_16;
|
||||
this.collisionPlane.z = _local_17;
|
||||
this.collisionPlane.w = _local_19;
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_43 = Math.sqrt(_local_43);
|
||||
this.collisionPlane.x = (_local_30 / _local_43);
|
||||
this.collisionPlane.y = (_local_31 / _local_43);
|
||||
this.collisionPlane.z = (_local_32 / _local_43);
|
||||
this.collisionPlane.w = (((this.collisionPoint.x * this.collisionPlane.x) + (this.collisionPoint.y * this.collisionPlane.y)) + (this.collisionPoint.z * this.collisionPlane.z));
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
return (_local_1 < 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
256
src/alternativa/engine3d/core/Face.as
Normal file
256
src/alternativa/engine3d/core/Face.as
Normal file
@@ -0,0 +1,256 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.materials.Material;
|
||||
import flash.geom.Vector3D;
|
||||
import __AS3__.vec.Vector;
|
||||
import flash.geom.Point;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Face
|
||||
{
|
||||
|
||||
alternativa3d static var collector:Face;
|
||||
|
||||
public var material:Material;
|
||||
public var smoothingGroups:uint = 0;
|
||||
alternativa3d var normalX:Number;
|
||||
alternativa3d var normalY:Number;
|
||||
alternativa3d var normalZ:Number;
|
||||
alternativa3d var offset:Number;
|
||||
alternativa3d var wrapper:Wrapper;
|
||||
alternativa3d var next:Face;
|
||||
alternativa3d var processNext:Face;
|
||||
alternativa3d var processNegative:Face;
|
||||
alternativa3d var processPositive:Face;
|
||||
alternativa3d var distance:Number;
|
||||
alternativa3d var geometry:VG;
|
||||
public var id:Object;
|
||||
|
||||
|
||||
alternativa3d static function create():Face
|
||||
{
|
||||
var _local_1:Face;
|
||||
if (collector != null)
|
||||
{
|
||||
_local_1 = collector;
|
||||
collector = _local_1.next;
|
||||
_local_1.next = null;
|
||||
return (_local_1);
|
||||
};
|
||||
return (new (Face)());
|
||||
}
|
||||
|
||||
|
||||
alternativa3d function create():Face
|
||||
{
|
||||
var _local_1:Face;
|
||||
if (collector != null)
|
||||
{
|
||||
_local_1 = collector;
|
||||
collector = _local_1.next;
|
||||
_local_1.next = null;
|
||||
return (_local_1);
|
||||
};
|
||||
return (new Face());
|
||||
}
|
||||
|
||||
public function get normal():Vector3D
|
||||
{
|
||||
var _local_1:Wrapper = this.wrapper;
|
||||
var _local_2:Vertex = _local_1.vertex;
|
||||
_local_1 = _local_1.next;
|
||||
var _local_3:Vertex = _local_1.vertex;
|
||||
_local_1 = _local_1.next;
|
||||
var _local_4:Vertex = _local_1.vertex;
|
||||
var _local_5:Number = (_local_3.x - _local_2.x);
|
||||
var _local_6:Number = (_local_3.y - _local_2.y);
|
||||
var _local_7:Number = (_local_3.z - _local_2.z);
|
||||
var _local_8:Number = (_local_4.x - _local_2.x);
|
||||
var _local_9:Number = (_local_4.y - _local_2.y);
|
||||
var _local_10:Number = (_local_4.z - _local_2.z);
|
||||
var _local_11:Number = ((_local_10 * _local_6) - (_local_9 * _local_7));
|
||||
var _local_12:Number = ((_local_8 * _local_7) - (_local_10 * _local_5));
|
||||
var _local_13:Number = ((_local_9 * _local_5) - (_local_8 * _local_6));
|
||||
var _local_14:Number = (((_local_11 * _local_11) + (_local_12 * _local_12)) + (_local_13 * _local_13));
|
||||
if (_local_14 > 0.001)
|
||||
{
|
||||
_local_14 = (1 / Math.sqrt(_local_14));
|
||||
_local_11 = (_local_11 * _local_14);
|
||||
_local_12 = (_local_12 * _local_14);
|
||||
_local_13 = (_local_13 * _local_14);
|
||||
};
|
||||
return (new Vector3D(_local_11, _local_12, _local_13, (((_local_2.x * _local_11) + (_local_2.y * _local_12)) + (_local_2.z * _local_13))));
|
||||
}
|
||||
|
||||
public function get vertices():Vector.<Vertex>
|
||||
{
|
||||
var _local_1:Vector.<Vertex> = new Vector.<Vertex>();
|
||||
var _local_2:int;
|
||||
var _local_3:Wrapper = this.wrapper;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
_local_1[_local_2] = _local_3.vertex;
|
||||
_local_2++;
|
||||
_local_3 = _local_3.next;
|
||||
};
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
public function getUV(_arg_1:Vector3D):Point
|
||||
{
|
||||
var _local_2:Vertex = this.wrapper.vertex;
|
||||
var _local_3:Vertex = this.wrapper.next.vertex;
|
||||
var _local_4:Vertex = this.wrapper.next.next.vertex;
|
||||
var _local_5:Number = (_local_3.x - _local_2.x);
|
||||
var _local_6:Number = (_local_3.y - _local_2.y);
|
||||
var _local_7:Number = (_local_3.z - _local_2.z);
|
||||
var _local_8:Number = (_local_3.u - _local_2.u);
|
||||
var _local_9:Number = (_local_3.v - _local_2.v);
|
||||
var _local_10:Number = (_local_4.x - _local_2.x);
|
||||
var _local_11:Number = (_local_4.y - _local_2.y);
|
||||
var _local_12:Number = (_local_4.z - _local_2.z);
|
||||
var _local_13:Number = (_local_4.u - _local_2.u);
|
||||
var _local_14:Number = (_local_4.v - _local_2.v);
|
||||
var _local_15:Number = (((((((-(this.normalX) * _local_11) * _local_7) + ((_local_10 * this.normalY) * _local_7)) + ((this.normalX * _local_6) * _local_12)) - ((_local_5 * this.normalY) * _local_12)) - ((_local_10 * _local_6) * this.normalZ)) + ((_local_5 * _local_11) * this.normalZ));
|
||||
var _local_16:Number = (((-(this.normalY) * _local_12) + (_local_11 * this.normalZ)) / _local_15);
|
||||
var _local_17:Number = (((this.normalX * _local_12) - (_local_10 * this.normalZ)) / _local_15);
|
||||
var _local_18:Number = (((-(this.normalX) * _local_11) + (_local_10 * this.normalY)) / _local_15);
|
||||
var _local_19:Number = ((((((((_local_2.x * this.normalY) * _local_12) - ((this.normalX * _local_2.y) * _local_12)) - ((_local_2.x * _local_11) * this.normalZ)) + ((_local_10 * _local_2.y) * this.normalZ)) + ((this.normalX * _local_11) * _local_2.z)) - ((_local_10 * this.normalY) * _local_2.z)) / _local_15);
|
||||
var _local_20:Number = (((this.normalY * _local_7) - (_local_6 * this.normalZ)) / _local_15);
|
||||
var _local_21:Number = (((-(this.normalX) * _local_7) + (_local_5 * this.normalZ)) / _local_15);
|
||||
var _local_22:Number = (((this.normalX * _local_6) - (_local_5 * this.normalY)) / _local_15);
|
||||
var _local_23:Number = ((((((((this.normalX * _local_2.y) * _local_7) - ((_local_2.x * this.normalY) * _local_7)) + ((_local_2.x * _local_6) * this.normalZ)) - ((_local_5 * _local_2.y) * this.normalZ)) - ((this.normalX * _local_6) * _local_2.z)) + ((_local_5 * this.normalY) * _local_2.z)) / _local_15);
|
||||
var _local_24:Number = ((_local_8 * _local_16) + (_local_13 * _local_20));
|
||||
var _local_25:Number = ((_local_8 * _local_17) + (_local_13 * _local_21));
|
||||
var _local_26:Number = ((_local_8 * _local_18) + (_local_13 * _local_22));
|
||||
var _local_27:Number = (((_local_8 * _local_19) + (_local_13 * _local_23)) + _local_2.u);
|
||||
var _local_28:Number = ((_local_9 * _local_16) + (_local_14 * _local_20));
|
||||
var _local_29:Number = ((_local_9 * _local_17) + (_local_14 * _local_21));
|
||||
var _local_30:Number = ((_local_9 * _local_18) + (_local_14 * _local_22));
|
||||
var _local_31:Number = (((_local_9 * _local_19) + (_local_14 * _local_23)) + _local_2.v);
|
||||
return (new Point(((((_local_24 * _arg_1.x) + (_local_25 * _arg_1.y)) + (_local_26 * _arg_1.z)) + _local_27), ((((_local_28 * _arg_1.x) + (_local_29 * _arg_1.y)) + (_local_30 * _arg_1.z)) + _local_31)));
|
||||
}
|
||||
|
||||
public function toString():String
|
||||
{
|
||||
return (("[Face " + this.id) + "]");
|
||||
}
|
||||
|
||||
alternativa3d function calculateBestSequenceAndNormal():void
|
||||
{
|
||||
var _local_1:Wrapper;
|
||||
var _local_2:Vertex;
|
||||
var _local_3:Vertex;
|
||||
var _local_4:Vertex;
|
||||
var _local_5:Number;
|
||||
var _local_6:Number;
|
||||
var _local_7:Number;
|
||||
var _local_8:Number;
|
||||
var _local_9:Number;
|
||||
var _local_10:Number;
|
||||
var _local_11:Number;
|
||||
var _local_12:Number;
|
||||
var _local_13:Number;
|
||||
var _local_14:Number;
|
||||
var _local_15:Number;
|
||||
var _local_16:Wrapper;
|
||||
var _local_17:Wrapper;
|
||||
var _local_18:Wrapper;
|
||||
var _local_19:Wrapper;
|
||||
var _local_20:Wrapper;
|
||||
if (this.wrapper.next.next.next != null)
|
||||
{
|
||||
_local_15 = -1E22;
|
||||
_local_1 = this.wrapper;
|
||||
while (_local_1 != null)
|
||||
{
|
||||
_local_19 = ((_local_1.next != null) ? _local_1.next : this.wrapper);
|
||||
_local_20 = ((_local_19.next != null) ? _local_19.next : this.wrapper);
|
||||
_local_2 = _local_1.vertex;
|
||||
_local_3 = _local_19.vertex;
|
||||
_local_4 = _local_20.vertex;
|
||||
_local_5 = (_local_3.x - _local_2.x);
|
||||
_local_6 = (_local_3.y - _local_2.y);
|
||||
_local_7 = (_local_3.z - _local_2.z);
|
||||
_local_8 = (_local_4.x - _local_2.x);
|
||||
_local_9 = (_local_4.y - _local_2.y);
|
||||
_local_10 = (_local_4.z - _local_2.z);
|
||||
_local_11 = ((_local_10 * _local_6) - (_local_9 * _local_7));
|
||||
_local_12 = ((_local_8 * _local_7) - (_local_10 * _local_5));
|
||||
_local_13 = ((_local_9 * _local_5) - (_local_8 * _local_6));
|
||||
_local_14 = (((_local_11 * _local_11) + (_local_12 * _local_12)) + (_local_13 * _local_13));
|
||||
if (_local_14 > _local_15)
|
||||
{
|
||||
_local_15 = _local_14;
|
||||
_local_16 = _local_1;
|
||||
};
|
||||
_local_1 = _local_1.next;
|
||||
};
|
||||
if (_local_16 != this.wrapper)
|
||||
{
|
||||
_local_17 = this.wrapper.next.next.next;
|
||||
while (_local_17.next != null)
|
||||
{
|
||||
_local_17 = _local_17.next;
|
||||
};
|
||||
_local_18 = this.wrapper;
|
||||
while (((!(_local_18.next == _local_16)) && (!(_local_18.next == null))))
|
||||
{
|
||||
_local_18 = _local_18.next;
|
||||
};
|
||||
_local_17.next = this.wrapper;
|
||||
_local_18.next = null;
|
||||
this.wrapper = _local_16;
|
||||
};
|
||||
};
|
||||
_local_1 = this.wrapper;
|
||||
_local_2 = _local_1.vertex;
|
||||
_local_1 = _local_1.next;
|
||||
_local_3 = _local_1.vertex;
|
||||
_local_1 = _local_1.next;
|
||||
_local_4 = _local_1.vertex;
|
||||
_local_5 = (_local_3.x - _local_2.x);
|
||||
_local_6 = (_local_3.y - _local_2.y);
|
||||
_local_7 = (_local_3.z - _local_2.z);
|
||||
_local_8 = (_local_4.x - _local_2.x);
|
||||
_local_9 = (_local_4.y - _local_2.y);
|
||||
_local_10 = (_local_4.z - _local_2.z);
|
||||
_local_11 = ((_local_10 * _local_6) - (_local_9 * _local_7));
|
||||
_local_12 = ((_local_8 * _local_7) - (_local_10 * _local_5));
|
||||
_local_13 = ((_local_9 * _local_5) - (_local_8 * _local_6));
|
||||
_local_14 = (((_local_11 * _local_11) + (_local_12 * _local_12)) + (_local_13 * _local_13));
|
||||
if (_local_14 > 0)
|
||||
{
|
||||
_local_14 = (1 / Math.sqrt(_local_14));
|
||||
_local_11 = (_local_11 * _local_14);
|
||||
_local_12 = (_local_12 * _local_14);
|
||||
_local_13 = (_local_13 * _local_14);
|
||||
this.normalX = _local_11;
|
||||
this.normalY = _local_12;
|
||||
this.normalZ = _local_13;
|
||||
};
|
||||
this.offset = (((_local_2.x * _local_11) + (_local_2.y * _local_12)) + (_local_2.z * _local_13));
|
||||
}
|
||||
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
this.material = null;
|
||||
if(this.wrapper != null)
|
||||
{
|
||||
this.wrapper.destroy();
|
||||
this.wrapper = null;
|
||||
}
|
||||
if(this.geometry != null)
|
||||
{
|
||||
this.geometry.destroy();
|
||||
this.geometry = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
406
src/alternativa/engine3d/core/Light3D.as
Normal file
406
src/alternativa/engine3d/core/Light3D.as
Normal file
@@ -0,0 +1,406 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Light3D extends Object3D
|
||||
{
|
||||
|
||||
public var color:uint;
|
||||
public var intensity:Number = 1;
|
||||
alternativa3d var localWeight:Number;
|
||||
alternativa3d var localRed:Number;
|
||||
alternativa3d var localGreen:Number;
|
||||
alternativa3d var localBlue:Number;
|
||||
alternativa3d var cma:Number;
|
||||
alternativa3d var cmb:Number;
|
||||
alternativa3d var cmc:Number;
|
||||
alternativa3d var cmd:Number;
|
||||
alternativa3d var cme:Number;
|
||||
alternativa3d var cmf:Number;
|
||||
alternativa3d var cmg:Number;
|
||||
alternativa3d var cmh:Number;
|
||||
alternativa3d var cmi:Number;
|
||||
alternativa3d var cmj:Number;
|
||||
alternativa3d var cmk:Number;
|
||||
alternativa3d var cml:Number;
|
||||
alternativa3d var oma:Number;
|
||||
alternativa3d var omb:Number;
|
||||
alternativa3d var omc:Number;
|
||||
alternativa3d var omd:Number;
|
||||
alternativa3d var ome:Number;
|
||||
alternativa3d var omf:Number;
|
||||
alternativa3d var omg:Number;
|
||||
alternativa3d var omh:Number;
|
||||
alternativa3d var omi:Number;
|
||||
alternativa3d var omj:Number;
|
||||
alternativa3d var omk:Number;
|
||||
alternativa3d var oml:Number;
|
||||
alternativa3d var nextLight:Light3D;
|
||||
|
||||
|
||||
override public function clone():Object3D
|
||||
{
|
||||
var _local_1:Light3D = new Light3D();
|
||||
_local_1.clonePropertiesFrom(this);
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
override protected function clonePropertiesFrom(_arg_1:Object3D):void
|
||||
{
|
||||
super.clonePropertiesFrom(_arg_1);
|
||||
var _local_2:Light3D = (_arg_1 as Light3D);
|
||||
this.color = _local_2.color;
|
||||
this.intensity = _local_2.intensity;
|
||||
}
|
||||
|
||||
alternativa3d function calculateCameraMatrix(_arg_1:Camera3D):void
|
||||
{
|
||||
composeMatrix();
|
||||
var _local_2:Object3D = this;
|
||||
while (_local_2._parent != null)
|
||||
{
|
||||
_local_2 = _local_2._parent;
|
||||
_local_2.composeMatrix();
|
||||
appendMatrix(_local_2);
|
||||
};
|
||||
appendMatrix(_arg_1);
|
||||
this.cma = ma;
|
||||
this.cmb = mb;
|
||||
this.cmc = mc;
|
||||
this.cmd = md;
|
||||
this.cme = me;
|
||||
this.cmf = mf;
|
||||
this.cmg = mg;
|
||||
this.cmh = mh;
|
||||
this.cmi = mi;
|
||||
this.cmj = mj;
|
||||
this.cmk = mk;
|
||||
this.cml = ml;
|
||||
}
|
||||
|
||||
alternativa3d function calculateObjectMatrix(_arg_1:Object3D):void
|
||||
{
|
||||
this.oma = (((_arg_1.ima * this.cma) + (_arg_1.imb * this.cme)) + (_arg_1.imc * this.cmi));
|
||||
this.omb = (((_arg_1.ima * this.cmb) + (_arg_1.imb * this.cmf)) + (_arg_1.imc * this.cmj));
|
||||
this.omc = (((_arg_1.ima * this.cmc) + (_arg_1.imb * this.cmg)) + (_arg_1.imc * this.cmk));
|
||||
this.omd = ((((_arg_1.ima * this.cmd) + (_arg_1.imb * this.cmh)) + (_arg_1.imc * this.cml)) + _arg_1.imd);
|
||||
this.ome = (((_arg_1.ime * this.cma) + (_arg_1.imf * this.cme)) + (_arg_1.img * this.cmi));
|
||||
this.omf = (((_arg_1.ime * this.cmb) + (_arg_1.imf * this.cmf)) + (_arg_1.img * this.cmj));
|
||||
this.omg = (((_arg_1.ime * this.cmc) + (_arg_1.imf * this.cmg)) + (_arg_1.img * this.cmk));
|
||||
this.omh = ((((_arg_1.ime * this.cmd) + (_arg_1.imf * this.cmh)) + (_arg_1.img * this.cml)) + _arg_1.imh);
|
||||
this.omi = (((_arg_1.imi * this.cma) + (_arg_1.imj * this.cme)) + (_arg_1.imk * this.cmi));
|
||||
this.omj = (((_arg_1.imi * this.cmb) + (_arg_1.imj * this.cmf)) + (_arg_1.imk * this.cmj));
|
||||
this.omk = (((_arg_1.imi * this.cmc) + (_arg_1.imj * this.cmg)) + (_arg_1.imk * this.cmk));
|
||||
this.oml = ((((_arg_1.imi * this.cmd) + (_arg_1.imj * this.cmh)) + (_arg_1.imk * this.cml)) + _arg_1.iml);
|
||||
}
|
||||
|
||||
override alternativa3d function setParent(_arg_1:Object3DContainer):void
|
||||
{
|
||||
var _local_2:Object3DContainer;
|
||||
var _local_3:Light3D;
|
||||
var _local_4:Light3D;
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
_local_2 = _parent;
|
||||
while (_local_2._parent != null)
|
||||
{
|
||||
_local_2 = _local_2._parent;
|
||||
};
|
||||
_local_4 = _local_2.lightList;
|
||||
while (_local_4 != null)
|
||||
{
|
||||
if (_local_4 == this)
|
||||
{
|
||||
if (_local_3 != null)
|
||||
{
|
||||
_local_3.nextLight = this.nextLight;
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_2.lightList = this.nextLight;
|
||||
};
|
||||
this.nextLight = null;
|
||||
break;
|
||||
};
|
||||
_local_3 = _local_4;
|
||||
_local_4 = _local_4.nextLight;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_2 = _arg_1;
|
||||
while (_local_2._parent != null)
|
||||
{
|
||||
_local_2 = _local_2._parent;
|
||||
};
|
||||
this.nextLight = _local_2.lightList;
|
||||
_local_2.lightList = this;
|
||||
};
|
||||
_parent = _arg_1;
|
||||
}
|
||||
|
||||
alternativa3d function drawDebug(_arg_1:Camera3D):void
|
||||
{
|
||||
}
|
||||
|
||||
override alternativa3d function updateBounds(_arg_1:Object3D, _arg_2:Object3D=null):void
|
||||
{
|
||||
_arg_1.boundMinX = -1E22;
|
||||
_arg_1.boundMinY = -1E22;
|
||||
_arg_1.boundMinZ = -1E22;
|
||||
_arg_1.boundMaxX = 1E22;
|
||||
_arg_1.boundMaxY = 1E22;
|
||||
_arg_1.boundMaxZ = 1E22;
|
||||
}
|
||||
|
||||
override alternativa3d function cullingInCamera(_arg_1:Camera3D, _arg_2:int):int
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
alternativa3d function checkFrustumCulling(_arg_1:Camera3D):Boolean
|
||||
{
|
||||
var _local_2:Vertex = boundVertexList;
|
||||
_local_2.x = boundMinX;
|
||||
_local_2.y = boundMinY;
|
||||
_local_2.z = boundMinZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = boundMaxX;
|
||||
_local_2.y = boundMinY;
|
||||
_local_2.z = boundMinZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = boundMinX;
|
||||
_local_2.y = boundMaxY;
|
||||
_local_2.z = boundMinZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = boundMaxX;
|
||||
_local_2.y = boundMaxY;
|
||||
_local_2.z = boundMinZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = boundMinX;
|
||||
_local_2.y = boundMinY;
|
||||
_local_2.z = boundMaxZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = boundMaxX;
|
||||
_local_2.y = boundMinY;
|
||||
_local_2.z = boundMaxZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = boundMinX;
|
||||
_local_2.y = boundMaxY;
|
||||
_local_2.z = boundMaxZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = boundMaxX;
|
||||
_local_2.y = boundMaxY;
|
||||
_local_2.z = boundMaxZ;
|
||||
_local_2 = boundVertexList;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
_local_2.cameraX = ((((ma * _local_2.x) + (mb * _local_2.y)) + (mc * _local_2.z)) + md);
|
||||
_local_2.cameraY = ((((me * _local_2.x) + (mf * _local_2.y)) + (mg * _local_2.z)) + mh);
|
||||
_local_2.cameraZ = ((((mi * _local_2.x) + (mj * _local_2.y)) + (mk * _local_2.z)) + ml);
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
_local_2 = boundVertexList;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (_local_2.cameraZ > _arg_1.nearClipping) break;
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (_local_2 == null)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = boundVertexList;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (_local_2.cameraZ < _arg_1.farClipping) break;
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (_local_2 == null)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = boundVertexList;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (-(_local_2.cameraX) < _local_2.cameraZ) break;
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (_local_2 == null)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = boundVertexList;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (_local_2.cameraX < _local_2.cameraZ) break;
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (_local_2 == null)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = boundVertexList;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (-(_local_2.cameraY) < _local_2.cameraZ) break;
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (_local_2 == null)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = boundVertexList;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (_local_2.cameraY < _local_2.cameraZ) break;
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (_local_2 == null)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
return (true);
|
||||
}
|
||||
|
||||
alternativa3d function checkBoundsIntersection(_arg_1:Object3D):Boolean
|
||||
{
|
||||
var _local_2:Number;
|
||||
var _local_3:Number;
|
||||
var _local_4:Number = ((boundMaxX - boundMinX) * 0.5);
|
||||
var _local_5:Number = ((boundMaxY - boundMinY) * 0.5);
|
||||
var _local_6:Number = ((boundMaxZ - boundMinZ) * 0.5);
|
||||
var _local_7:Number = (this.oma * _local_4);
|
||||
var _local_8:Number = (this.ome * _local_4);
|
||||
var _local_9:Number = (this.omi * _local_4);
|
||||
var _local_10:Number = (this.omb * _local_5);
|
||||
var _local_11:Number = (this.omf * _local_5);
|
||||
var _local_12:Number = (this.omj * _local_5);
|
||||
var _local_13:Number = (this.omc * _local_6);
|
||||
var _local_14:Number = (this.omg * _local_6);
|
||||
var _local_15:Number = (this.omk * _local_6);
|
||||
var _local_16:Number = ((_arg_1.boundMaxX - _arg_1.boundMinX) * 0.5);
|
||||
var _local_17:Number = ((_arg_1.boundMaxY - _arg_1.boundMinY) * 0.5);
|
||||
var _local_18:Number = ((_arg_1.boundMaxZ - _arg_1.boundMinZ) * 0.5);
|
||||
var _local_19:Number = ((((((this.oma * (boundMinX + _local_4)) + (this.omb * (boundMinY + _local_5))) + (this.omc * (boundMinZ + _local_6))) + this.omd) - _arg_1.boundMinX) - _local_16);
|
||||
var _local_20:Number = ((((((this.ome * (boundMinX + _local_4)) + (this.omf * (boundMinY + _local_5))) + (this.omg * (boundMinZ + _local_6))) + this.omh) - _arg_1.boundMinY) - _local_17);
|
||||
var _local_21:Number = ((((((this.omi * (boundMinX + _local_4)) + (this.omj * (boundMinY + _local_5))) + (this.omk * (boundMinZ + _local_6))) + this.oml) - _arg_1.boundMinZ) - _local_18);
|
||||
_local_2 = 0;
|
||||
_local_3 = ((_local_7 >= 0) ? _local_7 : -(_local_7));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((_local_10 >= 0) ? _local_10 : -(_local_10));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((_local_13 >= 0) ? _local_13 : -(_local_13));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_2 = (_local_2 + _local_16);
|
||||
_local_3 = ((_local_19 >= 0) ? _local_19 : -(_local_19));
|
||||
_local_2 = (_local_2 - _local_3);
|
||||
if (_local_2 <= 0)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = 0;
|
||||
_local_3 = ((_local_8 >= 0) ? _local_8 : -(_local_8));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((_local_11 >= 0) ? _local_11 : -(_local_11));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((_local_14 >= 0) ? _local_14 : -(_local_14));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_2 = (_local_2 + _local_17);
|
||||
_local_3 = ((_local_20 >= 0) ? _local_20 : -(_local_20));
|
||||
_local_2 = (_local_2 - _local_3);
|
||||
if (_local_2 <= 0)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = 0;
|
||||
_local_3 = ((_local_9 >= 0) ? _local_9 : -(_local_9));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((_local_12 >= 0) ? _local_12 : -(_local_12));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((_local_15 >= 0) ? _local_15 : -(_local_15));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_2 = (_local_2 + _local_17);
|
||||
_local_3 = ((_local_21 >= 0) ? _local_21 : -(_local_21));
|
||||
_local_2 = (_local_2 - _local_3);
|
||||
if (_local_2 <= 0)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = 0;
|
||||
_local_3 = (((this.oma * _local_7) + (this.ome * _local_8)) + (this.omi * _local_9));
|
||||
_local_3 = ((_local_3 >= 0) ? _local_3 : -(_local_3));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = (((this.oma * _local_10) + (this.ome * _local_11)) + (this.omi * _local_12));
|
||||
_local_3 = ((_local_3 >= 0) ? _local_3 : -(_local_3));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = (((this.oma * _local_13) + (this.ome * _local_14)) + (this.omi * _local_15));
|
||||
_local_3 = ((_local_3 >= 0) ? _local_3 : -(_local_3));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((this.oma >= 0) ? (this.oma * _local_16) : (-(this.oma) * _local_16));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((this.ome >= 0) ? (this.ome * _local_17) : (-(this.ome) * _local_17));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((this.omi >= 0) ? (this.omi * _local_18) : (-(this.omi) * _local_18));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = (((this.oma * _local_19) + (this.ome * _local_20)) + (this.omi * _local_21));
|
||||
_local_3 = ((_local_3 >= 0) ? _local_3 : -(_local_3));
|
||||
_local_2 = (_local_2 - _local_3);
|
||||
if (_local_2 <= 0)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = 0;
|
||||
_local_3 = (((this.omb * _local_7) + (this.omf * _local_8)) + (this.omj * _local_9));
|
||||
_local_3 = ((_local_3 >= 0) ? _local_3 : -(_local_3));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = (((this.omb * _local_10) + (this.omf * _local_11)) + (this.omj * _local_12));
|
||||
_local_3 = ((_local_3 >= 0) ? _local_3 : -(_local_3));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = (((this.omb * _local_13) + (this.omf * _local_14)) + (this.omj * _local_15));
|
||||
_local_3 = ((_local_3 >= 0) ? _local_3 : -(_local_3));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((this.omb >= 0) ? (this.omb * _local_16) : (-(this.omb) * _local_16));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((this.omf >= 0) ? (this.omf * _local_17) : (-(this.omf) * _local_17));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((this.omj >= 0) ? (this.omj * _local_18) : (-(this.omj) * _local_18));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = (((this.omb * _local_19) + (this.omf * _local_20)) + (this.omj * _local_21));
|
||||
_local_3 = ((_local_3 >= 0) ? _local_3 : -(_local_3));
|
||||
_local_2 = (_local_2 - _local_3);
|
||||
if (_local_2 <= 0)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = 0;
|
||||
_local_3 = (((this.omc * _local_7) + (this.omg * _local_8)) + (this.omk * _local_9));
|
||||
_local_3 = ((_local_3 >= 0) ? _local_3 : -(_local_3));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = (((this.omc * _local_10) + (this.omg * _local_11)) + (this.omk * _local_12));
|
||||
_local_3 = ((_local_3 >= 0) ? _local_3 : -(_local_3));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = (((this.omc * _local_13) + (this.omg * _local_14)) + (this.omk * _local_15));
|
||||
_local_3 = ((_local_3 >= 0) ? _local_3 : -(_local_3));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((this.omc >= 0) ? (this.omc * _local_16) : (-(this.omc) * _local_16));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((this.omg >= 0) ? (this.omg * _local_17) : (-(this.omg) * _local_17));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = ((this.omk >= 0) ? (this.omk * _local_18) : (-(this.omk) * _local_18));
|
||||
_local_2 = (_local_2 + _local_3);
|
||||
_local_3 = (((this.omc * _local_19) + (this.omg * _local_20)) + (this.omk * _local_21));
|
||||
_local_3 = ((_local_3 >= 0) ? _local_3 : -(_local_3));
|
||||
_local_2 = (_local_2 - _local_3);
|
||||
if (_local_2 <= 0)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
18
src/alternativa/engine3d/core/MipMapping.as
Normal file
18
src/alternativa/engine3d/core/MipMapping.as
Normal file
@@ -0,0 +1,18 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
public class MipMapping
|
||||
{
|
||||
|
||||
public static const NONE:int = 0;
|
||||
|
||||
public static const OBJECT_DISTANCE:int = 1;
|
||||
|
||||
public static const PER_PIXEL:int = 2;
|
||||
|
||||
|
||||
public function MipMapping()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
117
src/alternativa/engine3d/core/MouseEvent3D.as
Normal file
117
src/alternativa/engine3d/core/MouseEvent3D.as
Normal file
@@ -0,0 +1,117 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.geom.Vector3D;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class MouseEvent3D extends Event
|
||||
{
|
||||
|
||||
public static const CLICK:String = "click3D";
|
||||
public static const DOUBLE_CLICK:String = "doubleClick3D";
|
||||
public static const MOUSE_DOWN:String = "mouseDown3D";
|
||||
public static const MOUSE_UP:String = "mouseUp3D";
|
||||
public static const MOUSE_OVER:String = "mouseOver3D";
|
||||
public static const MOUSE_OUT:String = "mouseOut3D";
|
||||
public static const ROLL_OVER:String = "rollOver3D";
|
||||
public static const ROLL_OUT:String = "rollOut3D";
|
||||
public static const MOUSE_MOVE:String = "mouseMove3D";
|
||||
public static const MOUSE_WHEEL:String = "mouseWheel3D";
|
||||
|
||||
public var ctrlKey:Boolean;
|
||||
public var altKey:Boolean;
|
||||
public var shiftKey:Boolean;
|
||||
public var buttonDown:Boolean;
|
||||
public var delta:int;
|
||||
public var relatedObject:Object3D;
|
||||
public var localOrigin:Vector3D = new Vector3D();
|
||||
public var localDirection:Vector3D = new Vector3D();
|
||||
alternativa3d var _target:Object3D;
|
||||
alternativa3d var _currentTarget:Object3D;
|
||||
alternativa3d var _bubbles:Boolean;
|
||||
alternativa3d var _eventPhase:uint = 3;
|
||||
alternativa3d var stop:Boolean = false;
|
||||
alternativa3d var stopImmediate:Boolean = false;
|
||||
|
||||
public function MouseEvent3D(_arg_1:String, _arg_2:Boolean=true, _arg_3:Object3D=null, _arg_4:Boolean=false, _arg_5:Boolean=false, _arg_6:Boolean=false, _arg_7:Boolean=false, _arg_8:int=0)
|
||||
{
|
||||
super(_arg_1, _arg_2);
|
||||
this.relatedObject = _arg_3;
|
||||
this.altKey = _arg_4;
|
||||
this.ctrlKey = _arg_5;
|
||||
this.shiftKey = _arg_6;
|
||||
this.buttonDown = _arg_7;
|
||||
this.delta = _arg_8;
|
||||
}
|
||||
|
||||
alternativa3d function calculateLocalRay(_arg_1:Number, _arg_2:Number, _arg_3:Object3D, _arg_4:Camera3D):void
|
||||
{
|
||||
_arg_4.calculateRay(this.localOrigin, this.localDirection, _arg_1, _arg_2);
|
||||
_arg_3.composeMatrix();
|
||||
var _local_5:Object3D = _arg_3;
|
||||
while (_local_5._parent != null)
|
||||
{
|
||||
_local_5 = _local_5._parent;
|
||||
_local_5.composeMatrix();
|
||||
_arg_3.appendMatrix(_local_5);
|
||||
};
|
||||
_arg_3.invertMatrix();
|
||||
var _local_6:Number = this.localOrigin.x;
|
||||
var _local_7:Number = this.localOrigin.y;
|
||||
var _local_8:Number = this.localOrigin.z;
|
||||
var _local_9:Number = this.localDirection.x;
|
||||
var _local_10:Number = this.localDirection.y;
|
||||
var _local_11:Number = this.localDirection.z;
|
||||
this.localOrigin.x = ((((_arg_3.ma * _local_6) + (_arg_3.mb * _local_7)) + (_arg_3.mc * _local_8)) + _arg_3.md);
|
||||
this.localOrigin.y = ((((_arg_3.me * _local_6) + (_arg_3.mf * _local_7)) + (_arg_3.mg * _local_8)) + _arg_3.mh);
|
||||
this.localOrigin.z = ((((_arg_3.mi * _local_6) + (_arg_3.mj * _local_7)) + (_arg_3.mk * _local_8)) + _arg_3.ml);
|
||||
this.localDirection.x = (((_arg_3.ma * _local_9) + (_arg_3.mb * _local_10)) + (_arg_3.mc * _local_11));
|
||||
this.localDirection.y = (((_arg_3.me * _local_9) + (_arg_3.mf * _local_10)) + (_arg_3.mg * _local_11));
|
||||
this.localDirection.z = (((_arg_3.mi * _local_9) + (_arg_3.mj * _local_10)) + (_arg_3.mk * _local_11));
|
||||
}
|
||||
|
||||
override public function get bubbles():Boolean
|
||||
{
|
||||
return (this._bubbles);
|
||||
}
|
||||
|
||||
override public function get eventPhase():uint
|
||||
{
|
||||
return (this._eventPhase);
|
||||
}
|
||||
|
||||
override public function get target():Object
|
||||
{
|
||||
return (this._target);
|
||||
}
|
||||
|
||||
override public function get currentTarget():Object
|
||||
{
|
||||
return (this._currentTarget);
|
||||
}
|
||||
|
||||
override public function stopPropagation():void
|
||||
{
|
||||
this.stop = true;
|
||||
}
|
||||
|
||||
override public function stopImmediatePropagation():void
|
||||
{
|
||||
this.stopImmediate = true;
|
||||
}
|
||||
|
||||
override public function clone():Event
|
||||
{
|
||||
return (new MouseEvent3D(type, this._bubbles, this.relatedObject, this.altKey, this.ctrlKey, this.shiftKey, this.buttonDown, this.delta));
|
||||
}
|
||||
|
||||
override public function toString():String
|
||||
{
|
||||
return (formatToString("MouseEvent3D", "type", "bubbles", "eventPhase", "relatedObject", "altKey", "ctrlKey", "shiftKey", "buttonDown", "delta"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
1465
src/alternativa/engine3d/core/Object3D.as
Normal file
1465
src/alternativa/engine3d/core/Object3D.as
Normal file
File diff suppressed because it is too large
Load Diff
835
src/alternativa/engine3d/core/Object3DContainer.as
Normal file
835
src/alternativa/engine3d/core/Object3DContainer.as
Normal file
@@ -0,0 +1,835 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import __AS3__.vec.Vector;
|
||||
import flash.geom.Vector3D;
|
||||
import flash.utils.Dictionary;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Object3DContainer extends Object3D
|
||||
{
|
||||
|
||||
public var mouseChildren:Boolean = true;
|
||||
public var childrenList:Object3D;
|
||||
alternativa3d var lightList:Light3D;
|
||||
alternativa3d var visibleChildren:Vector.<Object3D> = new Vector.<Object3D>();
|
||||
alternativa3d var numVisibleChildren:int = 0;
|
||||
|
||||
|
||||
public function get children() : Vector.<Object3D>
|
||||
{
|
||||
var objects:Vector.<Object3D> = new Vector.<Object3D>();
|
||||
|
||||
var child:Object3D = childrenList;
|
||||
|
||||
while(child != null)
|
||||
{
|
||||
objects.push(child);
|
||||
|
||||
child = child.next;
|
||||
}
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
public function addChild(_arg_1:Object3D):Object3D
|
||||
{
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new TypeError("Parameter child must be non-null."));
|
||||
};
|
||||
if (_arg_1 == this)
|
||||
{
|
||||
throw (new ArgumentError("An object cannot be added as a child of itself."));
|
||||
};
|
||||
var _local_2:Object3DContainer = _parent;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (_local_2 == _arg_1)
|
||||
{
|
||||
throw (new ArgumentError("An object cannot be added as a child to one of it's children (or children's children, etc.)."));
|
||||
};
|
||||
_local_2 = _local_2._parent;
|
||||
};
|
||||
if (_arg_1._parent != null)
|
||||
{
|
||||
_arg_1._parent.removeChild(_arg_1);
|
||||
};
|
||||
this.addToList(_arg_1);
|
||||
return (_arg_1);
|
||||
}
|
||||
|
||||
public function removeChild(_arg_1:Object3D):Object3D
|
||||
{
|
||||
var _local_2:Object3D;
|
||||
var _local_3:Object3D;
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new TypeError("Parameter child must be non-null."));
|
||||
};
|
||||
if (_arg_1._parent != this)
|
||||
{
|
||||
throw (new ArgumentError("The supplied Object3D must be a child of the caller."));
|
||||
};
|
||||
_local_3 = this.childrenList;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
if (_local_3 == _arg_1)
|
||||
{
|
||||
if (_local_2 != null)
|
||||
{
|
||||
_local_2.next = _local_3.next;
|
||||
} else
|
||||
{
|
||||
this.childrenList = _local_3.next;
|
||||
};
|
||||
_local_3.next = null;
|
||||
_local_3.setParent(null);
|
||||
return (_arg_1);
|
||||
};
|
||||
_local_2 = _local_3;
|
||||
_local_3 = _local_3.next;
|
||||
};
|
||||
throw (new ArgumentError("Cannot remove child."));
|
||||
}
|
||||
|
||||
public function addChildAt(_arg_1:Object3D, _arg_2:int):Object3D
|
||||
{
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new TypeError("Parameter child must be non-null."));
|
||||
};
|
||||
if (_arg_1 == this)
|
||||
{
|
||||
throw (new ArgumentError("An object cannot be added as a child of itself."));
|
||||
};
|
||||
if (_arg_2 < 0)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
var _local_3:Object3DContainer = _parent;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
if (_local_3 == _arg_1)
|
||||
{
|
||||
throw (new ArgumentError("An object cannot be added as a child to one of it's children (or children's children, etc.)."));
|
||||
};
|
||||
_local_3 = _local_3._parent;
|
||||
};
|
||||
var _local_4:Object3D = this.childrenList;
|
||||
var _local_5:int;
|
||||
while (_local_5 < _arg_2)
|
||||
{
|
||||
if (_local_4 == null)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
_local_4 = _local_4.next;
|
||||
_local_5++;
|
||||
};
|
||||
if (_arg_1._parent != null)
|
||||
{
|
||||
_arg_1._parent.removeChild(_arg_1);
|
||||
};
|
||||
this.addToList(_arg_1, _local_4);
|
||||
return (_arg_1);
|
||||
}
|
||||
|
||||
public function removeChildAt(_arg_1:int):Object3D
|
||||
{
|
||||
if (_arg_1 < 0)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
var _local_2:Object3D = this.childrenList;
|
||||
var _local_3:int;
|
||||
while (_local_3 < _arg_1)
|
||||
{
|
||||
if (_local_2 == null)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
_local_2 = _local_2.next;
|
||||
_local_3++;
|
||||
};
|
||||
if (_local_2 == null)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
this.removeChild(_local_2);
|
||||
return (_local_2);
|
||||
}
|
||||
|
||||
public function getChildAt(_arg_1:int):Object3D
|
||||
{
|
||||
if (_arg_1 < 0)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
var _local_2:Object3D = this.childrenList;
|
||||
var _local_3:int;
|
||||
while (_local_3 < _arg_1)
|
||||
{
|
||||
if (_local_2 == null)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
_local_2 = _local_2.next;
|
||||
_local_3++;
|
||||
};
|
||||
if (_local_2 == null)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
return (_local_2);
|
||||
}
|
||||
|
||||
public function getChildIndex(_arg_1:Object3D):int
|
||||
{
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new TypeError("Parameter child must be non-null."));
|
||||
};
|
||||
if (_arg_1._parent != this)
|
||||
{
|
||||
throw (new ArgumentError("The supplied Object3D must be a child of the caller."));
|
||||
};
|
||||
var _local_2:int;
|
||||
var _local_3:Object3D = this.childrenList;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
if (_local_3 == _arg_1)
|
||||
{
|
||||
return (_local_2);
|
||||
};
|
||||
_local_2++;
|
||||
_local_3 = _local_3.next;
|
||||
};
|
||||
throw (new ArgumentError("Cannot get child index."));
|
||||
}
|
||||
|
||||
public function setChildIndex(_arg_1:Object3D, _arg_2:int):void
|
||||
{
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new TypeError("Parameter child must be non-null."));
|
||||
};
|
||||
if (_arg_1._parent != this)
|
||||
{
|
||||
throw (new ArgumentError("The supplied Object3D must be a child of the caller."));
|
||||
};
|
||||
if (_arg_2 < 0)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
var _local_3:Object3D = this.childrenList;
|
||||
var _local_4:int;
|
||||
while (_local_4 < _arg_2)
|
||||
{
|
||||
if (_local_3 == null)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
_local_3 = _local_3.next;
|
||||
_local_4++;
|
||||
};
|
||||
this.removeChild(_arg_1);
|
||||
this.addToList(_arg_1, _local_3);
|
||||
}
|
||||
|
||||
public function swapChildren(_arg_1:Object3D, _arg_2:Object3D):void
|
||||
{
|
||||
var _local_3:Object3D;
|
||||
if (((_arg_1 == null) || (_arg_2 == null)))
|
||||
{
|
||||
throw (new TypeError("Parameter child must be non-null."));
|
||||
};
|
||||
if (((!(_arg_1._parent == this)) || (!(_arg_2._parent == this))))
|
||||
{
|
||||
throw (new ArgumentError("The supplied Object3D must be a child of the caller."));
|
||||
};
|
||||
if (_arg_1 != _arg_2)
|
||||
{
|
||||
if (_arg_1.next == _arg_2)
|
||||
{
|
||||
this.removeChild(_arg_2);
|
||||
this.addToList(_arg_2, _arg_1);
|
||||
} else
|
||||
{
|
||||
if (_arg_2.next == _arg_1)
|
||||
{
|
||||
this.removeChild(_arg_1);
|
||||
this.addToList(_arg_1, _arg_2);
|
||||
} else
|
||||
{
|
||||
_local_3 = _arg_1.next;
|
||||
this.removeChild(_arg_1);
|
||||
this.addToList(_arg_1, _arg_2);
|
||||
this.removeChild(_arg_2);
|
||||
this.addToList(_arg_2, _local_3);
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public function swapChildrenAt(_arg_1:int, _arg_2:int):void
|
||||
{
|
||||
var _local_3:int;
|
||||
var _local_4:Object3D;
|
||||
var _local_5:Object3D;
|
||||
var _local_6:Object3D;
|
||||
if (((_arg_1 < 0) || (_arg_2 < 0)))
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
if (_arg_1 != _arg_2)
|
||||
{
|
||||
_local_4 = this.childrenList;
|
||||
_local_3 = 0;
|
||||
while (_local_3 < _arg_1)
|
||||
{
|
||||
if (_local_4 == null)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
_local_4 = _local_4.next;
|
||||
_local_3++;
|
||||
};
|
||||
if (_local_4 == null)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
_local_5 = this.childrenList;
|
||||
_local_3 = 0;
|
||||
while (_local_3 < _arg_2)
|
||||
{
|
||||
if (_local_5 == null)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
_local_5 = _local_5.next;
|
||||
_local_3++;
|
||||
};
|
||||
if (_local_5 == null)
|
||||
{
|
||||
throw (new RangeError("The supplied index is out of bounds."));
|
||||
};
|
||||
if (_local_4 != _local_5)
|
||||
{
|
||||
if (_local_4.next == _local_5)
|
||||
{
|
||||
this.removeChild(_local_5);
|
||||
this.addToList(_local_5, _local_4);
|
||||
} else
|
||||
{
|
||||
if (_local_5.next == _local_4)
|
||||
{
|
||||
this.removeChild(_local_4);
|
||||
this.addToList(_local_4, _local_5);
|
||||
} else
|
||||
{
|
||||
_local_6 = _local_4.next;
|
||||
this.removeChild(_local_4);
|
||||
this.addToList(_local_4, _local_5);
|
||||
this.removeChild(_local_5);
|
||||
this.addToList(_local_5, _local_6);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public function getChildByName(_arg_1:String):Object3D
|
||||
{
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new TypeError("Parameter name must be non-null."));
|
||||
};
|
||||
var _local_2:Object3D = this.childrenList;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (_local_2.name == _arg_1)
|
||||
{
|
||||
return (_local_2);
|
||||
};
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
return (null);
|
||||
}
|
||||
|
||||
public function contains(_arg_1:Object3D):Boolean
|
||||
{
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
throw (new TypeError("Parameter child must be non-null."));
|
||||
};
|
||||
if (_arg_1 == this)
|
||||
{
|
||||
return (true);
|
||||
};
|
||||
var _local_2:Object3D = this.childrenList;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if ((_local_2 is Object3DContainer))
|
||||
{
|
||||
if ((_local_2 as Object3DContainer).contains(_arg_1))
|
||||
{
|
||||
return (true);
|
||||
};
|
||||
} else
|
||||
{
|
||||
if (_local_2 == _arg_1)
|
||||
{
|
||||
return (true);
|
||||
};
|
||||
};
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
return (false);
|
||||
}
|
||||
|
||||
public function get numChildren():int
|
||||
{
|
||||
var _local_1:int;
|
||||
var _local_2:Object3D = this.childrenList;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
_local_1++;
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
override public function intersectRay(_arg_1:Vector3D, _arg_2:Vector3D, _arg_3:Dictionary=null, _arg_4:Camera3D=null):RayIntersectionData
|
||||
{
|
||||
var _local_5:Vector3D;
|
||||
var _local_6:Vector3D;
|
||||
var _local_7:RayIntersectionData;
|
||||
var _local_10:RayIntersectionData;
|
||||
if (((!(_arg_3 == null)) && (_arg_3[this])))
|
||||
{
|
||||
return (null);
|
||||
};
|
||||
if ((!(boundIntersectRay(_arg_1, _arg_2, boundMinX, boundMinY, boundMinZ, boundMaxX, boundMaxY, boundMaxZ))))
|
||||
{
|
||||
return (null);
|
||||
};
|
||||
var _local_8:Number = 1E22;
|
||||
var _local_9:Object3D = this.childrenList;
|
||||
while (_local_9 != null)
|
||||
{
|
||||
_local_9.composeMatrix();
|
||||
_local_9.invertMatrix();
|
||||
if (_local_5 == null)
|
||||
{
|
||||
_local_5 = new Vector3D();
|
||||
_local_6 = new Vector3D();
|
||||
};
|
||||
_local_5.x = ((((_local_9.ma * _arg_1.x) + (_local_9.mb * _arg_1.y)) + (_local_9.mc * _arg_1.z)) + _local_9.md);
|
||||
_local_5.y = ((((_local_9.me * _arg_1.x) + (_local_9.mf * _arg_1.y)) + (_local_9.mg * _arg_1.z)) + _local_9.mh);
|
||||
_local_5.z = ((((_local_9.mi * _arg_1.x) + (_local_9.mj * _arg_1.y)) + (_local_9.mk * _arg_1.z)) + _local_9.ml);
|
||||
_local_6.x = (((_local_9.ma * _arg_2.x) + (_local_9.mb * _arg_2.y)) + (_local_9.mc * _arg_2.z));
|
||||
_local_6.y = (((_local_9.me * _arg_2.x) + (_local_9.mf * _arg_2.y)) + (_local_9.mg * _arg_2.z));
|
||||
_local_6.z = (((_local_9.mi * _arg_2.x) + (_local_9.mj * _arg_2.y)) + (_local_9.mk * _arg_2.z));
|
||||
_local_10 = _local_9.intersectRay(_local_5, _local_6, _arg_3, _arg_4);
|
||||
if (((!(_local_10 == null)) && (_local_10.time < _local_8)))
|
||||
{
|
||||
_local_8 = _local_10.time;
|
||||
_local_7 = _local_10;
|
||||
};
|
||||
_local_9 = _local_9.next;
|
||||
};
|
||||
return (_local_7);
|
||||
}
|
||||
|
||||
override alternativa3d function checkIntersection(_arg_1:Number, _arg_2:Number, _arg_3:Number, _arg_4:Number, _arg_5:Number, _arg_6:Number, _arg_7:Number, _arg_8:Dictionary):Boolean
|
||||
{
|
||||
var _local_10:Number;
|
||||
var _local_11:Number;
|
||||
var _local_12:Number;
|
||||
var _local_13:Number;
|
||||
var _local_14:Number;
|
||||
var _local_15:Number;
|
||||
var _local_9:Object3D = this.childrenList;
|
||||
while (_local_9 != null)
|
||||
{
|
||||
if (((!(_arg_8 == null)) && (!(_arg_8[_local_9]))))
|
||||
{
|
||||
_local_9.composeMatrix();
|
||||
_local_9.invertMatrix();
|
||||
_local_10 = ((((_local_9.ma * _arg_1) + (_local_9.mb * _arg_2)) + (_local_9.mc * _arg_3)) + _local_9.md);
|
||||
_local_11 = ((((_local_9.me * _arg_1) + (_local_9.mf * _arg_2)) + (_local_9.mg * _arg_3)) + _local_9.mh);
|
||||
_local_12 = ((((_local_9.mi * _arg_1) + (_local_9.mj * _arg_2)) + (_local_9.mk * _arg_3)) + _local_9.ml);
|
||||
_local_13 = (((_local_9.ma * _arg_4) + (_local_9.mb * _arg_5)) + (_local_9.mc * _arg_6));
|
||||
_local_14 = (((_local_9.me * _arg_4) + (_local_9.mf * _arg_5)) + (_local_9.mg * _arg_6));
|
||||
_local_15 = (((_local_9.mi * _arg_4) + (_local_9.mj * _arg_5)) + (_local_9.mk * _arg_6));
|
||||
if (((boundCheckIntersection(_local_10, _local_11, _local_12, _local_13, _local_14, _local_15, _arg_7, _local_9.boundMinX, _local_9.boundMinY, _local_9.boundMinZ, _local_9.boundMaxX, _local_9.boundMaxY, _local_9.boundMaxZ)) && (_local_9.checkIntersection(_local_10, _local_11, _local_12, _local_13, _local_14, _local_15, _arg_7, _arg_8))))
|
||||
{
|
||||
return (true);
|
||||
};
|
||||
};
|
||||
_local_9 = _local_9.next;
|
||||
};
|
||||
return (false);
|
||||
}
|
||||
|
||||
override alternativa3d function collectPlanes(_arg_1:Vector3D, _arg_2:Vector3D, _arg_3:Vector3D, _arg_4:Vector3D, _arg_5:Vector3D, _arg_6:Vector.<Face>, _arg_7:Dictionary=null):void
|
||||
{
|
||||
if (((!(_arg_7 == null)) && (_arg_7[this])))
|
||||
{
|
||||
return;
|
||||
};
|
||||
var _local_8:Vector3D = calculateSphere(_arg_1, _arg_2, _arg_3, _arg_4, _arg_5);
|
||||
if ((!(boundIntersectSphere(_local_8, boundMinX, boundMinY, boundMinZ, boundMaxX, boundMaxY, boundMaxZ))))
|
||||
{
|
||||
return;
|
||||
};
|
||||
var _local_9:Object3D = this.childrenList;
|
||||
while (_local_9 != null)
|
||||
{
|
||||
_local_9.composeAndAppend(this);
|
||||
_local_9.collectPlanes(_arg_1, _arg_2, _arg_3, _arg_4, _arg_5, _arg_6, _arg_7);
|
||||
_local_9 = _local_9.next;
|
||||
};
|
||||
}
|
||||
|
||||
override public function clone():Object3D
|
||||
{
|
||||
var _local_1:Object3DContainer = new Object3DContainer();
|
||||
_local_1.clonePropertiesFrom(this);
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
override protected function clonePropertiesFrom(_arg_1:Object3D):void
|
||||
{
|
||||
var _local_4:Object3D;
|
||||
var _local_5:Object3D;
|
||||
super.clonePropertiesFrom(_arg_1);
|
||||
var _local_2:Object3DContainer = (_arg_1 as Object3DContainer);
|
||||
this.mouseChildren = _local_2.mouseChildren;
|
||||
var _local_3:Object3D = _local_2.childrenList;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
_local_5 = _local_3.clone();
|
||||
if (this.childrenList != null)
|
||||
{
|
||||
_local_4.next = _local_5;
|
||||
} else
|
||||
{
|
||||
this.childrenList = _local_5;
|
||||
};
|
||||
_local_4 = _local_5;
|
||||
_local_5.setParent(this);
|
||||
_local_3 = _local_3.next;
|
||||
};
|
||||
}
|
||||
|
||||
override alternativa3d function draw(_arg_1:Camera3D):void
|
||||
{
|
||||
var _local_2:int;
|
||||
this.numVisibleChildren = 0;
|
||||
var _local_3:Object3D = this.childrenList;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
if (_local_3.visible)
|
||||
{
|
||||
_local_3.composeAndAppend(this);
|
||||
if (_local_3.cullingInCamera(_arg_1, culling) >= 0)
|
||||
{
|
||||
_local_3.concat(this);
|
||||
this.visibleChildren[this.numVisibleChildren] = _local_3;
|
||||
this.numVisibleChildren++;
|
||||
};
|
||||
};
|
||||
_local_3 = _local_3.next;
|
||||
};
|
||||
if (this.numVisibleChildren > 0)
|
||||
{
|
||||
if (((_arg_1.debug) && ((_local_2 = _arg_1.checkInDebug(this)) > 0)))
|
||||
{
|
||||
if ((_local_2 & Debug.BOUNDS))
|
||||
{
|
||||
Debug.drawBounds(_arg_1, this, boundMinX, boundMinY, boundMinZ, boundMaxX, boundMaxY, boundMaxZ);
|
||||
};
|
||||
};
|
||||
this.drawVisibleChildren(_arg_1);
|
||||
};
|
||||
}
|
||||
|
||||
alternativa3d function drawVisibleChildren(_arg_1:Camera3D):void
|
||||
{
|
||||
var _local_3:Object3D;
|
||||
var _local_2:int = (this.numVisibleChildren - 1);
|
||||
while (_local_2 >= 0)
|
||||
{
|
||||
_local_3 = this.visibleChildren[_local_2];
|
||||
_local_3.draw(_arg_1);
|
||||
this.visibleChildren[_local_2] = null;
|
||||
_local_2--;
|
||||
};
|
||||
}
|
||||
|
||||
override alternativa3d function getVG(_arg_1:Camera3D):VG
|
||||
{
|
||||
var _local_2:VG;
|
||||
var _local_3:VG;
|
||||
var _local_5:VG;
|
||||
var _local_4:Object3D = this.childrenList;
|
||||
while (_local_4 != null)
|
||||
{
|
||||
if (_local_4.visible)
|
||||
{
|
||||
_local_4.composeAndAppend(this);
|
||||
if (_local_4.cullingInCamera(_arg_1, culling) >= 0)
|
||||
{
|
||||
_local_4.concat(this);
|
||||
_local_5 = _local_4.getVG(_arg_1);
|
||||
if (_local_5 != null)
|
||||
{
|
||||
if (_local_2 != null)
|
||||
{
|
||||
_local_3.next = _local_5;
|
||||
} else
|
||||
{
|
||||
_local_2 = _local_5;
|
||||
_local_3 = _local_5;
|
||||
};
|
||||
while (_local_3.next != null)
|
||||
{
|
||||
_local_3 = _local_3.next;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
_local_4 = _local_4.next;
|
||||
};
|
||||
return (_local_2);
|
||||
}
|
||||
|
||||
override alternativa3d function updateBounds(_arg_1:Object3D, _arg_2:Object3D=null):void
|
||||
{
|
||||
var _local_3:Object3D = this.childrenList;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
if (_arg_2 != null)
|
||||
{
|
||||
_local_3.composeAndAppend(_arg_2);
|
||||
} else
|
||||
{
|
||||
_local_3.composeMatrix();
|
||||
};
|
||||
_local_3.updateBounds(_arg_1, _local_3);
|
||||
_local_3 = _local_3.next;
|
||||
};
|
||||
}
|
||||
|
||||
override alternativa3d function split(_arg_1:Vector3D, _arg_2:Vector3D, _arg_3:Vector3D, _arg_4:Number):Vector.<Object3D>
|
||||
{
|
||||
var _local_10:Object3D;
|
||||
var _local_11:Object3D;
|
||||
var _local_13:Object3D;
|
||||
var _local_14:Vector3D;
|
||||
var _local_15:Vector3D;
|
||||
var _local_16:Vector3D;
|
||||
var _local_17:int;
|
||||
var _local_18:Vector.<Object3D>;
|
||||
var _local_19:Number;
|
||||
var _local_5:Vector.<Object3D> = new Vector.<Object3D>(2);
|
||||
var _local_6:Vector3D = calculatePlane(_arg_1, _arg_2, _arg_3);
|
||||
var _local_7:Object3D = this.childrenList;
|
||||
this.childrenList = null;
|
||||
var _local_8:Object3DContainer = (this.clone() as Object3DContainer);
|
||||
var _local_9:Object3DContainer = (this.clone() as Object3DContainer);
|
||||
var _local_12:Object3D = _local_7;
|
||||
while (_local_12 != null)
|
||||
{
|
||||
_local_13 = _local_12.next;
|
||||
_local_12.next = null;
|
||||
_local_12.setParent(null);
|
||||
_local_12.composeMatrix();
|
||||
_local_12.calculateInverseMatrix();
|
||||
_local_14 = new Vector3D(((((_local_12.ima * _arg_1.x) + (_local_12.imb * _arg_1.y)) + (_local_12.imc * _arg_1.z)) + _local_12.imd), ((((_local_12.ime * _arg_1.x) + (_local_12.imf * _arg_1.y)) + (_local_12.img * _arg_1.z)) + _local_12.imh), ((((_local_12.imi * _arg_1.x) + (_local_12.imj * _arg_1.y)) + (_local_12.imk * _arg_1.z)) + _local_12.iml));
|
||||
_local_15 = new Vector3D(((((_local_12.ima * _arg_2.x) + (_local_12.imb * _arg_2.y)) + (_local_12.imc * _arg_2.z)) + _local_12.imd), ((((_local_12.ime * _arg_2.x) + (_local_12.imf * _arg_2.y)) + (_local_12.img * _arg_2.z)) + _local_12.imh), ((((_local_12.imi * _arg_2.x) + (_local_12.imj * _arg_2.y)) + (_local_12.imk * _arg_2.z)) + _local_12.iml));
|
||||
_local_16 = new Vector3D(((((_local_12.ima * _arg_3.x) + (_local_12.imb * _arg_3.y)) + (_local_12.imc * _arg_3.z)) + _local_12.imd), ((((_local_12.ime * _arg_3.x) + (_local_12.imf * _arg_3.y)) + (_local_12.img * _arg_3.z)) + _local_12.imh), ((((_local_12.imi * _arg_3.x) + (_local_12.imj * _arg_3.y)) + (_local_12.imk * _arg_3.z)) + _local_12.iml));
|
||||
_local_17 = _local_12.testSplit(_local_14, _local_15, _local_16, _arg_4);
|
||||
if (_local_17 < 0)
|
||||
{
|
||||
if (_local_10 != null)
|
||||
{
|
||||
_local_10.next = _local_12;
|
||||
} else
|
||||
{
|
||||
_local_8.childrenList = _local_12;
|
||||
};
|
||||
_local_10 = _local_12;
|
||||
_local_12.setParent(_local_8);
|
||||
} else
|
||||
{
|
||||
if (_local_17 > 0)
|
||||
{
|
||||
if (_local_11 != null)
|
||||
{
|
||||
_local_11.next = _local_12;
|
||||
} else
|
||||
{
|
||||
_local_9.childrenList = _local_12;
|
||||
};
|
||||
_local_11 = _local_12;
|
||||
_local_12.setParent(_local_9);
|
||||
} else
|
||||
{
|
||||
_local_18 = _local_12.split(_local_14, _local_15, _local_16, _arg_4);
|
||||
_local_19 = _local_12.distance;
|
||||
if (_local_18[0] != null)
|
||||
{
|
||||
_local_12 = _local_18[0];
|
||||
if (_local_10 != null)
|
||||
{
|
||||
_local_10.next = _local_12;
|
||||
} else
|
||||
{
|
||||
_local_8.childrenList = _local_12;
|
||||
};
|
||||
_local_10 = _local_12;
|
||||
_local_12.setParent(_local_8);
|
||||
_local_12.distance = _local_19;
|
||||
};
|
||||
if (_local_18[1] != null)
|
||||
{
|
||||
_local_12 = _local_18[1];
|
||||
if (_local_11 != null)
|
||||
{
|
||||
_local_11.next = _local_12;
|
||||
} else
|
||||
{
|
||||
_local_9.childrenList = _local_12;
|
||||
};
|
||||
_local_11 = _local_12;
|
||||
_local_12.setParent(_local_9);
|
||||
_local_12.distance = _local_19;
|
||||
};
|
||||
};
|
||||
};
|
||||
_local_12 = _local_13;
|
||||
};
|
||||
if (_local_10 != null)
|
||||
{
|
||||
_local_8.calculateBounds();
|
||||
_local_5[0] = _local_8;
|
||||
};
|
||||
if (_local_11 != null)
|
||||
{
|
||||
_local_9.calculateBounds();
|
||||
_local_5[1] = _local_9;
|
||||
};
|
||||
return (_local_5);
|
||||
}
|
||||
|
||||
alternativa3d function addToList(_arg_1:Object3D, _arg_2:Object3D=null):void
|
||||
{
|
||||
var _local_3:Object3D;
|
||||
_arg_1.next = _arg_2;
|
||||
_arg_1.setParent(this);
|
||||
if (_arg_2 == this.childrenList)
|
||||
{
|
||||
this.childrenList = _arg_1;
|
||||
} else
|
||||
{
|
||||
_local_3 = this.childrenList;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
if (_local_3.next == _arg_2)
|
||||
{
|
||||
_local_3.next = _arg_1;
|
||||
return;
|
||||
};
|
||||
_local_3 = _local_3.next;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
override alternativa3d function setParent(_arg_1:Object3DContainer):void
|
||||
{
|
||||
var _local_2:Object3DContainer;
|
||||
var _local_3:Light3D;
|
||||
if (_arg_1 == null)
|
||||
{
|
||||
_local_2 = _parent;
|
||||
while (_local_2._parent != null)
|
||||
{
|
||||
_local_2 = _local_2._parent;
|
||||
};
|
||||
if (_local_2.lightList != null)
|
||||
{
|
||||
this.transferLights(_local_2, this);
|
||||
};
|
||||
} else
|
||||
{
|
||||
if (this.lightList != null)
|
||||
{
|
||||
_local_2 = _arg_1;
|
||||
while (_local_2._parent != null)
|
||||
{
|
||||
_local_2 = _local_2._parent;
|
||||
};
|
||||
_local_3 = this.lightList;
|
||||
while (_local_3.nextLight != null)
|
||||
{
|
||||
_local_3 = _local_3.nextLight;
|
||||
};
|
||||
_local_3.nextLight = _local_2.lightList;
|
||||
_local_2.lightList = this.lightList;
|
||||
this.lightList = null;
|
||||
};
|
||||
};
|
||||
_parent = _arg_1;
|
||||
}
|
||||
|
||||
private function transferLights(_arg_1:Object3DContainer, _arg_2:Object3DContainer):void
|
||||
{
|
||||
var _local_4:Light3D;
|
||||
var _local_5:Light3D;
|
||||
var _local_6:Light3D;
|
||||
var _local_3:Object3D = this.childrenList;
|
||||
while (_local_3 != null)
|
||||
{
|
||||
if ((_local_3 is Light3D))
|
||||
{
|
||||
_local_4 = (_local_3 as Light3D);
|
||||
_local_5 = null;
|
||||
_local_6 = _arg_1.lightList;
|
||||
while (_local_6 != null)
|
||||
{
|
||||
if (_local_6 == _local_4)
|
||||
{
|
||||
if (_local_5 != null)
|
||||
{
|
||||
_local_5.nextLight = _local_6.nextLight;
|
||||
} else
|
||||
{
|
||||
_arg_1.lightList = _local_6.nextLight;
|
||||
};
|
||||
_local_6.nextLight = _arg_2.lightList;
|
||||
_arg_2.lightList = _local_6;
|
||||
break;
|
||||
};
|
||||
_local_5 = _local_6;
|
||||
_local_6 = _local_6.nextLight;
|
||||
};
|
||||
} else
|
||||
{
|
||||
if ((_local_3 is Object3DContainer))
|
||||
{
|
||||
(_local_3 as Object3DContainer).transferLights(_arg_1, _arg_2);
|
||||
};
|
||||
};
|
||||
if (_arg_1.lightList == null) break;
|
||||
_local_3 = _local_3.next;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
597
src/alternativa/engine3d/core/PerformanceController.as
Normal file
597
src/alternativa/engine3d/core/PerformanceController.as
Normal file
@@ -0,0 +1,597 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import flash.net.SharedObject;
|
||||
import __AS3__.vec.Vector;
|
||||
import flash.display.Stage;
|
||||
import flash.utils.setTimeout;
|
||||
import flash.events.Event;
|
||||
import flash.utils.clearInterval;
|
||||
import flash.utils.getTimer;
|
||||
import __AS3__.vec.*;
|
||||
|
||||
public class PerformanceController
|
||||
{
|
||||
|
||||
public static const FOG:String = "fog";
|
||||
public static const DIRECTIONAL_LIGHT:String = "directionalLight";
|
||||
public static const SHADOW_MAP:String = "shadowMap";
|
||||
public static const SOFT_TRANSPARENCY:String = "softTransparency";
|
||||
public static const SHADOWS:String = "shadows";
|
||||
public static const ANTI_ALIAS:String = "antiAlias";
|
||||
public static const SSAO:String = "ssao";
|
||||
public static const DEFERRED_LIGHTING:String = "deferredLighting";
|
||||
private static var storage:SharedObject = SharedObject.getLocal("performance");
|
||||
|
||||
private var types:Vector.<String> = new Vector.<String>();
|
||||
private var speeds:Vector.<Number> = new Vector.<Number>();
|
||||
private var actives:Vector.<Boolean> = new Vector.<Boolean>();
|
||||
private var stage:Stage;
|
||||
private var camera:Camera3D;
|
||||
private var fpsThreshold:Number;
|
||||
private var ratioThreshold:Number;
|
||||
private var testTime:Number;
|
||||
private var maxAttempts:uint;
|
||||
private var key:String;
|
||||
private var traceLog:Boolean;
|
||||
private var mask:int;
|
||||
private var id:uint;
|
||||
private var idleId:uint;
|
||||
private var timer:int;
|
||||
private var frameCounter:int;
|
||||
private var lowCounter:int;
|
||||
private var state:int;
|
||||
private var features:Vector.<Feature>;
|
||||
private var featuresCount:int;
|
||||
private var index:int;
|
||||
private var _block:Boolean = false;
|
||||
private var afterIdle:Boolean;
|
||||
|
||||
|
||||
public function addFeature(_arg_1:String, _arg_2:Number, _arg_3:Boolean):void
|
||||
{
|
||||
var _local_4:String;
|
||||
if (this.camera != null)
|
||||
{
|
||||
throw (new Error("Cannot add feature during analysis."));
|
||||
};
|
||||
if (((((((((!(_arg_1 == FOG)) && (!(_arg_1 == SHADOWS))) && (!(_arg_1 == DIRECTIONAL_LIGHT))) && (!(_arg_1 == SHADOW_MAP))) && (!(_arg_1 == SOFT_TRANSPARENCY))) && (!(_arg_1 == ANTI_ALIAS))) && (!(_arg_1 == SSAO))) && (!(_arg_1 == DEFERRED_LIGHTING))))
|
||||
{
|
||||
throw (new Error("Nonexistent feature."));
|
||||
};
|
||||
for each (_local_4 in this.types)
|
||||
{
|
||||
if (_local_4 == _arg_1)
|
||||
{
|
||||
throw (new Error("Feature already exists."));
|
||||
};
|
||||
};
|
||||
this.types.push(_arg_1);
|
||||
this.speeds.push(_arg_2);
|
||||
this.actives.push(_arg_3);
|
||||
}
|
||||
|
||||
public function get activated():Boolean
|
||||
{
|
||||
return (!(this.camera == null));
|
||||
}
|
||||
|
||||
public function clearSharedObject():void
|
||||
{
|
||||
storage.clear();
|
||||
}
|
||||
|
||||
public function start(_arg_1:Stage, _arg_2:Camera3D, _arg_3:Number, _arg_4:Number, _arg_5:Number, _arg_6:Number, _arg_7:uint, _arg_8:String, _arg_9:Boolean=false):void
|
||||
{
|
||||
var _local_10:int;
|
||||
if (this.camera != null)
|
||||
{
|
||||
throw (new Error("Analysis already started."));
|
||||
};
|
||||
var _local_11:int = this.types.length;
|
||||
this.stage = _arg_1;
|
||||
this.camera = _arg_2;
|
||||
this.fpsThreshold = _arg_3;
|
||||
this.ratioThreshold = _arg_4;
|
||||
this.testTime = _arg_6;
|
||||
this.maxAttempts = _arg_7;
|
||||
this.key = _arg_8;
|
||||
this.traceLog = _arg_9;
|
||||
this.mask = 0;
|
||||
_local_10 = 0;
|
||||
while (_local_10 < _local_11)
|
||||
{
|
||||
this.key = (this.key + ("_5_" + this.types[_local_10]));
|
||||
if (this.actives[_local_10])
|
||||
{
|
||||
this.mask = (this.mask | (1 << _local_10));
|
||||
};
|
||||
_local_10++;
|
||||
};
|
||||
if (storage.data[this.key] != undefined)
|
||||
{
|
||||
this.mask = storage.data[this.key];
|
||||
} else
|
||||
{
|
||||
this.save();
|
||||
};
|
||||
this.features = new Vector.<Feature>();
|
||||
this.featuresCount = 0;
|
||||
_local_10 = 0;
|
||||
while (_local_10 < _local_11)
|
||||
{
|
||||
if ((this.mask & (1 << _local_10)) > 0)
|
||||
{
|
||||
this.features[this.featuresCount] = new Feature(this.types[_local_10], this.speeds[_local_10]);
|
||||
this.featuresCount++;
|
||||
};
|
||||
_local_10++;
|
||||
};
|
||||
this.index = (this.featuresCount - 1);
|
||||
_local_10 = 0;
|
||||
while (_local_10 < _local_11)
|
||||
{
|
||||
if ((this.mask & (1 << _local_10)) == 0)
|
||||
{
|
||||
this.features[this.featuresCount] = new Feature(this.types[_local_10], this.speeds[_local_10]);
|
||||
this.featuresCount++;
|
||||
this.disableFeature(this.types[_local_10]);
|
||||
};
|
||||
_local_10++;
|
||||
};
|
||||
this.afterIdle = false;
|
||||
if (_arg_5 > 0)
|
||||
{
|
||||
this.idleId = setTimeout(this.onIdle, (_arg_5 * 1000));
|
||||
} else
|
||||
{
|
||||
this.onIdle();
|
||||
};
|
||||
this.traceFeatures("\nStart", true);
|
||||
}
|
||||
|
||||
public function stop():void
|
||||
{
|
||||
if (this.camera == null)
|
||||
{
|
||||
return;
|
||||
};
|
||||
this.stage.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
|
||||
clearInterval(this.id);
|
||||
clearInterval(this.idleId);
|
||||
var _local_1:int = this.types.length;
|
||||
var _local_2:int;
|
||||
while (_local_2 < _local_1)
|
||||
{
|
||||
this.restoreFeature(this.types[_local_2]);
|
||||
_local_2++;
|
||||
};
|
||||
this.stage = null;
|
||||
this.camera = null;
|
||||
}
|
||||
|
||||
public function get block():Boolean
|
||||
{
|
||||
return (this._block);
|
||||
}
|
||||
|
||||
public function set block(_arg_1:Boolean):void
|
||||
{
|
||||
if (this._block != _arg_1)
|
||||
{
|
||||
this._block = _arg_1;
|
||||
this.traceFeatures(("\nBlock " + this._block), false);
|
||||
if (((!(this.camera == null)) && (this.afterIdle)))
|
||||
{
|
||||
if (this._block)
|
||||
{
|
||||
this.stage.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
|
||||
clearInterval(this.id);
|
||||
if (this.index < (this.featuresCount - 1))
|
||||
{
|
||||
this.disableFeature(Feature(this.features[(this.index + 1)]).type);
|
||||
};
|
||||
} else
|
||||
{
|
||||
this.stage.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);
|
||||
this.timer = getTimer();
|
||||
if (this.state == 0)
|
||||
{
|
||||
this.testCurrent();
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
private function onIdle():void
|
||||
{
|
||||
this.state = 0;
|
||||
this.afterIdle = true;
|
||||
if ((!(this._block)))
|
||||
{
|
||||
this.stage.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);
|
||||
this.timer = getTimer();
|
||||
this.testCurrent();
|
||||
};
|
||||
}
|
||||
|
||||
private function onEnterFrame(_arg_1:Event):void
|
||||
{
|
||||
var _local_4:Number;
|
||||
var _local_2:int = getTimer();
|
||||
var _local_3:Number = ((_local_2 - this.timer) / 1000);
|
||||
this.timer = _local_2;
|
||||
if (this.state == 1)
|
||||
{
|
||||
_local_4 = this.changeStrength(Feature(this.features[this.index]).type, (_local_3 * this.speeds[this.index]));
|
||||
if (_local_4 >= 1)
|
||||
{
|
||||
if ((this.index + 1) < this.featuresCount)
|
||||
{
|
||||
this.testNext();
|
||||
} else
|
||||
{
|
||||
this.testCurrent();
|
||||
};
|
||||
};
|
||||
} else
|
||||
{
|
||||
if (this.state == -1)
|
||||
{
|
||||
_local_4 = this.changeStrength(Feature(this.features[this.index]).type, (-(_local_3) * this.speeds[this.index]));
|
||||
if (_local_4 <= 0)
|
||||
{
|
||||
this.mask = (this.mask & (~(1 << this.types.indexOf(Feature(this.features[this.index]).type))));
|
||||
this.save();
|
||||
this.index--;
|
||||
this.swap();
|
||||
this.traceFeatures(null, true);
|
||||
this.testCurrent();
|
||||
};
|
||||
} else
|
||||
{
|
||||
this.frameCounter++;
|
||||
if ((1 / _local_3) < this.fpsThreshold)
|
||||
{
|
||||
this.lowCounter++;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
private function testNext():void
|
||||
{
|
||||
this.state = 0;
|
||||
this.frameCounter = 0;
|
||||
this.lowCounter = 0;
|
||||
this.testFeature(Feature(this.features[(this.index + 1)]).type);
|
||||
this.id = setTimeout(this.onTestNext, (this.testTime * 1000));
|
||||
this.traceFeatures(((("\nTest Next " + String((this.index + 1))) + " ") + this.features[(this.index + 1)].type), false);
|
||||
}
|
||||
|
||||
private function onTestNext():void
|
||||
{
|
||||
if ((this.lowCounter / this.frameCounter) < this.ratioThreshold)
|
||||
{
|
||||
this.index++;
|
||||
this.mask = (this.mask | (1 << this.types.indexOf(Feature(this.features[this.index]).type)));
|
||||
this.save();
|
||||
Feature(this.features[this.index]).attempts = 0;
|
||||
this.state = 1;
|
||||
this.traceFeatures("SUCCESS", true);
|
||||
} else
|
||||
{
|
||||
this.swap();
|
||||
this.traceFeatures("FAIL", true);
|
||||
if ((this.index + 1) < this.featuresCount)
|
||||
{
|
||||
this.testNext();
|
||||
} else
|
||||
{
|
||||
this.testCurrent();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
private function testCurrent():void
|
||||
{
|
||||
this.state = 0;
|
||||
this.frameCounter = 0;
|
||||
this.lowCounter = 0;
|
||||
this.id = setTimeout(this.onTestCurrent, (this.testTime * 1000));
|
||||
this.traceFeatures(((("\nTest Current " + this.index) + " ") + ((this.index >= 0) ? this.features[this.index].type : "none")), false);
|
||||
}
|
||||
|
||||
private function onTestCurrent():void
|
||||
{
|
||||
if ((this.lowCounter / this.frameCounter) < this.ratioThreshold)
|
||||
{
|
||||
this.traceFeatures("SUCCESS", true);
|
||||
if ((this.index + 1) < this.featuresCount)
|
||||
{
|
||||
this.testNext();
|
||||
} else
|
||||
{
|
||||
this.testCurrent();
|
||||
};
|
||||
} else
|
||||
{
|
||||
if (this.index >= 0)
|
||||
{
|
||||
this.traceFeatures("FAIL", false);
|
||||
this.state = -1;
|
||||
} else
|
||||
{
|
||||
this.traceFeatures("FAIL", true);
|
||||
this.testCurrent();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
private function swap():void
|
||||
{
|
||||
var _local_1:Feature = Feature(this.features[(this.index + 1)]);
|
||||
this.disableFeature(_local_1.type);
|
||||
_local_1.attempts++;
|
||||
var _local_2:int = (this.index + 1);
|
||||
while (_local_2 < (this.featuresCount - 1))
|
||||
{
|
||||
this.features[_local_2] = this.features[(_local_2 + 1)];
|
||||
_local_2++;
|
||||
};
|
||||
if (_local_1.attempts < this.maxAttempts)
|
||||
{
|
||||
this.features[(this.featuresCount - 1)] = _local_1;
|
||||
} else
|
||||
{
|
||||
this.featuresCount--;
|
||||
this.features.length = this.featuresCount;
|
||||
};
|
||||
}
|
||||
|
||||
private function save():void
|
||||
{
|
||||
storage.data[this.key] = this.mask;
|
||||
}
|
||||
|
||||
private function traceFeatures(_arg_1:String=null, _arg_2:Boolean=false):void
|
||||
{
|
||||
var _local_3:int;
|
||||
var _local_4:String;
|
||||
if (this.traceLog)
|
||||
{
|
||||
if (_arg_1 != null)
|
||||
{
|
||||
};
|
||||
if (_arg_2)
|
||||
{
|
||||
_local_3 = 0;
|
||||
while (_local_3 <= this.index)
|
||||
{
|
||||
_local_3++;
|
||||
};
|
||||
_local_3 = (this.index + 1);
|
||||
while (_local_3 < this.featuresCount)
|
||||
{
|
||||
_local_3++;
|
||||
};
|
||||
_local_4 = " ";
|
||||
_local_3 = 0;
|
||||
while (_local_3 < this.types.length)
|
||||
{
|
||||
_local_4 = (_local_4 + (this.types[_local_3] + (((this.mask & (1 << _local_3)) > 0) ? "+ " : "- ")));
|
||||
_local_3++;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
private function disableFeature(_arg_1:String):void
|
||||
{
|
||||
switch (_arg_1)
|
||||
{
|
||||
case FOG:
|
||||
this.camera.fogStrength = 0;
|
||||
return;
|
||||
case DIRECTIONAL_LIGHT:
|
||||
this.camera.directionalLightStrength = 0;
|
||||
return;
|
||||
case SHADOW_MAP:
|
||||
this.camera.shadowMapStrength = 0;
|
||||
return;
|
||||
case SOFT_TRANSPARENCY:
|
||||
this.camera.softTransparencyStrength = 0;
|
||||
return;
|
||||
case SHADOWS:
|
||||
this.camera.shadowsStrength = 0;
|
||||
return;
|
||||
case ANTI_ALIAS:
|
||||
this.camera.view.antiAliasEnabled = false;
|
||||
return;
|
||||
case SSAO:
|
||||
this.camera.ssaoStrength = 0;
|
||||
return;
|
||||
case DEFERRED_LIGHTING:
|
||||
this.camera.deferredLightingStrength = 0;
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
private function restoreFeature(_arg_1:String):void
|
||||
{
|
||||
switch (_arg_1)
|
||||
{
|
||||
case FOG:
|
||||
this.camera.fogStrength = 1;
|
||||
return;
|
||||
case DIRECTIONAL_LIGHT:
|
||||
this.camera.directionalLightStrength = 1;
|
||||
return;
|
||||
case SHADOW_MAP:
|
||||
this.camera.shadowMapStrength = 1;
|
||||
return;
|
||||
case SOFT_TRANSPARENCY:
|
||||
this.camera.softTransparencyStrength = 1;
|
||||
return;
|
||||
case SHADOWS:
|
||||
this.camera.shadowsStrength = 1;
|
||||
this.camera.shadowsDistanceMultiplier = 1;
|
||||
return;
|
||||
case ANTI_ALIAS:
|
||||
this.camera.view.antiAliasEnabled = true;
|
||||
return;
|
||||
case SSAO:
|
||||
this.camera.ssaoStrength = 1;
|
||||
return;
|
||||
case DEFERRED_LIGHTING:
|
||||
this.camera.deferredLightingStrength = 1;
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
private function testFeature(_arg_1:String):void
|
||||
{
|
||||
switch (_arg_1)
|
||||
{
|
||||
case FOG:
|
||||
this.camera.fogStrength = 0.01;
|
||||
return;
|
||||
case DIRECTIONAL_LIGHT:
|
||||
this.camera.directionalLightStrength = 0.01;
|
||||
return;
|
||||
case SHADOW_MAP:
|
||||
this.camera.shadowMapStrength = 0.01;
|
||||
return;
|
||||
case SOFT_TRANSPARENCY:
|
||||
this.camera.softTransparencyStrength = 0.01;
|
||||
return;
|
||||
case SHADOWS:
|
||||
this.camera.shadowsStrength = 0.01;
|
||||
return;
|
||||
case ANTI_ALIAS:
|
||||
this.camera.view.antiAliasEnabled = true;
|
||||
return;
|
||||
case SSAO:
|
||||
this.camera.ssaoStrength = 0.01;
|
||||
return;
|
||||
case DEFERRED_LIGHTING:
|
||||
this.camera.deferredLightingStrength = 0.01;
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
private function changeStrength(_arg_1:String, _arg_2:Number):Number
|
||||
{
|
||||
var _local_3:Number = 0;
|
||||
switch (_arg_1)
|
||||
{
|
||||
case FOG:
|
||||
this.camera.fogStrength = (this.camera.fogStrength + _arg_2);
|
||||
if (this.camera.fogStrength > 1)
|
||||
{
|
||||
this.camera.fogStrength = 1;
|
||||
};
|
||||
if (this.camera.fogStrength < 0)
|
||||
{
|
||||
this.camera.fogStrength = 0;
|
||||
};
|
||||
_local_3 = this.camera.fogStrength;
|
||||
break;
|
||||
case DIRECTIONAL_LIGHT:
|
||||
this.camera.directionalLightStrength = (this.camera.directionalLightStrength + _arg_2);
|
||||
if (this.camera.directionalLightStrength > 1)
|
||||
{
|
||||
this.camera.directionalLightStrength = 1;
|
||||
};
|
||||
if (this.camera.directionalLightStrength < 0)
|
||||
{
|
||||
this.camera.directionalLightStrength = 0;
|
||||
};
|
||||
_local_3 = this.camera.directionalLightStrength;
|
||||
break;
|
||||
case SHADOW_MAP:
|
||||
this.camera.shadowMapStrength = (this.camera.shadowMapStrength + _arg_2);
|
||||
if (this.camera.shadowMapStrength > 1)
|
||||
{
|
||||
this.camera.shadowMapStrength = 1;
|
||||
};
|
||||
if (this.camera.shadowMapStrength < 0)
|
||||
{
|
||||
this.camera.shadowMapStrength = 0;
|
||||
};
|
||||
_local_3 = this.camera.shadowMapStrength;
|
||||
break;
|
||||
case SOFT_TRANSPARENCY:
|
||||
this.camera.softTransparencyStrength = (this.camera.softTransparencyStrength + _arg_2);
|
||||
if (this.camera.softTransparencyStrength > 1)
|
||||
{
|
||||
this.camera.softTransparencyStrength = 1;
|
||||
};
|
||||
if (this.camera.softTransparencyStrength < 0)
|
||||
{
|
||||
this.camera.softTransparencyStrength = 0;
|
||||
};
|
||||
_local_3 = this.camera.softTransparencyStrength;
|
||||
break;
|
||||
case SHADOWS:
|
||||
this.camera.shadowsStrength = (this.camera.shadowsStrength + _arg_2);
|
||||
if (this.camera.shadowsStrength > 1)
|
||||
{
|
||||
this.camera.shadowsStrength = 1;
|
||||
};
|
||||
if (this.camera.shadowsStrength < 0)
|
||||
{
|
||||
this.camera.shadowsStrength = 0;
|
||||
};
|
||||
_local_3 = this.camera.shadowsStrength;
|
||||
break;
|
||||
case ANTI_ALIAS:
|
||||
this.camera.view.antiAliasEnabled = (_arg_2 > 0);
|
||||
_local_3 = ((this.camera.view.antiAliasEnabled) ? 1 : 0);
|
||||
break;
|
||||
case SSAO:
|
||||
this.camera.ssaoStrength = (this.camera.ssaoStrength + _arg_2);
|
||||
if (this.camera.ssaoStrength > 1)
|
||||
{
|
||||
this.camera.ssaoStrength = 1;
|
||||
};
|
||||
if (this.camera.ssaoStrength < 0)
|
||||
{
|
||||
this.camera.ssaoStrength = 0;
|
||||
};
|
||||
_local_3 = this.camera.ssaoStrength;
|
||||
break;
|
||||
case DEFERRED_LIGHTING:
|
||||
this.camera.deferredLightingStrength = (this.camera.deferredLightingStrength + _arg_2);
|
||||
if (this.camera.deferredLightingStrength > 1)
|
||||
{
|
||||
this.camera.deferredLightingStrength = 1;
|
||||
};
|
||||
if (this.camera.deferredLightingStrength < 0)
|
||||
{
|
||||
this.camera.deferredLightingStrength = 0;
|
||||
};
|
||||
_local_3 = this.camera.deferredLightingStrength;
|
||||
break;
|
||||
};
|
||||
return (_local_3);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
|
||||
class Feature
|
||||
{
|
||||
|
||||
public var type:String;
|
||||
public var speed:Number;
|
||||
public var attempts:int = 0;
|
||||
|
||||
public function Feature(_arg_1:String, _arg_2:Number)
|
||||
{
|
||||
this.type = _arg_1;
|
||||
this.speed = _arg_2;
|
||||
}
|
||||
|
||||
}
|
||||
23
src/alternativa/engine3d/core/RayIntersectionData.as
Normal file
23
src/alternativa/engine3d/core/RayIntersectionData.as
Normal file
@@ -0,0 +1,23 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import flash.geom.Vector3D;
|
||||
import flash.geom.Point;
|
||||
|
||||
public class RayIntersectionData
|
||||
{
|
||||
|
||||
public var object:Object3D;
|
||||
public var face:Face;
|
||||
public var point:Vector3D;
|
||||
public var uv:Point;
|
||||
public var time:Number;
|
||||
|
||||
|
||||
public function toString():String
|
||||
{
|
||||
return (((((((((("[RayIntersectionData " + this.object) + ", ") + this.face) + ", ") + this.point) + ", ") + this.uv) + ", ") + this.time) + "]");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
759
src/alternativa/engine3d/core/Shadow.as
Normal file
759
src/alternativa/engine3d/core/Shadow.as
Normal file
@@ -0,0 +1,759 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.gfx.core.ProgramResource;
|
||||
import __AS3__.vec.Vector;
|
||||
import alternativa.gfx.core.VertexBufferResource;
|
||||
import alternativa.gfx.core.IndexBufferResource;
|
||||
import flash.geom.Vector3D;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.lights.DirectionalLight;
|
||||
import alternativa.gfx.core.TextureResource;
|
||||
import flash.utils.ByteArray;
|
||||
import alternativa.gfx.agal.FragmentShader;
|
||||
import alternativa.gfx.agal.Shader;
|
||||
import alternativa.gfx.core.Device;
|
||||
import flash.display3D.Context3DVertexBufferFormat;
|
||||
import flash.display3D.Context3DProgramType;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class Shadow
|
||||
{
|
||||
|
||||
private static var casterProgram:ProgramResource;
|
||||
private static var casterConst:Vector.<Number> = Vector.<Number>([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]);
|
||||
private static var volumeProgram:ProgramResource;
|
||||
private static var volumeVertexBuffer:VertexBufferResource = new VertexBufferResource(Vector.<Number>([0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1]), 3);
|
||||
private static var volumeIndexBuffer:IndexBufferResource = new IndexBufferResource(Vector.<uint>([0, 1, 3, 2, 3, 1, 7, 6, 4, 5, 4, 6, 4, 5, 0, 1, 0, 5, 3, 2, 7, 6, 7, 2, 0, 3, 4, 7, 4, 3, 5, 6, 1, 2, 1, 6]));
|
||||
private static var volumeTransformConst:Vector.<Number> = new Vector.<Number>(20);
|
||||
private static var volumeFragmentConst:Vector.<Number> = Vector.<Number>([1, 0, 1, 0.5]);
|
||||
private static var receiverPrograms:Array = new Array();
|
||||
|
||||
public var mapSize:int;
|
||||
public var blur:int;
|
||||
public var attenuation:Number;
|
||||
public var nearDistance:Number;
|
||||
public var farDistance:Number;
|
||||
public var color:int;
|
||||
public var alpha:Number;
|
||||
public var direction:Vector3D = new Vector3D(0, 0, -1);
|
||||
public var offset:Number = 0;
|
||||
public var backFadeRange:Number = 0;
|
||||
private var casters:Vector.<Mesh> = new Vector.<Mesh>();
|
||||
private var castersCount:int = 0;
|
||||
alternativa3d var receiversBuffers:Vector.<int> = new Vector.<int>();
|
||||
alternativa3d var receiversFirstIndexes:Vector.<int> = new Vector.<int>();
|
||||
alternativa3d var receiversNumsTriangles:Vector.<int> = new Vector.<int>();
|
||||
alternativa3d var receiversCount:int = 0;
|
||||
private var dir:Vector3D = new Vector3D();
|
||||
private var light:DirectionalLight = new DirectionalLight(0);
|
||||
private var boundVertexList:Vertex = Vertex.createList(8);
|
||||
private var planeX:Number;
|
||||
private var planeY:Number;
|
||||
private var planeSize:Number;
|
||||
private var minZ:Number;
|
||||
alternativa3d var boundMinX:Number;
|
||||
alternativa3d var boundMinY:Number;
|
||||
alternativa3d var boundMinZ:Number;
|
||||
alternativa3d var boundMaxX:Number;
|
||||
alternativa3d var boundMaxY:Number;
|
||||
alternativa3d var boundMaxZ:Number;
|
||||
alternativa3d var cameraInside:Boolean;
|
||||
private var transformConst:Vector.<Number> = new Vector.<Number>(12);
|
||||
private var uvConst:Vector.<Number> = Vector.<Number>([0, 0, 0, 1, 0, 0, 0, 1]);
|
||||
private var colorConst:Vector.<Number> = new Vector.<Number>(12);
|
||||
private var clampConst:Vector.<Number> = Vector.<Number>([0, 0, 0, 1]);
|
||||
alternativa3d var texture:TextureResource;
|
||||
alternativa3d var textureScaleU:Number;
|
||||
alternativa3d var textureScaleV:Number;
|
||||
alternativa3d var textureOffsetU:Number;
|
||||
alternativa3d var textureOffsetV:Number;
|
||||
|
||||
public function Shadow(_arg_1:int, _arg_2:int, _arg_3:Number, _arg_4:Number, _arg_5:Number, _arg_6:int=0, _arg_7:Number=1)
|
||||
{
|
||||
if (_arg_1 > ShadowAtlas.sizeLimit)
|
||||
{
|
||||
throw (new Error("Value of mapSize too big."));
|
||||
};
|
||||
var _local_8:Number = (Math.log(_arg_1) / Math.LN2);
|
||||
if (_local_8 != int(_local_8))
|
||||
{
|
||||
throw (new Error("Value of mapSize must be power of 2."));
|
||||
};
|
||||
this.mapSize = _arg_1;
|
||||
this.blur = _arg_2;
|
||||
this.attenuation = _arg_3;
|
||||
this.nearDistance = _arg_4;
|
||||
this.farDistance = _arg_5;
|
||||
this.color = _arg_6;
|
||||
this.alpha = _arg_7;
|
||||
}
|
||||
|
||||
alternativa3d static function getCasterProgram():ProgramResource
|
||||
{
|
||||
var _local_2:ByteArray;
|
||||
var _local_3:FragmentShader;
|
||||
var _local_1:ProgramResource = casterProgram;
|
||||
if (_local_1 == null)
|
||||
{
|
||||
_local_2 = new ShadowCasterVertexShader().agalcode;
|
||||
_local_3 = new FragmentShader();
|
||||
_local_3.mov(FragmentShader.oc, Shader.v0);
|
||||
_local_1 = new ProgramResource(_local_2, _local_3.agalcode);
|
||||
casterProgram = _local_1;
|
||||
};
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
|
||||
public function addCaster(_arg_1:Mesh):void
|
||||
{
|
||||
this.casters[this.castersCount] = _arg_1;
|
||||
this.castersCount++;
|
||||
}
|
||||
|
||||
public function removeCaster(_arg_1:Mesh):void
|
||||
{
|
||||
var _local_2:int;
|
||||
while (_local_2 < this.castersCount)
|
||||
{
|
||||
if (this.casters[_local_2] == _arg_1)
|
||||
{
|
||||
this.castersCount--;
|
||||
while (_local_2 < this.castersCount)
|
||||
{
|
||||
this.casters[_local_2] = this.casters[int((_local_2 + 1))];
|
||||
_local_2++;
|
||||
};
|
||||
this.casters.length = this.castersCount;
|
||||
return;
|
||||
};
|
||||
_local_2++;
|
||||
};
|
||||
}
|
||||
|
||||
public function removeAllCasters():void
|
||||
{
|
||||
this.castersCount = 0;
|
||||
this.casters.length = 0;
|
||||
}
|
||||
|
||||
alternativa3d function checkVisibility(_arg_1:Camera3D):Boolean
|
||||
{
|
||||
var _local_24:Object3D;
|
||||
var _local_25:Object3D;
|
||||
var _local_26:Vertex;
|
||||
var _local_27:Number;
|
||||
if (this.castersCount == 0)
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
if (this.direction != null)
|
||||
{
|
||||
this.dir.x = this.direction.x;
|
||||
this.dir.y = this.direction.y;
|
||||
this.dir.z = this.direction.z;
|
||||
this.dir.normalize();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dir.x = 0;
|
||||
this.dir.y = 0;
|
||||
this.dir.z = -1;
|
||||
};
|
||||
this.light.rotationX = (Math.atan2(this.dir.z, Math.sqrt(((this.dir.x * this.dir.x) + (this.dir.y * this.dir.y)))) - (Math.PI / 2));
|
||||
this.light.rotationY = 0;
|
||||
this.light.rotationZ = -(Math.atan2(this.dir.x, this.dir.y));
|
||||
this.light.composeMatrix();
|
||||
var _local_2:Number = this.light.ma;
|
||||
var _local_3:Number = this.light.mb;
|
||||
var _local_4:Number = this.light.mc;
|
||||
var _local_5:Number = this.light.md;
|
||||
var _local_6:Number = this.light.me;
|
||||
var _local_7:Number = this.light.mf;
|
||||
var _local_8:Number = this.light.mg;
|
||||
var _local_9:Number = this.light.mh;
|
||||
var _local_10:Number = this.light.mi;
|
||||
var _local_11:Number = this.light.mj;
|
||||
var _local_12:Number = this.light.mk;
|
||||
var _local_13:Number = this.light.ml;
|
||||
this.light.invertMatrix();
|
||||
this.light.ima = this.light.ma;
|
||||
this.light.imb = this.light.mb;
|
||||
this.light.imc = this.light.mc;
|
||||
this.light.imd = this.light.md;
|
||||
this.light.ime = this.light.me;
|
||||
this.light.imf = this.light.mf;
|
||||
this.light.img = this.light.mg;
|
||||
this.light.imh = this.light.mh;
|
||||
this.light.imi = this.light.mi;
|
||||
this.light.imj = this.light.mj;
|
||||
this.light.imk = this.light.mk;
|
||||
this.light.iml = this.light.ml;
|
||||
this.light.boundMinX = 1E22;
|
||||
this.light.boundMinY = 1E22;
|
||||
this.light.boundMinZ = 1E22;
|
||||
this.light.boundMaxX = -1E22;
|
||||
this.light.boundMaxY = -1E22;
|
||||
this.light.boundMaxZ = -1E22;
|
||||
var _local_14:int;
|
||||
while (_local_14 < this.castersCount)
|
||||
{
|
||||
_local_24 = this.casters[_local_14];
|
||||
_local_24.composeMatrix();
|
||||
_local_25 = _local_24._parent;
|
||||
while (_local_25 != null)
|
||||
{
|
||||
Object3D.tA.composeMatrixFromSource(_local_25);
|
||||
_local_24.appendMatrix(Object3D.tA);
|
||||
_local_25 = _local_25._parent;
|
||||
};
|
||||
_local_24.appendMatrix(this.light);
|
||||
_local_26 = this.boundVertexList;
|
||||
_local_26.x = _local_24.boundMinX;
|
||||
_local_26.y = _local_24.boundMinY;
|
||||
_local_26.z = _local_24.boundMinZ;
|
||||
_local_26 = _local_26.next;
|
||||
_local_26.x = _local_24.boundMaxX;
|
||||
_local_26.y = _local_24.boundMinY;
|
||||
_local_26.z = _local_24.boundMinZ;
|
||||
_local_26 = _local_26.next;
|
||||
_local_26.x = _local_24.boundMinX;
|
||||
_local_26.y = _local_24.boundMaxY;
|
||||
_local_26.z = _local_24.boundMinZ;
|
||||
_local_26 = _local_26.next;
|
||||
_local_26.x = _local_24.boundMaxX;
|
||||
_local_26.y = _local_24.boundMaxY;
|
||||
_local_26.z = _local_24.boundMinZ;
|
||||
_local_26 = _local_26.next;
|
||||
_local_26.x = _local_24.boundMinX;
|
||||
_local_26.y = _local_24.boundMinY;
|
||||
_local_26.z = _local_24.boundMaxZ;
|
||||
_local_26 = _local_26.next;
|
||||
_local_26.x = _local_24.boundMaxX;
|
||||
_local_26.y = _local_24.boundMinY;
|
||||
_local_26.z = _local_24.boundMaxZ;
|
||||
_local_26 = _local_26.next;
|
||||
_local_26.x = _local_24.boundMinX;
|
||||
_local_26.y = _local_24.boundMaxY;
|
||||
_local_26.z = _local_24.boundMaxZ;
|
||||
_local_26 = _local_26.next;
|
||||
_local_26.x = _local_24.boundMaxX;
|
||||
_local_26.y = _local_24.boundMaxY;
|
||||
_local_26.z = _local_24.boundMaxZ;
|
||||
_local_26 = this.boundVertexList;
|
||||
while (_local_26 != null)
|
||||
{
|
||||
_local_26.cameraX = ((((_local_24.ma * _local_26.x) + (_local_24.mb * _local_26.y)) + (_local_24.mc * _local_26.z)) + _local_24.md);
|
||||
_local_26.cameraY = ((((_local_24.me * _local_26.x) + (_local_24.mf * _local_26.y)) + (_local_24.mg * _local_26.z)) + _local_24.mh);
|
||||
_local_26.cameraZ = ((((_local_24.mi * _local_26.x) + (_local_24.mj * _local_26.y)) + (_local_24.mk * _local_26.z)) + _local_24.ml);
|
||||
if (_local_26.cameraX < this.light.boundMinX)
|
||||
{
|
||||
this.light.boundMinX = _local_26.cameraX;
|
||||
};
|
||||
if (_local_26.cameraX > this.light.boundMaxX)
|
||||
{
|
||||
this.light.boundMaxX = _local_26.cameraX;
|
||||
};
|
||||
if (_local_26.cameraY < this.light.boundMinY)
|
||||
{
|
||||
this.light.boundMinY = _local_26.cameraY;
|
||||
};
|
||||
if (_local_26.cameraY > this.light.boundMaxY)
|
||||
{
|
||||
this.light.boundMaxY = _local_26.cameraY;
|
||||
};
|
||||
if (_local_26.cameraZ < this.light.boundMinZ)
|
||||
{
|
||||
this.light.boundMinZ = _local_26.cameraZ;
|
||||
};
|
||||
if (_local_26.cameraZ > this.light.boundMaxZ)
|
||||
{
|
||||
this.light.boundMaxZ = _local_26.cameraZ;
|
||||
};
|
||||
_local_26 = _local_26.next;
|
||||
};
|
||||
_local_14++;
|
||||
};
|
||||
var _local_15:int = ((((this.mapSize - 1) - 1) - this.blur) - this.blur);
|
||||
var _local_16:Number = (this.light.boundMaxX - this.light.boundMinX);
|
||||
var _local_17:Number = (this.light.boundMaxY - this.light.boundMinY);
|
||||
var _local_18:Number = ((_local_16 > _local_17) ? _local_16 : _local_17);
|
||||
var _local_19:Number = (_local_18 / _local_15);
|
||||
var _local_20:Number = ((1 + this.blur) * _local_19);
|
||||
var _local_21:Number = ((1 + this.blur) * _local_19);
|
||||
if (_local_16 > _local_17)
|
||||
{
|
||||
_local_21 = (_local_21 + (((Math.ceil(((_local_17 - 0.01) / (_local_19 + _local_19))) * (_local_19 + _local_19)) - _local_17) * 0.5));
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_20 = (_local_20 + (((Math.ceil(((_local_16 - 0.01) / (_local_19 + _local_19))) * (_local_19 + _local_19)) - _local_16) * 0.5));
|
||||
};
|
||||
this.light.boundMinX = (this.light.boundMinX - _local_20);
|
||||
this.light.boundMaxX = (this.light.boundMaxX + _local_20);
|
||||
this.light.boundMinY = (this.light.boundMinY - _local_21);
|
||||
this.light.boundMaxY = (this.light.boundMaxY + _local_21);
|
||||
this.light.boundMinZ = (this.light.boundMinZ + this.offset);
|
||||
this.light.boundMaxZ = (this.light.boundMaxZ + this.attenuation);
|
||||
this.planeSize = ((_local_18 * this.mapSize) / _local_15);
|
||||
if (_local_16 > _local_17)
|
||||
{
|
||||
this.planeX = this.light.boundMinX;
|
||||
this.planeY = (this.light.boundMinY - (((this.light.boundMaxX - this.light.boundMinX) - (this.light.boundMaxY - this.light.boundMinY)) * 0.5));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.planeX = (this.light.boundMinX - (((this.light.boundMaxY - this.light.boundMinY) - (this.light.boundMaxX - this.light.boundMinX)) * 0.5));
|
||||
this.planeY = this.light.boundMinY;
|
||||
};
|
||||
var _local_22:Number = _arg_1.farClipping;
|
||||
_arg_1.farClipping = (this.farDistance * _arg_1.shadowsDistanceMultiplier);
|
||||
this.light.ma = _local_2;
|
||||
this.light.mb = _local_3;
|
||||
this.light.mc = _local_4;
|
||||
this.light.md = _local_5;
|
||||
this.light.me = _local_6;
|
||||
this.light.mf = _local_7;
|
||||
this.light.mg = _local_8;
|
||||
this.light.mh = _local_9;
|
||||
this.light.mi = _local_10;
|
||||
this.light.mj = _local_11;
|
||||
this.light.mk = _local_12;
|
||||
this.light.ml = _local_13;
|
||||
this.light.appendMatrix(_arg_1);
|
||||
var _local_23:Boolean = this.cullingInCamera(_arg_1);
|
||||
_arg_1.farClipping = _local_22;
|
||||
if (_local_23)
|
||||
{
|
||||
if (((_arg_1.debug) && (_arg_1.checkInDebug(this.light) & Debug.BOUNDS)))
|
||||
{
|
||||
Debug.drawBounds(_arg_1, this.light, this.light.boundMinX, this.light.boundMinY, this.light.boundMinZ, this.light.boundMaxX, this.light.boundMaxY, this.light.boundMaxZ, 0xFF00FF);
|
||||
};
|
||||
this.boundMinX = 1E22;
|
||||
this.boundMinY = 1E22;
|
||||
this.boundMinZ = 1E22;
|
||||
this.boundMaxX = -1E22;
|
||||
this.boundMaxY = -1E22;
|
||||
this.boundMaxZ = -1E22;
|
||||
_local_26 = this.boundVertexList;
|
||||
while (_local_26 != null)
|
||||
{
|
||||
_local_26.cameraX = ((((_local_2 * _local_26.x) + (_local_3 * _local_26.y)) + (_local_4 * _local_26.z)) + _local_5);
|
||||
_local_26.cameraY = ((((_local_6 * _local_26.x) + (_local_7 * _local_26.y)) + (_local_8 * _local_26.z)) + _local_9);
|
||||
_local_26.cameraZ = ((((_local_10 * _local_26.x) + (_local_11 * _local_26.y)) + (_local_12 * _local_26.z)) + _local_13);
|
||||
if (_local_26.cameraX < this.boundMinX)
|
||||
{
|
||||
this.boundMinX = _local_26.cameraX;
|
||||
};
|
||||
if (_local_26.cameraX > this.boundMaxX)
|
||||
{
|
||||
this.boundMaxX = _local_26.cameraX;
|
||||
};
|
||||
if (_local_26.cameraY < this.boundMinY)
|
||||
{
|
||||
this.boundMinY = _local_26.cameraY;
|
||||
};
|
||||
if (_local_26.cameraY > this.boundMaxY)
|
||||
{
|
||||
this.boundMaxY = _local_26.cameraY;
|
||||
};
|
||||
if (_local_26.cameraZ < this.boundMinZ)
|
||||
{
|
||||
this.boundMinZ = _local_26.cameraZ;
|
||||
};
|
||||
if (_local_26.cameraZ > this.boundMaxZ)
|
||||
{
|
||||
this.boundMaxZ = _local_26.cameraZ;
|
||||
};
|
||||
_local_26 = _local_26.next;
|
||||
};
|
||||
this.cameraInside = false;
|
||||
if (this.minZ <= _arg_1.nearClipping)
|
||||
{
|
||||
_local_27 = ((((this.light.ima * _arg_1.gmd) + (this.light.imb * _arg_1.gmh)) + (this.light.imc * _arg_1.gml)) + this.light.imd);
|
||||
if ((((_local_27 - _arg_1.nearClipping) <= this.light.boundMaxX) && ((_local_27 + _arg_1.nearClipping) >= this.light.boundMinX)))
|
||||
{
|
||||
_local_27 = ((((this.light.ime * _arg_1.gmd) + (this.light.imf * _arg_1.gmh)) + (this.light.img * _arg_1.gml)) + this.light.imh);
|
||||
if ((((_local_27 - _arg_1.nearClipping) <= this.light.boundMaxY) && ((_local_27 + _arg_1.nearClipping) >= this.light.boundMinY)))
|
||||
{
|
||||
_local_27 = ((((this.light.imi * _arg_1.gmd) + (this.light.imj * _arg_1.gmh)) + (this.light.imk * _arg_1.gml)) + this.light.iml);
|
||||
if ((((_local_27 - _arg_1.nearClipping) <= this.light.boundMaxZ) && ((_local_27 + _arg_1.nearClipping) >= this.light.boundMinZ)))
|
||||
{
|
||||
this.cameraInside = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
return (_local_23);
|
||||
}
|
||||
|
||||
alternativa3d function renderCasters(_arg_1:Camera3D):void
|
||||
{
|
||||
var _local_10:Mesh;
|
||||
var _local_2:Device = _arg_1.device;
|
||||
var _local_3:Number = (2 / this.planeSize);
|
||||
var _local_4:Number = (-2 / this.planeSize);
|
||||
var _local_5:Number = (1 / ((this.light.boundMaxZ - this.attenuation) - (this.light.boundMinZ - this.offset)));
|
||||
var _local_6:Number = (-(this.light.boundMinZ - this.offset) * _local_5);
|
||||
var _local_7:Number = ((this.light.boundMinX + this.light.boundMaxX) * 0.5);
|
||||
var _local_8:Number = ((this.light.boundMinY + this.light.boundMaxY) * 0.5);
|
||||
var _local_9:int;
|
||||
while (_local_9 < this.castersCount)
|
||||
{
|
||||
_local_10 = this.casters[_local_9];
|
||||
_local_10.prepareResources();
|
||||
casterConst[0] = (_local_10.ma * _local_3);
|
||||
casterConst[1] = (_local_10.mb * _local_3);
|
||||
casterConst[2] = (_local_10.mc * _local_3);
|
||||
casterConst[3] = ((_local_10.md - _local_7) * _local_3);
|
||||
casterConst[4] = (_local_10.me * _local_4);
|
||||
casterConst[5] = (_local_10.mf * _local_4);
|
||||
casterConst[6] = (_local_10.mg * _local_4);
|
||||
casterConst[7] = ((_local_10.mh - _local_8) * _local_4);
|
||||
casterConst[8] = (_local_10.mi * _local_5);
|
||||
casterConst[9] = (_local_10.mj * _local_5);
|
||||
casterConst[10] = (_local_10.mk * _local_5);
|
||||
casterConst[11] = ((_local_10.ml * _local_5) + _local_6);
|
||||
casterConst[12] = this.textureScaleU;
|
||||
casterConst[13] = this.textureScaleV;
|
||||
casterConst[16] = (((2 * this.textureOffsetU) - 1) + this.textureScaleU);
|
||||
casterConst[17] = -(((2 * this.textureOffsetV) - 1) + this.textureScaleV);
|
||||
_local_2.setVertexBufferAt(0, _local_10.vertexBuffer, 0, Context3DVertexBufferFormat.FLOAT_3);
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 0, casterConst, 5, false);
|
||||
_local_2.drawTriangles(_local_10.indexBuffer, 0, _local_10.numTriangles);
|
||||
_local_9++;
|
||||
};
|
||||
this.clampConst[0] = this.textureOffsetU;
|
||||
this.clampConst[1] = this.textureOffsetV;
|
||||
this.clampConst[2] = (this.textureOffsetU + this.textureScaleU);
|
||||
this.clampConst[3] = (this.textureOffsetV + this.textureScaleV);
|
||||
}
|
||||
|
||||
alternativa3d function renderVolume(_arg_1:Camera3D):void
|
||||
{
|
||||
var _local_2:Device = _arg_1.device;
|
||||
volumeTransformConst[0] = this.light.ma;
|
||||
volumeTransformConst[1] = this.light.mb;
|
||||
volumeTransformConst[2] = this.light.mc;
|
||||
volumeTransformConst[3] = this.light.md;
|
||||
volumeTransformConst[4] = this.light.me;
|
||||
volumeTransformConst[5] = this.light.mf;
|
||||
volumeTransformConst[6] = this.light.mg;
|
||||
volumeTransformConst[7] = this.light.mh;
|
||||
volumeTransformConst[8] = this.light.mi;
|
||||
volumeTransformConst[9] = this.light.mj;
|
||||
volumeTransformConst[10] = this.light.mk;
|
||||
volumeTransformConst[11] = this.light.ml;
|
||||
volumeTransformConst[12] = (this.light.boundMaxX - this.light.boundMinX);
|
||||
volumeTransformConst[13] = (this.light.boundMaxY - this.light.boundMinY);
|
||||
volumeTransformConst[14] = (this.light.boundMaxZ - this.light.boundMinZ);
|
||||
volumeTransformConst[15] = 1;
|
||||
volumeTransformConst[16] = this.light.boundMinX;
|
||||
volumeTransformConst[17] = this.light.boundMinY;
|
||||
volumeTransformConst[18] = this.light.boundMinZ;
|
||||
volumeTransformConst[19] = 1;
|
||||
_local_2.setProgram(this.getVolumeProgram());
|
||||
_local_2.setVertexBufferAt(0, volumeVertexBuffer, 0, Context3DVertexBufferFormat.FLOAT_3);
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 11, volumeTransformConst, 5, false);
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 16, _arg_1.projection, 1);
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 17, _arg_1.correction, 1);
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 13, volumeFragmentConst, 1);
|
||||
_local_2.drawTriangles(volumeIndexBuffer, 0, 12);
|
||||
}
|
||||
|
||||
alternativa3d function renderReceivers(_arg_1:Camera3D):void
|
||||
{
|
||||
var _local_21:int;
|
||||
var _local_2:Device = _arg_1.device;
|
||||
var _local_3:Number = (this.light.boundMinZ - this.offset);
|
||||
var _local_4:Number = ((this.light.boundMaxZ - this.attenuation) - _local_3);
|
||||
var _local_5:Number = (this.light.ima / this.planeSize);
|
||||
var _local_6:Number = (this.light.imb / this.planeSize);
|
||||
var _local_7:Number = (this.light.imc / this.planeSize);
|
||||
var _local_8:Number = ((this.light.imd - this.planeX) / this.planeSize);
|
||||
var _local_9:Number = (this.light.ime / this.planeSize);
|
||||
var _local_10:Number = (this.light.imf / this.planeSize);
|
||||
var _local_11:Number = (this.light.img / this.planeSize);
|
||||
var _local_12:Number = ((this.light.imh - this.planeY) / this.planeSize);
|
||||
var _local_13:Number = (this.light.imi / _local_4);
|
||||
var _local_14:Number = (this.light.imj / _local_4);
|
||||
var _local_15:Number = (this.light.imk / _local_4);
|
||||
var _local_16:Number = ((this.light.iml - _local_3) / _local_4);
|
||||
this.transformConst[0] = (((_local_5 * _arg_1.gma) + (_local_6 * _arg_1.gme)) + (_local_7 * _arg_1.gmi));
|
||||
this.transformConst[1] = (((_local_5 * _arg_1.gmb) + (_local_6 * _arg_1.gmf)) + (_local_7 * _arg_1.gmj));
|
||||
this.transformConst[2] = (((_local_5 * _arg_1.gmc) + (_local_6 * _arg_1.gmg)) + (_local_7 * _arg_1.gmk));
|
||||
this.transformConst[3] = ((((_local_5 * _arg_1.gmd) + (_local_6 * _arg_1.gmh)) + (_local_7 * _arg_1.gml)) + _local_8);
|
||||
this.transformConst[4] = (((_local_9 * _arg_1.gma) + (_local_10 * _arg_1.gme)) + (_local_11 * _arg_1.gmi));
|
||||
this.transformConst[5] = (((_local_9 * _arg_1.gmb) + (_local_10 * _arg_1.gmf)) + (_local_11 * _arg_1.gmj));
|
||||
this.transformConst[6] = (((_local_9 * _arg_1.gmc) + (_local_10 * _arg_1.gmg)) + (_local_11 * _arg_1.gmk));
|
||||
this.transformConst[7] = ((((_local_9 * _arg_1.gmd) + (_local_10 * _arg_1.gmh)) + (_local_11 * _arg_1.gml)) + _local_12);
|
||||
this.transformConst[8] = (((_local_13 * _arg_1.gma) + (_local_14 * _arg_1.gme)) + (_local_15 * _arg_1.gmi));
|
||||
this.transformConst[9] = (((_local_13 * _arg_1.gmb) + (_local_14 * _arg_1.gmf)) + (_local_15 * _arg_1.gmj));
|
||||
this.transformConst[10] = (((_local_13 * _arg_1.gmc) + (_local_14 * _arg_1.gmg)) + (_local_15 * _arg_1.gmk));
|
||||
this.transformConst[11] = ((((_local_13 * _arg_1.gmd) + (_local_14 * _arg_1.gmh)) + (_local_15 * _arg_1.gml)) + _local_16);
|
||||
this.uvConst[0] = this.textureScaleU;
|
||||
this.uvConst[1] = this.textureScaleV;
|
||||
this.uvConst[4] = this.textureOffsetU;
|
||||
this.uvConst[5] = this.textureOffsetV;
|
||||
var _local_17:Number = (this.nearDistance * _arg_1.shadowsDistanceMultiplier);
|
||||
var _local_18:Number = (this.farDistance * _arg_1.shadowsDistanceMultiplier);
|
||||
var _local_19:Number = (1 - ((this.minZ - _local_17) / (_local_18 - _local_17)));
|
||||
if (_local_19 < 0)
|
||||
{
|
||||
_local_19 = 0;
|
||||
};
|
||||
if (_local_19 > 1)
|
||||
{
|
||||
_local_19 = 1;
|
||||
};
|
||||
this.colorConst[0] = 0;
|
||||
this.colorConst[1] = 0x0100;
|
||||
this.colorConst[2] = 1;
|
||||
this.colorConst[3] = (this.attenuation / _local_4);
|
||||
this.colorConst[4] = 0;
|
||||
this.colorConst[5] = (this.backFadeRange / _local_4);
|
||||
this.colorConst[6] = (this.offset / _local_4);
|
||||
this.colorConst[7] = 1;
|
||||
this.colorConst[8] = (((this.color >> 16) & 0xFF) / 0xFF);
|
||||
this.colorConst[9] = (((this.color >> 8) & 0xFF) / 0xFF);
|
||||
this.colorConst[10] = ((this.color & 0xFF) / 0xFF);
|
||||
this.colorConst[11] = ((this.alpha * _local_19) * _arg_1.shadowsStrength);
|
||||
_local_2.setProgram(this.getReceiverProgram(_arg_1.view.quality, this.cameraInside, _arg_1.view.correction));
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 11, _arg_1.transform, 3);
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 14, _arg_1.projection, 1);
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 15, this.transformConst, 3);
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 18, _arg_1.correction, 1);
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 19, this.uvConst, 2);
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 13, this.colorConst, 3);
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 16, this.clampConst, 1);
|
||||
var _local_20:int;
|
||||
while (_local_20 < this.receiversCount)
|
||||
{
|
||||
_local_21 = this.receiversBuffers[_local_20];
|
||||
_local_2.setVertexBufferAt(0, _arg_1.receiversVertexBuffers[_local_21], 0, Context3DVertexBufferFormat.FLOAT_3);
|
||||
_local_2.drawTriangles(_arg_1.receiversIndexBuffers[_local_21], this.receiversFirstIndexes[_local_20], this.receiversNumsTriangles[_local_20]);
|
||||
_arg_1.numShadows++;
|
||||
_local_20++;
|
||||
};
|
||||
this.receiversCount = 0;
|
||||
}
|
||||
|
||||
private function getVolumeProgram():ProgramResource
|
||||
{
|
||||
var _local_2:ByteArray;
|
||||
var _local_3:FragmentShader;
|
||||
var _local_1:ProgramResource = volumeProgram;
|
||||
if (_local_1 == null)
|
||||
{
|
||||
_local_2 = new ShadowVolumeVertexShader().agalcode;
|
||||
_local_3 = new FragmentShader();
|
||||
_local_3.mov(FragmentShader.oc, FragmentShader.fc[13]);
|
||||
_local_1 = new ProgramResource(_local_2, _local_3.agalcode);
|
||||
volumeProgram = _local_1;
|
||||
};
|
||||
return (_local_1);
|
||||
}
|
||||
|
||||
private function getReceiverProgram(_arg_1:Boolean, _arg_2:Boolean, _arg_3:Boolean):ProgramResource
|
||||
{
|
||||
var _local_6:ByteArray;
|
||||
var _local_7:ByteArray;
|
||||
var _local_4:int = ((int(_arg_1) | (int(_arg_2) << 1)) | (int(_arg_3) << 2));
|
||||
var _local_5:ProgramResource = receiverPrograms[_local_4];
|
||||
if (_local_5 == null)
|
||||
{
|
||||
_local_6 = new ShadowReceiverVertexShader(_arg_3).agalcode;
|
||||
_local_7 = new ShadowReceiverFragmentShader(_arg_1, _arg_2).agalcode;
|
||||
_local_5 = new ProgramResource(_local_6, _local_7);
|
||||
receiverPrograms[_local_4] = _local_5;
|
||||
};
|
||||
return (_local_5);
|
||||
}
|
||||
|
||||
private function cullingInCamera(_arg_1:Camera3D):Boolean
|
||||
{
|
||||
var _local_3:Boolean;
|
||||
var _local_4:Boolean;
|
||||
var _local_2:Vertex = this.boundVertexList;
|
||||
_local_2.x = this.light.boundMinX;
|
||||
_local_2.y = this.light.boundMinY;
|
||||
_local_2.z = this.light.boundMinZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = this.light.boundMaxX;
|
||||
_local_2.y = this.light.boundMinY;
|
||||
_local_2.z = this.light.boundMinZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = this.light.boundMinX;
|
||||
_local_2.y = this.light.boundMaxY;
|
||||
_local_2.z = this.light.boundMinZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = this.light.boundMaxX;
|
||||
_local_2.y = this.light.boundMaxY;
|
||||
_local_2.z = this.light.boundMinZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = this.light.boundMinX;
|
||||
_local_2.y = this.light.boundMinY;
|
||||
_local_2.z = this.light.boundMaxZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = this.light.boundMaxX;
|
||||
_local_2.y = this.light.boundMinY;
|
||||
_local_2.z = this.light.boundMaxZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = this.light.boundMinX;
|
||||
_local_2.y = this.light.boundMaxY;
|
||||
_local_2.z = this.light.boundMaxZ;
|
||||
_local_2 = _local_2.next;
|
||||
_local_2.x = this.light.boundMaxX;
|
||||
_local_2.y = this.light.boundMaxY;
|
||||
_local_2.z = this.light.boundMaxZ;
|
||||
this.minZ = 1E22;
|
||||
_local_2 = this.boundVertexList;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
_local_2.cameraX = ((((this.light.ma * _local_2.x) + (this.light.mb * _local_2.y)) + (this.light.mc * _local_2.z)) + this.light.md);
|
||||
_local_2.cameraY = ((((this.light.me * _local_2.x) + (this.light.mf * _local_2.y)) + (this.light.mg * _local_2.z)) + this.light.mh);
|
||||
_local_2.cameraZ = ((((this.light.mi * _local_2.x) + (this.light.mj * _local_2.y)) + (this.light.mk * _local_2.z)) + this.light.ml);
|
||||
if (_local_2.cameraZ < this.minZ)
|
||||
{
|
||||
this.minZ = _local_2.cameraZ;
|
||||
};
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
var _local_5:Number = _arg_1.nearClipping;
|
||||
_local_2 = this.boundVertexList;
|
||||
_local_3 = false;
|
||||
_local_4 = false;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (_local_2.cameraZ > _local_5)
|
||||
{
|
||||
_local_3 = true;
|
||||
if (_local_4) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_4 = true;
|
||||
if (_local_3) break;
|
||||
};
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (((_local_4) && (!(_local_3))))
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
var _local_6:Number = _arg_1.farClipping;
|
||||
_local_2 = this.boundVertexList;
|
||||
_local_3 = false;
|
||||
_local_4 = false;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (_local_2.cameraZ < _local_6)
|
||||
{
|
||||
_local_3 = true;
|
||||
if (_local_4) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_4 = true;
|
||||
if (_local_3) break;
|
||||
};
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (((_local_4) && (!(_local_3))))
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = this.boundVertexList;
|
||||
_local_3 = false;
|
||||
_local_4 = false;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (-(_local_2.cameraX) < _local_2.cameraZ)
|
||||
{
|
||||
_local_3 = true;
|
||||
if (_local_4) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_4 = true;
|
||||
if (_local_3) break;
|
||||
};
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (((_local_4) && (!(_local_3))))
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = this.boundVertexList;
|
||||
_local_3 = false;
|
||||
_local_4 = false;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (_local_2.cameraX < _local_2.cameraZ)
|
||||
{
|
||||
_local_3 = true;
|
||||
if (_local_4) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_4 = true;
|
||||
if (_local_3) break;
|
||||
};
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (((_local_4) && (!(_local_3))))
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = this.boundVertexList;
|
||||
_local_3 = false;
|
||||
_local_4 = false;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (-(_local_2.cameraY) < _local_2.cameraZ)
|
||||
{
|
||||
_local_3 = true;
|
||||
if (_local_4) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_4 = true;
|
||||
if (_local_3) break;
|
||||
};
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (((_local_4) && (!(_local_3))))
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
_local_2 = this.boundVertexList;
|
||||
_local_3 = false;
|
||||
_local_4 = false;
|
||||
while (_local_2 != null)
|
||||
{
|
||||
if (_local_2.cameraY < _local_2.cameraZ)
|
||||
{
|
||||
_local_3 = true;
|
||||
if (_local_4) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_4 = true;
|
||||
if (_local_3) break;
|
||||
};
|
||||
_local_2 = _local_2.next;
|
||||
};
|
||||
if (((_local_4) && (!(_local_3))))
|
||||
{
|
||||
return (false);
|
||||
};
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
139
src/alternativa/engine3d/core/ShadowAtlas.as
Normal file
139
src/alternativa/engine3d/core/ShadowAtlas.as
Normal file
@@ -0,0 +1,139 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.gfx.core.VertexBufferResource;
|
||||
import alternativa.gfx.core.IndexBufferResource;
|
||||
import __AS3__.vec.Vector;
|
||||
import alternativa.gfx.core.RenderTargetTextureResource;
|
||||
import alternativa.gfx.core.Device;
|
||||
import flash.display3D.Context3DVertexBufferFormat;
|
||||
import flash.display3D.Context3DProgramType;
|
||||
import flash.utils.ByteArray;
|
||||
import alternativa.gfx.core.ProgramResource;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class ShadowAtlas
|
||||
{
|
||||
|
||||
alternativa3d static const sizeLimit:int = 0x0400;
|
||||
private static var blurPrograms:Array = new Array();
|
||||
private static var blurVertexBuffer:VertexBufferResource = new VertexBufferResource(Vector.<Number>([-1, 1, 0, 0, 0, -1, -1, 0, 0, 1, 1, -1, 0, 1, 1, 1, 1, 0, 1, 0]), 5);
|
||||
private static var blurIndexBuffer:IndexBufferResource = new IndexBufferResource(Vector.<uint>([0, 1, 3, 2, 3, 1]));
|
||||
private static var blurConst:Vector.<Number> = Vector.<Number>([0, 0, 0, 1, 0, 0, 0, 1]);
|
||||
|
||||
alternativa3d var shadows:Vector.<Shadow> = new Vector.<Shadow>();
|
||||
alternativa3d var shadowsCount:int = 0;
|
||||
private var mapSize:int;
|
||||
private var blur:int;
|
||||
private var maps:Array = new Array();
|
||||
private var map1:RenderTargetTextureResource;
|
||||
private var map2:RenderTargetTextureResource;
|
||||
|
||||
public function ShadowAtlas(_arg_1:int, _arg_2:int)
|
||||
{
|
||||
this.mapSize = _arg_1;
|
||||
this.blur = _arg_2;
|
||||
}
|
||||
|
||||
alternativa3d function renderCasters(_arg_1:Camera3D):void
|
||||
{
|
||||
var _local_9:Shadow;
|
||||
var _local_2:Device = _arg_1.device;
|
||||
var _local_3:int = int((sizeLimit / this.mapSize));
|
||||
var _local_4:int = int(Math.ceil((this.shadowsCount / _local_3)));
|
||||
var _local_5:int = ((this.shadowsCount > _local_3) ? _local_3 : this.shadowsCount);
|
||||
_local_4 = int((1 << Math.ceil((Math.log(_local_4) / Math.LN2))));
|
||||
_local_5 = int((1 << Math.ceil((Math.log(_local_5) / Math.LN2))));
|
||||
if (_local_4 > _local_3)
|
||||
{
|
||||
_local_4 = _local_3;
|
||||
this.shadowsCount = (_local_4 * _local_5);
|
||||
};
|
||||
var _local_6:int = ((_local_4 << 8) | _local_5);
|
||||
this.map1 = this.maps[_local_6];
|
||||
var _local_7:int = ((1 << 16) | _local_6);
|
||||
this.map2 = this.maps[_local_7];
|
||||
if (this.map1 == null)
|
||||
{
|
||||
this.map1 = new RenderTargetTextureResource((_local_5 * this.mapSize), (_local_4 * this.mapSize));
|
||||
this.map2 = new RenderTargetTextureResource((_local_5 * this.mapSize), (_local_4 * this.mapSize));
|
||||
this.maps[_local_6] = this.map1;
|
||||
this.maps[_local_7] = this.map2;
|
||||
};
|
||||
_local_2.setRenderToTexture(this.map1, true);
|
||||
_local_2.clear(0, 0, 0, 0, 0);
|
||||
var _local_8:int;
|
||||
while (_local_8 < this.shadowsCount)
|
||||
{
|
||||
_local_9 = this.shadows[_local_8];
|
||||
_local_9.texture = this.map1;
|
||||
_local_9.textureScaleU = (1 / _local_5);
|
||||
_local_9.textureScaleV = (1 / _local_4);
|
||||
_local_9.textureOffsetU = ((_local_8 % _local_5) / _local_5);
|
||||
_local_9.textureOffsetV = (int((_local_8 / _local_5)) / _local_4);
|
||||
_local_9.renderCasters(_arg_1);
|
||||
_local_8++;
|
||||
};
|
||||
}
|
||||
|
||||
alternativa3d function renderBlur(_arg_1:Camera3D):void
|
||||
{
|
||||
var _local_2:Device = _arg_1.device;
|
||||
if (this.blur > 0)
|
||||
{
|
||||
_local_2.setVertexBufferAt(0, blurVertexBuffer, 0, Context3DVertexBufferFormat.FLOAT_3);
|
||||
_local_2.setVertexBufferAt(1, blurVertexBuffer, 3, Context3DVertexBufferFormat.FLOAT_2);
|
||||
blurConst[0] = (1 / this.map1.width);
|
||||
blurConst[1] = (1 / this.map1.height);
|
||||
blurConst[3] = ((1 + this.blur) + this.blur);
|
||||
blurConst[4] = (this.blur / this.map1.width);
|
||||
blurConst[5] = (this.blur / this.map1.height);
|
||||
_local_2.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, blurConst, 2);
|
||||
_local_2.setRenderToTexture(this.map2, false);
|
||||
_local_2.clear(0, 0, 0, 0);
|
||||
_local_2.setProgram(this.getBlurProgram(1, this.blur));
|
||||
_local_2.setTextureAt(0, this.map1);
|
||||
_local_2.drawTriangles(blurIndexBuffer, 0, 2);
|
||||
_local_2.setRenderToTexture(this.map1, false);
|
||||
_local_2.clear(0, 0, 0, 0);
|
||||
_local_2.setProgram(this.getBlurProgram(2, this.blur));
|
||||
_local_2.setTextureAt(0, this.map2);
|
||||
_local_2.drawTriangles(blurIndexBuffer, 0, 2);
|
||||
};
|
||||
}
|
||||
|
||||
alternativa3d function clear():void
|
||||
{
|
||||
var _local_2:Shadow;
|
||||
var _local_1:int;
|
||||
while (_local_1 < this.shadowsCount)
|
||||
{
|
||||
_local_2 = this.shadows[_local_1];
|
||||
_local_2.texture = null;
|
||||
_local_1++;
|
||||
};
|
||||
this.shadows.length = 0;
|
||||
this.shadowsCount = 0;
|
||||
}
|
||||
|
||||
private function getBlurProgram(_arg_1:int, _arg_2:int):ProgramResource
|
||||
{
|
||||
var _local_5:ByteArray;
|
||||
var _local_6:ByteArray;
|
||||
var _local_3:int = ((_arg_1 << 16) + _arg_2);
|
||||
var _local_4:ProgramResource = blurPrograms[_local_3];
|
||||
if (_local_4 == null)
|
||||
{
|
||||
_local_5 = new ShadowAtlasVertexShader().agalcode;
|
||||
_local_6 = new ShadowAtlasFragmentShader(_arg_2, (_arg_1 == 1)).agalcode;
|
||||
_local_4 = new ProgramResource(_local_5, _local_6);
|
||||
blurPrograms[_local_3] = _local_4;
|
||||
};
|
||||
return (_local_4);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
44
src/alternativa/engine3d/core/ShadowAtlasFragmentShader.as
Normal file
44
src/alternativa/engine3d/core/ShadowAtlasFragmentShader.as
Normal file
@@ -0,0 +1,44 @@
|
||||
package alternativa.engine3d.core{
|
||||
import alternativa.gfx.agal.FragmentShader;
|
||||
import alternativa.gfx.agal.SamplerDim;
|
||||
import alternativa.gfx.agal.SamplerRepeat;
|
||||
import alternativa.gfx.agal.SamplerFilter;
|
||||
import alternativa.gfx.agal.SamplerMipMap;
|
||||
|
||||
public class ShadowAtlasFragmentShader extends FragmentShader {
|
||||
|
||||
public function ShadowAtlasFragmentShader(_arg_1:int, _arg_2:Boolean){
|
||||
var _local_3:int;
|
||||
super();
|
||||
mov(ft1, v0);
|
||||
tex(ft3, ft1, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
if (_arg_2)
|
||||
{
|
||||
sub(ft1.x, v0, fc[1]);
|
||||
} else
|
||||
{
|
||||
sub(ft1.y, v0, fc[1]);
|
||||
};
|
||||
_local_3 = -(_arg_1);
|
||||
while (_local_3 <= _arg_1)
|
||||
{
|
||||
if (_local_3 != 0)
|
||||
{
|
||||
tex(ft2, ft1, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.NEAREST).mipmap(SamplerMipMap.NONE));
|
||||
add(ft3.w, ft3, ft2);
|
||||
};
|
||||
if (_arg_2)
|
||||
{
|
||||
add(ft1.x, ft1, fc[0]);
|
||||
} else
|
||||
{
|
||||
add(ft1.y, ft1, fc[0]);
|
||||
};
|
||||
_local_3++;
|
||||
};
|
||||
div(ft3.w, ft3, fc[0]);
|
||||
mov(oc, ft3);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
12
src/alternativa/engine3d/core/ShadowAtlasVertexShader.as
Normal file
12
src/alternativa/engine3d/core/ShadowAtlasVertexShader.as
Normal file
@@ -0,0 +1,12 @@
|
||||
package alternativa.engine3d.core{
|
||||
import alternativa.gfx.agal.VertexShader;
|
||||
|
||||
public class ShadowAtlasVertexShader extends VertexShader {
|
||||
|
||||
public function ShadowAtlasVertexShader(){
|
||||
mov(op, va0);
|
||||
mov(v0, va1);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
18
src/alternativa/engine3d/core/ShadowCasterVertexShader.as
Normal file
18
src/alternativa/engine3d/core/ShadowCasterVertexShader.as
Normal file
@@ -0,0 +1,18 @@
|
||||
package alternativa.engine3d.core{
|
||||
import alternativa.gfx.agal.VertexShader;
|
||||
|
||||
public class ShadowCasterVertexShader extends VertexShader {
|
||||
|
||||
public function ShadowCasterVertexShader(){
|
||||
dp4(vt0.x, va0, vc[0]);
|
||||
dp4(vt0.y, va0, vc[1]);
|
||||
dp4(vt0.zw, va0, vc[2]);
|
||||
mul(vt0.xy, vt0, vc[3]);
|
||||
add(vt0.xy, vt0, vc[4]);
|
||||
mov(op.xyz, vt0);
|
||||
mov(op.w, vc[3]);
|
||||
mov(v0, vt0);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
560
src/alternativa/engine3d/core/ShadowMap.as
Normal file
560
src/alternativa/engine3d/core/ShadowMap.as
Normal file
@@ -0,0 +1,560 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.gfx.core.VertexBufferResource;
|
||||
import alternativa.gfx.core.IndexBufferResource;
|
||||
import __AS3__.vec.Vector;
|
||||
import flash.geom.Rectangle;
|
||||
import alternativa.gfx.core.RenderTargetTextureResource;
|
||||
import alternativa.gfx.core.BitmapTextureResource;
|
||||
import alternativa.engine3d.lights.DirectionalLight;
|
||||
import flash.display.BitmapData;
|
||||
import alternativa.engine3d.materials.TextureMaterial;
|
||||
import alternativa.engine3d.objects.Sprite3D;
|
||||
import alternativa.engine3d.objects.Mesh;
|
||||
import alternativa.engine3d.objects.BSP;
|
||||
import alternativa.gfx.core.Device;
|
||||
import flash.display3D.Context3DVertexBufferFormat;
|
||||
import flash.display3D.Context3DProgramType;
|
||||
import flash.utils.ByteArray;
|
||||
import alternativa.gfx.core.ProgramResource;
|
||||
import __AS3__.vec.*;
|
||||
import alternativa.engine3d.alternativa3d;
|
||||
|
||||
use namespace alternativa3d;
|
||||
|
||||
public class ShadowMap
|
||||
{
|
||||
|
||||
private static const sizeLimit:int = 0x0800;
|
||||
private static const bigValue:Number = 0x0800;
|
||||
public static const numSamples:int = 6;
|
||||
|
||||
private var programs:Array = new Array();
|
||||
private var spriteVertexBuffer:VertexBufferResource = new VertexBufferResource(Vector.<Number>([0, 2, 4, 6]), 1);
|
||||
private var spriteIndexBuffer:IndexBufferResource = new IndexBufferResource(Vector.<uint>([0, 1, 3, 1, 2, 3]));
|
||||
alternativa3d var transform:Vector.<Number> = Vector.<Number>([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
|
||||
alternativa3d var params:Vector.<Number> = Vector.<Number>([(-255 * bigValue), -(bigValue), bigValue, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
||||
private var coords:Vector.<Number> = Vector.<Number>([0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, (1 / 0xFF), 1]);
|
||||
private var fragment:Vector.<Number> = Vector.<Number>([(1 / 0xFF), 0, 1, 1]);
|
||||
private var alphaTestConst:Vector.<Number> = Vector.<Number>([0, 0, 0, 1]);
|
||||
private var scissor:Rectangle = new Rectangle();
|
||||
alternativa3d var map:RenderTargetTextureResource;
|
||||
alternativa3d var noise:BitmapTextureResource;
|
||||
private var noiseSize:int = 64;
|
||||
private var noiseAngle:Number = 1.0471975511966;
|
||||
private var noiseRadius:Number = 1.3;
|
||||
private var noiseRandom:Number = 0.3;
|
||||
public var mapSize:int;
|
||||
public var nearDistance:Number;
|
||||
public var farDistance:Number;
|
||||
public var bias:Number = 0;
|
||||
public var biasMultiplier:Number = 30;
|
||||
public var additionalSpace:Number = 0;
|
||||
public var alphaThreshold:Number = 0.1;
|
||||
private var defaultLight:DirectionalLight = new DirectionalLight(0x7F7F7F);
|
||||
private var boundVertexList:Vertex = Vertex.createList(8);
|
||||
private var light:DirectionalLight;
|
||||
private var dirZ:Number;
|
||||
private var planeX:Number;
|
||||
private var planeY:Number;
|
||||
private var planeSize:Number;
|
||||
private var pixel:Number;
|
||||
alternativa3d var boundMinX:Number;
|
||||
alternativa3d var boundMinY:Number;
|
||||
alternativa3d var boundMinZ:Number;
|
||||
alternativa3d var boundMaxX:Number;
|
||||
alternativa3d var boundMaxY:Number;
|
||||
alternativa3d var boundMaxZ:Number;
|
||||
|
||||
public function ShadowMap(_arg_1:int, _arg_2:Number, _arg_3:Number, _arg_4:Number=0, _arg_5:Number=0)
|
||||
{
|
||||
var _local_10:int;
|
||||
var _local_11:Number;
|
||||
var _local_12:int;
|
||||
var _local_13:int;
|
||||
var _local_14:int;
|
||||
super();
|
||||
if (_arg_1 > sizeLimit)
|
||||
{
|
||||
throw (new Error("Value of mapSize too big."));
|
||||
};
|
||||
var _local_6:Number = (Math.log(_arg_1) / Math.LN2);
|
||||
if (_local_6 != int(_local_6))
|
||||
{
|
||||
throw (new Error("Value of mapSize must be power of 2."));
|
||||
};
|
||||
this.mapSize = _arg_1;
|
||||
this.nearDistance = _arg_2;
|
||||
this.farDistance = _arg_3;
|
||||
this.bias = _arg_4;
|
||||
this.additionalSpace = _arg_5;
|
||||
this.defaultLight.rotationX = Math.PI;
|
||||
this.map = new RenderTargetTextureResource(_arg_1, _arg_1);
|
||||
var _local_7:Vector.<uint> = new Vector.<uint>();
|
||||
var _local_8:int;
|
||||
var _local_9:int;
|
||||
while (_local_9 < this.noiseSize)
|
||||
{
|
||||
_local_10 = 0;
|
||||
while (_local_10 < this.noiseSize)
|
||||
{
|
||||
_local_11 = (Math.random() * this.noiseAngle);
|
||||
_local_12 = (Math.sin(_local_11) * 0xFF);
|
||||
_local_13 = (Math.cos(_local_11) * 0xFF);
|
||||
_local_14 = ((this.noiseRandom + (Math.random() * (1 - this.noiseRandom))) * 0xFF);
|
||||
_local_7[_local_8] = (((_local_12 << 16) | (_local_13 << 8)) | _local_14);
|
||||
_local_8++;
|
||||
_local_10++;
|
||||
};
|
||||
_local_9++;
|
||||
};
|
||||
this.noise = new BitmapTextureResource(new BitmapData(this.noiseSize, this.noiseSize, false, 0), false);
|
||||
this.noise.bitmapData.setVector(this.noise.bitmapData.rect, _local_7);
|
||||
}
|
||||
|
||||
alternativa3d function calculateBounds(_arg_1:Camera3D):void
|
||||
{
|
||||
if (_arg_1.directionalLight != null)
|
||||
{
|
||||
this.light = _arg_1.directionalLight;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.light = this.defaultLight;
|
||||
};
|
||||
this.light.composeMatrix();
|
||||
this.dirZ = this.light.mk;
|
||||
this.light.calculateInverseMatrix();
|
||||
var _local_2:Number = this.light.ima;
|
||||
var _local_3:Number = this.light.imb;
|
||||
var _local_4:Number = this.light.imc;
|
||||
var _local_5:Number = this.light.imd;
|
||||
var _local_6:Number = this.light.ime;
|
||||
var _local_7:Number = this.light.imf;
|
||||
var _local_8:Number = this.light.img;
|
||||
var _local_9:Number = this.light.imh;
|
||||
var _local_10:Number = this.light.imi;
|
||||
var _local_11:Number = this.light.imj;
|
||||
var _local_12:Number = this.light.imk;
|
||||
var _local_13:Number = this.light.iml;
|
||||
this.light.ima = (((_local_2 * _arg_1.gma) + (_local_3 * _arg_1.gme)) + (_local_4 * _arg_1.gmi));
|
||||
this.light.imb = (((_local_2 * _arg_1.gmb) + (_local_3 * _arg_1.gmf)) + (_local_4 * _arg_1.gmj));
|
||||
this.light.imc = (((_local_2 * _arg_1.gmc) + (_local_3 * _arg_1.gmg)) + (_local_4 * _arg_1.gmk));
|
||||
this.light.imd = ((((_local_2 * _arg_1.gmd) + (_local_3 * _arg_1.gmh)) + (_local_4 * _arg_1.gml)) + _local_5);
|
||||
this.light.ime = (((_local_6 * _arg_1.gma) + (_local_7 * _arg_1.gme)) + (_local_8 * _arg_1.gmi));
|
||||
this.light.imf = (((_local_6 * _arg_1.gmb) + (_local_7 * _arg_1.gmf)) + (_local_8 * _arg_1.gmj));
|
||||
this.light.img = (((_local_6 * _arg_1.gmc) + (_local_7 * _arg_1.gmg)) + (_local_8 * _arg_1.gmk));
|
||||
this.light.imh = ((((_local_6 * _arg_1.gmd) + (_local_7 * _arg_1.gmh)) + (_local_8 * _arg_1.gml)) + _local_9);
|
||||
this.light.imi = (((_local_10 * _arg_1.gma) + (_local_11 * _arg_1.gme)) + (_local_12 * _arg_1.gmi));
|
||||
this.light.imj = (((_local_10 * _arg_1.gmb) + (_local_11 * _arg_1.gmf)) + (_local_12 * _arg_1.gmj));
|
||||
this.light.imk = (((_local_10 * _arg_1.gmc) + (_local_11 * _arg_1.gmg)) + (_local_12 * _arg_1.gmk));
|
||||
this.light.iml = ((((_local_10 * _arg_1.gmd) + (_local_11 * _arg_1.gmh)) + (_local_12 * _arg_1.gml)) + _local_13);
|
||||
var _local_14:Vertex = this.boundVertexList;
|
||||
_local_14.x = -(_arg_1.nearClipping);
|
||||
_local_14.y = -(_arg_1.nearClipping);
|
||||
_local_14.z = _arg_1.nearClipping;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = -(_arg_1.nearClipping);
|
||||
_local_14.y = _arg_1.nearClipping;
|
||||
_local_14.z = _arg_1.nearClipping;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = _arg_1.nearClipping;
|
||||
_local_14.y = _arg_1.nearClipping;
|
||||
_local_14.z = _arg_1.nearClipping;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = _arg_1.nearClipping;
|
||||
_local_14.y = -(_arg_1.nearClipping);
|
||||
_local_14.z = _arg_1.nearClipping;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = -(this.farDistance);
|
||||
_local_14.y = -(this.farDistance);
|
||||
_local_14.z = this.farDistance;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = -(this.farDistance);
|
||||
_local_14.y = this.farDistance;
|
||||
_local_14.z = this.farDistance;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = this.farDistance;
|
||||
_local_14.y = this.farDistance;
|
||||
_local_14.z = this.farDistance;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = this.farDistance;
|
||||
_local_14.y = -(this.farDistance);
|
||||
_local_14.z = this.farDistance;
|
||||
this.light.boundMinX = 1E22;
|
||||
this.light.boundMinY = 1E22;
|
||||
this.light.boundMinZ = 1E22;
|
||||
this.light.boundMaxX = -1E22;
|
||||
this.light.boundMaxY = -1E22;
|
||||
this.light.boundMaxZ = -1E22;
|
||||
_local_14 = this.boundVertexList;
|
||||
while (_local_14 != null)
|
||||
{
|
||||
_local_14.cameraX = ((((this.light.ima * _local_14.x) + (this.light.imb * _local_14.y)) + (this.light.imc * _local_14.z)) + this.light.imd);
|
||||
_local_14.cameraY = ((((this.light.ime * _local_14.x) + (this.light.imf * _local_14.y)) + (this.light.img * _local_14.z)) + this.light.imh);
|
||||
_local_14.cameraZ = ((((this.light.imi * _local_14.x) + (this.light.imj * _local_14.y)) + (this.light.imk * _local_14.z)) + this.light.iml);
|
||||
if (_local_14.cameraX < this.light.boundMinX)
|
||||
{
|
||||
this.light.boundMinX = _local_14.cameraX;
|
||||
};
|
||||
if (_local_14.cameraX > this.light.boundMaxX)
|
||||
{
|
||||
this.light.boundMaxX = _local_14.cameraX;
|
||||
};
|
||||
if (_local_14.cameraY < this.light.boundMinY)
|
||||
{
|
||||
this.light.boundMinY = _local_14.cameraY;
|
||||
};
|
||||
if (_local_14.cameraY > this.light.boundMaxY)
|
||||
{
|
||||
this.light.boundMaxY = _local_14.cameraY;
|
||||
};
|
||||
if (_local_14.cameraZ < this.light.boundMinZ)
|
||||
{
|
||||
this.light.boundMinZ = _local_14.cameraZ;
|
||||
};
|
||||
if (_local_14.cameraZ > this.light.boundMaxZ)
|
||||
{
|
||||
this.light.boundMaxZ = _local_14.cameraZ;
|
||||
};
|
||||
_local_14 = _local_14.next;
|
||||
};
|
||||
var _local_15:Vertex = this.boundVertexList;
|
||||
var _local_16:Vertex = this.boundVertexList.next.next.next.next.next.next;
|
||||
var _local_17:Vertex = this.boundVertexList.next.next.next.next;
|
||||
var _local_18:Number = (_local_16.cameraX - _local_15.cameraX);
|
||||
var _local_19:Number = (_local_16.cameraY - _local_15.cameraY);
|
||||
var _local_20:Number = (_local_16.cameraZ - _local_15.cameraZ);
|
||||
var _local_21:Number = (_local_17.cameraX - _local_16.cameraX);
|
||||
var _local_22:Number = (_local_17.cameraY - _local_16.cameraY);
|
||||
var _local_23:Number = (_local_17.cameraZ - _local_16.cameraZ);
|
||||
var _local_24:Number = (((_local_18 * _local_18) + (_local_19 * _local_19)) + (_local_20 * _local_20));
|
||||
var _local_25:Number = (((_local_21 * _local_21) + (_local_22 * _local_22)) + (_local_23 * _local_23));
|
||||
var _local_26:int = Math.ceil(this.noiseRadius);
|
||||
this.planeSize = ((_local_24 > _local_25) ? Math.sqrt(_local_24) : Math.sqrt(_local_25));
|
||||
this.pixel = (this.planeSize / ((this.mapSize - 1) - this.noiseRadius));
|
||||
this.planeSize = (this.planeSize + ((_local_26 * this.pixel) * 2));
|
||||
this.light.boundMinX = (this.light.boundMinX - (_local_26 * this.pixel));
|
||||
this.light.boundMaxX = (this.light.boundMaxX + (_local_26 * this.pixel));
|
||||
this.light.boundMinY = (this.light.boundMinY - (_local_26 * this.pixel));
|
||||
this.light.boundMaxY = (this.light.boundMaxY + (_local_26 * this.pixel));
|
||||
this.light.boundMinZ = (this.light.boundMinZ - this.additionalSpace);
|
||||
_local_14 = this.boundVertexList;
|
||||
_local_14.x = this.light.boundMinX;
|
||||
_local_14.y = this.light.boundMinY;
|
||||
_local_14.z = this.light.boundMinZ;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = this.light.boundMaxX;
|
||||
_local_14.y = this.light.boundMinY;
|
||||
_local_14.z = this.light.boundMinZ;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = this.light.boundMinX;
|
||||
_local_14.y = this.light.boundMaxY;
|
||||
_local_14.z = this.light.boundMinZ;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = this.light.boundMaxX;
|
||||
_local_14.y = this.light.boundMaxY;
|
||||
_local_14.z = this.light.boundMinZ;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = this.light.boundMinX;
|
||||
_local_14.y = this.light.boundMinY;
|
||||
_local_14.z = this.light.boundMaxZ;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = this.light.boundMaxX;
|
||||
_local_14.y = this.light.boundMinY;
|
||||
_local_14.z = this.light.boundMaxZ;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = this.light.boundMinX;
|
||||
_local_14.y = this.light.boundMaxY;
|
||||
_local_14.z = this.light.boundMaxZ;
|
||||
_local_14 = _local_14.next;
|
||||
_local_14.x = this.light.boundMaxX;
|
||||
_local_14.y = this.light.boundMaxY;
|
||||
_local_14.z = this.light.boundMaxZ;
|
||||
this.boundMinX = 1E22;
|
||||
this.boundMinY = 1E22;
|
||||
this.boundMinZ = 1E22;
|
||||
this.boundMaxX = -1E22;
|
||||
this.boundMaxY = -1E22;
|
||||
this.boundMaxZ = -1E22;
|
||||
_local_14 = this.boundVertexList;
|
||||
while (_local_14 != null)
|
||||
{
|
||||
_local_14.cameraX = ((((this.light.ma * _local_14.x) + (this.light.mb * _local_14.y)) + (this.light.mc * _local_14.z)) + this.light.md);
|
||||
_local_14.cameraY = ((((this.light.me * _local_14.x) + (this.light.mf * _local_14.y)) + (this.light.mg * _local_14.z)) + this.light.mh);
|
||||
_local_14.cameraZ = ((((this.light.mi * _local_14.x) + (this.light.mj * _local_14.y)) + (this.light.mk * _local_14.z)) + this.light.ml);
|
||||
if (_local_14.cameraX < this.boundMinX)
|
||||
{
|
||||
this.boundMinX = _local_14.cameraX;
|
||||
};
|
||||
if (_local_14.cameraX > this.boundMaxX)
|
||||
{
|
||||
this.boundMaxX = _local_14.cameraX;
|
||||
};
|
||||
if (_local_14.cameraY < this.boundMinY)
|
||||
{
|
||||
this.boundMinY = _local_14.cameraY;
|
||||
};
|
||||
if (_local_14.cameraY > this.boundMaxY)
|
||||
{
|
||||
this.boundMaxY = _local_14.cameraY;
|
||||
};
|
||||
if (_local_14.cameraZ < this.boundMinZ)
|
||||
{
|
||||
this.boundMinZ = _local_14.cameraZ;
|
||||
};
|
||||
if (_local_14.cameraZ > this.boundMaxZ)
|
||||
{
|
||||
this.boundMaxZ = _local_14.cameraZ;
|
||||
};
|
||||
_local_14 = _local_14.next;
|
||||
};
|
||||
}
|
||||
|
||||
alternativa3d function render(_arg_1:Camera3D, _arg_2:Vector.<Object3D>, _arg_3:int):void
|
||||
{
|
||||
var _local_12:Object3D;
|
||||
var _local_13:VertexBufferResource;
|
||||
var _local_14:IndexBufferResource;
|
||||
var _local_15:int;
|
||||
var _local_16:Boolean;
|
||||
var _local_17:TextureMaterial;
|
||||
var _local_18:Sprite3D;
|
||||
var _local_19:Number;
|
||||
var _local_20:Number;
|
||||
var _local_21:Number;
|
||||
var _local_22:Number;
|
||||
var _local_23:Number;
|
||||
var _local_24:Number;
|
||||
var _local_25:Number;
|
||||
var _local_26:Number;
|
||||
var _local_27:Number;
|
||||
var _local_28:Number;
|
||||
var _local_29:Number;
|
||||
var _local_30:Number;
|
||||
var _local_31:Number;
|
||||
var _local_32:Number;
|
||||
var _local_33:Mesh;
|
||||
var _local_34:BSP;
|
||||
var _local_4:Device = _arg_1.device;
|
||||
this.planeX = (Math.floor((this.light.boundMinX / this.pixel)) * this.pixel);
|
||||
this.planeY = (Math.floor((this.light.boundMinY / this.pixel)) * this.pixel);
|
||||
this.scissor.width = (Math.ceil((this.light.boundMaxX / this.pixel)) - (this.planeX / this.pixel));
|
||||
this.scissor.height = (Math.ceil((this.light.boundMaxY / this.pixel)) - (this.planeY / this.pixel));
|
||||
var _local_5:Number = (2 / this.planeSize);
|
||||
var _local_6:Number = (-2 / this.planeSize);
|
||||
var _local_7:Number = (0xFF / (this.light.boundMaxZ - this.light.boundMinZ));
|
||||
var _local_8:Number = (-(this.planeX + (this.planeSize * 0.5)) * _local_5);
|
||||
var _local_9:Number = (-(this.planeY + (this.planeSize * 0.5)) * _local_6);
|
||||
var _local_10:Number = (-(this.light.boundMinZ) * _local_7);
|
||||
if (this.mapSize != this.map.width)
|
||||
{
|
||||
this.map.dispose();
|
||||
this.map = new RenderTargetTextureResource(this.mapSize, this.mapSize);
|
||||
};
|
||||
_local_4.setRenderToTexture(this.map, true);
|
||||
_local_4.clear(1, 0, 0);
|
||||
_local_4.setScissorRectangle(this.scissor);
|
||||
this.transform[14] = (1 / 0xFF);
|
||||
var _local_11:int;
|
||||
while (_local_11 < _arg_3)
|
||||
{
|
||||
_local_12 = _arg_2[_local_11];
|
||||
_local_13 = null;
|
||||
_local_14 = null;
|
||||
_local_16 = false;
|
||||
if ((_local_12 is Sprite3D))
|
||||
{
|
||||
_local_18 = Sprite3D(_local_12);
|
||||
_local_17 = TextureMaterial(_local_18.material);
|
||||
_local_19 = _local_18.width;
|
||||
_local_20 = _local_18.height;
|
||||
if (_local_18.autoSize)
|
||||
{
|
||||
_local_31 = (_local_18.bottomRightU - _local_18.topLeftU);
|
||||
_local_32 = (_local_18.bottomRightV - _local_18.topLeftV);
|
||||
_local_19 = (_local_17.texture.width * _local_31);
|
||||
_local_20 = (_local_17.texture.height * _local_32);
|
||||
};
|
||||
_local_21 = Math.tan(Math.asin(-(this.dirZ)));
|
||||
_local_19 = (_local_19 * _local_18.scaleX);
|
||||
_local_20 = (_local_20 * _local_18.scaleY);
|
||||
_local_22 = ((((this.light.ima * _local_12.md) + (this.light.imb * _local_12.mh)) + (this.light.imc * _local_12.ml)) + this.light.imd);
|
||||
_local_23 = ((((this.light.ime * _local_12.md) + (this.light.imf * _local_12.mh)) + (this.light.img * _local_12.ml)) + this.light.imh);
|
||||
_local_24 = ((((this.light.imi * _local_12.md) + (this.light.imj * _local_12.mh)) + (this.light.imk * _local_12.ml)) + this.light.iml);
|
||||
_local_23 = (_local_23 + ((Math.sin(-(this.dirZ)) * _local_20) / 4));
|
||||
_local_24 = (_local_24 - ((Math.cos(-(this.dirZ)) * _local_20) / 4));
|
||||
_local_25 = (-(_local_19) * _local_18.originX);
|
||||
_local_26 = (-(_local_20) * _local_18.originY);
|
||||
_local_27 = (-(_local_26) / _local_21);
|
||||
_local_28 = (_local_25 + _local_19);
|
||||
_local_29 = (_local_26 + _local_20);
|
||||
_local_30 = (-(_local_29) / _local_21);
|
||||
_local_25 = (((_local_25 + _local_22) * _local_5) + _local_8);
|
||||
_local_26 = (((_local_26 + _local_23) * _local_6) + _local_9);
|
||||
_local_27 = (((_local_27 + _local_24) * _local_7) + _local_10);
|
||||
_local_28 = (((_local_28 + _local_22) * _local_5) + _local_8);
|
||||
_local_29 = (((_local_29 + _local_23) * _local_6) + _local_9);
|
||||
_local_30 = (((_local_30 + _local_24) * _local_7) + _local_10);
|
||||
_local_27 = (_local_27 - (((this.bias * this.biasMultiplier) * _local_7) / _local_21));
|
||||
_local_30 = (_local_30 - (((this.bias * this.biasMultiplier) * _local_7) / _local_21));
|
||||
this.coords[0] = _local_25;
|
||||
this.coords[1] = _local_26;
|
||||
this.coords[2] = _local_27;
|
||||
this.coords[4] = 0;
|
||||
this.coords[5] = 0;
|
||||
this.coords[8] = _local_25;
|
||||
this.coords[9] = _local_29;
|
||||
this.coords[10] = _local_30;
|
||||
this.coords[12] = 0;
|
||||
this.coords[13] = 1;
|
||||
this.coords[16] = _local_28;
|
||||
this.coords[17] = _local_29;
|
||||
this.coords[18] = _local_30;
|
||||
this.coords[20] = 1;
|
||||
this.coords[21] = 1;
|
||||
this.coords[24] = _local_28;
|
||||
this.coords[25] = _local_26;
|
||||
this.coords[26] = _local_27;
|
||||
this.coords[28] = 1;
|
||||
this.coords[29] = 0;
|
||||
_local_13 = this.spriteVertexBuffer;
|
||||
_local_14 = this.spriteIndexBuffer;
|
||||
_local_15 = 2;
|
||||
_local_16 = true;
|
||||
_local_4.setProgram(this.getProgram(true, true));
|
||||
_local_4.setVertexBufferAt(0, _local_13, 0, Context3DVertexBufferFormat.FLOAT_1);
|
||||
_local_4.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 0, this.coords, 9, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.transform[0] = ((((this.light.ima * _local_12.ma) + (this.light.imb * _local_12.me)) + (this.light.imc * _local_12.mi)) * _local_5);
|
||||
this.transform[1] = ((((this.light.ima * _local_12.mb) + (this.light.imb * _local_12.mf)) + (this.light.imc * _local_12.mj)) * _local_5);
|
||||
this.transform[2] = ((((this.light.ima * _local_12.mc) + (this.light.imb * _local_12.mg)) + (this.light.imc * _local_12.mk)) * _local_5);
|
||||
this.transform[3] = ((((((this.light.ima * _local_12.md) + (this.light.imb * _local_12.mh)) + (this.light.imc * _local_12.ml)) + this.light.imd) * _local_5) + _local_8);
|
||||
this.transform[4] = ((((this.light.ime * _local_12.ma) + (this.light.imf * _local_12.me)) + (this.light.img * _local_12.mi)) * _local_6);
|
||||
this.transform[5] = ((((this.light.ime * _local_12.mb) + (this.light.imf * _local_12.mf)) + (this.light.img * _local_12.mj)) * _local_6);
|
||||
this.transform[6] = ((((this.light.ime * _local_12.mc) + (this.light.imf * _local_12.mg)) + (this.light.img * _local_12.mk)) * _local_6);
|
||||
this.transform[7] = ((((((this.light.ime * _local_12.md) + (this.light.imf * _local_12.mh)) + (this.light.img * _local_12.ml)) + this.light.imh) * _local_6) + _local_9);
|
||||
this.transform[8] = ((((this.light.imi * _local_12.ma) + (this.light.imj * _local_12.me)) + (this.light.imk * _local_12.mi)) * _local_7);
|
||||
this.transform[9] = ((((this.light.imi * _local_12.mb) + (this.light.imj * _local_12.mf)) + (this.light.imk * _local_12.mj)) * _local_7);
|
||||
this.transform[10] = ((((this.light.imi * _local_12.mc) + (this.light.imj * _local_12.mg)) + (this.light.imk * _local_12.mk)) * _local_7);
|
||||
this.transform[11] = ((((((this.light.imi * _local_12.md) + (this.light.imj * _local_12.mh)) + (this.light.imk * _local_12.ml)) + this.light.iml) * _local_7) + _local_10);
|
||||
if ((_local_12 is Mesh))
|
||||
{
|
||||
_local_33 = Mesh(_local_12);
|
||||
_local_33.prepareResources();
|
||||
_local_13 = _local_33.vertexBuffer;
|
||||
_local_14 = _local_33.indexBuffer;
|
||||
_local_15 = _local_33.numTriangles;
|
||||
_local_17 = (_local_33.faceList.material as TextureMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((_local_12 is BSP))
|
||||
{
|
||||
_local_34 = BSP(_local_12);
|
||||
_local_34.prepareResources();
|
||||
_local_13 = _local_34.vertexBuffer;
|
||||
_local_14 = _local_34.indexBuffer;
|
||||
_local_15 = _local_34.numTriangles;
|
||||
_local_17 = (_local_34.faces[0].material as TextureMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_17 = null;
|
||||
};
|
||||
};
|
||||
if (((!(_local_17 == null)) && (_local_17.transparent)))
|
||||
{
|
||||
_local_16 = true;
|
||||
_local_4.setProgram(this.getProgram(true, false));
|
||||
_local_4.setVertexBufferAt(1, _local_13, 3, Context3DVertexBufferFormat.FLOAT_2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_local_4.setProgram(this.getProgram(false, false));
|
||||
};
|
||||
_local_4.setVertexBufferAt(0, _local_13, 0, Context3DVertexBufferFormat.FLOAT_3);
|
||||
_local_4.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 0, this.transform, 4, false);
|
||||
};
|
||||
if (((!(_local_13 == null)) && (!(_local_14 == null))))
|
||||
{
|
||||
_local_4.setTextureAt(4, null);
|
||||
_local_4.setTextureAt(6, null);
|
||||
if (_local_16)
|
||||
{
|
||||
_local_4.setTextureAt(0, _local_17.textureResource);
|
||||
this.alphaTestConst[0] = _local_17.textureResource.correctionU;
|
||||
this.alphaTestConst[1] = _local_17.textureResource.correctionV;
|
||||
this.alphaTestConst[3] = ((_local_12 is Sprite3D) ? 0.99 : this.alphaThreshold);
|
||||
_local_4.setProgramConstantsFromVector(Context3DProgramType.VERTEX, 10, this.alphaTestConst, 1);
|
||||
};
|
||||
_local_4.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, this.fragment, 1);
|
||||
_local_4.drawTriangles(_local_14, 0, _local_15);
|
||||
};
|
||||
if (_local_16)
|
||||
{
|
||||
_local_4.setTextureAt(0, null);
|
||||
_local_4.setVertexBufferAt(1, null);
|
||||
};
|
||||
_local_11++;
|
||||
};
|
||||
_local_4.setScissorRectangle(null);
|
||||
_local_5 = (1 / this.planeSize);
|
||||
_local_6 = (1 / this.planeSize);
|
||||
_local_8 = (-(this.planeX) * _local_5);
|
||||
_local_9 = (-(this.planeY) * _local_6);
|
||||
this.transform[0] = (this.light.ima * _local_5);
|
||||
this.transform[1] = (this.light.imb * _local_5);
|
||||
this.transform[2] = (this.light.imc * _local_5);
|
||||
this.transform[3] = ((this.light.imd * _local_5) + _local_8);
|
||||
this.transform[4] = (this.light.ime * _local_6);
|
||||
this.transform[5] = (this.light.imf * _local_6);
|
||||
this.transform[6] = (this.light.img * _local_6);
|
||||
this.transform[7] = ((this.light.imh * _local_6) + _local_9);
|
||||
this.transform[8] = (this.light.imi * _local_7);
|
||||
this.transform[9] = (this.light.imj * _local_7);
|
||||
this.transform[10] = (this.light.imk * _local_7);
|
||||
this.transform[11] = (((this.light.iml * _local_7) + _local_10) - ((this.bias * this.biasMultiplier) * _local_7));
|
||||
this.transform[12] = this.nearDistance;
|
||||
this.transform[13] = (this.farDistance - this.nearDistance);
|
||||
this.transform[14] = -(_local_7);
|
||||
this.params[4] = 0;
|
||||
this.params[5] = 0;
|
||||
this.params[6] = (this.noiseRadius / this.mapSize);
|
||||
this.params[7] = (1 / numSamples);
|
||||
this.params[8] = (_arg_1.view._width / this.noiseSize);
|
||||
this.params[9] = (_arg_1.view._height / this.noiseSize);
|
||||
this.params[11] = ((_arg_1.directionalLight != null) ? (_arg_1.directionalLightStrength * _arg_1.shadowMapStrength) : 0);
|
||||
this.params[12] = Math.cos(this.noiseAngle);
|
||||
this.params[13] = Math.sin(this.noiseAngle);
|
||||
this.params[16] = -(Math.sin(this.noiseAngle));
|
||||
this.params[17] = Math.cos(this.noiseAngle);
|
||||
}
|
||||
|
||||
public function dispose():void
|
||||
{
|
||||
this.map.reset();
|
||||
this.noise.reset();
|
||||
}
|
||||
|
||||
private function getProgram(_arg_1:Boolean, _arg_2:Boolean):ProgramResource
|
||||
{
|
||||
var _local_5:ByteArray;
|
||||
var _local_6:ByteArray;
|
||||
var _local_3:int = (int(_arg_1) | (int(_arg_2) << 1));
|
||||
var _local_4:ProgramResource = this.programs[_local_3];
|
||||
if (_local_4 == null)
|
||||
{
|
||||
_local_5 = new ShadowMapVertexShader(_arg_1, _arg_2).agalcode;
|
||||
_local_6 = new ShadowMapFragmentShader(_arg_1).agalcode;
|
||||
_local_4 = new ProgramResource(_local_5, _local_6);
|
||||
this.programs[_local_3] = _local_4;
|
||||
};
|
||||
return (_local_4);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
29
src/alternativa/engine3d/core/ShadowMapFragmentShader.as
Normal file
29
src/alternativa/engine3d/core/ShadowMapFragmentShader.as
Normal file
@@ -0,0 +1,29 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.gfx.agal.FragmentShader;
|
||||
import alternativa.gfx.agal.SamplerDim;
|
||||
import alternativa.gfx.agal.SamplerFilter;
|
||||
import alternativa.gfx.agal.SamplerMipMap;
|
||||
import alternativa.gfx.agal.SamplerRepeat;
|
||||
|
||||
public class ShadowMapFragmentShader extends FragmentShader
|
||||
{
|
||||
|
||||
|
||||
public function ShadowMapFragmentShader(param1:Boolean)
|
||||
{
|
||||
super();
|
||||
if(param1)
|
||||
{
|
||||
tex(ft0,v1,fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(SamplerFilter.LINEAR).mipmap(SamplerMipMap.NONE));
|
||||
sub(ft0.w,ft0,v1);
|
||||
kil(ft0.w);
|
||||
}
|
||||
frc(ft0,v0.z);
|
||||
sub(ft0.x,v0.z,ft0);
|
||||
mul(ft0.x,ft0,fc[0]);
|
||||
mov(ft0.zw,fc[0]);
|
||||
mov(oc,ft0);
|
||||
}
|
||||
}
|
||||
}
|
||||
40
src/alternativa/engine3d/core/ShadowMapVertexShader.as
Normal file
40
src/alternativa/engine3d/core/ShadowMapVertexShader.as
Normal file
@@ -0,0 +1,40 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
import alternativa.gfx.agal.VertexShader;
|
||||
|
||||
public class ShadowMapVertexShader extends VertexShader
|
||||
{
|
||||
|
||||
|
||||
public function ShadowMapVertexShader(param1:Boolean, param2:Boolean)
|
||||
{
|
||||
super();
|
||||
if(param2)
|
||||
{
|
||||
mov(vt0,cc.rel(va0.x,0));
|
||||
mov(v0,vt0);
|
||||
mul(vt0.z,vt0,vc[8]);
|
||||
mov(op,vt0);
|
||||
if(param1)
|
||||
{
|
||||
mov(vt0,vc[10]);
|
||||
mul(v1,cc.rel(va0.x,1),vt0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mov(vt0,vc[3]);
|
||||
dp4(vt0.x,va0,vc[0]);
|
||||
dp4(vt0.y,va0,vc[1]);
|
||||
dp4(vt0.z,va0,vc[2]);
|
||||
mov(v0,vt0);
|
||||
mul(vt0.z,vt0,vc[3]);
|
||||
mov(op,vt0);
|
||||
if(param1)
|
||||
{
|
||||
mul(v1,va1,vc[10]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package alternativa.engine3d.core{
|
||||
import alternativa.gfx.agal.FragmentShader;
|
||||
import alternativa.gfx.agal.SamplerFilter;
|
||||
import alternativa.gfx.agal.SamplerMipMap;
|
||||
import alternativa.gfx.agal.SamplerDim;
|
||||
import alternativa.gfx.agal.SamplerRepeat;
|
||||
|
||||
public class ShadowReceiverFragmentShader extends FragmentShader {
|
||||
|
||||
public function ShadowReceiverFragmentShader(_arg_1:Boolean, _arg_2:Boolean){
|
||||
var _local_3:SamplerFilter = ((_arg_1) ? SamplerFilter.LINEAR : SamplerFilter.NEAREST);
|
||||
var _local_4:SamplerMipMap = ((_arg_1) ? SamplerMipMap.LINEAR : SamplerMipMap.NEAREST);
|
||||
if (_arg_2)
|
||||
{
|
||||
max(ft0, v0, fc[16]);
|
||||
min(ft0.x, ft0, fc[16].z);
|
||||
min(ft0.y, ft0, fc[16].w);
|
||||
tex(ft0, ft0, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(_local_3).mipmap(_local_4));
|
||||
} else
|
||||
{
|
||||
tex(ft0, v0, fs0.dim(SamplerDim.D2).repeat(SamplerRepeat.CLAMP).filter(_local_3).mipmap(_local_4));
|
||||
};
|
||||
sub(ft1, v0.z, fc[14]);
|
||||
div(ft2, ft1, fc[13]);
|
||||
max(ft3, ft1, fc[13].x);
|
||||
mul(ft3, ft3, fc[13].y);
|
||||
min(ft3, ft3, fc[14]);
|
||||
sub(ft4, fc[14], ft3);
|
||||
mul(ft2, ft2, ft3);
|
||||
mul(ft1, ft1, ft4);
|
||||
add(ft2, ft1, ft2);
|
||||
sub(ft2, fc[14], ft2);
|
||||
mul(ft0, ft0, ft2);
|
||||
sub(ft1, v0, fc[14]);
|
||||
div(ft1, ft1, fc[14].y);
|
||||
sat(ft1, ft1);
|
||||
mul(ft0, ft0, ft1.z);
|
||||
mov(ft0.xyz, fc[15]);
|
||||
mul(ft0.w, ft0, fc[15]);
|
||||
mov(oc, ft0);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
42
src/alternativa/engine3d/core/ShadowReceiverVertexShader.as
Normal file
42
src/alternativa/engine3d/core/ShadowReceiverVertexShader.as
Normal file
@@ -0,0 +1,42 @@
|
||||
package alternativa.engine3d.core{
|
||||
import alternativa.gfx.agal.VertexShader;
|
||||
|
||||
public class ShadowReceiverVertexShader extends VertexShader {
|
||||
|
||||
public function ShadowReceiverVertexShader(_arg_1:Boolean){
|
||||
dp4(vt0.x, va0, vc[11]);
|
||||
dp4(vt0.y, va0, vc[12]);
|
||||
dp4(vt0.z, va0, vc[13]);
|
||||
mov(vt0.w, va0);
|
||||
dp4(vt1, vt0, vc[15]);
|
||||
dp4(vt1.y, vt0, vc[16]);
|
||||
mul(vt1.xy, vt1, vc[19]);
|
||||
add(v0.xy, vt1, vc[20]);
|
||||
dp4(v0.zw, vt0, vc[17]);
|
||||
div(vt1.z, vc[14].w, vt0);
|
||||
add(vt1.z, vt1, vc[14]);
|
||||
mul(vt1.z, vt1, vc[14].x);
|
||||
sub(vt1.z, vt1, vc[14].y);
|
||||
div(vt1.z, vt1, vc[14].x);
|
||||
sub(vt1.z, vt1, vc[14]);
|
||||
div(vt1.z, vc[14].w, vt1);
|
||||
mov(vt2, vc[20]);
|
||||
nrm(vt2.xyz, vt0.xyz);
|
||||
sub(vt1.z, vt0, vt1);
|
||||
div(vt1.z, vt1, vt2);
|
||||
mul(vt2, vt2, vt1.z);
|
||||
sub(vt0, vt0, vt2);
|
||||
if (_arg_1)
|
||||
{
|
||||
mul(vt0.xy, vt0, vc[18]);
|
||||
mul(vt1.xy, vc[18].zw, vt0.z);
|
||||
add(vt0.xy, vt0, vt1);
|
||||
};
|
||||
mov(op.xw, vt0.xz);
|
||||
neg(op.y, vt0);
|
||||
mul(vt0.z, vt0, vc[14]);
|
||||
add(op.z, vt0, vc[14].w);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
23
src/alternativa/engine3d/core/ShadowVolumeVertexShader.as
Normal file
23
src/alternativa/engine3d/core/ShadowVolumeVertexShader.as
Normal file
@@ -0,0 +1,23 @@
|
||||
package alternativa.engine3d.core{
|
||||
import alternativa.gfx.agal.VertexShader;
|
||||
|
||||
public class ShadowVolumeVertexShader extends VertexShader {
|
||||
|
||||
public function ShadowVolumeVertexShader(){
|
||||
mul(vt1, va0, vc[14]);
|
||||
add(vt1.xyz, vt1, vc[15]);
|
||||
dp4(vt0.x, vt1, vc[11]);
|
||||
dp4(vt0.y, vt1, vc[12]);
|
||||
dp4(vt0.z, vt1, vc[13]);
|
||||
mov(vt0.w, vt1);
|
||||
mul(vt0.xy, vt0, vc[17]);
|
||||
mul(vt1.xy, vc[17].zw, vt0.z);
|
||||
add(vt0.xy, vt0, vt1);
|
||||
mov(op.xw, vt0.xz);
|
||||
neg(op.y, vt0);
|
||||
mul(vt0.z, vt0, vc[16]);
|
||||
add(op.z, vt0, vc[16].w);
|
||||
}
|
||||
|
||||
}
|
||||
}//package alternativa.engine3d.core
|
||||
18
src/alternativa/engine3d/core/Sorting.as
Normal file
18
src/alternativa/engine3d/core/Sorting.as
Normal file
@@ -0,0 +1,18 @@
|
||||
package alternativa.engine3d.core
|
||||
{
|
||||
public class Sorting
|
||||
{
|
||||
|
||||
public static const NONE:int = 0;
|
||||
|
||||
public static const AVERAGE_Z:int = 1;
|
||||
|
||||
public static const DYNAMIC_BSP:int = 2;
|
||||
|
||||
|
||||
public function Sorting()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user