Permalink
Browse files

drag and drop inside materials

  • Loading branch information...
1 parent a4358c8 commit 0c338811bdeca42da61ae30130693126e2703343 @keyemkey keyemkey committed Jul 7, 2013
Showing with 413 additions and 149 deletions.
  1. +3 −1 awaybuilder-core/src/awaybuilder/CoreContext.as
  2. +1 −1 awaybuilder-core/src/awaybuilder/controller/scene/AddNewCubeTextureCommand.as
  3. +7 −6 awaybuilder-core/src/awaybuilder/controller/scene/AddNewEffectMethodCommand.as
  4. +3 −3 awaybuilder-core/src/awaybuilder/controller/scene/ChangeEffectMethodCommand.as
  5. +2 −2 awaybuilder-core/src/awaybuilder/controller/scene/ReparentLightCommand.as
  6. +125 −0 awaybuilder-core/src/awaybuilder/controller/scene/ReparentMaterialEffectCommand.as
  7. +1 −0 awaybuilder-core/src/awaybuilder/controller/scene/events/SceneEvent.as
  8. +5 −5 awaybuilder-core/src/awaybuilder/model/AssetsModel.as
  9. +3 −17 awaybuilder-core/src/awaybuilder/model/DocumentModel.as
  10. +1 −1 awaybuilder-core/src/awaybuilder/model/SmartDocumentServiceBase.as
  11. +5 −4 awaybuilder-core/src/awaybuilder/model/SmartFactoryModelBase.as
  12. +0 −2 awaybuilder-core/src/awaybuilder/model/vo/DocumentVO.as
  13. +4 −4 awaybuilder-core/src/awaybuilder/model/vo/scene/{EffectMethodVO.as → EffectVO.as}
  14. +1 −1 awaybuilder-core/src/awaybuilder/model/vo/scene/MaterialVO.as
  15. +0 −1 awaybuilder-core/src/awaybuilder/model/vo/scene/SharedAnimationNodeVO.as
  16. +19 −0 awaybuilder-core/src/awaybuilder/model/vo/scene/SharedEffectVO.as
  17. +7 −9 awaybuilder-core/src/awaybuilder/utils/encoders/AWDEncoder.as
  18. +47 −45 awaybuilder-core/src/awaybuilder/view/components/LibraryPanel.mxml
  19. +0 −1 awaybuilder-core/src/awaybuilder/view/components/controls/AnimationTree.as
  20. +3 −3 awaybuilder-core/src/awaybuilder/view/components/controls/DroppableEffectsList.as
  21. +125 −0 awaybuilder-core/src/awaybuilder/view/components/controls/MaterialsTree.as
  22. +3 −0 awaybuilder-core/src/awaybuilder/view/components/controls/tree/GenericDataDescriptor.as
  23. +3 −3 awaybuilder-core/src/awaybuilder/view/components/controls/tree/TreeItemRenderer.mxml
  24. +4 −4 awaybuilder-core/src/awaybuilder/view/components/editors/EffectMethodPropertyEditor.mxml
  25. +0 −11 awaybuilder-core/src/awaybuilder/view/components/editors/MaterialGroupPropertiesEditor.mxml
  26. +1 −0 awaybuilder-core/src/awaybuilder/view/components/events/LibraryPanelEvent.as
  27. +21 −11 awaybuilder-core/src/awaybuilder/view/mediators/CoreEditorMediator.as
  28. +8 −11 awaybuilder-core/src/awaybuilder/view/mediators/LibraryPanelMediator.as
  29. +11 −3 awaybuilder-core/src/awaybuilder/view/mediators/PropertiesPanelMediator.as
View
4 awaybuilder-core/src/awaybuilder/CoreContext.as
@@ -69,6 +69,7 @@ package awaybuilder
import awaybuilder.controller.scene.DeleteCommand;
import awaybuilder.controller.scene.ReparentAnimationCommand;
import awaybuilder.controller.scene.ReparentLightCommand;
+ import awaybuilder.controller.scene.ReparentMaterialEffectCommand;
import awaybuilder.controller.scene.ReparentObjectCommand;
import awaybuilder.controller.scene.RotateCommand;
import awaybuilder.controller.scene.ScaleCommand;
@@ -81,10 +82,10 @@ package awaybuilder
import awaybuilder.controller.scene.TranslateCommand;
import awaybuilder.controller.scene.TranslatePivotCommand;
import awaybuilder.controller.scene.events.SceneEvent;
+ import awaybuilder.model.ApplicationModel;
import awaybuilder.model.AssetsModel;
import awaybuilder.model.DocumentModel;
import awaybuilder.model.UndoRedoModel;
- import awaybuilder.model.ApplicationModel;
import awaybuilder.view.components.CoreEditor;
import awaybuilder.view.components.EditStatusBar;
import awaybuilder.view.components.EditToolBar;
@@ -153,6 +154,7 @@ package awaybuilder
commandMap.mapEvent(SceneEvent.REPARENT_OBJECTS, ReparentObjectCommand);
commandMap.mapEvent(SceneEvent.REPARENT_LIGHTS, ReparentLightCommand);
commandMap.mapEvent(SceneEvent.REPARENT_ANIMATIONS, ReparentAnimationCommand);
+ commandMap.mapEvent(SceneEvent.REPARENT_MATERIAL_EFFECT, ReparentMaterialEffectCommand);
commandMap.mapEvent(SceneEvent.CHANGE_MESH, ChangeMeshCommand);
commandMap.mapEvent(SceneEvent.CHANGE_SUBMESH, ChangeSubMeshCommand);
View
2 awaybuilder-core/src/awaybuilder/controller/scene/AddNewCubeTextureCommand.as
@@ -7,7 +7,7 @@ package awaybuilder.controller.scene
import awaybuilder.model.DocumentModel;
import awaybuilder.model.vo.scene.AssetVO;
import awaybuilder.model.vo.scene.CubeTextureVO;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
public class AddNewCubeTextureCommand extends HistoryCommandBase
{
View
13 awaybuilder-core/src/awaybuilder/controller/scene/AddNewEffectMethodCommand.as
@@ -4,8 +4,9 @@ package awaybuilder.controller.scene
import awaybuilder.controller.history.HistoryCommandBase;
import awaybuilder.controller.scene.events.SceneEvent;
import awaybuilder.model.DocumentModel;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
import awaybuilder.model.vo.scene.MaterialVO;
+ import awaybuilder.model.vo.scene.SharedEffectVO;
import awaybuilder.utils.AssetUtil;
public class AddNewEffectMethodCommand extends HistoryCommandBase
@@ -20,16 +21,16 @@ package awaybuilder.controller.scene
{
material = event.items[0] as MaterialVO;
}
- var oldValue:EffectMethodVO = event.oldValue as EffectMethodVO;
- var newValue:EffectMethodVO = event.newValue as EffectMethodVO;
+ var oldValue:EffectVO = event.oldValue as EffectVO;
+ var newValue:EffectVO = event.newValue as EffectVO;
if( event.isUndoAction )
{
- document.removeAsset( document.methods, oldValue );
+ document.removeAsset( document.materials, oldValue );
}
else
{
- document.methods.addItemAt( newValue, 0 );
+ document.materials.addItemAt( newValue, 0 );
}
if( material )
@@ -40,7 +41,7 @@ package awaybuilder.controller.scene
}
else
{
- material.effectMethods.addItem(newValue);
+ material.effectMethods.addItem( new SharedEffectVO(newValue));
}
material.fillFromMaterial( material );
}
View
6 awaybuilder-core/src/awaybuilder/controller/scene/ChangeEffectMethodCommand.as
@@ -2,7 +2,7 @@ package awaybuilder.controller.scene
{
import awaybuilder.controller.history.HistoryCommandBase;
import awaybuilder.controller.scene.events.SceneEvent;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
public class ChangeEffectMethodCommand extends HistoryCommandBase
{
@@ -11,9 +11,9 @@ package awaybuilder.controller.scene
override public function execute():void
{
- var newAsset:EffectMethodVO = event.newValue as EffectMethodVO;
+ var newAsset:EffectVO = event.newValue as EffectVO;
- var vo:EffectMethodVO = event.items[0] as EffectMethodVO;
+ var vo:EffectVO = event.items[0] as EffectVO;
saveOldValue( event, vo.clone() );
View
4 awaybuilder-core/src/awaybuilder/controller/scene/ReparentLightCommand.as
@@ -107,7 +107,7 @@ package awaybuilder.controller.scene
{
if( !event.oldValue )
{
- var oldValue:Dictionary = new Dictionary();
+ var oldValue:Vector.<DroppedAssetVO> = new Vector.<DroppedAssetVO>();
for each( var item:DroppedAssetVO in event.newValue )
{
var newItem:DroppedAssetVO = new DroppedAssetVO();
@@ -116,7 +116,7 @@ package awaybuilder.controller.scene
newItem.newPosition = item.newPosition;
newItem.oldParent = item.newParent;
newItem.oldPosition = item.oldPosition;
- oldValue[item.value] = newItem;
+ oldValue.push(newItem);
}
event.oldValue = oldValue;
}
View
125 awaybuilder-core/src/awaybuilder/controller/scene/ReparentMaterialEffectCommand.as
@@ -0,0 +1,125 @@
+package awaybuilder.controller.scene
+{
+ import awaybuilder.controller.history.HistoryCommandBase;
+ import awaybuilder.controller.history.HistoryEvent;
+ import awaybuilder.controller.scene.events.SceneEvent;
+ import awaybuilder.model.AssetsModel;
+ import awaybuilder.model.vo.DroppedAssetVO;
+ import awaybuilder.model.vo.scene.AssetVO;
+ import awaybuilder.model.vo.scene.EffectVO;
+ import awaybuilder.model.vo.scene.LightVO;
+ import awaybuilder.model.vo.scene.MaterialVO;
+ import awaybuilder.model.vo.scene.SharedEffectVO;
+
+ import flash.utils.Dictionary;
+
+ import mx.collections.ArrayCollection;
+
+ public class ReparentMaterialEffectCommand extends HistoryCommandBase
+ {
+ [Inject]
+ public var event:SceneEvent;
+
+ [Inject]
+ public var assets:AssetsModel;
+
+ override public function execute():void
+ {
+ saveOldValue( event, event.newValue );
+
+ if( event.isUndoAction )
+ {
+ undo();
+ return;
+ }
+ var material:MaterialVO;
+
+ for each( var item:DroppedAssetVO in event.newValue )
+ {
+ if( item.value is EffectVO )
+ {
+ if( item.newParent == item.oldParent ) return;
+
+ if( item.newParent && !item.oldParent )
+ {
+ material = item.newParent as MaterialVO;
+ if( material && !itemIsInList(material.effectMethods, item.value as AssetVO) )
+ {
+ if( item.newPosition < material.effectMethods.length )
+ {
+ material.effectMethods.addItemAt( new SharedEffectVO(item.value as EffectVO), item.newPosition );
+ }
+ else
+ {
+ material.effectMethods.addItem( new SharedEffectVO(item.value as EffectVO) );
+ }
+ }
+ }
+ }
+ }
+
+ commitHistoryEvent( event );
+ }
+ private function undo():void
+ {
+ var material:MaterialVO;
+
+ for each( var item:DroppedAssetVO in event.newValue )
+ {
+ if( item.value is LightVO )
+ {
+
+ if( item.oldParent )
+ {
+ material = item.oldParent as MaterialVO;
+ if( material && itemIsInList(material.effectMethods, item.value as AssetVO) )
+ {
+ removeItem( material.effectMethods, item.value as AssetVO );
+ }
+ }
+ }
+ }
+ }
+ private function itemIsInList( collection:ArrayCollection, asset:AssetVO ):Boolean
+ {
+ for each( var a:AssetVO in collection )
+ {
+ if( a.equals( asset ) ) return true;
+ }
+ return false;
+ }
+
+ private function removeItem( source:ArrayCollection, oddItem:AssetVO ):void
+ {
+ for (var i:int = 0; i < source.length; i++)
+ {
+ var item:AssetVO = source[i] as AssetVO;
+ if( item.equals( oddItem ) )
+ {
+ source.removeItemAt( i );
+ i--;
+ }
+ }
+ }
+
+ override protected function saveOldValue( event:HistoryEvent, prevValue:Object ):void
+ {
+ if( !event.oldValue )
+ {
+ var oldValue:Vector.<DroppedAssetVO> = new Vector.<DroppedAssetVO>();
+ for each( var item:DroppedAssetVO in event.newValue )
+ {
+ var newItem:DroppedAssetVO = new DroppedAssetVO();
+ newItem.value = item.value;
+ newItem.newParent = item.oldParent;
+ newItem.newPosition = item.newPosition;
+ newItem.oldParent = item.newParent;
+ newItem.oldPosition = item.oldPosition;
+ oldValue.push(newItem);
+ }
+ event.oldValue = oldValue;
+ }
+ }
+
+ }
+}
View
1 awaybuilder-core/src/awaybuilder/controller/scene/events/SceneEvent.as
@@ -17,6 +17,7 @@ import flash.events.Event;
public static const CHANGE_GLOBAL_OPTIONS:String = "changeGlobalOptions";
+ public static const REPARENT_MATERIAL_EFFECT:String = "reparentMaterialEffect";
public static const REPARENT_ANIMATIONS:String = "reparentAnimations";
public static const REPARENT_OBJECTS:String = "reparentObjects";
public static const REPARENT_LIGHTS:String = "reparentLights";
View
10 awaybuilder-core/src/awaybuilder/model/AssetsModel.as
@@ -82,7 +82,7 @@ package awaybuilder.model
import awaybuilder.model.vo.scene.CameraVO;
import awaybuilder.model.vo.scene.ContainerVO;
import awaybuilder.model.vo.scene.CubeTextureVO;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
import awaybuilder.model.vo.scene.GeometryVO;
import awaybuilder.model.vo.scene.LensVO;
import awaybuilder.model.vo.scene.LightPickerVO;
@@ -247,14 +247,14 @@ package awaybuilder.model
camera.x = camera.y = camera.z = 0;
return GetAsset(camera) as CameraVO;
}
- public function CreateProjectiveTextureMethod( textureProjector:TextureProjectorVO ):EffectMethodVO
+ public function CreateProjectiveTextureMethod( textureProjector:TextureProjectorVO ):EffectVO
{
var method:EffectMethodBase = new ProjectiveTextureMethod( GetObject(textureProjector) as TextureProjector );
method.name = "ProjectiveTexture " + AssetUtil.GetNextId("ProjectiveTexture");
- return GetAsset( method ) as EffectMethodVO;
+ return GetAsset( method ) as EffectVO;
}
- public function CreateEffectMethod( type:String ):EffectMethodVO
+ public function CreateEffectMethod( type:String ):EffectVO
{
var method:EffectMethodBase;
switch( type )
@@ -302,7 +302,7 @@ package awaybuilder.model
EnvMapMethod(method).mask = GetObject(defaultTexture) as Texture2DBase;
break;
}
- return GetAsset( method ) as EffectMethodVO;
+ return GetAsset( method ) as EffectVO;
}
public function CreateSkyBox():SkyBoxVO
{
View
20 awaybuilder-core/src/awaybuilder/model/DocumentModel.as
@@ -8,7 +8,7 @@ package awaybuilder.model
import awaybuilder.model.vo.scene.AssetVO;
import awaybuilder.model.vo.scene.ContainerVO;
import awaybuilder.model.vo.scene.CubeTextureVO;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
import awaybuilder.model.vo.scene.GeometryVO;
import awaybuilder.model.vo.scene.LightPickerVO;
import awaybuilder.model.vo.scene.LightVO;
@@ -159,17 +159,6 @@ package awaybuilder.model
if( lights ) lights.addEventListener(CollectionEvent.COLLECTION_CHANGE, assets_collectionChangeHandler );
}
- public function get methods():ArrayCollection
- {
- return _documentVO.methods;
- }
- public function set methods(value:ArrayCollection):void
- {
- if( methods ) methods.removeEventListener(CollectionEvent.COLLECTION_CHANGE, assets_collectionChangeHandler );
- _documentVO.methods = value;
- if( methods ) methods.addEventListener(CollectionEvent.COLLECTION_CHANGE, assets_collectionChangeHandler );
- }
-
public function fill( data:DocumentVO ):void
{
animations = new ArrayCollection( animations.source.concat( data.animations.source ) );
@@ -178,12 +167,11 @@ package awaybuilder.model
scene = new ArrayCollection( scene.source.concat( data.scene.source ) );
textures = new ArrayCollection( textures.source.concat( data.textures.source ) );
lights = new ArrayCollection( lights.source.concat( data.lights.source ) );
- methods = new ArrayCollection( methods.source.concat( data.methods.source ) );
}
public function getAllAssets():Array
{
- var assets:Array = scene.source.concat(materials.source.concat(textures.source.concat(animations.source.concat(methods.source.concat(geometry.source.concat(lights.source))))));
+ var assets:Array = scene.source.concat(materials.source.concat(textures.source.concat(animations.source.concat(geometry.source.concat(lights.source)))));
return assets;
}
@@ -204,7 +192,6 @@ package awaybuilder.model
materials = new ArrayCollection();
textures = new ArrayCollection();
geometry = new ArrayCollection();
- methods = new ArrayCollection();
animations = new ArrayCollection();
lights = new ArrayCollection();
_globalOptions = new GlobalOptionsVO();
@@ -266,15 +253,14 @@ package awaybuilder.model
{
case( asset is ObjectVO ):
return scene;
+ case( asset is EffectVO ):
case( asset is MaterialVO ):
return materials;
case( asset is TextureVO ):
case( asset is CubeTextureVO ):
return textures;
case( asset is GeometryVO ):
return geometry;
- case( asset is EffectMethodVO ):
- return methods;
case( asset is LightVO ):
case( asset is LightPickerVO ):
return lights;
View
2 awaybuilder-core/src/awaybuilder/model/SmartDocumentServiceBase.as
@@ -208,7 +208,7 @@ package awaybuilder.model
break;
case AssetType.EFFECTS_METHOD:
assets.checkEffectMethodForDefaulttexture(event.asset as EffectMethodBase)
- _document.methods.addItem( assets.GetAsset( event.asset ) );
+ _document.materials.addItem( assets.GetAsset( event.asset ) );
break;
case AssetType.LIGHT:
var light:LightBase = event.asset as LightBase;
View
9 awaybuilder-core/src/awaybuilder/model/SmartFactoryModelBase.as
@@ -89,7 +89,7 @@ package awaybuilder.model
import awaybuilder.model.vo.scene.CameraVO;
import awaybuilder.model.vo.scene.ContainerVO;
import awaybuilder.model.vo.scene.CubeTextureVO;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
import awaybuilder.model.vo.scene.ExtraItemVO;
import awaybuilder.model.vo.scene.GeometryVO;
import awaybuilder.model.vo.scene.LensVO;
@@ -102,6 +102,7 @@ package awaybuilder.model
import awaybuilder.model.vo.scene.ShadowMapperVO;
import awaybuilder.model.vo.scene.ShadowMethodVO;
import awaybuilder.model.vo.scene.SharedAnimationNodeVO;
+ import awaybuilder.model.vo.scene.SharedEffectVO;
import awaybuilder.model.vo.scene.SharedLightVO;
import awaybuilder.model.vo.scene.SkeletonPoseVO;
import awaybuilder.model.vo.scene.SkeletonVO;
@@ -183,7 +184,7 @@ package awaybuilder.model
return fillSubMesh( new SubMeshVO(), item as SubMesh );
case(item is EffectMethodBase):
- return fillEffectMethod( new EffectMethodVO(), item as EffectMethodBase );
+ return fillEffectMethod( new EffectVO(), item as EffectMethodBase );
case(item is LightPickerBase):
return fillLightPicker( new LightPickerVO(), item as StaticLightPicker );
@@ -248,7 +249,7 @@ package awaybuilder.model
}
return asset;
}
- private function fillEffectMethod( asset:EffectMethodVO, item:EffectMethodBase ):EffectMethodVO
+ private function fillEffectMethod( asset:EffectVO, item:EffectMethodBase ):EffectVO
{
asset.type = getQualifiedClassName( item ).split("::")[1];
asset.name = item.name;
@@ -899,7 +900,7 @@ package awaybuilder.model
asset.alphaThreshold = singlePassMaterialBase.alphaThreshold;
for (var i:int = 0; i < singlePassMaterialBase.numMethods; i++)
{
- asset.effectMethods.addItem( GetAsset(singlePassMaterialBase.getMethodAt( i )) );
+ asset.effectMethods.addItem( new SharedEffectVO( GetAsset(singlePassMaterialBase.getMethodAt( i )) as EffectVO ) );
}
}
View
2 awaybuilder-core/src/awaybuilder/model/vo/DocumentVO.as
@@ -18,7 +18,5 @@ package awaybuilder.model.vo
public var lights:ArrayCollection = new ArrayCollection();
- public var methods:ArrayCollection = new ArrayCollection();
-
}
}
View
8 ...ybuilder/model/vo/scene/EffectMethodVO.as → ...rc/awaybuilder/model/vo/scene/EffectVO.as
@@ -3,7 +3,7 @@ package awaybuilder.model.vo.scene
import away3d.materials.methods.EffectMethodBase;
[Bindable]
- public class EffectMethodVO extends AssetVO
+ public class EffectVO extends AssetVO
{
public var type:String;
@@ -52,14 +52,14 @@ package awaybuilder.model.vo.scene
public var minDistance:Number;
public var maxDistance:Number;
- public function clone():EffectMethodVO
+ public function clone():EffectVO
{
- var vo:EffectMethodVO = new EffectMethodVO();
+ var vo:EffectVO = new EffectVO();
vo.fillFromEffectMethod( this );
return vo;
}
- public function fillFromEffectMethod( asset:EffectMethodVO ):void
+ public function fillFromEffectMethod( asset:EffectVO ):void
{
this.name = asset.name;
this.alpha = asset.alpha;
View
2 awaybuilder-core/src/awaybuilder/model/vo/scene/MaterialVO.as
@@ -62,7 +62,7 @@ package awaybuilder.model.vo.scene
public var shadowMethod:ShadowMethodVO;
- public var effectMethods:ArrayCollection = new ArrayCollection();
+ public var effectMethods:ArrayCollection = new ArrayCollection(); // SharedEffectMethodVO
public function clone():MaterialVO
{
View
1 awaybuilder-core/src/awaybuilder/model/vo/scene/SharedAnimationNodeVO.as
@@ -11,7 +11,6 @@ package awaybuilder.model.vo.scene
this.fillFromAnimationNode( animationNodeVO );
this.id = animationNodeVO.id;
this.linkedAsset = animationNodeVO;
- trace( "SharedAnimationNodeVO" , animationNodeVO.name );
}
public var linkedAsset:AssetVO;
View
19 awaybuilder-core/src/awaybuilder/model/vo/scene/SharedEffectVO.as
@@ -0,0 +1,19 @@
+package awaybuilder.model.vo.scene
+{
+ import awaybuilder.model.vo.scene.interfaces.IShared;
+
+ [Bindable]
+ public class SharedEffectVO extends EffectVO implements IShared
+ {
+
+ public function SharedEffectVO( effectVO:EffectVO )
+ {
+ this.fillFromEffectMethod( effectVO );
+ this.id = effectVO.id;
+ this.linkedAsset = effectVO;
+ }
+
+ public var linkedAsset:AssetVO;
+
+ }
+}
View
16 awaybuilder-core/src/awaybuilder/utils/encoders/AWDEncoder.as
@@ -14,7 +14,7 @@ package awaybuilder.utils.encoders
import awaybuilder.model.vo.scene.CameraVO;
import awaybuilder.model.vo.scene.ContainerVO;
import awaybuilder.model.vo.scene.CubeTextureVO;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
import awaybuilder.model.vo.scene.ExtraItemVO;
import awaybuilder.model.vo.scene.GeometryVO;
import awaybuilder.model.vo.scene.LensVO;
@@ -210,7 +210,6 @@ package awaybuilder.utils.encoders
//create a AWDBlock class for all supported Assets
_createAwdBlocks(document.textures);
- _createAwdBlocks(document.methods);
_createAwdBlocks(document.lights);
_createAwdBlocks(document.materials);
_createAwdBlocks(document.geometry);
@@ -229,7 +228,6 @@ package awaybuilder.utils.encoders
//_encode all supported Assets that are not encodet yet
_encodeAddionalBlocks(document.textures);
- _encodeAddionalBlocks(document.methods);
_encodeAddionalBlocks(document.lights);
_encodeAddionalBlocks(document.materials);
_encodeAddionalBlocks(document.geometry);
@@ -294,7 +292,7 @@ package awaybuilder.utils.encoders
case (asset is TextureVO):
case (asset is CubeTextureVO):
case (asset is ShadowMethodVO):
- case (asset is EffectMethodVO):
+ case (asset is EffectVO):
case (asset is ShadingMethodVO):
case (asset is LightVO):
case (asset is LightPickerVO):
@@ -337,7 +335,7 @@ package awaybuilder.utils.encoders
case (asset is TextureVO):
case (asset is CubeTextureVO):
case (asset is ShadowMethodVO):
- case (asset is EffectMethodVO):
+ case (asset is EffectVO):
case (asset is ShadingMethodVO):
case (asset is LightVO):
case (asset is LightPickerVO):
@@ -385,8 +383,8 @@ package awaybuilder.utils.encoders
returnID=_encodeShadowMethod(ShadowMethodVO(asset));
if(_debug)trace("start encoding ShadowMethodVO = "+asset.name);
break;
- case (asset is EffectMethodVO):
- returnID=_encodeEffectMethod(EffectMethodVO(asset));
+ case (asset is EffectVO):
+ returnID=_encodeEffectMethod(EffectVO(asset));
if(_debug)trace("start encoding EffectMethodVO = "+asset.name);
break;
case (asset is LightVO):
@@ -1138,7 +1136,7 @@ package awaybuilder.utils.encoders
if(_debug)trace("ShadowMethod= "+mat.shadowMethod);
if(_debug)trace("ShadowMethod ID= "+_getBlockIDorEncodeAsset(mat.shadowMethod));
if (mat.shadowMethod)materialMethods.push(new AWDmethod(998, [1], [_getBlockIDorEncodeAsset(mat.shadowMethod)], [0], [BADDR]));
- for each (var effectMethVO:EffectMethodVO in mat.effectMethods){
+ for each (var effectMethVO:EffectVO in mat.effectMethods){
materialMethods.push(new AWDmethod(999, [1], [_getBlockIDorEncodeAsset(effectMethVO)], [0], [BADDR]));// to do - check the correct id for a "shared methdod block"-method
}
return materialMethods;
@@ -1376,7 +1374,7 @@ package awaybuilder.utils.encoders
if(_debug)trace("SharedMethod = "+ name + " has been encoded successfully!");
return returnID
}
- private function _encodeEffectMethod(methVO:EffectMethodVO) : uint
+ private function _encodeEffectMethod(methVO:EffectVO) : uint
{
var returnID:uint=0;
var cubeTexID:uint;
View
92 awaybuilder-core/src/awaybuilder/view/components/LibraryPanel.mxml
@@ -27,8 +27,9 @@
<s:Button width="100%" label="New Light Picker" styleName="addItemButton" cornerRadius="0" click="close(true,'newLightPicker')"/>
</s:SkinnablePopUpContainer>
</fx:Component>
- <fx:Component className="NewEffectPopup">
+ <fx:Component className="NewMatreialPopup">
<s:SkinnablePopUpContainer skinClass="awaybuilder.view.skins.LibrarySkinnablePopUpContainer" chromeColor="0x1d1d1c" color="0xdbdbdb" mouseDownOutside="close();">
+ <s:Button width="100%" label="New Material" styleName="addItemButton" cornerRadius="0" click="close(true,'Material')"/>
<s:Button width="100%" label="New LightMapMethod" styleName="addItemButton" cornerRadius="0" click="close(true,'LightMapMethod')"/>
<s:Button width="100%" label="New ProjectiveTextureMethod" styleName="addItemButton" cornerRadius="0" click="close(true,'ProjectiveTextureMethod')"/>
<s:Button width="100%" label="New RimLightMethod" styleName="addItemButton" cornerRadius="0" click="close(true,'RimLightMethod')"/>
@@ -138,14 +139,15 @@
protected function collapsiblepanel_creationCompleteHandler(event:FlexEvent):void
{
_expandedPanel = scenePanel;
- _panels = [scenePanel,materialsPanel,texturesPanel,geometryPanel,methodsPanel,animationsPanel,lightsPanel ];
+ _panels = [scenePanel,materialsPanel,texturesPanel,geometryPanel,animationsPanel,lightsPanel ];
}
protected function tree_changeHandler(event:IndexChangeEvent):void
{
var tree:Tree = event.target as Tree;
_tempSelectedItems = tree.selectedItems;
+ trace( "tree_changeHandler", _waitingForMouseUp );
if( !_waitingForMouseUp )
{
this.dispatchEvent( new LibraryPanelEvent( LibraryPanelEvent.TREE_CHANGE, _tempSelectedItems ) );
@@ -174,10 +176,6 @@
var pos:Point = button.localToGlobal( new Point() );
popup.move( pos.x-4, Math.min(pos.y-4, stage.height-popup.height-8) );
}
- protected function materialsPanel_addNewItemHandler(event:MouseEvent):void
- {
- this.dispatchEvent( new LibraryPanelEvent( LibraryPanelEvent.ADD_MATERIAL ) );
- }
protected function scenePanel_addNewItemHandler(event:MouseEvent):void
{
var button:ButtonBase = event.relatedObject as ButtonBase;
@@ -232,12 +230,12 @@
var pos:Point = button.localToGlobal( new Point() );
popup.move( pos.x-4, Math.min(pos.y-4, stage.height-popup.height-8) );
}
- private function methodsPanel_addNewItemHandler(event:MouseEvent):void
+ private function materialsPanel_addNewItemHandler(event:MouseEvent):void
{
var button:ButtonBase = event.relatedObject as ButtonBase;
- var popup:NewEffectPopup = new NewEffectPopup();
+ var popup:NewMatreialPopup = new NewMatreialPopup();
popup.open(this);
- popup.addEventListener('close', newEffectPopup_closeHandler);
+ popup.addEventListener('close', newMaterialsPopup_closeHandler);
var pos:Point = button.localToGlobal( new Point() );
popup.move( pos.x-4, Math.min(pos.y-4, stage.height-popup.height-8) );
}
@@ -251,9 +249,14 @@
popup.move( pos.x-4, Math.min(pos.y-4, stage.height-popup.height-8) );
}
- private function newEffectPopup_closeHandler(event:PopUpEvent):void
+ private function newMaterialsPopup_closeHandler(event:PopUpEvent):void
{
if (!event.commit) return;
+ if( event.data == "Material" )
+ {
+ this.dispatchEvent( new LibraryPanelEvent( LibraryPanelEvent.ADD_MATERIAL ) );
+ return;
+ }
this.dispatchEvent( new LibraryPanelEvent( LibraryPanelEvent.ADD_EFFECTMETHOD, event.data ) );
}
private function newGeometryPopup_closeHandler(event:PopUpEvent):void
@@ -287,11 +290,6 @@
systemManager.getSandboxRoot().removeEventListener(SandboxMouseEvent.MOUSE_UP_SOMEWHERE, mouseUpHandler, false);
}
- protected function methodsTree_dragCompleteHandler(event:DragEvent):void
- {
- methodsTree.selectedItems = selectedItems;
- }
-
protected function lightsTree_dragCompleteHandler(event:DragEvent):void
{
lightsTree.selectedItems = selectedItems;
@@ -361,39 +359,54 @@
return droppedAsses;
}
- protected function sceneTree_mouseDownHandler(event:MouseEvent):void
+ protected function tree_mouseDownHandler(event:MouseEvent):void
{
_waitingForMouseUp = true;
+ trace( "tree_mouseDownHandler", _waitingForMouseUp );
systemManager.getSandboxRoot().addEventListener(SandboxMouseEvent.MOUSE_UP_SOMEWHERE, mouseUpHandler, false, 0, true);
systemManager.getSandboxRoot().addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, false, 0, true);
}
+ protected function materialTree_itemDroppedHandler(event:TreeEvent):void
+ {
+ this.dispatchEvent( new LibraryPanelEvent( LibraryPanelEvent.MATERIALS_DROPPED, getAssetsFromDroppedItem(event.item as Dictionary) ) );
+ }
+
+ protected function materialTree_dragCompleteHandler(event:DragEvent):void
+ {
+ materialTree.selectedItems = selectedItems;
+ }
+
]]>
</fx:Script>
<s:VGroup width="235" height="100%" gap="0">
<controls:LibraryCollapsiblePanel id="scenePanel" skinClass="awaybuilder.view.skins.CollapsibleDropdownLibraryPanelSkin" borderVisible="false"
- title="Scene Objects" width="100%" collapsed="false" height="100%" addEnabled="true"
- addNewItem="scenePanel_addNewItemHandler(event)"
- collapsedChange="panel_collapsedChangeHandler(event)">
+ title="Scene Objects" width="100%" collapsed="false" height="100%" addEnabled="true"
+ addNewItem="scenePanel_addNewItemHandler(event)"
+ collapsedChange="panel_collapsedChangeHandler(event)">
<controls:SceneTree id="sceneTree" dataProvider="{model.scene}" selectedItems="{selectedItems}" indentation="16"
- dragEnabled="true" dropEnabled="true" dragMoveEnabled="true" allowMultipleSelection="true"
- focusSkin="mx.core.UIComponent"
- dataDescriptor="{new SceneDataDescriptor()}"
- change="tree_changeHandler(event)"
- itemDropped="sceneTree_itemDroppedHandler(event)"
- dragComplete="sceneTree_dragCompleteHandler(event)"
- mouseDown="sceneTree_mouseDownHandler(event)"
- width="100%" height="100%"/>
+ dragEnabled="true" dropEnabled="true" dragMoveEnabled="true" allowMultipleSelection="true"
+ focusSkin="mx.core.UIComponent"
+ dataDescriptor="{new SceneDataDescriptor()}"
+ change="tree_changeHandler(event)"
+ itemDropped="sceneTree_itemDroppedHandler(event)"
+ dragComplete="sceneTree_dragCompleteHandler(event)"
+ mouseDown="tree_mouseDownHandler(event)"
+ width="100%" height="100%"/>
</controls:LibraryCollapsiblePanel>
<controls:LibraryCollapsiblePanel id="materialsPanel" skinClass="awaybuilder.view.skins.CollapsibleDropdownLibraryPanelSkin" borderVisible="false"
title="Materials" height="24" width="100%" collapsed="true" addEnabled="true"
collapsedChange="panel_collapsedChangeHandler(event)"
addNewItem="materialsPanel_addNewItemHandler(event)">
- <tree:Tree id="materialTree" dataProvider="{model.materials}" selectedItems="{selectedItems}" indentation="16"
- allowMultipleSelection="true" focusSkin="mx.core.UIComponent"
- change="tree_changeHandler(event)"
- mouseDown="sceneTree_mouseDownHandler(event)"
- width="100%" height="100%"/>
+ <controls:MaterialsTree id="materialTree" dataProvider="{model.materials}" selectedItems="{selectedItems}" indentation="16"
+ dragEnabled="true" dropEnabled="true" dragMoveEnabled="true"
+ allowMultipleSelection="true" focusSkin="mx.core.UIComponent"
+ change="tree_changeHandler(event)"
+ itemDropped="materialTree_itemDroppedHandler(event)"
+ dragStart="tree_dragStartHandler(event)"
+ dragComplete="materialTree_dragCompleteHandler(event)"
+ mouseDown="tree_mouseDownHandler(event)"
+ width="100%" height="100%"/>
</controls:LibraryCollapsiblePanel>
<controls:LibraryCollapsiblePanel id="texturesPanel" skinClass="awaybuilder.view.skins.CollapsibleDropdownLibraryPanelSkin" borderVisible="false"
title="Textures" height="24" width="100%" collapsed="true" addEnabled="true"
@@ -412,17 +425,6 @@
change="tree_changeHandler(event)"
width="100%" height="100%"/>
</controls:LibraryCollapsiblePanel>
- <controls:LibraryCollapsiblePanel id="methodsPanel" skinClass="awaybuilder.view.skins.CollapsibleDropdownLibraryPanelSkin" borderVisible="false"
- title="Effects" height="24" width="100%" collapsed="true" addEnabled="true"
- collapsedChange="panel_collapsedChangeHandler(event)"
- addNewItem="methodsPanel_addNewItemHandler(event)">
- <tree:Tree id="methodsTree" dataProvider="{model.methods}" selectedItems="{selectedItems}" indentation="16"
- allowMultipleSelection="true" focusSkin="mx.core.UIComponent"
- dragMoveEnabled="false" dragEnabled="true"
- dragStart="tree_dragStartHandler(event)" dragComplete="methodsTree_dragCompleteHandler(event)"
- change="tree_changeHandler(event)"
- width="100%" height="100%"/>
- </controls:LibraryCollapsiblePanel>
<controls:LibraryCollapsiblePanel id="animationsPanel" skinClass="awaybuilder.view.skins.CollapsibleDropdownLibraryPanelSkin" borderVisible="false"
title="Animations" addEnabled="true"
height="24" width="100%" collapsed="true"
@@ -435,7 +437,7 @@
dragStart="tree_dragStartHandler(event)"
itemDropped="animationsTree_itemDroppedHandler(event)"
dragComplete="animationsTree_dragCompleteHandler(event)"
- mouseDown="sceneTree_mouseDownHandler(event)"
+ mouseDown="tree_mouseDownHandler(event)"
width="100%" height="100%"/>
</controls:LibraryCollapsiblePanel>
<controls:LibraryCollapsiblePanel id="lightsPanel" skinClass="awaybuilder.view.skins.CollapsibleDropdownLibraryPanelSkin" borderVisible="false"
@@ -450,7 +452,7 @@
itemDropped="lightsTree_itemDroppedHandler(event)"
change="tree_changeHandler(event)"
dragComplete="lightsTree_dragCompleteHandler(event)"
- mouseDown="sceneTree_mouseDownHandler(event)"
+ mouseDown="tree_mouseDownHandler(event)"
width="100%" height="100%"/>
</controls:LibraryCollapsiblePanel>
</s:VGroup>
View
1 awaybuilder-core/src/awaybuilder/view/components/controls/AnimationTree.as
@@ -32,7 +32,6 @@ package awaybuilder.view.components.controls
_druggingOverItem = true;
}
}
-
}
override protected function renderer_dragOverHandler(event:DragEvent):void
View
6 awaybuilder-core/src/awaybuilder/view/components/controls/DroppableEffectsList.as
@@ -1,7 +1,7 @@
package awaybuilder.view.components.controls
{
import awaybuilder.model.vo.scene.AssetVO;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
import awaybuilder.view.components.controls.events.DroppedEvent;
import flash.geom.Point;
@@ -197,10 +197,10 @@ package awaybuilder.view.components.controls
var items:Vector.<Object> = event.dragSource.dataForFormat("itemsByIndex") as Vector.<Object>;
for (var i:int = 0; i < items.length; i++)
{
- var asset:EffectMethodVO = items[i] as EffectMethodVO;
+ var asset:EffectVO = items[i] as EffectVO;
if( !asset )
return null;
- for each( var light:EffectMethodVO in dataProvider )
+ for each( var light:EffectVO in dataProvider )
{
if( light.equals(asset) )
View
125 awaybuilder-core/src/awaybuilder/view/components/controls/MaterialsTree.as
@@ -0,0 +1,125 @@
+package awaybuilder.view.components.controls
+{
+ import awaybuilder.model.vo.scene.EffectVO;
+ import awaybuilder.model.vo.scene.MaterialVO;
+ import awaybuilder.model.vo.scene.SharedEffectVO;
+ import awaybuilder.view.components.controls.tree.ITreeItemRenderer;
+ import awaybuilder.view.components.controls.tree.Tree;
+
+ import mx.core.DragSource;
+ import mx.core.UIComponent;
+ import mx.core.mx_internal;
+ import mx.events.DragEvent;
+ import mx.managers.DragManager;
+
+ import spark.layouts.supportClasses.DropLocation;
+
+ use namespace mx_internal;
+
+ public class MaterialsTree extends Tree
+ {
+ public function MaterialsTree()
+ {
+ super();
+ }
+
+ override protected function renderer_dragEnterHandler(event:DragEvent):void
+ {
+ var dropArea:UIComponent = event.target as UIComponent;
+ var items:Vector.<Object> = event.dragSource.dataForFormat("itemsByIndex") as Vector.<Object>;
+ validateDropRenderer( event.target as UIComponent, event.dragSource.dataForFormat("itemsByIndex") as Vector.<Object> );
+ }
+
+ override protected function renderer_dragOverHandler(event:DragEvent):void
+ {
+ event.stopPropagation();
+ event.stopImmediatePropagation();
+ validateDropRenderer( event.target as UIComponent, event.dragSource.dataForFormat("itemsByIndex") as Vector.<Object> );
+ }
+
+ private function validateDropRenderer( dropArea:UIComponent, items:Vector.<Object> ):void
+ {
+ if( !items ) return;
+ var renderer:ITreeItemRenderer = dropArea.parent as ITreeItemRenderer;
+ if( renderer.data == items[0] ) return;
+ if( renderer.data is SharedEffectVO ) return;
+ if( renderer.data is EffectVO ) return;
+ if( items[0] is SharedEffectVO ) return;
+
+ if( items[0] is EffectVO )
+ {
+ renderer.showDropIndicator = true;
+ DragManager.acceptDragDrop(dropArea);
+ _druggingOverItem = true;
+ }
+ }
+
+ override protected function calculateDropLocation(event:DragEvent):DropLocation
+ {
+ // Verify data format
+ if (!enabled || !event.dragSource.hasFormat("itemsByIndex"))
+ return null;
+
+ if( _druggingOverItem ) return null;
+
+ // Calculate the drop location
+ var dropLocation:DropLocation = layout.calculateDropLocation(event);
+
+ return dropLocation;
+ }
+
+// override public function addDragData(dragSource:DragSource):void
+// {
+// dragSource.addHandler(copySelectedItemsForDragDrop, "itemsByIndex");
+//
+// // Calculate the index of the focus item within the vector
+// // of ordered items returned for the "itemsByIndex" format.
+// var caretIndex:int = 0;
+// var draggedIndices:Vector.<int> = selectedIndices;
+// var count:int = draggedIndices.length;
+// for (var i:int = 0; i < count; i++)
+// {
+// if (mouseDownIndex > draggedIndices[i])
+// caretIndex++;
+// }
+// dragSource.addData(caretIndex, "caretIndex");
+// }
+//
+// /**
+// * @private
+// */
+// private function copySelectedItemsForDragDrop():Vector.<Object>
+// {
+// // Copy the vector so that we don't modify the original
+// // since selectedIndices returns a reference.
+// var draggedIndices:Vector.<int> = selectedIndices.slice(0, selectedIndices.length);
+// var result:Vector.<Object> = new Vector.<Object>(draggedIndices.length);
+//
+// // Sort in the order of the data source
+// draggedIndices.sort(compareValues);
+//
+// // Copy the items
+// var count:int = draggedIndices.length;
+// for (var i:int = 0; i < count; i++)
+// {
+// var item:Object = dataProvider.getItemAt(draggedIndices[i]);
+// if( item is EffectVO )
+// {
+// result[i] = new SharedEffectVO( item as EffectVO );
+// }
+// else
+// {
+// result[i] = dataProvider.getItemAt(draggedIndices[i]);
+// }
+//
+// }
+//
+// return result;
+// }
+//
+// private function compareValues(a:int, b:int):int
+// {
+// return a - b;
+// }
+ }
+}
View
3 awaybuilder-core/src/awaybuilder/view/components/controls/tree/GenericDataDescriptor.as
@@ -4,6 +4,7 @@ package awaybuilder.view.components.controls.tree
import awaybuilder.model.vo.scene.ContainerVO;
import awaybuilder.model.vo.scene.LightPickerVO;
import awaybuilder.model.vo.scene.LightVO;
+ import awaybuilder.model.vo.scene.MaterialVO;
import awaybuilder.utils.DataMerger;
import flash.utils.Dictionary;
@@ -30,6 +31,8 @@ package awaybuilder.view.components.controls.tree
{
case( node is ContainerVO ):
return ContainerVO( node ).children;
+ case( node is MaterialVO ):
+ return MaterialVO( node ).effectMethods;
case( node is LightPickerVO ):
return LightPickerVO( node ).lights;
case( node is LightVO ):
View
6 awaybuilder-core/src/awaybuilder/view/components/controls/tree/TreeItemRenderer.mxml
@@ -21,7 +21,7 @@
import awaybuilder.model.vo.scene.AssetVO;
import awaybuilder.model.vo.scene.CameraVO;
import awaybuilder.model.vo.scene.ContainerVO;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
import awaybuilder.model.vo.scene.GeometryVO;
import awaybuilder.model.vo.scene.LightPickerVO;
import awaybuilder.model.vo.scene.LightVO;
@@ -128,7 +128,7 @@
case( asset is ShadowMethodVO ):
return SHADOW;
- case( asset is EffectMethodVO ):
+ case( asset is EffectVO ):
return EFFECT;
case( asset is CameraVO ):
@@ -192,7 +192,7 @@
<s:BitmapImage source="{getStyle('icon')}"/>
- <s:Label id="labelDisplay" text="{data.name}" color.selected="0xFFFFFF" color.hovered="0xEEEEEE" paddingTop="2" paddingLeft="3" />
+ <s:Label id="labelDisplay" text="{(data is IShared)?IShared(data).linkedAsset.name:data.name}" color.selected="0xFFFFFF" color.hovered="0xEEEEEE" paddingTop="2" paddingLeft="3" />
</s:HGroup>
View
8 awaybuilder-core/src/awaybuilder/view/components/editors/EffectMethodPropertyEditor.mxml
@@ -24,7 +24,7 @@
<fx:Script><![CDATA[
import awaybuilder.model.vo.scene.AssetVO;
import awaybuilder.model.vo.scene.CubeTextureVO;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
import awaybuilder.model.vo.scene.LightVO;
import awaybuilder.model.vo.scene.TextureVO;
import awaybuilder.view.components.controls.events.ExtendedDropDownEvent;
@@ -36,7 +36,7 @@
import spark.events.IndexChangeEvent;
[Bindable]
- private var _asset:EffectMethodVO;
+ private var _asset:EffectVO;
[Bindable]
private var _selectedLight:LightVO;
@@ -47,8 +47,8 @@
override protected function validate():void
{
- if( !(data is EffectMethodVO) ) return;
- _asset = EffectMethodVO(data).clone();
+ if( !(data is EffectVO) ) return;
+ _asset = EffectVO(data).clone();
}
private function dropDownIconFunction(item:TextureVO):Object
View
11 awaybuilder-core/src/awaybuilder/view/components/editors/MaterialGroupPropertiesEditor.mxml
@@ -38,23 +38,12 @@
</fx:Declarations>
<fx:Script><![CDATA[
import awaybuilder.model.vo.scene.AssetVO;
- import awaybuilder.model.vo.scene.LightPickerVO;
- import awaybuilder.model.vo.scene.LightVO;
import awaybuilder.model.vo.scene.MaterialVO;
- import awaybuilder.model.vo.scene.ShadowMethodVO;
- import awaybuilder.model.vo.scene.SharedLightVO;
- import awaybuilder.model.vo.scene.TextureVO;
- import awaybuilder.model.vo.scene.interfaces.ITextured;
- import awaybuilder.view.components.controls.events.DroppedEvent;
- import awaybuilder.view.components.controls.events.ExtendedDropDownEvent;
import awaybuilder.view.components.editors.events.PropertyEditorEvent;
import mx.collections.ArrayCollection;
- import mx.events.ColorPickerEvent;
- import spark.components.supportClasses.ButtonBase;
import spark.events.IndexChangeEvent;
- import spark.events.PopUpEvent;
[Bindable] private var _selectedLightPicker:AssetVO;
View
1 awaybuilder-core/src/awaybuilder/view/components/events/LibraryPanelEvent.as
@@ -24,6 +24,7 @@ package awaybuilder.view.components.events
public static const LIGHT_DROPPED:String = "lightDropped";
public static const SCENEOBJECT_DROPPED:String = "sceneObjectDropped";
+ public static const MATERIALS_DROPPED:String = "materialsDropped";
public static const ANIMATIONS_DROPPED:String = "animationsDropped";
public function LibraryPanelEvent(type:String, data:Object=null )
View
32 awaybuilder-core/src/awaybuilder/view/mediators/CoreEditorMediator.as
@@ -106,7 +106,7 @@ package awaybuilder.view.mediators
import awaybuilder.model.vo.scene.CameraVO;
import awaybuilder.model.vo.scene.ContainerVO;
import awaybuilder.model.vo.scene.CubeTextureVO;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
import awaybuilder.model.vo.scene.ExtraItemVO;
import awaybuilder.model.vo.scene.GeometryVO;
import awaybuilder.model.vo.scene.LensVO;
@@ -118,6 +118,7 @@ package awaybuilder.view.mediators
import awaybuilder.model.vo.scene.ShadingMethodVO;
import awaybuilder.model.vo.scene.ShadowMapperVO;
import awaybuilder.model.vo.scene.ShadowMethodVO;
+ import awaybuilder.model.vo.scene.SharedEffectVO;
import awaybuilder.model.vo.scene.SharedLightVO;
import awaybuilder.model.vo.scene.SkeletonVO;
import awaybuilder.model.vo.scene.SkyBoxVO;
@@ -576,7 +577,7 @@ package awaybuilder.view.mediators
SkyBoxMaterial(obj.material).cubeMap = assets.GetObject(asset.cubeMap) as CubeTextureBase;
obj.name = asset.name;
}
- private function applyEffectMethod( asset:EffectMethodVO ):void
+ private function applyEffectMethod( asset:EffectVO ):void
{
var obj:EffectMethodBase = assets.GetObject( asset ) as EffectMethodBase;
applyName( obj, asset );
@@ -991,12 +992,16 @@ package awaybuilder.view.mediators
setTimeout( applyAgain, 50, asset ); // issue #200
- m.lightPicker = assets.GetObject(asset.lightPicker) as LightPickerBase;
m.mipmap = asset.mipmap;
m.smooth = asset.smooth;
m.blendMode = asset.blendMode;
- var effect:EffectMethodVO;
+ if( asset.lightPicker )
+ {
+ m.lightPicker = assets.GetObject(asset.lightPicker) as LightPickerBase;
+ }
+
+ var effect:SharedEffectVO;
var singlePassMaterialBase:SinglePassMaterialBase = m as SinglePassMaterialBase;
if( singlePassMaterialBase )
{
@@ -1043,7 +1048,7 @@ package awaybuilder.view.mediators
}
for each( effect in asset.effectMethods )
{
- singlePassMaterialBase.addMethod(assets.GetObject( effect ) as EffectMethodBase);
+ singlePassMaterialBase.addMethod(assets.GetObject( effect.linkedAsset ) as EffectMethodBase);
}
}
@@ -1091,11 +1096,16 @@ package awaybuilder.view.mediators
}
for each( effect in asset.effectMethods )
{
- multiPassMaterialBase.addMethod(assets.GetObject( effect ) as EffectMethodBase);
+ multiPassMaterialBase.addMethod(assets.GetObject( effect.linkedAsset ) as EffectMethodBase);
}
}
+ if( !asset.lightPicker )
+ {
+ m.lightPicker = null;
+ }
+
if( oldMaterial )
{
assets.ReplaceObject( oldMaterial, m );
@@ -1221,9 +1231,9 @@ package awaybuilder.view.mediators
{
applyMaterial( event.items[0] as MaterialVO );
}
- if( event.items[0] is EffectMethodVO )
+ if( event.items[0] is EffectVO )
{
- applyEffectMethod( event.items[0] as EffectMethodVO );
+ applyEffectMethod( event.items[0] as EffectVO );
}
if( event.items[0] is TextureProjectorVO )
{
@@ -1257,9 +1267,9 @@ package awaybuilder.view.mediators
private function eventDispatcher_addNewCubeTextureHandler(event:SceneEvent):void
{
if( event.items && event.items.length ) {
- if( event.items[0] is EffectMethodVO )
+ if( event.items[0] is EffectVO )
{
- applyEffectMethod( event.items[0] as EffectMethodVO );
+ applyEffectMethod( event.items[0] as EffectVO );
}
else if( event.items[0] is ShadingMethodVO )
{
@@ -1292,7 +1302,7 @@ package awaybuilder.view.mediators
private function eventDispatcher_changeEffectMethodHandler(event:SceneEvent):void
{
- var asset:EffectMethodVO = event.items[0] as EffectMethodVO;
+ var asset:EffectVO = event.items[0] as EffectVO;
if( asset )
{
applyEffectMethod( asset );
View
19 awaybuilder-core/src/awaybuilder/view/mediators/LibraryPanelMediator.as
@@ -13,7 +13,7 @@ package awaybuilder.view.mediators
import awaybuilder.model.vo.scene.CameraVO;
import awaybuilder.model.vo.scene.ContainerVO;
import awaybuilder.model.vo.scene.CubeTextureVO;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
import awaybuilder.model.vo.scene.GeometryVO;
import awaybuilder.model.vo.scene.LightPickerVO;
import awaybuilder.model.vo.scene.LightVO;
@@ -87,6 +87,8 @@ package awaybuilder.view.mediators
addViewListener(LibraryPanelEvent.LIGHT_DROPPED, view_lightDroppedHandler);
addViewListener(LibraryPanelEvent.SCENEOBJECT_DROPPED, view_sceneObjectDroppedHandler);
addViewListener(LibraryPanelEvent.ANIMATIONS_DROPPED, view_animationsDroppedHandler);
+ addViewListener(LibraryPanelEvent.MATERIALS_DROPPED, view_materialsDroppedHandler);
+
addContextListener(DocumentModelEvent.OBJECTS_COLLECTION_UPDATED, eventDispatcher_objectsCollectionHandler);
@@ -107,6 +109,10 @@ package awaybuilder.view.mediators
//----------------------------------------------------------------------
+ private function view_materialsDroppedHandler(event:LibraryPanelEvent):void
+ {
+ this.dispatch(new SceneEvent(SceneEvent.REPARENT_MATERIAL_EFFECT,[], event.data));
+ }
private function view_animationsDroppedHandler(event:LibraryPanelEvent):void
{
this.dispatch(new SceneEvent(SceneEvent.REPARENT_ANIMATIONS,[], event.data));
@@ -166,7 +172,7 @@ package awaybuilder.view.mediators
Alert.show( "To create a ProjectiveTextureMethod, you need TextureProjector", "TextureProjector is missing" );
return;
}
- var method:EffectMethodVO = assets.CreateEffectMethod( event.data as String );
+ var method:EffectVO = assets.CreateEffectMethod( event.data as String );
this.dispatch(new SceneEvent(SceneEvent.ADD_NEW_EFFECT_METHOD, null, method));
this.dispatch(new SceneEvent(SceneEvent.SELECT,[method]));
}
@@ -282,10 +288,6 @@ package awaybuilder.view.mediators
{
states.push( new DeleteStateVO( asset, TreeDataProvider(view.sceneTree.dataProvider).getItemParent( asset ) as AssetVO ) );
}
- for each( asset in view.methodsTree.selectedItems )
- {
- states.push( new DeleteStateVO( asset, TreeDataProvider(view.methodsTree.dataProvider).getItemParent( asset ) as AssetVO ) );
- }
for each( asset in view.animationsTree.selectedItems )
{
states.push( new DeleteStateVO( asset, TreeDataProvider(view.animationsTree.dataProvider).getItemParent( asset ) as AssetVO ) );
@@ -428,10 +430,6 @@ package awaybuilder.view.mediators
{
view.callLater( view.texturesTree.ensureIndexIsVisible, [view.texturesTree.selectedIndex] );
}
- if( view.methodsTree.selectedIndex )
- {
- view.callLater( view.methodsTree.ensureIndexIsVisible, [view.methodsTree.selectedIndex] );
- }
}
private function getItemIsSelected( id:String, selectedItems:Array ):Boolean
@@ -451,7 +449,6 @@ package awaybuilder.view.mediators
view.model.materials = document.materials;
view.model.textures = document.textures;
view.model.geometry = document.geometry;
- view.model.methods = document.methods;
view.model.lights = document.lights;
view.model.animations = document.animations;
}
View
14 awaybuilder-core/src/awaybuilder/view/mediators/PropertiesPanelMediator.as
@@ -14,7 +14,7 @@ package awaybuilder.view.mediators
import awaybuilder.model.vo.scene.CameraVO;
import awaybuilder.model.vo.scene.ContainerVO;
import awaybuilder.model.vo.scene.CubeTextureVO;
- import awaybuilder.model.vo.scene.EffectMethodVO;
+ import awaybuilder.model.vo.scene.EffectVO;
import awaybuilder.model.vo.scene.GeometryVO;
import awaybuilder.model.vo.scene.LensVO;
import awaybuilder.model.vo.scene.LightPickerVO;
@@ -895,8 +895,16 @@ package awaybuilder.view.mediators
view.texturePojectors = new ArrayCollection( texturePojectors );
var materials:ArrayCollection = new ArrayCollection();
- materials.addAll( document.materials );
materials.addItemAt( assets.defaultMaterial, 0 );
+
+ for each( asset in document.materials )
+ {
+ if( asset is MaterialVO )
+ {
+ materials.addItem( asset );
+ }
+ }
+
view.materials = materials;
}
private static function getStateByGroup( assets:Array ):String
@@ -949,7 +957,7 @@ package awaybuilder.view.mediators
return "lightPicker";
case(asset is ShadowMethodVO):
return "shadowMethod";
- case(asset is EffectMethodVO):
+ case(asset is EffectVO):
return "effectMethod";
case(asset is CubeTextureVO):
return "cubeTexture";

0 comments on commit 0c33881

Please sign in to comment.