Browse Source

Add button to set collision shape from bounding box of model

Josh Engebretson 10 years ago
parent
commit
223d423719

+ 29 - 1
Script/AtomicEditor/ui/inspector/ComponentInspector.ts

@@ -117,6 +117,11 @@ class ComponentInspector extends Atomic.UISection {
             this.addLightCascadeParametersUI(attrsVerticalLayout);
             this.addLightCascadeParametersUI(attrsVerticalLayout);
         }
         }
 
 
+        if (component.typeName == "CollisionShape") {
+            this.addCollisionShapeUI(attrsVerticalLayout);
+        }
+
+
         if (component.typeName == "JSComponent") {
         if (component.typeName == "JSComponent") {
             this.addJSComponentUI(attrsVerticalLayout);
             this.addJSComponentUI(attrsVerticalLayout);
         }
         }
@@ -420,7 +425,6 @@ class ComponentInspector extends Atomic.UISection {
 
 
     }
     }
 
 
-
     addLightCascadeParametersUI(layout: Atomic.UILayout) {
     addLightCascadeParametersUI(layout: Atomic.UILayout) {
 
 
         var light = <Atomic.Light> this.component;
         var light = <Atomic.Light> this.component;
@@ -473,6 +477,30 @@ class ComponentInspector extends Atomic.UISection {
     }
     }
 
 
 
 
+    addCollisionShapeUI(layout: Atomic.UILayout) {
+
+        var shape = <Atomic.CollisionShape> this.component;
+
+        var button = new Atomic.UIButton();
+        button.fontDescription = InspectorUtils.attrFontDesc;
+        button.gravity = Atomic.UI_GRAVITY_RIGHT;
+        button.text = "Set from Model";
+
+        button.onClick = () => {
+
+            var model = <Atomic.Drawable> shape.node.getComponent("StaticModel");
+            if (model) {
+                var box = model.boundingBox;
+                shape.setBox([box[3] - box[0], box[4] - box[1], box[5] - box[2]]);
+            }
+
+        };
+
+        layout.addChild(button);
+
+    }
+
+
     component: Atomic.Component;
     component: Atomic.Component;
     bindings: Array<DataBinding> = new Array();
     bindings: Array<DataBinding> = new Array();
 
 

+ 1 - 1
Script/AtomicEditor/ui/inspector/InspectorUtils.ts

@@ -108,7 +108,7 @@ class InspectorUtils {
 
 
 
 
   // "static constructor"
   // "static constructor"
-  private static attrFontDesc:Atomic.UIFontDescription;
+  static attrFontDesc:Atomic.UIFontDescription;
 
 
 }
 }