cursorscene now is not render layer + bug fixes

This commit is contained in:
Tubix
2024-12-18 18:14:17 +00:00
parent dc89c4a634
commit 736e6fb5e9
13 changed files with 293 additions and 277 deletions

Binary file not shown.

View File

@@ -61,9 +61,9 @@ package alternativa.editor
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);
this.view.graphics.endFill();
//this.view.graphics.beginFill(16777215);
//this.view.graphics.drawRect(0,0,1,1);
//this.view.graphics.endFill();
}
private function onEnterFrame(param1:Event) : void

View File

@@ -201,11 +201,11 @@ package alternativa.editor
{
removeEventListener(Event.ADDED_TO_STAGE,this.onAddedToStage);
this.keyMapper.startListening(stage);
this.cursorScene = new CursorScene(stage,this);
this.mainScene = new MainScene();
this.cursorScene.occupyMap = this.mainScene.occupyMap;
this.cursorScene = new CursorScene(stage,this,this.mainScene);
//this.cursorScene.occupyMap = this.mainScene.occupyMap;
addChild(this.mainScene.view);
addChild(this.cursorScene.view);
//addChild(this.cursorScene.view);
this.boundBoxesOverlay = new Shape();
addChild(this.boundBoxesOverlay);
this.dominationOverlay = new Shape();
@@ -214,7 +214,7 @@ package alternativa.editor
addChild(this.selectionRectOverlay);
this.initListeners();
this.eventJournal = new EventJournal();
var loc2:Object3D = this.cursorScene.camera;
var loc2:Object3D = this.mainScene.camera;
this.cameraDistance = Math.sqrt(loc2.x * loc2.x + loc2.y * loc2.y + loc2.z * loc2.z);
}
@@ -416,7 +416,7 @@ package alternativa.editor
}
else if(this.middleDown)
{
loc9 = this.cursorScene.camera.transformation;
loc9 = this.mainScene.camera.transformation;
loc10 = new Point3D(loc9.a,loc9.e,loc9.i);
loc11 = new Point3D(loc9.b,loc9.f,loc9.j);
loc10.multiply(10 * (this.prevMoveX - param1.stageX));
@@ -500,13 +500,13 @@ package alternativa.editor
if(this.mainScene.selectedProp)
loc2.copyFromObject3D(this.mainScene.selectedProp)
else
loc2.copyFromVector3D(this.cursorScene.camera.localToGlobal(cameraPointV3));
loc2.copyFromVector3D(this.mainScene.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(new Point3D().copyFromVector3D(this.cursorScene.camera.localToGlobal(cameraPointV3)),loc3);
loc5 = Point3D.difference(new Point3D().copyFromVector3D(this.mainScene.camera.localToGlobal(cameraPointV3)),loc3);
}
loc5.normalize();
loc5.multiply(param1 * 100);
@@ -553,7 +553,7 @@ package alternativa.editor
}
else
{
loc2 = new Point3D().copyFromVector3D(this.cursorScene.camera.localToGlobal(new Vector3D(0,0,this.cameraDistance)));
loc2 = new Point3D().copyFromVector3D(this.mainScene.camera.localToGlobal(new Vector3D(0,0,this.cameraDistance)));
}
loc4 = this.cursorScene.containerController.coords.clone();
loc4.subtract(loc2);
@@ -588,14 +588,14 @@ package alternativa.editor
this.cursorScene.containerController.moveBack(this.keyMapper.keyPressed(5));
this.cursorScene.cameraController.processInput();
this.cursorScene.containerController.processInput();
this.cursorScene.calculate();
this.cameraTransformation = this.cursorScene.camera.transformation;
//this.cursorScene.calculate();
this.cameraTransformation = this.mainScene.camera.transformation;
cameraOffset.x = this.cameraTransformation.d;
cameraOffset.y = this.cameraTransformation.h;
cameraOffset.z = this.cameraTransformation.l;
this.cursorScene.drawAxis(this.cameraTransformation);
var loc2:Point3D = this.cameraTransformation.getRotations();
this.mainScene.setCameraPosition(cameraOffset,loc2.x,loc2.y,loc2.z);
//var loc2:Point3D = this.cameraTransformation.getRotations();
//this.mainScene.setCameraPosition(cameraOffset,loc2.x,loc2.y,loc2.z);
this.mainScene.calculate();
if(this._showBoundBoxes)
{
@@ -631,9 +631,9 @@ package alternativa.editor
}
getMeshBounds(loc2,this.min,this.max);
fillBBPoints(this.min,this.max,this.bbPoints);
var loc3:Number = this.cursorScene.camera.focalLength;
var loc6:Number = 0.5 * this.cursorScene.view.width;
var loc7:Number = 0.5 * this.cursorScene.view.height;
var loc3:Number = this.mainScene.camera.focalLength;
var loc6:Number = 0.5 * this.mainScene.view.width;
var loc7:Number = 0.5 * this.mainScene.view.height;
loc5 = 0;
while(loc5 < 8)
{
@@ -703,9 +703,9 @@ package alternativa.editor
case Keyboard.NUMBER_0:
if(param1.ctrlKey)
{
this.cursorScene.camera.rotationX = this.cursorScene.camera.rotationX = this.cursorScene.camera.rotationX = -2.0943951023931953;
this.mainScene.camera.rotationX = this.mainScene.camera.rotationX = this.mainScene.camera.rotationX = -2.0943951023931953;
this.cursorScene.cameraController.coords = new Point3D(250,-7800,4670);
loc5 = this.cursorScene.camera;
loc5 = this.mainScene.camera;
this.cameraDistance = Math.sqrt(loc5.x * loc5.x + loc5.y * loc5.y + loc5.z * loc5.z);
}
break;
@@ -889,7 +889,7 @@ package alternativa.editor
this.eventJournal.addEvent(EventJournal.ADD,loc3);
setTimeout(this.cursorScene.updateMaterial,200);
loc2.addEventListener(MouseEvent3D.MOUSE_DOWN,this.onPropMouseDown);
if(this._snapMode && !this.cursorScene.freeState && (this.multiplePropMode == MultiPropMode.NONE && this.cursorScene.occupyMap.isConflict(loc2) || this.multiplePropMode == MultiPropMode.GROUP && this.cursorScene.occupyMap.isConflictGroup(loc2)))
if(this._snapMode && !this.cursorScene.freeState && (this.multiplePropMode == MultiPropMode.NONE && this.mainScene.occupyMap.isConflict(loc2) || this.multiplePropMode == MultiPropMode.GROUP && this.mainScene.occupyMap.isConflictGroup(loc2)))
{
Alert.show("This location is occupied. Continue?","",Alert.YES | Alert.NO,this,this.alertConflict,null,Alert.YES);
}

View File

@@ -8,42 +8,68 @@ package alternativa.editor.engine3d.loaders
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 batch:Map;
private var materialNames:Array;
private var totalFiles:int;
private var currFileIndex:int;
private var materialIndex:int;
private var batch:Map;
private var currentFileNumber:int;
private var _textures:Map;
public function TextureMapsBatchLoader()
{
super();
}
private function loadNextTextureFile() : void
public function get textures() : Map
{
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);
return this._textures;
}
private function getStubBitmapData() : BitmapData
{
var loc1:uint = 0;
var loc2:uint = 0;
var loc3:uint = 0;
if(stubBitmapData == null)
{
loc1 = 20;
stubBitmapData = new BitmapData(loc1,loc1,false,0);
loc2 = 0;
while(loc2 < loc1)
{
loc3 = 0;
while(loc3 < loc1)
{
stubBitmapData.setPixel(!!(loc2 % 2) ? int(loc3) : loc3 + 1,loc2,16711935);
loc3 += 2;
}
loc2++;
}
}
return stubBitmapData;
}
public function close() : void
{
if(this.loader != null)
{
this.loader.close();
}
}
private function clean() : void
@@ -53,28 +79,18 @@ package alternativa.editor.engine3d.loaders
this.materialNames = null;
}
public function get textures() : Map
public function unload() : void
{
return this._textures;
this._textures = null;
}
private function onTextureLoadingStart(e:Event) : void
public function load(param1:String, param2:Map, param3:LoaderContext) : 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;
var loc4:String = null;
var loc5:TextureMapsInfo = null;
this.baseUrl = param1;
this.batch = param2;
this.loaderContext = param3;
if(this.loader == null)
{
this.loader = new TextureMapsLoader();
@@ -90,24 +106,58 @@ package alternativa.editor.engine3d.loaders
}
this.totalFiles = 0;
this.materialNames = new Array();
for(materialName in batch)
for(loc4 in param2)
{
this.materialNames.push(materialName);
info = batch[materialName];
this.totalFiles += info.opacityMapFileName == null ? 1 : 2;
this.materialNames.push(loc4);
loc5 = param2[loc4];
this.totalFiles += loc5.opacityMapFileName == null ? 1 : 2;
}
this.currentFileNumber = 1;
this.currFileIndex = 0;
this.materialIndex = 0;
this._textures = new Map();
this.loadNextTextureFile();
}
private function onMaterialTexturesLoadingComplete(e:Event) : void
private function loadNextTextureFile() : void
{
if(e is IOErrorEvent)
var loc1:TextureMapsInfo = this.batch[this.materialNames[this.materialIndex]];
this.loader.load(this.baseUrl + loc1.diffuseMapFileName,loc1.opacityMapFileName == null ? null : this.baseUrl + loc1.opacityMapFileName,this.loaderContext);
}
private function onTextureLoadingStart(param1:Event) : void
{
dispatchEvent(param1);
}
private function onTextureLoadingComplete(param1:Event) : void
{
dispatchEvent(param1);
++this.currFileIndex;
}
private function onProgress(param1:ProgressEvent) : void
{
dispatchEvent(new LoaderProgressEvent(LoaderProgressEvent.LOADING_PROGRESS,LoadingStage.TEXTURE,this.totalFiles,this.currFileIndex,param1.bytesLoaded,param1.bytesTotal));
}
private function onMaterialTexturesLoadingComplete(param1:Event) : void
{
var loc2:IOErrorEvent = null;
var loc3:TextureMapsInfo = null;
if(param1 is IOErrorEvent)
{
this._textures.add(this.materialNames[this.materialIndex],this.getStubBitmapData());
dispatchEvent(e);
loc2 = IOErrorEvent(param1);
loc3 = this.batch[this.materialNames[this.materialIndex]];
if(loc3.diffuseMapFileName)
{
loc2.text += this.baseUrl + loc3.diffuseMapFileName;
}
if(loc3.opacityMapFileName)
{
loc2.text += this.baseUrl + loc3.opacityMapFileName;
}
dispatchEvent(loc2);
}
else
{
@@ -123,45 +173,6 @@ package alternativa.editor.engine3d.loaders
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;
}
}
}

View File

@@ -2,15 +2,20 @@ 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)
public var opacityMapFileName:String;
public function TextureMapsInfo(param1:String = null, param2:String = null)
{
super();
this.diffuseMapFileName = diffuseMapFileName;
this.opacityMapFileName = opacityMapFileName;
this.diffuseMapFileName = param1;
this.opacityMapFileName = param2;
}
public function toString() : String
{
return "[Object TextureMapsInfo, diffuseMapFileName:" + this.diffuseMapFileName + ", opacityMapFileName: " + this.opacityMapFileName + "]";
}
}
}

View File

@@ -13,14 +13,7 @@ package alternativa.editor.engine3d.loaders
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;
@@ -29,29 +22,106 @@ package alternativa.editor.engine3d.loaders
private static const STATE_LOADING_ALPHA_MAP:int = 2;
private var bitmapLoader:Loader;
private var _bitmapData:BitmapData;
private var loaderContext:LoaderContext;
private var bitmapLoader:Loader;
private var alphaTextureUrl:String;
private var _bitmapData:BitmapData;
private var loaderContext:LoaderContext;
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)
public function TextureMapsLoader(param1:String = null, param2:String = null, param3:LoaderContext = null)
{
super();
if(diffuseTextureUrl != null)
if(param1 != null)
{
this.load(diffuseTextureUrl,alphaTextureUrl,loaderContext);
this.load(param1,param2,param3);
}
}
public function load(param1:String, param2:String = null, param3:LoaderContext = null) : void
{
this.alphaTextureUrl = param2;
this.loaderContext = param3;
if(this.bitmapLoader == null)
{
this.bitmapLoader = new Loader();
this.bitmapLoader.contentLoaderInfo.addEventListener(Event.OPEN,this.onOpen);
this.bitmapLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,this.onComplete);
this.bitmapLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,this.onProgress);
this.bitmapLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,this.onLoadError);
}
else
{
this.close();
}
this.startLoading(STATE_LOADING_DIFFUSE_MAP,param1);
}
private function onOpen(param1:Event) : void
{
dispatchEvent(new LoaderEvent(LoaderEvent.LOADING_START,LoadingStage.TEXTURE));
}
private function onProgress(param1:Event) : void
{
dispatchEvent(param1);
}
private function startLoading(param1:int, param2:String) : void
{
this.loaderState = param1;
this.bitmapLoader.load(new URLRequest(param2),this.loaderContext);
}
private function onComplete(param1:Event) : void
{
var loc2:BitmapData = null;
var loc3:BitmapData = null;
dispatchEvent(new LoaderEvent(LoaderEvent.LOADING_COMPLETE,LoadingStage.TEXTURE));
switch(this.loaderState)
{
case STATE_LOADING_DIFFUSE_MAP:
this._bitmapData = Bitmap(this.bitmapLoader.content).bitmapData;
if(this.alphaTextureUrl != null)
{
this.startLoading(STATE_LOADING_ALPHA_MAP,this.alphaTextureUrl);
break;
}
this.complete();
break;
case STATE_LOADING_ALPHA_MAP:
loc2 = this._bitmapData;
this._bitmapData = new BitmapData(this._bitmapData.width,this._bitmapData.height,true,0);
this._bitmapData.copyPixels(loc2,loc2.rect,new Point());
loc3 = Bitmap(this.bitmapLoader.content).bitmapData;
if(this._bitmapData.width != loc3.width || this._bitmapData.height != loc3.height)
{
loc2.draw(loc3,new Matrix(this._bitmapData.width / loc3.width,0,0,this._bitmapData.height / loc3.height),null,BlendMode.NORMAL,null,true);
loc3.dispose();
loc3 = loc2;
}
this._bitmapData.copyChannel(loc3,loc3.rect,new Point(),BitmapDataChannel.RED,BitmapDataChannel.ALPHA);
loc3.dispose();
this.complete();
}
}
private function onLoadError(param1:IOErrorEvent) : void
{
this.loaderState = STATE_IDLE;
dispatchEvent(param1);
}
private function complete() : void
{
this.loaderState = STATE_IDLE;
this.bitmapLoader.unload();
dispatchEvent(new Event(Event.COMPLETE));
}
public function get bitmapData() : BitmapData
{
return this._bitmapData;
@@ -67,96 +137,6 @@ package alternativa.editor.engine3d.loaders
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)
@@ -169,19 +149,6 @@ package alternativa.editor.engine3d.loaders
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);
}
}
}

View File

@@ -15,6 +15,7 @@ package alternativa.editor.prop
import alternativa.engine3d.core.Object3DContainer;
import alternativa.engine3d.core.Vertex;
import flash.geom.Vector3D;
import alternativa.engine3d.materials.FillMaterial;
public class Prop extends Object3DContainer
{
@@ -153,7 +154,7 @@ package alternativa.editor.prop
protected function initBitmapData() : void
{
this._material = Mesh(this._object).faceList.material;
if(_material is TextureMaterial)
if(_material is TextureMaterial && !(_material is FillMaterial))
{
this.bitmapData = TextureMaterial(this._material).texture;
}

View File

@@ -5,28 +5,23 @@ package alternativa.editor.scene
import alternativa.editor.prop.Prop;
import alternativa.editor.prop.Sprite3DProp;
import alternativa.editor.engine3d.controllers.WalkController;
import alternativa.engine3d.core.Camera3D;
import alternativa.engine3d.core.Object3D;
import alternativa.engine3d.core.View;
import alternativa.engine3d.materials.Material;
import alternativa.types.Matrix4;
import alternativa.types.Point3D;
import alternativa.types.Set;
import alternativa.types.Texture;
import alternativa.utils.MathUtils;
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.display.DisplayObject;
import flash.display.Graphics;
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;
import mx.controls.Alert;
public class CursorScene extends EditorScene
public class CursorScene
{
private static var redClass:Class = CursorScene_redClass;
@@ -62,10 +57,13 @@ package alternativa.editor.scene
private var _visible:Boolean = false;
public function CursorScene(param1:DisplayObject, container:Sprite)
private var mainScene:MainScene;
public function CursorScene(param1:DisplayObject, container:Sprite, mainScene:MainScene)
{
super();
this.eventSourceObject = param1;
this.mainScene = mainScene;
this.initControllers();
container.addChild(this.axisIndicatorOverlay = new Shape());
}
@@ -73,17 +71,17 @@ package alternativa.editor.scene
private function initControllers() : void
{
this.cameraController = new WalkController(this.eventSourceObject);
this.cameraController.object = camera;
this.cameraController.object = this.mainScene.camera;
this.cameraController.speedMultiplier = 4;
this.cameraController.speedThreshold = 1;
this.cameraController.mouseEnabled = false;
this.cameraController.coords = new Point3D(250,-7800,4670);
this.container = new Object3DContainer();
root.addChild(this.container);
this.mainScene.root.addChild(this.container);
this.containerController = new WalkController(this.eventSourceObject);
this.containerController.object = this.container;
this.containerController.mouseEnabled = false;
this.container.addChild(camera);
this.container.addChild(this.mainScene.camera);
}
public function set object(param1:Prop) : void
@@ -94,7 +92,7 @@ package alternativa.editor.scene
loc2 = new Vector3D(this._object.x,this._object.y,this._object.z);
if(this._visible)
{
root.removeChild(this._object);
this.mainScene.root.removeChild(this._object);
}
}
this._object = param1;
@@ -107,7 +105,7 @@ package alternativa.editor.scene
}
if(this._visible)
{
root.addChild(this._object);
this.mainScene.root.addChild(this._object);
}
if(this._snapMode || this._object is MeshProp && !(this._object is Sprite3DProp))
{
@@ -145,6 +143,11 @@ package alternativa.editor.scene
private function createMaterials() : void
{
if(_object.bitmapData == null)
{
Alert.show("No texture on " + _object.name + ", " + _object.groupName + ", " + _object.libraryName + ", " + (_object as MeshProp).textureName);
return;
}
var loc1:BitmapData = this._object.bitmapData.clone();
var loc2:BitmapData = loc1.clone();
var loc3:Matrix = new Matrix();
@@ -172,7 +175,7 @@ package alternativa.editor.scene
var loc1:Vector3D = null;
if(this._object)
{
loc1 = camera.projectGlobal(new Vector3D(view.mouseX,view.mouseY,this._object.z));
loc1 = this.mainScene.camera.projectGlobal(new Vector3D(this.mainScene.view.mouseX,this.mainScene.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))
@@ -188,28 +191,13 @@ package alternativa.editor.scene
return this._freeState;
}
override protected function initScene() : void
{
root = new Object3DContainer();
camera = new Camera3D();
camera.rotationX = -MathUtils.DEG90 - MathUtils.DEG30;
view = new View(100,100);
camera.view = view;
//view.interactive = false;
view.mouseEnabled = false;
view.mouseChildren = false;
view.graphics.beginFill(16777215);
view.graphics.drawRect(0,0,1,1);
view.graphics.endFill();
}
public function updateMaterial() : void
{
if(this._object)
{
if(this._snapMode)
{
if(occupyMap.isConflict(this._object))
if(this.mainScene.occupyMap.isConflict(this._object))
{
this._freeState = false;
this._object.setMaterial(this.redMaterial);
@@ -231,9 +219,9 @@ package alternativa.editor.scene
{
if(this._object)
{
if(root.getChildByName(this._object.name))
if(this.mainScene.root.getChildByName(this._object.name))
{
root.removeChild(this._object);
this.mainScene.root.removeChild(this._object);
}
this._object = null;
this._visible = false;
@@ -265,12 +253,12 @@ package alternativa.editor.scene
{
if(this._visible)
{
root.addChild(this._object);
this.mainScene.root.addChild(this._object);
this.updateMaterial();
}
else
{
root.removeChild(this._object);
this.mainScene.root.removeChild(this._object);
}
}
}
@@ -283,25 +271,25 @@ package alternativa.editor.scene
public function moveByArrows(param1:uint) : void
{
move(this._object,param1);
this.mainScene.move(this._object,param1);
this.updateMaterial();
}
override public function viewResize(param1:Number, param2:Number) : void
public function viewResize(param1:Number, param2:Number) : void
{
super.viewResize(param1,param2);
this.axisIndicatorOverlay.y = view.height - this.axisIndicatorSize;
//super.viewResize(param1,param2);
this.axisIndicatorOverlay.y = this.mainScene.view.height - this.axisIndicatorSize;
}
public function rotateCursorCounterClockwise() : void
{
rotatePropsCounterClockwise(this.getCursorObjectSet());
this.mainScene.rotatePropsCounterClockwise(this.getCursorObjectSet());
this.snapCursorToGrid();
}
public function rotateCursorClockwise() : void
{
rotatePropsClockwise(this.getCursorObjectSet());
this.mainScene.rotatePropsClockwise(this.getCursorObjectSet());
this.snapCursorToGrid();
}

View File

@@ -68,10 +68,10 @@ package alternativa.editor.scene
this.camera = new Camera3D();
this.camera.rotationX = -MathUtils.DEG90 - MathUtils.DEG30;
this.camera.setPositionXYZ(250,-7800,4670);
root.addChild(this.camera);
//root.addChild(this.camera);
this.view = new View(100,100);
this.camera.view = view;
//this.view.interactive = true;
this.view.interactive = true;
this.view.buttonMode = true;
this.view.useHandCursor = false;
this.view.graphics.beginFill(16777215);
@@ -97,7 +97,7 @@ package alternativa.editor.scene
return CameraFacing.X;
}
protected function move(param1:Prop, param2:uint) : void
public function move(param1:Prop, param2:uint) : void
{
var loc3:Point = null;
var loc4:CameraFacing = null;
@@ -199,7 +199,7 @@ package alternativa.editor.scene
return new Point((loc3 + loc2) / 2,(loc5 + loc4) / 2);
}
protected function rotatePropsCounterClockwise(param1:Set) : void
public function rotatePropsCounterClockwise(param1:Set) : void
{
var loc3:* = undefined;
var loc4:Prop = null;
@@ -217,7 +217,7 @@ package alternativa.editor.scene
}
}
protected function rotatePropsClockwise(param1:Set) : void
public function rotatePropsClockwise(param1:Set) : void
{
var loc3:* = undefined;
var loc4:Prop = null;

View File

@@ -99,8 +99,8 @@ package alternativa.editor.scene
this.selectedProps = new Set();
this.selectablePropTypes = AlternativaEditor.DEFAULT_SELECTABLE_TYPES;
var loc2:Number = 15 * hBase2;
this.grid = new Plane(loc2,loc2,15,15);
this.grid.setMaterialToAllFaces(new WireMaterial(1,loc2,loc2,15,9474192));
this.grid = new Plane(loc2,loc2);
this.grid.setMaterialToAllFaces(new WireMaterial(10,loc2,loc2,15,9474192));
root.addChild(this.grid);
this.grid.x = hBase;
this.grid.y = hBase;
@@ -837,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();
}

View File

@@ -71,7 +71,8 @@ package alternativa.engine3d.core
};
if (_arg_1._parent != this)
{
throw (new ArgumentError("The supplied Object3D must be a child of the caller."));
return null;
//throw (new ArgumentError("The supplied Object3D must be a child of the caller."));
};
_local_3 = this.childrenList;
while (_local_3 != null)

View File

@@ -72,6 +72,8 @@ package alternativa.engine3d.core{
public var offsetX:Number = 0;
public var offsetY:Number = 0;
private var _interactive:Boolean = false;
public function View(width:Number, height:Number, constrainedMode:Boolean=false){
super();
this._width = width;
@@ -123,11 +125,43 @@ package alternativa.engine3d.core{
this.device = staticDevice;
}
public function get interactive() : Boolean
{
return this._interactive;
}
public function set interactive(param1:Boolean) : void
{
if(this._interactive == param1)
{
return;
}
this._interactive = param1;
if(this._interactive)
{
addEventListener(MouseEvent.MOUSE_DOWN,this.onMouseDown);
addEventListener(MouseEvent.MOUSE_UP,this.onMouseUp);
addEventListener(MouseEvent.MOUSE_MOVE,this.onMouseMove);
addEventListener(MouseEvent.MOUSE_WHEEL,this.onMouseWheel);
addEventListener(MouseEvent.MOUSE_OUT,this.onMouseOut);
}
else
{
removeEventListener(MouseEvent.MOUSE_DOWN,this.onMouseDown);
removeEventListener(MouseEvent.MOUSE_UP,this.onMouseUp);
removeEventListener(MouseEvent.MOUSE_MOVE,this.onMouseMove);
removeEventListener(MouseEvent.MOUSE_WHEEL,this.onMouseWheel);
removeEventListener(MouseEvent.MOUSE_OUT,this.onMouseOut);
this.pressedTarget = this.overedTarget = this.clickedTarget = null;
}
}
private function onRemoveFromStage(_arg_1:Event):void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, this.onKeyDown);
stage.removeEventListener(KeyboardEvent.KEY_UP, this.onKeyUp);
addEventListener(Event.ADDED_TO_STAGE, this.onAddToStage);
removeEventListener(Event.REMOVED_FROM_STAGE, this.onRemoveFromStage);
this.interactive = false;
this.canvas.graphics.clear();
var _local_2:int = views.indexOf(this);
while (_local_2 < (views.length - 1))
@@ -192,6 +226,15 @@ package alternativa.engine3d.core{
this.target = null;
}
private function onMouseUp(_arg_1:MouseEvent):void{
this.onMouse(_arg_1);
if (this.pressedTarget != null)
{
this.propagateEvent(MouseEvent3D.MOUSE_UP, this.pressedTarget, this.branchToVector(this.pressedTarget, branch));
this.pressedTarget = null;
}
}
private function onMouseWheel(_arg_1:MouseEvent):void{
this.onMouse(_arg_1);
this.defineTarget(_arg_1);

View File

@@ -23,7 +23,7 @@ package alternativa.engine3d.materials
this.alpha = _arg_2;
this.lineThickness = _arg_3;
this.lineColor = _arg_4;
//_texture = new BitmapData(1,1,true,(alpha * 255 << 24) + color);
super(new BitmapData(1,1,true,(alpha * 255 << 24) + color));
}
override alternativa3d function get transparent():Boolean