From 5a18f40302bd5bfefffd783bc68ace658b87e6ce Mon Sep 17 00:00:00 2001 From: Tubix Date: Sun, 2 Feb 2025 23:29:09 +0000 Subject: [PATCH] prop collision toggle added --- .../editor/PropGeneralPropertiesPanel.mxml | 49 +++++++++++ src/alternativa/editor/SceneContainer.as | 7 ++ .../mapexport/TanksXmlExporterV1Lite.as | 4 + src/alternativa/editor/prop/MeshProp.as | 79 +++++++++++++++++- src/alternativa/editor/prop/Prop.as | 2 +- .../editor/prop/no_collision_texture.png | Bin 0 -> 5256 bytes src/alternativa/editor/scene/MainScene.as | 49 +++++++++-- 7 files changed, 177 insertions(+), 13 deletions(-) create mode 100644 src/alternativa/editor/PropGeneralPropertiesPanel.mxml create mode 100644 src/alternativa/editor/prop/no_collision_texture.png diff --git a/src/alternativa/editor/PropGeneralPropertiesPanel.mxml b/src/alternativa/editor/PropGeneralPropertiesPanel.mxml new file mode 100644 index 0000000..dd1b3b8 --- /dev/null +++ b/src/alternativa/editor/PropGeneralPropertiesPanel.mxml @@ -0,0 +1,49 @@ + + + + + = new Vector.(); + + private function onCreationComplete():void + { + } + + private function onCollisionChanged(param1:Event):void + { + for each(var prop:MeshProp in _selectedProps) + { + prop.collisionEnabled = this.collision.selected; + } + } + + public function init(selectedProps:Set, collisionEnabled:Boolean) : void + { + _selectedProps.length = 0; + for(var prop:* in selectedProps) + { + if(prop is MeshProp && !(prop is Sprite3DProp)) + { + _selectedProps.push(prop as MeshProp); + } + } + + this.collision.selected = collisionEnabled; + } + + ]]> + + + + + + + \ No newline at end of file diff --git a/src/alternativa/editor/SceneContainer.as b/src/alternativa/editor/SceneContainer.as index 4c0ed90..8a3128a 100644 --- a/src/alternativa/editor/SceneContainer.as +++ b/src/alternativa/editor/SceneContainer.as @@ -34,6 +34,12 @@ package alternativa.editor public class SceneContainer extends UIComponent { + private static var _instance:SceneContainer; + public static function get instance() : SceneContainer + { + return _instance; + } + private static const cameraPoint:Point3D = new Point3D(0,0,1000); private static const cameraOffset:Point3D = new Point3D(); @@ -100,6 +106,7 @@ package alternativa.editor public function SceneContainer() { + _instance = this; this.multiplePropMode = MultiPropMode.NONE; this.mouseDownPoint = new Point(); this.rectProps = new Set(); diff --git a/src/alternativa/editor/mapexport/TanksXmlExporterV1Lite.as b/src/alternativa/editor/mapexport/TanksXmlExporterV1Lite.as index 6097d5e..7f87eff 100644 --- a/src/alternativa/editor/mapexport/TanksXmlExporterV1Lite.as +++ b/src/alternativa/editor/mapexport/TanksXmlExporterV1Lite.as @@ -236,6 +236,10 @@ package alternativa.editor.mapexport protected function createTileCollisionXml(param1:MeshProp, param2:XML) : void { + if(!param1.collisionEnabled) + { + return; + } var loc4:CollisionPrimitive = null; var loc3:Vector. = this.collPrimCache.getPrimitives(param1.libraryName,param1.groupName,param1.name); if(loc3 == null) diff --git a/src/alternativa/editor/prop/MeshProp.as b/src/alternativa/editor/prop/MeshProp.as index 85719df..cfa2293 100644 --- a/src/alternativa/editor/prop/MeshProp.as +++ b/src/alternativa/editor/prop/MeshProp.as @@ -20,6 +20,11 @@ package alternativa.editor.prop public class MeshProp extends Prop { + [Embed(source="no_collision_texture.png")] + private static const NO_COLLISION_TEXTURE_MASK_Class:Class; + + private static const NO_COLLISION_TEXTURE_Bitmap:BitmapData = new NO_COLLISION_TEXTURE_MASK_Class().bitmapData; + public var bitmaps:Map; protected var _textureName:String = ""; @@ -33,6 +38,12 @@ package alternativa.editor.prop private var bound:Mesh; private var _objects:Vector.; + + private var _collisionEnabled:Boolean = true; + + private var _noCollisionTexture:BitmapData = null; + private var _noCollisionMaterial:TextureMaterial = null; + public function MeshProp(mainObject:Object3D, objects:Vector., param2:String, param3:String, param4:String, param5:Boolean = true) { @@ -121,6 +132,7 @@ package alternativa.editor.prop { loc2 = loc1 as Mesh; loc2.setMaterialToAllFaces(this.collisionMaterial); + addChild(loc2); } setMaterial(null); } @@ -133,6 +145,7 @@ package alternativa.editor.prop { loc2 = loc1 as Mesh; loc2.setMaterialToAllFaces(null); + removeChild(loc2); } setMaterial(_material); } @@ -162,17 +175,27 @@ package alternativa.editor.prop { _material.dispose(); } - _material = new TextureMaterial(bitmapData); - if(_selected) - { - this.disposeSelectTexture(); + _material = new TextureMaterial(bitmapData); + + this.disposeSelectTexture(); + + if(_selected) + { select(); } else { setMaterial(_material); } + if(_noCollisionTexture != null) + { + _noCollisionMaterial.dispose(); + _noCollisionMaterial = null; + _noCollisionTexture.dispose(); + _noCollisionTexture = null; + } + this.setToCollisionDisabledTextureIfNeeded(); if(this._textureName == "DEFAULT") { this._textureName = ""; @@ -216,6 +239,7 @@ package alternativa.editor.prop loc2.bitmaps = this.bitmaps; loc2._textureName = this._textureName; loc2.height = height; + loc2.collisionEnabled = this._collisionEnabled; return loc2; } @@ -259,6 +283,53 @@ package alternativa.editor.prop this.bound = null; } } + + public function get collisionEnabled() : Boolean + { + return this._collisionEnabled; + } + public function set collisionEnabled(enabled:Boolean) : void + { + if(this._collisionEnabled == enabled) + return; + + this._collisionEnabled = enabled; + + this.setToCollisionDisabledTextureIfNeeded(); + } + private function setToCollisionDisabledTextureIfNeeded() : void + { + if(_collisionEnabled) + return; + if(_selected) //shouldn't change texture of 'selected' + return; + if(hidden) + return; + if(this._textureName == InvisibleTexture.TEXTURE_NAME) + return; + + if(_noCollisionTexture == null) + { + _noCollisionTexture = this.bitmapData.clone(); + + _matrix.a = this.bitmapData.width / NO_COLLISION_TEXTURE_Bitmap.width; + _matrix.d = this.bitmapData.height / NO_COLLISION_TEXTURE_Bitmap.height; + + _noCollisionTexture.draw(NO_COLLISION_TEXTURE_Bitmap, _matrix); + + //_noCollisionTexture = NO_COLLISION_TEXTURE_Bitmap.clone(); + _noCollisionMaterial = new TextureMaterial(_noCollisionTexture); + } + + setMaterial(_noCollisionMaterial); + } + + public override function deselect() : void + { + super.deselect(); + + this.setToCollisionDisabledTextureIfNeeded(); + } } } diff --git a/src/alternativa/editor/prop/Prop.as b/src/alternativa/editor/prop/Prop.as index c6d8426..aa1348a 100644 --- a/src/alternativa/editor/prop/Prop.as +++ b/src/alternativa/editor/prop/Prop.as @@ -31,7 +31,7 @@ package alternativa.editor.prop public static const KILL_GEOMETRY:int = 6; - private static const _matrix:Matrix = new Matrix(); + protected static const _matrix:Matrix = new Matrix(); private static var redClass:Class = Prop_redClass; diff --git a/src/alternativa/editor/prop/no_collision_texture.png b/src/alternativa/editor/prop/no_collision_texture.png new file mode 100644 index 0000000000000000000000000000000000000000..ab87f171728f2c977ae45b13c023435e8c28fb20 GIT binary patch literal 5256 zcmeHKc~leU77r8+1d$XK6cC31Dr&X~AtWWTMuHlQKno~RCX-1RLl%+%3GOHY7FX4AL7l7=#&c z8G&GEREp<2R72LU?v3VWS~~l!#jg}KZ9h*ZU98#jS=-}SxgfE>;>+%is=6v{L+Rm( zpG=+VJIj;X*ivHXCS*&WT+NOORBRADj$HU#z>DWT-Iu3Lb@DK-{^3&QIortrGdfnh z2<11Q5mx71&T<|8OJ!kct@ibq6W@(%CGrl|q0N7sJ#uu+qHJ<{?WVlk8she)B(clI z#NM>}Yg@iwT|{kf-Zrwzsp)pyr}bA8>j(skRd`59cV$#F!xRD~lAT zlFJwt@8O-3T}zI?97!(zd`}$TCa^)t+BkE~@mHlcpOIF`#-`+5sDtl% zdfPQWN?k{2?vnWbT=}q``Mu+`;Z~uoR;<}u4J!?@24BCfQDL!hU*y*3P78zY@4{Yv^e5<@Fldc$5Fn2p8Ub0$4;wBFKXc% zc)oj!vyW z$%ue)hrG)p*MBXZX4xh06&az$wj=f#mngn%>$SKLS$2g}b=sXVcV}nnx9QK)pFL8>qPq9Mo2*M+(?b$Wj;r{T zuJTF>giHC97`BKZ(u811xG+PDMP)=pqZta6E2RWXC;1zAfIx}q5y+rSR_S;KKE=$- z1J@=qodTI5dIg^nD-uH?YApu&(0phNs=$D!!IbGF$X_d!@ghTK3{rqQJ|#)7*YN1{ z^z?LEI*X>(%IQolmrG~BbQq=r1XX8L=@A1}rSmXR3~+>EI#i2m^tf6DnK%)NI#ti7 zP{26!#y_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F{YQ$J{g^7eZK5R)%@Rn7|$a}s;o+M2UA+Z`t~jUdGWmdHukk) zUpF}Kr9HlRB(7(L7{4OfI6uWR&)wN2ysv!5+{IR_ErNS9!NXy+Q><)bT4!bJR(&nVP&M3H}6I=Z`bYn<-qNU_q^6cYFIocEBE!wtq;py9eU0Ba`P02jGMRXf3}K>w{t3rn6Gs1 zvDtX!(!Mzl_(|4tx7xX!6iL_%50DFR;NDLlCpa{2UgdB= zJLg>b#vM=NWyPahYp?goftU3a=1gN`E=&(-sKKqXU<>$>}d5a zQqXtAJcm_o*Za;cv586QJ(28Md8(|y8L@u7GiL*j)n*YB?~(&gI_EjJCaJLSP>A76 zd&7m&PAqf%Hyy*)l~f;ZPqkd0yX~aHYcFHRivq8*QLPFM2yc`o;#}IYm}M6o!ZM{# z9lWxjqEn$Z?$R>irV+u@GXirVp^84&!J5b4o}J&Ad`xx|4kSOBHMy(^$!^(4+!7U^ zvo+__%$DCqzI1f0CI$V2*z0nI2j`JJ<98tackE*(&9KV^4r*7=I$$^3|5o`jpVZ|n z%OZ|=`-Jo|AAJ1Qd*wTad%;;PtO@H!7bIUfGXCMQSL;r7w`o?Lkir#L@8!tEJA~Gc z*oH0c(mlkQGc#*96z+tir9{u5%N==wzzgyA!aS?2{GgBv0{iZ3pz|obZcyjx&Ggls>x$^rKC~LF4vBO#@=ueezx7elN_B9==kID={(ep8#D~! zSd&t{71lFsp_IVq)~WgVyMyrOn||E8?n?M6eN%atUxfwia9(f`U$YQ&6hgQlBJ@CT HV&;DU)S=LO literal 0 HcmV?d00001 diff --git a/src/alternativa/editor/scene/MainScene.as b/src/alternativa/editor/scene/MainScene.as index f0e9d45..9986bd9 100644 --- a/src/alternativa/editor/scene/MainScene.as +++ b/src/alternativa/editor/scene/MainScene.as @@ -44,6 +44,10 @@ package alternativa.editor.scene import flash.geom.Vector3D; import alternativa.engine3d.core.Object3DContainer; import alternativa.editor.prop.CTFFlagBase; + import alternativa.editor.PropGeneralPropertiesPanel; + import mx.controls.Alert; + import mx.containers.HBox; + import alternativa.editor.SceneContainer; public class MainScene extends EditorScene { @@ -64,7 +68,7 @@ package alternativa.editor.scene private var texturePanel:TexturePanel; - private var propertyPanel:Panel; + private const propertyPanel:HBox = new HBox(); private var bonusTypesPanel:BonusRegionPropertiesPanel; @@ -85,12 +89,15 @@ package alternativa.editor.scene private var domSpawnPoint:SpawnPoint; private var controlPointNameField:ControlPointNameField; + + private var propGeneralProperties:PropGeneralPropertiesPanel; public function MainScene() { this.hiddenProps = []; this.bonusTypesPanel = new BonusRegionPropertiesPanel(); this.killZonePanel = new KillZonePropertiesPanel(); + this.propGeneralProperties = new PropGeneralPropertiesPanel(); this._selectablePropTypes = new Set(); this.exporters = {}; this.layers = new Layers(); @@ -112,6 +119,7 @@ package alternativa.editor.scene this.createControlPointNameTextField(); collider = new EllipsoidCollider(30,30,30); __root = root; + this.propertyPanel.percentHeight = this.propertyPanel.percentWidth = 100; GlobalEventDispatcher.addListener(LayerVisibilityChangeEvent.VISIBILITY_CHANGED,this.onLayerVisibilityChange); GlobalEventDispatcher.addListener(LayerContentChangeEvent.LAYER_CONTENT_CHANGED,this.onLayerContentChange); GlobalEventDispatcher.addListener(DominationSpawnLinkStartEvent.DOMINATION_SPAWN_LINK_START,this.onDominationLinkStart); @@ -178,6 +186,7 @@ package alternativa.editor.scene public function exportScene(param1:FileType, param2:FileStream) : void { + SceneContainer.instance.cursorScene.clear(); FileExporter(this.exporters[param1]).exportToFileStream(param2); this._changed = false; } @@ -391,7 +400,7 @@ package alternativa.editor.scene public function setPropertyPanel(param1:Panel) : void { - this.propertyPanel = param1; + param1.addChild(this.propertyPanel); this.texturePanel = new TexturePanel(); this.texturePanel.addEventListener(PropListEvent.SELECT,this.onTexturePanelSelect); } @@ -553,8 +562,7 @@ package alternativa.editor.scene } this.selectedProps.clear(); this.selectedProp = null; - this.hidePropertyPanelItem(this.bonusTypesPanel); - this.hidePropertyPanelItem(this.texturePanel); + this.hideAllPropertyPanelItems(); } public function deselectProp(param1:Prop) : void @@ -569,6 +577,7 @@ package alternativa.editor.scene if(this.selectedProps.length > 0) { + this.selectedProp = this.selectedProps.peek(); this.showPropertyPanel(); } @@ -593,7 +602,10 @@ package alternativa.editor.scene this.selectedProp = loc3; } } - this.showPropertyPanel(); + if(this.selectedProp != null) + { + this.showPropertyPanel(); + } } public function selectConflictingProps() : void @@ -847,7 +859,7 @@ package alternativa.editor.scene } } - public function showPropertyPanel() : void + private function showPropertyPanel() : void { var loc1:Map = null; this.hideAllPropertyPanelItems(); @@ -874,15 +886,34 @@ package alternativa.editor.scene } this.bonusTypesPanel.setBonusRegion(null); - for(var item:* in this.selectedProps) + + var item:*; + for(item in this.selectedProps) { if(!(item is MeshProp)) + return; + } + + this.showTexturePanel(); + + + var collisionEnabled:Boolean = (this.selectedProp as MeshProp).collisionEnabled; + + for(item in this.selectedProps) + { + if(item is Sprite3DProp) + continue; + if(collisionEnabled != (item as MeshProp).collisionEnabled) { return; } } - this.showTexturePanel(); + this.texturePanel.percentWidth = 100 - this.propGeneralProperties.percentWidth; + + this.showPropertyPanelItem(this.propGeneralProperties); + + this.propGeneralProperties.init(this.selectedProps, collisionEnabled); } private function showTexturePanel() : void @@ -891,6 +922,8 @@ package alternativa.editor.scene if(!loc1) return; + this.texturePanel.percentWidth = 100; + this.showPropertyPanelItem(this.texturePanel); if(loc1 != this.currentBitmaps) {