Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

...
  • 16 commits
  • 20 files changed
  • 3 commit comments
  • 4 contributors
Showing with 351 additions and 184 deletions.
  1. +7 −3 awaybuilder-core/src/awaybuilder/model/AssetsModel.as
  2. +1 −1  awaybuilder-core/src/awaybuilder/model/IDocumentService.as
  3. +36 −4 awaybuilder-core/src/awaybuilder/model/SmartDocumentServiceBase.as
  4. +22 −3 awaybuilder-core/src/awaybuilder/model/SmartFactoryModelBase.as
  5. +12 −1 awaybuilder-core/src/awaybuilder/model/vo/scene/SubGeometryVO.as
  6. +8 −4 awaybuilder-core/src/awaybuilder/model/vo/scene/SubMeshVO.as
  7. +143 −92 awaybuilder-core/src/awaybuilder/utils/encoders/AWDEncoder.as
  8. +35 −32 awaybuilder-core/src/awaybuilder/utils/scene/Scene3DManager.as
  9. +2 −2 awaybuilder-core/src/awaybuilder/view/components/editors/EffectMethodPropertyEditor.mxml
  10. +9 −0 awaybuilder-core/src/awaybuilder/view/components/editors/SubGeometryPropertiesEditor.mxml
  11. +6 −7 awaybuilder-core/src/awaybuilder/view/mediators/CoreEditorMediator.as
  12. +2 −1  awaybuilder-core/src/awaybuilder/view/scene/controls/Gizmo3DBase.as
  13. +2 −0  awaybuilder-core/src/awaybuilder/view/scene/controls/RotateGizmo3D.as
  14. +2 −0  awaybuilder-core/src/awaybuilder/view/scene/controls/ScaleGizmo3D.as
  15. +31 −12 awaybuilder-core/src/awaybuilder/view/scene/controls/TranslateGizmo3D.as
  16. +5 −4 awaybuilder-desktop/src/awaybuilder/desktop/controller/OpenFromInvokeCommand.as
  17. +26 −16 awaybuilder-desktop/src/awaybuilder/desktop/model/DesktopDocumentService.as
  18. +2 −2 awaybuilder-desktop/src/awaybuilder/desktop/view/mediators/ApplicationMediator.as
  19. BIN  exampleScenes/awd/sponza/sponza_lights.awd
  20. BIN  exampleScenes/awd/sponza/sponza_lights_textures.awd
10 awaybuilder-core/src/awaybuilder/model/AssetsModel.as
View
@@ -524,8 +524,10 @@ package awaybuilder.model
if(EnvMapMethod (method).envMap.name=="defaultTexture"){
EnvMapMethod (method).envMap=GetObject(defaultCubeTexture) as BitmapCubeTexture;
}
- if(EnvMapMethod (method).mask.name=="defaultTexture"){
- EnvMapMethod (method).mask=GetObject(defaultTexture) as Texture2DBase;
+ if(EnvMapMethod (method).mask){
+ if(EnvMapMethod (method).mask.name=="defaultTexture"){
+ EnvMapMethod (method).mask=GetObject(defaultTexture) as Texture2DBase;
+ }
}
}
if (method is LightMapMethod){
@@ -568,7 +570,9 @@ package awaybuilder.model
for (i=0;i<mat.numMethods;i++){
checkEffectMethodForDefaulttexture(mat.getMethodAt(i));
}
-
+ // now all texutures are checked and replaced with defaults
+ // check each material-property, and return false, if it is not default
+ if ((mat.name!="Default")&& (mat.name!="defaultMaterial"))return false;
if (getQualifiedClassName( mat.ambientMethod ).split("::")[1]!="BasicAmbientMethod")return false;
if (getQualifiedClassName( mat.diffuseMethod ).split("::")[1]!="BasicDiffuseMethod")return false;
if (getQualifiedClassName( mat.specularMethod ).split("::")[1]!="BasicSpecularMethod")return false;
2  awaybuilder-core/src/awaybuilder/model/IDocumentService.as
View
@@ -13,6 +13,6 @@ package awaybuilder.model
function openBitmap( items:Array, property:String ):void;
- function load( url:String, name:String, event:Event ):void;
+ function load( url:String, name:String, event:Event):void;
}
}
40 awaybuilder-core/src/awaybuilder/model/SmartDocumentServiceBase.as
View
@@ -3,6 +3,7 @@ package awaybuilder.model
import away3d.animators.nodes.AnimationNodeBase;
import away3d.cameras.Camera3D;
import away3d.containers.ObjectContainer3D;
+ import away3d.core.base.ISubGeometry;
import away3d.entities.Mesh;
import away3d.entities.TextureProjector;
import away3d.events.AssetEvent;
@@ -29,6 +30,7 @@ package awaybuilder.model
import awaybuilder.model.vo.scene.AssetVO;
import awaybuilder.model.vo.scene.CubeTextureVO;
import awaybuilder.model.vo.scene.GeometryVO;
+ import awaybuilder.model.vo.scene.SubGeometryVO;
import awaybuilder.utils.logging.AwayBuilderLoadErrorLogger;
import flash.display.Bitmap;
@@ -38,7 +40,9 @@ package awaybuilder.model
import flash.net.URLRequest;
import flash.utils.ByteArray;
import flash.utils.Endian;
+ import flash.utils.getQualifiedClassName;
+ import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.core.FlexGlobals;
import mx.managers.CursorManager;
@@ -183,10 +187,11 @@ package awaybuilder.model
if (assets.checkIfMaterialIsDefault(TextureMaterial(mesh.subMeshes[i].material)))
mesh.subMeshes[i].material = assets.GetObject(assets.defaultMaterial) as MaterialBase;
- if( !isGeometryInList( assets.GetAsset(mesh.geometry) as GeometryVO ) )
- {
+
+ if( isGeometryInList( assets.GetAsset(mesh.geometry) as GeometryVO ) )
+ updateSubGeometries(assets.GetAsset(mesh.geometry) as GeometryVO,mesh);
+ else
_document.geometry.addItem( assets.GetAsset(mesh.geometry) as GeometryVO );
- }
_objects.push( mesh );
break;
case AssetType.CONTAINER:
@@ -329,6 +334,34 @@ package awaybuilder.model
{
return (flags & testFlag) == testFlag;
}
+ private function updateSubGeometries( g:GeometryVO, mesh:Mesh ):void
+ {
+ var updateSubs:Boolean=false;
+ var subGeoCount:int=0;
+ for each (var subGeo:SubGeometryVO in g.subGeometries){
+ if (subGeoCount>=mesh.geometry.subGeometries.length){
+ updateSubs=true;
+ break;
+ }
+ var type:String = getQualifiedClassName( mesh.geometry.subGeometries[subGeoCount] ).split("::")[1];
+ if (type!=subGeo.type){
+ updateSubs=true;
+ break;
+ }
+ }
+ if (updateSubs){
+ g.subGeometries=new ArrayCollection();
+ subGeoCount=0;
+ for each( var sub:ISubGeometry in mesh.geometry.subGeometries )
+ {
+ subGeoCount++;
+ var subGeometryVO:SubGeometryVO = assets.GetAsset(sub) as SubGeometryVO;
+ subGeometryVO.name="SubGeometry #"+subGeoCount;
+ g.subGeometries.addItem( subGeometryVO );
+ }
+ }
+ }
+
private function isGeometryInList( geometry:GeometryVO ):Boolean
{
for each ( var asset:AssetVO in _document.geometry )
@@ -338,7 +371,6 @@ package awaybuilder.model
}
return false;
}
-
protected function documentReady( document:DocumentVO, globalOptions:GlobalOptionsVO = null ):void {
throw new Error( "Abstract method error" );
}
25 awaybuilder-core/src/awaybuilder/model/SmartFactoryModelBase.as
View
@@ -79,8 +79,10 @@ package awaybuilder.model
import away3d.primitives.SkyBox;
import away3d.primitives.SphereGeometry;
import away3d.primitives.TorusGeometry;
+ import away3d.textures.ATFTexture;
import away3d.textures.BitmapCubeTexture;
import away3d.textures.BitmapTexture;
+ import away3d.textures.Texture2DBase;
import awaybuilder.model.vo.scene.AnimationNodeVO;
import awaybuilder.model.vo.scene.AnimationSetVO;
@@ -158,7 +160,10 @@ package awaybuilder.model
return fillMaterial( new MaterialVO(), item as MaterialBase );
case(item is BitmapTexture):
- return fillTexture( new TextureVO(), item as BitmapTexture );
+ return fillBitmapTexture( new TextureVO(), item as BitmapTexture );
+
+ case(item is ATFTexture):
+ return fillATFTexture( new TextureVO(), item as ATFTexture );
case(item is Geometry):
return fillGeometry( new GeometryVO(), item as Geometry );
@@ -318,7 +323,7 @@ package awaybuilder.model
var lightMapMethod:LightMapMethod = item as LightMapMethod;
asset.texture = GetAsset(lightMapMethod.texture) as TextureVO;
asset.mode = lightMapMethod.blendMode;
-// asset.useSecondaryUV = lightMapMethod.useSecondaryUV;
+ asset.useSecondaryUV = lightMapMethod.useSecondaryUV;
break;
case(item is OutlineMethod):
var outlineMethod:OutlineMethod = item as OutlineMethod;
@@ -356,6 +361,7 @@ package awaybuilder.model
asset.name = "SubMesh";
asset.material = GetAsset( item.material ) as MaterialVO;
asset.subGeometry = GetAsset( item.subGeometry ) as SubGeometryVO;
+ asset.uvTransform = item.uvTransform;
return asset;
}
private function fillShadowMethod( asset:ShadowMethodVO, item:ShadowMapMethodBase ):ShadowMethodVO
@@ -460,9 +466,14 @@ package awaybuilder.model
asset.vertexStride = obj.vertexStride;
asset.autoDerivedNormals = obj.autoDeriveVertexNormals;
asset.autoDerivedTangents = obj.autoDeriveVertexTangents;
+ asset.hasUVData = !obj.autoGenerateDummyUVs
asset.UVData = obj.UVData;
asset.UVStride = obj.UVStride;
asset.UVOffset = obj.UVOffset;
+ asset.hasSecUVData = obj.hasSecondaryUVs;
+ asset.SecUVData = obj.SecondaryUVData;
+ asset.SecUVStride = obj.secondaryUVStride;
+ asset.SecUVOffset = obj.secondaryUVOffset;
asset.vertexNormalData = obj.vertexNormalData;
asset.vertexNormalOffset = obj.vertexNormalOffset;
asset.vertexNormalStride = obj.vertexNormalStride;
@@ -770,9 +781,17 @@ package awaybuilder.model
asset.negativeZ = item.negativeZ;
return asset;
}
- private function fillTexture( asset:TextureVO, item:BitmapTexture ):TextureVO
+ private function fillATFTexture( asset:TextureVO, item:ATFTexture ):TextureVO
{
asset = fillAsset( asset, item ) as TextureVO;
+
+ //asset.bitmapData = item.atfData.;
+ return asset;
+ }
+ private function fillBitmapTexture( asset:TextureVO, item:BitmapTexture ):TextureVO
+ {
+ asset = fillAsset( asset, item ) as TextureVO;
+
asset.bitmapData = item.bitmapData;
return asset;
}
13 awaybuilder-core/src/awaybuilder/model/vo/scene/SubGeometryVO.as
View
@@ -18,10 +18,16 @@ package awaybuilder.model.vo.scene
public var scaleU:Number;
public var scaleV:Number;
+ public var hasUVData : Boolean;
public var UVData : Vector.<Number>;
public var UVStride : uint;
public var UVOffset : int;
+ public var hasSecUVData : Boolean;
+ public var SecUVData : Vector.<Number>;
+ public var SecUVStride : uint;
+ public var SecUVOffset : int;
+
public var vertexNormalData : Vector.<Number>;
public var vertexNormalOffset : int;
public var vertexNormalStride : uint;
@@ -58,9 +64,14 @@ package awaybuilder.model.vo.scene
this.vertexStride = asset.vertexStride;
this.autoDerivedNormals = asset.autoDerivedNormals;
this.autoDerivedTangents = asset.autoDerivedTangents;
+ this.hasUVData = asset.hasUVData;
this.UVData = asset.UVData;
this.UVStride = asset.UVStride;
- this.UVOffset = asset.UVOffset;
+ this.UVOffset = asset.UVOffset;
+ this.hasSecUVData = asset.hasSecUVData;
+ this.SecUVData = asset.SecUVData;
+ this.SecUVStride = asset.SecUVStride;
+ this.SecUVOffset = asset.SecUVOffset;
this.vertexNormalData = asset.vertexNormalData;
this.vertexNormalOffset = asset.vertexNormalOffset;
this.vertexNormalStride = asset.vertexNormalStride;
12 awaybuilder-core/src/awaybuilder/model/vo/scene/SubMeshVO.as
View
@@ -1,15 +1,16 @@
package awaybuilder.model.vo.scene
{
+ import flash.display3D.textures.Texture;
+ import flash.geom.Matrix;
+
+ import mx.collections.ArrayCollection;
+
import away3d.core.base.SubMesh;
import away3d.materials.MaterialBase;
import away3d.materials.TextureMaterial;
import awaybuilder.utils.AssetUtil;
- import flash.display3D.textures.Texture;
-
- import mx.collections.ArrayCollection;
-
[Bindable]
public class SubMeshVO extends AssetVO
{
@@ -18,6 +19,8 @@ package awaybuilder.model.vo.scene
public var subGeometry:SubGeometryVO;
+ public var uvTransform:Matrix;
+
public var parentMesh:MeshVO;
public function clone():SubMeshVO
@@ -27,6 +30,7 @@ package awaybuilder.model.vo.scene
m.material = this.material;
m.subGeometry = this.subGeometry;
m.parentMesh = this.parentMesh;
+ m.uvTransform = this.uvTransform;
return m;
}
235 awaybuilder-core/src/awaybuilder/utils/encoders/AWDEncoder.as
View
@@ -1,9 +1,24 @@
package awaybuilder.utils.encoders
{
+ import flash.display.BitmapData;
+ import flash.display.BlendMode;
+ import flash.display.JPEGEncoderOptions;
+ import flash.display.PNGEncoderOptions;
+ import flash.geom.Matrix;
+ import flash.geom.Matrix3D;
+ import flash.geom.Vector3D;
+ import flash.utils.ByteArray;
+ import flash.utils.CompressionAlgorithm;
+ import flash.utils.Dictionary;
+ import flash.utils.Endian;
+
+ import mx.collections.ArrayCollection;
+
import away3d.animators.data.SkeletonJoint;
import away3d.core.base.Geometry;
import away3d.core.math.MathConsts;
import away3d.entities.Mesh;
+ import away3d.materials.ColorMaterial;
import away3d.materials.methods.MethodVO;
import awaybuilder.AwayBuilder;
@@ -37,19 +52,6 @@ package awaybuilder.utils.encoders
import awaybuilder.model.vo.scene.TextureProjectorVO;
import awaybuilder.model.vo.scene.TextureVO;
- import flash.display.BitmapData;
- import flash.display.BlendMode;
- import flash.display.JPEGEncoderOptions;
- import flash.display.PNGEncoderOptions;
- import flash.geom.Matrix3D;
- import flash.geom.Vector3D;
- import flash.utils.ByteArray;
- import flash.utils.CompressionAlgorithm;
- import flash.utils.Dictionary;
- import flash.utils.Endian;
-
- import mx.collections.ArrayCollection;
-
public class AWDEncoder implements ISceneGraphEncoder
{
// set debug to true to get some traces in the console
@@ -273,7 +275,6 @@ package awaybuilder.utils.encoders
if(_debug)trace("SUCCESS");
return true;
}
-
// encodes all assets in a ArrayCollection, if they have not allready been _encodet
private function _encodeAddionalBlocks(assetList:ArrayCollection) : void
{
@@ -583,7 +584,10 @@ package awaybuilder.utils.encoders
_encodeStream(2, sub.indexData);
var scaleU : Number = 1/sub.scaleU;
var scaleV : Number = 1/sub.scaleV;
- _encodeStream(3, sub.UVData, sub.UVOffset, sub.UVStride, scaleU, scaleV);
+ if(sub.hasUVData)
+ _encodeStream(3, sub.UVData, sub.UVOffset, sub.UVStride, scaleU, scaleV);
+ if(sub.hasSecUVData)
+ _encodeStream(8, sub.SecUVData, sub.SecUVOffset, sub.SecUVStride);
if ( (_exportNormals) && (!sub.autoDerivedNormals) ) _encodeStream(4, sub.vertexNormalData, sub.vertexNormalOffset, sub.vertexNormalStride);
if ( (_exportTangents) && (!sub.autoDerivedTangents) ) _encodeStream(5, sub.vertexTangentData, sub.vertexTangentOffset, sub.vertexTangentStride);
if (sub.jointIndexData){
@@ -721,8 +725,6 @@ package awaybuilder.utils.encoders
// encode Container (id=22)
private function _encodeContainer3D(container : ContainerVO, parentId:uint=0) : uint
{
- var i : uint;
- var parentId : uint;
var returnID:uint=_encodeBlockHeader(22);
_blockBody.writeUnsignedInt(parentId);
@@ -758,8 +760,46 @@ package awaybuilder.utils.encoders
geomId = _getBlockIDorEncodeAsset(mesh.geometry);
materialIds=new Vector.<uint>;
var subMeshVo:SubMeshVO;
- for each (subMeshVo in mesh.subMeshes)
+ var uvTransform:Matrix=SubMeshVO(mesh.subMeshes[0]).uvTransform;
+ var uvArray:Array=new Array();
+ var storeUV:Boolean=false;
+ var storeSubUV:Boolean=false;
+ for each (subMeshVo in mesh.subMeshes){
+ if(!storeSubUV){
+ var subUvTransform:Matrix=subMeshVo.uvTransform;
+ if (subUvTransform!=uvTransform)
+ storeSubUV=true;
+ }
materialIds.push( _getBlockIDorEncodeAsset(subMeshVo.material));
+ }
+ if (storeSubUV){
+ storeUV=true;
+ for each (subMeshVo in mesh.subMeshes){
+ var subUvTransform2:Matrix=subMeshVo.uvTransform;
+ if (subUvTransform2==null)
+ subUvTransform2=new Matrix();
+ uvArray.push(subUvTransform2.a);
+ uvArray.push(subUvTransform2.b);
+ uvArray.push(subUvTransform2.c);
+ uvArray.push(subUvTransform2.d);
+ uvArray.push(subUvTransform2.tx);
+ uvArray.push(subUvTransform2.ty);
+ }
+ }
+ else{
+ var identityUV:Matrix=new Matrix();
+ if (uvTransform){
+ if(uvTransform!=identityUV){
+ storeUV=true;
+ uvArray.push(uvTransform.a);
+ uvArray.push(uvTransform.b);
+ uvArray.push(uvTransform.c);
+ uvArray.push(uvTransform.d);
+ uvArray.push(uvTransform.tx);
+ uvArray.push(uvTransform.ty);
+ }
+ }
+ }
returnID=_encodeBlockHeader(23);
@@ -777,6 +817,12 @@ package awaybuilder.utils.encoders
if(mesh.pivotY!=0)_encodeProperty(2,mesh.pivotY, _matrixNrType);
if(mesh.pivotZ!=0)_encodeProperty(3,mesh.pivotZ, _matrixNrType);
if(!mesh.castsShadows)_encodeProperty(5,mesh.castsShadows, BOOL);
+ if (storeUV){
+ if(storeSubUV)
+ _encodeProperty(902,uvArray, _propNrType);
+ else
+ _encodeProperty(901,uvArray, _propNrType);
+ }
_endElement(); // Prop list
_beginElement(); // Attr list
@@ -1022,66 +1068,62 @@ package awaybuilder.utils.encoders
var matType:int=1;
// optional properties:
- var color:uint;//1
- var texture:int;//2
- var normalTexture:int;//3
- var spezialType:uint;//4
+ var color:uint=0xcccccc;//1
+ var texture:int=-1;//2
+ var normalTexture:int=0;//3
+ var spezialType:uint=0;//4
var smooth:Boolean=true;//5
var mipmap:Boolean=true;//6
var bothSides:Boolean=false;//7
var alphaPremultiplied:Boolean=false;//8
- var blendMode:uint;//9
- var alpha:Number;//10
+ var blendMode:uint=0;//9
+ var alpha:Number=1.0;//10
var alphaBlending:Boolean=false;//11
- var alphaThreshold:Number;//12
+ var alphaThreshold:Number=0;//12
var repeat:Boolean=true;//13
//var diffuse-Level:Number;//14
- var ambient:uint;//15
- var ambientColor:uint;//16
- var ambientTexture:int;//17
- var specular:Number;//18
- var gloss:Number;//19
- var specularColor:uint;//20
- var specularTexture:uint;//21
- var lightPicker:int;//22
+ var ambient:uint=1.0;//15
+ var ambientColor:uint=0xffffff;//16
+ var ambientTexture:int=-1;//17
+ var specular:Number=1.0;//18
+ var gloss:Number=50;//19
+ var specularColor:uint=0xffffff;//20
+ var specularTexture:uint=0;//21
+ var lightPicker:int=0;//22
+
var allMethods:Vector.<AWDmethod>=_encodeAllShadingMethods(mtl);
- texture=-1;
if (mtl.diffuseTexture) texture=_getBlockIDorEncodeAsset(mtl.diffuseTexture);
- ambientTexture=-1;
if (mtl.ambientTexture) ambientTexture=_getBlockIDorEncodeAsset(mtl.ambientTexture);
if ((texture>=0)||(ambientTexture>=0)) matType=2;
if (matType==1) color=mtl.diffuseColor;
if (mtl.type==MaterialVO.SINGLEPASS){
- if (mtl.alpha!=1.0) alpha=mtl.alpha;
- if (mtl.alphaBlending!=false) alphaBlending=mtl.alphaBlending;
+ alpha=mtl.alpha;
+ alphaBlending=mtl.alphaBlending;
}
else{
spezialType=1;
}
- if (mtl.alphaThreshold!=Number(0.0)) alphaThreshold=mtl.alphaThreshold;
- if (mtl.ambientLevel!=Number(1.0)) ambient=mtl.ambientLevel;
- if (mtl.ambientColor!=uint(0xffffff)) ambientColor=mtl.ambientColor;
- if (mtl.specularLevel!=Number(1.0)) specular=mtl.specularLevel;
- if (mtl.specularGloss!=Number(50)) gloss=mtl.specularGloss;
- if (mtl.specularColor!=uint(0xffffff)) specularColor=mtl.specularColor;
+ alphaThreshold=mtl.alphaThreshold;
+ ambient=mtl.ambientLevel;
+ ambientColor=mtl.ambientColor;
+ specular=mtl.specularLevel;
+ gloss=mtl.specularGloss;
+ specularColor=mtl.specularColor;
+
if (mtl.normalTexture) normalTexture=_getBlockIDorEncodeAsset(mtl.normalTexture);
if (mtl.specularTexture) specularTexture=_getBlockIDorEncodeAsset(mtl.specularTexture);
- if (mtl.lightPicker){
- if(_debug)trace("lightPicker");
- if (_getBlockIDorEncodeAsset(mtl.lightPicker)!=0) lightPicker=_getBlockIDorEncodeAsset(mtl.lightPicker);
- }
+ if (mtl.lightPicker) lightPicker=_getBlockIDorEncodeAsset(mtl.lightPicker);
smooth=mtl.smooth;
mipmap=mtl.mipmap;
bothSides=mtl.bothSides;
repeat=mtl.repeat;
alphaPremultiplied=mtl.alphaPremultiplied;
- var thisBlendMode:uint=blendModeDic[mtl.blendMode];
- if ((thisBlendMode!=1)&&(thisBlendMode!=2)&&(thisBlendMode!=8)&&(thisBlendMode!=10)) thisBlendMode=0;
- if (thisBlendMode>0) blendMode=thisBlendMode;
+ blendMode=blendModeDic[mtl.blendMode];
+ if ((blendMode!=1)&&(blendMode!=2)&&(blendMode!=8)&&(blendMode!=10)) blendMode=0;
returnID=_encodeBlockHeader(81);
@@ -1091,28 +1133,28 @@ package awaybuilder.utils.encoders
// Property list
_beginElement(); // Prop list
- if (color){ _encodeProperty(1,color, COLOR);}//color
- if (texture>=0){_encodeProperty(2,texture, BADDR);}//texture
- if (normalTexture){_encodeProperty(3,normalTexture, BADDR);}//normalMap
+ if (color!=0xcccccc){ _encodeProperty(1,color, COLOR);}//color
+ if (texture>0){_encodeProperty(2,texture, BADDR);}//texture
+ if (normalTexture>0){_encodeProperty(3,normalTexture, BADDR);}//normalMap
if (spezialType){_encodeProperty(4,spezialType, UINT8);}// multi/singlepass
- if (smooth==false){_encodeProperty(5, smooth, BOOL);} // smooth
- if (mipmap==false){_encodeProperty(6, mipmap, BOOL);} // mipmap
- if (bothSides==true){_encodeProperty(7, bothSides, BOOL);} // bothsides
- if (alphaPremultiplied==true){_encodeProperty(8, alphaPremultiplied, BOOL);} // pre-multiplied
- if (blendMode){_encodeProperty(9, blendMode, UINT8);} // BlendMode
- if (alpha){_encodeProperty(10, alpha, _propNrType);}// alpha
- if (alphaBlending==true){_encodeProperty(11, alphaBlending, BOOL);}// alphaBlending
- if (alphaThreshold){_encodeProperty(12, alphaThreshold, _propNrType);}// alphaThreshold
- if (repeat==true){_encodeProperty(13, repeat, BOOL);}// repeat
+ if (!smooth){_encodeProperty(5, smooth, BOOL);} // smooth
+ if (!mipmap){_encodeProperty(6, mipmap, BOOL);} // mipmap
+ if (bothSides){_encodeProperty(7, bothSides, BOOL);} // bothsides
+ if (alphaPremultiplied){_encodeProperty(8, alphaPremultiplied, BOOL);} // pre-multiplied
+ if (blendMode>0){_encodeProperty(9, blendMode, UINT8);} // BlendMode
+ if (alpha!=1.0){_encodeProperty(10, alpha, _propNrType);}// alpha
+ if (alphaBlending){_encodeProperty(11, alphaBlending, BOOL);}// alphaBlending
+ if (alphaThreshold>0){_encodeProperty(12, alphaThreshold, _propNrType);}// alphaThreshold
+ if (repeat){_encodeProperty(13, repeat, BOOL);}// repeat
//if (diffuse){_encodeProperty(14, diffuse, FLOAT32);}// diffuse-level (might come in later version)
- if (ambient){_encodeProperty(15, ambient, _propNrType);}// ambient-level
- if (ambientColor){_encodeProperty(16, ambientColor, COLOR);}// ambient-color
- if (ambientTexture>=0){_encodeProperty(17, ambientTexture, BADDR);}//ambientMap
- if (specular){_encodeProperty(18, specular, _propNrType);}// specular-level
- if (gloss){_encodeProperty(19, gloss, _propNrType);}// specular-gloss
- if (specularColor){_encodeProperty(20, specularColor, COLOR);}// specular-color
- if (specularTexture){_encodeProperty(21, specularTexture, BADDR);}//specularMap
- if (lightPicker){_encodeProperty(22, lightPicker, BADDR);}//lightPicker
+ if (ambient!=1){_encodeProperty(15, ambient, _propNrType);}// ambient-level
+ if (ambientColor!=0xffffff){_encodeProperty(16, ambientColor, COLOR);}// ambient-color
+ if (ambientTexture>0){_encodeProperty(17, ambientTexture, BADDR);}//ambientMap
+ if (specular!=1){_encodeProperty(18, specular, _propNrType);}// specular-level
+ if (gloss!=50){_encodeProperty(19, gloss, _propNrType);}// specular-gloss
+ if (specularColor!=0xffffff){_encodeProperty(20, specularColor, COLOR);}// specular-color
+ if (specularTexture>0){_encodeProperty(21, specularTexture, BADDR);}//specularMap
+ if (lightPicker>0){_encodeProperty(22, lightPicker, BADDR);}//lightPicker
_endElement(); // Prop list
// _encode all previous stored methods.
@@ -1249,8 +1291,7 @@ package awaybuilder.utils.encoders
if(bitMapHasTransparency(tex.bitmapData,tex.bitmapData.rect.width,tex.bitmapData.rect.height))
extension=".png";
var texturePath:String="textures/"+getFileName(tex.name, extension);
- _blockBody.writeUnsignedInt(texturePath.length);
- _blockBody.writeUTFBytes(texturePath);
+ _writeString(texturePath);
}
_beginElement(); // Properties (empty)
@@ -1313,38 +1354,36 @@ package awaybuilder.utils.encoders
if(bitMapHasTransparency(cubeTexture.positiveX,cubeTexture.positiveX.rect.width,cubeTexture.positiveX.rect.height))
extension=".png";
texturePath="textures/"+getFileName(cubeTexture.name,extension,"_posX.");
- _blockBody.writeUnsignedInt(texturePath.length);
- _blockBody.writeUTFBytes(texturePath);
+ _writeString(texturePath);
+
extension=".jpg";
if(bitMapHasTransparency(cubeTexture.negativeX,cubeTexture.negativeX.rect.width,cubeTexture.negativeX.rect.height))
extension=".png";
texturePath="textures/"+getFileName(cubeTexture.name,extension,"_negX.");
- _blockBody.writeUnsignedInt(texturePath.length);
- _blockBody.writeUTFBytes(texturePath);
+ _writeString(texturePath);
+
extension=".jpg";
if(bitMapHasTransparency(cubeTexture.positiveY,cubeTexture.positiveY.rect.width,cubeTexture.positiveY.rect.height))
extension=".png";
- texturePath="textures/"+getFileName(cubeTexture.name,extension,"_posY.");
- _blockBody.writeUnsignedInt(texturePath.length);
- _blockBody.writeUTFBytes(texturePath);
+ _writeString(texturePath);
+
extension=".jpg";
if(bitMapHasTransparency(cubeTexture.negativeY,cubeTexture.negativeY.rect.width,cubeTexture.negativeY.rect.height))
extension=".png";
texturePath="textures/"+getFileName(cubeTexture.name,extension,"_negY.");
- _blockBody.writeUnsignedInt(texturePath.length);
- _blockBody.writeUTFBytes(texturePath);
+ _writeString(texturePath);
+
extension=".jpg";
if(bitMapHasTransparency(cubeTexture.positiveZ,cubeTexture.positiveZ.rect.width,cubeTexture.positiveZ.rect.height))
extension=".png";
texturePath="textures/"+getFileName(cubeTexture.name,extension,"_posZ.");
- _blockBody.writeUnsignedInt(texturePath.length);
- _blockBody.writeUTFBytes(texturePath);
+ _writeString(texturePath);
+
extension=".jpg";
if(bitMapHasTransparency(cubeTexture.negativeZ,cubeTexture.negativeZ.rect.width,cubeTexture.negativeZ.rect.height))
extension=".png";
texturePath="textures/"+getFileName(cubeTexture.name,extension,"_negZ.");
- _blockBody.writeUnsignedInt(texturePath.length);
- _blockBody.writeUTFBytes(texturePath);
+ _writeString(texturePath);
}
@@ -1427,7 +1466,7 @@ package awaybuilder.utils.encoders
break;
case "LightMapMethod"://EffectMethodVO.LIGHT_MAP:
texID=_getBlockIDorEncodeAsset(methVO.texture);
- returnID=_encodeSharedMethodBlock(methVO.name,404, [401,1], [blendModeDic[methVO.mode],texID], [10,0], [UINT8,BADDR]);
+ returnID=_encodeSharedMethodBlock(methVO.name,404, [401,1, 701], [blendModeDic[methVO.mode],texID, methVO.useSecondaryUV], [10,0, false], [UINT8,BADDR, BOOL]);
break;
case "ProjectiveTextureMethod":
texID=_getBlockIDorEncodeAsset(methVO.textureProjector);
@@ -1440,7 +1479,7 @@ package awaybuilder.utils.encoders
texID=_getBlockIDorEncodeAsset(methVO.texture);
returnID=_encodeSharedMethodBlock(methVO.name,407, [701,1], [methVO.useSecondaryUV,texID], [false,0], [BOOL,BADDR]);
break;
- case "RefractionMapMethod"://EffectMethodVO.REFRACTION_ENV_MAP:
+ case "RefractionEnvMapMethod"://EffectMethodVO.REFRACTION_ENV_MAP:
cubeTexID=_getBlockIDorEncodeAsset(methVO.cubeTexture);
texID=_getBlockIDorEncodeAsset(methVO.texture);
returnID=_encodeSharedMethodBlock(methVO.name,408, [1,101,102,103,104,105], [cubeTexID, methVO.refraction, methVO.r, methVO.g, methVO.b, methVO.alpha], [0,0.1,0.01,0.01,0.01,1], [BADDR,_propNrType,_propNrType,_propNrType,_propNrType,_propNrType]);
@@ -1781,7 +1820,8 @@ package awaybuilder.utils.encoders
_blockBody.writeUnsignedInt(parentId);//parent
_encodeMatrix3D(getTransformMatrix(targetObj));//matrix
_blockBody.writeUTF(targetObj.name);//name
- _blockBody.writeShort(1);//has sceneHeader
+
+ _blockBody.writeShort(1);//num Commands (allways 1 for now)
_blockBody.writeShort(1);//"PutIntoSceneGraph"-type =1
@@ -1927,6 +1967,12 @@ package awaybuilder.utils.encoders
_encodeJointWeightStream( Vector.<Number>(data));
_endElement();
break;
+ case 8:
+ _blockBody.writeByte(_geoNrType);
+ _beginElement();
+ _encodeUVStream( Vector.<Number>(data), 2, offset, stride,scaleU, scaleV);
+ _endElement();
+ break;
}
}
@@ -2100,8 +2146,7 @@ package awaybuilder.utils.encoders
break;
case AWDSTRING:
_blockBody.writeShort(id);
- _blockBody.writeUnsignedInt(values[0].length);
- _blockBody.writeUTFBytes(values[0]);
+ _writeString(values[0]);
return;
}
@@ -2226,13 +2271,19 @@ package awaybuilder.utils.encoders
break;
case AWDSTRING:
- _blockBody.writeUnsignedInt(value.length);
- _blockBody.writeUTFBytes(value);
+ _writeString(value);
break;
}
}
+ private function _writeString(thisString:String) : void
+ {
+ var ba:ByteArray= new ByteArray();
+ ba.writeUTFBytes(thisString);
+ _blockBody.writeUnsignedInt(ba.length);
+ _blockBody.writeUTFBytes(thisString);
+ }
private function _beginElement() : void
{
_elemSizeOffsets.push(_blockBody.position);
67 awaybuilder-core/src/awaybuilder/utils/scene/Scene3DManager.as
View
@@ -1,9 +1,9 @@
package awaybuilder.utils.scene
{
- import away3d.cameras.lenses.LensBase;
import avmplus.*;
import away3d.cameras.*;
+ import away3d.cameras.lenses.LensBase;
import away3d.containers.*;
import away3d.core.managers.*;
import away3d.core.pick.*;
@@ -35,9 +35,11 @@ package awaybuilder.utils.scene
{
// Singleton instance declaration
public static const instance : Scene3DManager = new Scene3DManager();
+
+ public function Scene3DManager() { if ( instance ) throw new Error("Scene3DManager is a singleton"); }
+
private var sceneDoubleClickDetected : Boolean;
private var doubleClick3DMonitor : Boolean;
- public function Scene3DManager() { if ( instance ) throw new Error("Scene3DManager is a singleton"); }
public static var active:Boolean = true;
@@ -53,16 +55,12 @@ package awaybuilder.utils.scene
public static var camera:Camera3D;
public static var gizmoCamera:Camera3D;
- public static var selectedObjects:ArrayList = new ArrayList();// TODO: Use vector
+ public static var selectedObjects:Vector.<ObjectContainer3D> = new Vector.<ObjectContainer3D>();
public static var selectedObject:ObjectContainer3D;
public static var multiSelection:Boolean = false;
public static var mouseSelection:ObjectContainer3D;
public static var lensSelected:LensBase;
-// public static var objects:ArrayList = new ArrayList(); // TODO: Use vector
-// public static var lights:ArrayList = new ArrayList();// TODO: Use vector
-// public static var textureProjectors:ArrayList = new ArrayList();// TODO: Use vector
-
public static var grid:WireframePlane;
public static var backgroundGrid:WireframePlane;
public static var orientationTool:OrientationTool;
@@ -96,6 +94,7 @@ package awaybuilder.utils.scene
private function onContextCreated(e:Stage3DEvent):void
{
+ trace( "onContextCreated" );
backgroundView = new View3D();
backgroundView.shareContext = true;
backgroundView.stage3DProxy = stage3DProxy;
@@ -180,7 +179,6 @@ package awaybuilder.utils.scene
//handle stage events
scope.addEventListener(MouseEvent.MOUSE_DOWN, instance.onMouseDown);
- scope.addEventListener(MouseEvent.MOUSE_UP, instance.onMouseUp);
scope.addEventListener(MouseEvent.DOUBLE_CLICK, instance.onSceneDoubleClick);
containerBreadCrumbs = new Array();
@@ -336,13 +334,15 @@ package awaybuilder.utils.scene
private function onMouseDown(e:MouseEvent):void
{
-
+ scope.addEventListener(MouseEvent.MOUSE_UP, instance.onMouseUp);
}
private function onMouseUp(e:MouseEvent):void
{
+ scope.removeEventListener(MouseEvent.MOUSE_UP, instance.onMouseUp);
if (active)
{
+ if( currentGizmo.isMoving ) return;
if (!CameraManager.hasMoved && !multiSelection && !currentGizmo.active && !orientationTool.orientationClicked) deselectAndDispatch();
}
orientationTool.orientationClicked = false;
@@ -364,20 +364,21 @@ package awaybuilder.utils.scene
switch (mode)
{
- case GizmoMode.TRANSLATE : currentGizmo = translateGizmo;
-
+ case GizmoMode.TRANSLATE :
+ currentGizmo = translateGizmo;
break;
- case GizmoMode.ROTATE: currentGizmo = rotateGizmo;
-
+ case GizmoMode.ROTATE:
+ currentGizmo = rotateGizmo;
break;
- case GizmoMode.SCALE: currentGizmo = scaleGizmo;
-
+ case GizmoMode.SCALE:
+ currentGizmo = scaleGizmo;
break;
}
- if (selectedObject) {
+ if (selectedObject)
+ {
var isLightGizmo:LightGizmo3D = selectedObject.parent as LightGizmo3D;
if (!isLightGizmo ||
(isLightGizmo.type==LightGizmo3D.DIRECTIONAL_LIGHT && Scene3DManager.currentGizmo==rotateGizmo) ||
@@ -389,7 +390,8 @@ package awaybuilder.utils.scene
public static function updateGizmo() : void {
gizmoCamera.transform = camera.transform.clone();
var isLightGizmo:LightGizmo3D = (selectedObject && selectedObject.parent) as LightGizmo3D;
- if (isLightGizmo && isLightGizmo.type==LightGizmo3D.DIRECTIONAL_LIGHT && Scene3DManager.currentGizmo==rotateGizmo) {
+ if (isLightGizmo && isLightGizmo.type==LightGizmo3D.DIRECTIONAL_LIGHT && Scene3DManager.currentGizmo==rotateGizmo)
+ {
var oC:ObjectContainer3D = Scene3DManager.camera.clone() as ObjectContainer3D;
oC.moveForward(1000);
currentGizmo.position = oC.position;
@@ -629,13 +631,16 @@ package awaybuilder.utils.scene
private static function attachGizmos(container:ObjectContainer3D) : void {
var childCtr:int = 0;
- while (childCtr < container.numChildren) {
+ while (childCtr < container.numChildren)
+ {
attachGizmos(container.getChildAt(childCtr++));
}
- if (getQualifiedClassName(container)=="away3d.containers::ObjectContainer3D" && container.numChildren == 0) {
+ if (getQualifiedClassName(container)=="away3d.containers::ObjectContainer3D" && container.numChildren == 0)
+ {
addEmptyContainerRepresentation(container);
- } else if (container is Camera3D) {
+ }
+ else if (container is Camera3D) {
addCamera(container as Camera3D);
}
@@ -899,7 +904,7 @@ package awaybuilder.utils.scene
var itemsDeselected:Boolean = false;
for(var i:int=0;i<selectedObjects.length;i++)
{
- var oC:ObjectContainer3D = selectedObjects.getItemAt(i) as ObjectContainer3D;
+ var oC:ObjectContainer3D = selectedObjects[i];
var m:Entity = oC as Entity;
var g:ISceneRepresentation = oC as ISceneRepresentation;
if (m && !g) g = m.parent as ISceneRepresentation;
@@ -918,7 +923,7 @@ package awaybuilder.utils.scene
itemsDeselected = true;
}
- selectedObjects = new ArrayList();
+ selectedObjects = new Vector.<ObjectContainer3D>();
selectedObject = null;
currentGizmo.hide();
return itemsDeselected;
@@ -929,19 +934,17 @@ package awaybuilder.utils.scene
if (unselectAll()) instance.dispatchEvent(new Scene3DManagerEvent(Scene3DManagerEvent.MESH_SELECTED));
}
- public static function unSelectObjectByName(meshName:String):void
+ public static function unSelectObjectByName( name:String ):void
{
- for(var i:int=0;i<selectedObjects.length;i++)
+ for each( var o:ObjectContainer3D in selectedObjects )
{
- var m:Entity = selectedObjects.getItemAt(i) as Entity;
- if (m.name == meshName)
+ if (o.name == name)
{
- if (m is Mesh) m.showBounds = false;
- selectedObject = selectedObjects.getItemAt(selectedObjects.length-1) as Entity;
-
+ if (o is Mesh) Mesh(o).showBounds = false;
+ selectedObject = selectedObjects[selectedObjects.length-1];
break;
}
- }
+ }
instance.dispatchEvent(new Scene3DManagerEvent(Scene3DManagerEvent.MESH_SELECTED));
}
@@ -1016,7 +1019,7 @@ package awaybuilder.utils.scene
else bounds.updateContainerBounds();
bounds.showBounds = true;
- selectedObjects.addItem(oC);
+ selectedObjects.push(oC);
selectedObject = oC;
currentGizmo.show(selectedObject);
@@ -1027,7 +1030,7 @@ package awaybuilder.utils.scene
private static function addToSelection(m:ObjectContainer3D, eventType:String) : void {
if (m is Entity) (m as Entity).showBounds = true;
- selectedObjects.addItem(m);
+ selectedObjects.push(m);
selectedObject = m;
currentGizmo.show(selectedObject);
4 awaybuilder-core/src/awaybuilder/view/components/editors/EffectMethodPropertyEditor.mxml
View
@@ -247,12 +247,12 @@
</s:FormItem>
<s:FormItem label="Strength " skinClass="awaybuilder.view.skins.PropertyFormItemSkin" width="100%">
<controls:DragableNumericStepper id="strengthStepper" value="@{_asset.strength}"
- stepSize="0.1" snapInterval="0.001" minimum="0" maximum="1"
+ stepSize="0.1" snapInterval="0.001" minimum="0" maximum="1" width="100%"
change="valueStepper_changeHandler(event)" />
</s:FormItem>
<s:FormItem label="Power" skinClass="awaybuilder.view.skins.PropertyFormItemSkin" width="100%">
<controls:DragableNumericStepper id="powerStepper" value="@{_asset.power}"
- stepSize="1" snapInterval="0.01" minimum="0" maximum="10"
+ stepSize="1" snapInterval="0.01" minimum="0" maximum="10" width="100%"
change="valueStepper_changeHandler(event)" />
</s:FormItem>
</s:Form>
9 awaybuilder-core/src/awaybuilder/view/components/editors/SubGeometryPropertiesEditor.mxml
View
@@ -57,6 +57,15 @@
</s:Form>
<s:Form width="100%" skinClass="awaybuilder.view.skins.PropertyFormSkin">
<s:FormItem label="" skinClass="awaybuilder.view.skins.PropertyFormItemSkin" width="100%"/>
+ <s:FormItem label="Has UV" skinClass="awaybuilder.view.skins.PropertyFormItemSkin" width="100%">
+ <s:Label width="100%" text="{_asset.hasUVData}" fontSize="12"/>
+ </s:FormItem>
+ <s:FormItem label="SecondaryUV" skinClass="awaybuilder.view.skins.PropertyFormItemSkin" width="100%">
+ <s:Label width="100%" text="{_asset.hasSecUVData}" fontSize="12"/>
+ </s:FormItem>
+ </s:Form>
+ <s:Form width="100%" skinClass="awaybuilder.view.skins.PropertyFormSkin">
+ <s:FormItem label="" skinClass="awaybuilder.view.skins.PropertyFormItemSkin" width="100%"/>
<s:FormItem label="AutoDerived-Normals" skinClass="awaybuilder.view.skins.PropertyFormItemSkin" width="100%">
<s:Label width="100%" text="{_asset.autoDerivedNormals}" fontSize="12"/>
</s:FormItem>
13 awaybuilder-core/src/awaybuilder/view/mediators/CoreEditorMediator.as
View
@@ -647,7 +647,7 @@ package awaybuilder.view.mediators
{
var lightMapMethod:LightMapMethod = obj as LightMapMethod;
lightMapMethod.texture = assets.GetObject( asset.texture ) as Texture2DBase;
-// lightMapMethod.useSecondaryUV = assets.useSecondaryUV;
+ //lightMapMethod.useSecondaryUV = assets.useSecondaryUV;
lightMapMethod.blendMode = asset.mode;
}
else if( obj is OutlineMethod )
@@ -1694,15 +1694,14 @@ package awaybuilder.view.mediators
}
private function selectObjectsScene( o:ObjectContainer3D ):void
{
- for each( var object:ObjectContainer3D in Scene3DManager.selectedObjects.source )
+ for each( var objectContainer3D:ObjectContainer3D in Scene3DManager.selectedObjects )
{
- if( object == o )
+ if( objectContainer3D == o )
{
return;
}
}
Scene3DManager.selectObject(o);
-
}
private function selectContainersScene( c:ObjectContainer3D ):void
{
@@ -1793,9 +1792,9 @@ package awaybuilder.view.mediators
var asset:AssetVO;
var isSceneRepresentation:ISceneRepresentation;
- for each( var item:Object in Scene3DManager.selectedObjects.source )
+ for each( var objectContainer:ObjectContainer3D in Scene3DManager.selectedObjects )
{
- mesh = item as Mesh;
+ mesh = objectContainer as Mesh;
if( mesh )
{
if ((isSceneRepresentation = (mesh.parent as ISceneRepresentation))!=null)
@@ -1806,7 +1805,6 @@ package awaybuilder.view.mediators
}
this.dispatch(new SceneEvent(SceneEvent.SELECT,selected));
-
}
private function scene_meshSelectedFromViewHandler(event:Scene3DManagerEvent) : void {
@@ -1854,6 +1852,7 @@ package awaybuilder.view.mediators
var vo:ObjectVO = assets.GetAsset( event.object ) as ObjectVO;
var newValues:Vector.<Vector3D> = new Vector.<Vector3D>();
newValues.push( event.endValue );
+ trace( event.endValue );
var oldValues:Vector.<Vector3D> = new Vector.<Vector3D>();
oldValues.push( event.startValue );
switch( event.gizmoMode )
3  awaybuilder-core/src/awaybuilder/view/scene/controls/Gizmo3DBase.as
View
@@ -20,6 +20,7 @@ package awaybuilder.view.scene.controls
public var active:Boolean = false;
public var hasMoved:Boolean = false;
+ public var isMoving : Boolean = false;
public var currentMesh:ObjectContainer3D;
public var currentAxis:String = "";
@@ -113,8 +114,8 @@ package awaybuilder.view.scene.controls
var pos:Vector3D = new Vector3D(currentMesh.x, currentMesh.y, currentMesh.z);
pos = mat.transformVector(pos);
content.position = pos;
- this.position = currentMesh.parent.scenePosition.clone();
+ this.position = currentMesh.parent.scenePosition.clone();
return;
}
2  awaybuilder-core/src/awaybuilder/view/scene/controls/RotateGizmo3D.as
View
@@ -234,6 +234,7 @@ package awaybuilder.view.scene.controls
}
hasMoved = true;
+ isMoving = true;
active = true;
CameraManager.active = false;
@@ -323,6 +324,7 @@ package awaybuilder.view.scene.controls
protected function handleMouseUp(event:Event):void
{
+ isMoving = false;
Scene3DManager.stage.removeEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
Scene3DManager.stage.removeEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
2  awaybuilder-core/src/awaybuilder/view/scene/controls/ScaleGizmo3D.as
View
@@ -246,6 +246,7 @@ package awaybuilder.view.scene.controls
}
hasMoved = true;
+ isMoving = true;
active = true;
CameraManager.active = false;
@@ -336,6 +337,7 @@ package awaybuilder.view.scene.controls
protected function handleMouseUp(event:Event):void
{
+ isMoving = false;
Scene3DManager.stage.removeEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
Scene3DManager.stage.removeEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
43 awaybuilder-core/src/awaybuilder/view/scene/controls/TranslateGizmo3D.as
View
@@ -1,18 +1,22 @@
package awaybuilder.view.scene.controls
{
- import away3d.primitives.WireframeRegularPolygon;
- import awaybuilder.view.scene.representations.ISceneRepresentation;
+ import away3d.cameras.Camera3D;
import away3d.containers.ObjectContainer3D;
import away3d.core.pick.PickingColliderType;
+ import away3d.entities.Entity;
import away3d.entities.Mesh;
+ import away3d.entities.TextureProjector;
import away3d.events.MouseEvent3D;
+ import away3d.lights.LightBase;
import away3d.primitives.ConeGeometry;
import away3d.primitives.CylinderGeometry;
+ import away3d.primitives.WireframeRegularPolygon;
import awaybuilder.utils.scene.CameraManager;
import awaybuilder.utils.scene.Scene3DManager;
import awaybuilder.utils.scene.modes.GizmoMode;
import awaybuilder.view.scene.events.Gizmo3DEvent;
+ import awaybuilder.view.scene.representations.ISceneRepresentation;
import flash.events.Event;
import flash.events.MouseEvent;
@@ -197,30 +201,42 @@ package awaybuilder.view.scene.controls
click.x = Scene3DManager.stage.mouseX;
click.y = Scene3DManager.stage.mouseY;
- if (currentMesh.parent is ISceneRepresentation) actualMesh = (currentMesh.parent as ISceneRepresentation).sceneObject;
- else actualMesh = currentMesh;
+ if (currentMesh.parent is ISceneRepresentation)
+ {
+ actualMesh = (currentMesh.parent as ISceneRepresentation).sceneObject;
+ switch( true )
+ {
+ case actualMesh is TextureProjector:
+ case actualMesh is Entity:
+ startValue = new Vector3D(actualMesh.x, actualMesh.y, actualMesh.z);
+ break;
+ default:
+ startValue = new Vector3D(0, 0, 0);
+ break;
+ }
+ }
+ else
+ {
+ actualMesh = currentMesh;
+ startValue = new Vector3D(actualMesh.x, actualMesh.y, actualMesh.z);
+ }
- startValue = new Vector3D(actualMesh.x, actualMesh.y, actualMesh.z);
startScenePosition = actualMesh.parent.scenePosition.clone();
-
+
switch(currentAxis)
{
case "xAxis":
-
xCone.material = highlightDownMaterial;
xCylinder.material = highlightDownMaterial;
-
break;
case "yAxis":
-
yCone.material = highlightDownMaterial;
yCylinder.material = highlightDownMaterial;
break;
case "zAxis":
-
zCone.material = highlightDownMaterial;
zCylinder.material = highlightDownMaterial;
@@ -228,11 +244,13 @@ package awaybuilder.view.scene.controls
}
hasMoved = true;
+ isMoving = true;
active = true;
CameraManager.active = false;
Scene3DManager.stage.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
Scene3DManager.stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
+
}
protected function handleMouseMove(e:MouseEvent):void
@@ -290,7 +308,6 @@ package awaybuilder.view.scene.controls
var pos:Vector3D = this.position.subtract(startScenePosition);
pos = actualMesh.parent.inverseSceneTransform.deltaTransformVector(pos).add(startValue);
-
actualMesh.x = pos.x;
actualMesh.y = pos.y;
actualMesh.z = pos.z;
@@ -300,8 +317,9 @@ package awaybuilder.view.scene.controls
dispatchEvent(new Gizmo3DEvent(Gizmo3DEvent.MOVE, GizmoMode.TRANSLATE, actualMesh, pos, startValue, pos));
}
- protected function handleMouseUp(event:Event):void
+ protected function handleMouseUp(event:MouseEvent):void
{
+ isMoving = false;
Scene3DManager.stage.removeEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
Scene3DManager.stage.removeEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove);
@@ -318,6 +336,7 @@ package awaybuilder.view.scene.controls
var pos:Vector3D = new Vector3D(actualMesh.x, actualMesh.y, actualMesh.z);
dispatchEvent(new Gizmo3DEvent(Gizmo3DEvent.RELEASE, GizmoMode.TRANSLATE, actualMesh, pos, startValue, pos));
+
}
}
9 awaybuilder-desktop/src/awaybuilder/desktop/controller/OpenFromInvokeCommand.as
View
@@ -30,8 +30,9 @@ package awaybuilder.desktop.controller
{
if( document.empty )
{
- var nextEvent:ConcatenateDataOperationEvent = new ConcatenateDataOperationEvent(ConcatenateDataOperationEvent.CONCAT_DOCUMENT_DATA );
- documentService.load( event.file.url, event.file.name, nextEvent );
+ //var nextEvent:ConcatenateDataOperationEvent = new ConcatenateDataOperationEvent(ConcatenateDataOperationEvent.CONCAT_DOCUMENT_DATA );
+ var nextEvent:ReplaceDocumentDataEvent = new ReplaceDocumentDataEvent(ReplaceDocumentDataEvent.REPLACE_DOCUMENT_DATA );
+ documentService.load( event.file.url, event.file.name, nextEvent);
return;
}
@@ -46,12 +47,12 @@ package awaybuilder.desktop.controller
{
case Alert.YES:
nextEvent = new ConcatenateDataOperationEvent(ConcatenateDataOperationEvent.CONCAT_DOCUMENT_DATA );
- documentService.load( event.file.url, event.file.name, nextEvent );
+ documentService.load( event.file.url, event.file.name, nextEvent);
break;
case Alert.NO:
this.dispatch(new DocumentEvent(DocumentEvent.NEW_DOCUMENT));
nextEvent = new ReplaceDocumentDataEvent(ReplaceDocumentDataEvent.REPLACE_DOCUMENT_DATA );
- documentService.load( event.file.url, event.file.name, nextEvent );
+ documentService.load( event.file.url, event.file.name, nextEvent);
break;
}
}
42 awaybuilder-desktop/src/awaybuilder/desktop/model/DesktopDocumentService.as
View
@@ -1,5 +1,18 @@
package awaybuilder.desktop.model
{
+ import flash.display.Bitmap;
+ import flash.display.BitmapData;
+ import flash.display.JPEGEncoderOptions;
+ import flash.events.Event;
+ import flash.filesystem.File;
+ import flash.filesystem.FileMode;
+ import flash.filesystem.FileStream;
+ import flash.net.FileFilter;
+ import flash.utils.ByteArray;
+ import flash.utils.Dictionary;
+
+ import mx.managers.CursorManager;
+
import awaybuilder.controller.events.ConcatenateDataOperationEvent;
import awaybuilder.controller.events.DocumentEvent;
import awaybuilder.controller.events.ReplaceDocumentDataEvent;
@@ -18,19 +31,6 @@ package awaybuilder.desktop.model
import awaybuilder.utils.encoders.AWDEncoder;
import awaybuilder.utils.encoders.ISceneGraphEncoder;
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.display.JPEGEncoderOptions;
- import flash.events.Event;
- import flash.filesystem.File;
- import flash.filesystem.FileMode;
- import flash.filesystem.FileStream;
- import flash.net.FileFilter;
- import flash.utils.ByteArray;
- import flash.utils.Dictionary;
-
- import mx.managers.CursorManager;
-
public class DesktopDocumentService extends SmartDocumentServiceBase implements IDocumentService
{
private static const FILE_EXTENSION : String = '.awd';
@@ -52,10 +52,14 @@ package awaybuilder.desktop.model
[Inject]
public var applicationModel:ApplicationModel;
+ [Inject]
+ public var document:DocumentModel;
public function load( url:String, name:String, event:Event ):void
{
_name = name;
_nextEvent = event;
+ if (document.empty)
+ _path = url;
loadAssets( url );
}
@@ -63,7 +67,9 @@ package awaybuilder.desktop.model
{
_items = items;
_property = property;
- var file:File = new File();
+ var file:File=File.documentsDirectory;
+ if(document.path)
+ file = File.documentsDirectory.resolvePath(document.path);
file.addEventListener(Event.SELECT, bitmapFile_open_selectHandler);
file.addEventListener(Event.CANCEL, bitmapFile_open_cancelHandler);
var filters:Array = [];
@@ -76,7 +82,9 @@ package awaybuilder.desktop.model
{
_nextEvent = event;
_createNew = createNew;
- var file:File = new File();
+ var file:File=File.documentsDirectory;
+ if(document.path)
+ file = File.documentsDirectory.resolvePath(document.path);
file.addEventListener(Event.SELECT, file_open_selectHandler);
file.addEventListener(Event.CANCEL, file_open_cancelHandler);
var filters:Array = [];
@@ -107,7 +115,9 @@ package awaybuilder.desktop.model
{
defaultName += FILE_EXTENSION;
}
- var file:File = File.documentsDirectory.resolvePath("./" + defaultName);
+ var file:File=File.documentsDirectory.resolvePath("./" + defaultName);
+ if(document.path)
+ file = File.documentsDirectory.resolvePath(document.path).resolvePath("./" + defaultName);;
file.addEventListener(Event.SELECT, file_save_selectHandler);
file.addEventListener(Event.CANCEL, file_save_cancelHandler);
file.browseForSave("Save Document As");
4 awaybuilder-desktop/src/awaybuilder/desktop/view/mediators/ApplicationMediator.as
View
@@ -146,7 +146,7 @@ package awaybuilder.desktop.view.mediators
{
if(event.arguments.length == 1)
{
- const extensions:Vector.<String> = new <String>["awd"];
+ const extensions:Vector.<String> = new <String>["awd","AWD"];
var filePath:String = event.arguments[0];
var file:File = new File(filePath);
if(file.exists && extensions.indexOf(file.extension) >= 0)
@@ -266,7 +266,7 @@ package awaybuilder.desktop.view.mediators
const extensions:Vector.<String> = new <String>["awd","3ds","obj","md2","png","jpg","atf","dae","md5"];
for each(var file:File in fileList)
{
- if(file.exists && extensions.indexOf(file.extension) >= 0)
+ if(file.exists && extensions.indexOf(file.extension.toLowerCase()) >= 0)
{
DragManager.acceptDragDrop(this.app);
break;
BIN  exampleScenes/awd/sponza/sponza_lights.awd
View
Binary file not shown
BIN  exampleScenes/awd/sponza/sponza_lights_textures.awd
View
Binary file not shown

Showing you all comments on commits in this comparison.

amerdababneh

Hi,
It wold be very helpful to add a way to import multiple texture files at the same time

nilwave

ambient is declared as uint in encodeMaterial, you should change to Number.

Robin Lockhart
Owner

yes. thank you. will do so.

Something went wrong with that request. Please try again.