Browse Source

Merge branch 'animcomposer' of github.com:neph1/sdk into animcomposer

rickard 3 years ago
parent
commit
b0d7ad068f

+ 28 - 1
jme3-core/src/com/jme3/gde/core/scene/controller/SceneToolController.java

@@ -67,6 +67,22 @@ public class SceneToolController extends AbstractAppState {
     protected AssetManager manager;
     protected AssetManager manager;
     protected Material blueMat;
     protected Material blueMat;
     protected AbstractCameraController camController;
     protected AbstractCameraController camController;
+    
+    private SceneToolControllerListener toolListener;
+    
+    /**
+     * Expandable interface to send callbacks to (primarily) gui. 
+     */
+    public interface SceneToolControllerListener {
+        
+        /**
+         * Called when cursor's location changes.
+         *
+         * @param location location for cursor
+         */
+        public void onSetCursorLocation(Vector3f location);
+    }
+    
 
 
     @SuppressWarnings("LeakingThisInConstructor")
     @SuppressWarnings("LeakingThisInConstructor")
     public SceneToolController(AssetManager manager) {
     public SceneToolController(AssetManager manager) {
@@ -193,6 +209,9 @@ public class SceneToolController extends AbstractAppState {
         if (camController != null) {
         if (camController != null) {
             camController.doSetCamFocus(location);
             camController.doSetCamFocus(location);
         }
         }
+        if (toolListener != null) {
+            toolListener.onSetCursorLocation(location);
+        }
     }
     }
 
 
     public void snapCursorToSelection() {
     public void snapCursorToSelection() {
@@ -428,5 +447,13 @@ public class SceneToolController extends AbstractAppState {
     public Spatial getSelectionShape() {
     public Spatial getSelectionShape() {
         return selectionShape;
         return selectionShape;
     }
     }
-
+    
+    /**
+     * Set the listener to receive callbacks from this class.
+     * 
+     * @param listener listener
+     */
+    public void setToolListener(final SceneToolControllerListener listener) {
+        this.toolListener = listener;
+    }
 }
 }

+ 2 - 0
jme3-scenecomposer/src/com/jme3/gde/scenecomposer/Bundle.properties

@@ -71,3 +71,5 @@ SceneComposerTopComponent.jLabel9.text=Camera Position:
 SceneComposerTopComponent.jLabel10.text=Camera Look Direction:
 SceneComposerTopComponent.jLabel10.text=Camera Look Direction:
 SceneComposerTopComponent.jLabel11.text=(NaN, NaN, NaN)
 SceneComposerTopComponent.jLabel11.text=(NaN, NaN, NaN)
 SceneComposerTopComponent.jLabel12.text=(NaN, NaN, NaN)
 SceneComposerTopComponent.jLabel12.text=(NaN, NaN, NaN)
+SceneComposerTopComponent.cursorPositionLabel.text=(NaN, NaN, NaN)
+SceneComposerTopComponent.cursorPositionHeader.text=Cursor Position:

+ 23 - 3
jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.form

@@ -77,17 +77,19 @@
                       <Component id="jSpinner1" min="-2" pref="80" max="-2" attributes="0"/>
                       <Component id="jSpinner1" min="-2" pref="80" max="-2" attributes="0"/>
                   </Group>
                   </Group>
               </Group>
               </Group>
-              <Group type="102" alignment="0" attributes="0">
+              <Group type="102" attributes="0">
                   <Group type="103" groupAlignment="0" attributes="0">
                   <Group type="103" groupAlignment="0" attributes="0">
                       <Component id="jLabel9" alignment="0" min="-2" max="-2" attributes="0"/>
                       <Component id="jLabel9" alignment="0" min="-2" max="-2" attributes="0"/>
                       <Component id="jLabel10" alignment="0" min="-2" max="-2" attributes="0"/>
                       <Component id="jLabel10" alignment="0" min="-2" max="-2" attributes="0"/>
+                      <Component id="cursorPositionHeader" alignment="0" min="-2" max="-2" attributes="0"/>
                   </Group>
                   </Group>
                   <EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
                   <EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
                   <Group type="103" groupAlignment="0" attributes="0">
                   <Group type="103" groupAlignment="0" attributes="0">
+                      <Component id="cursorPositionLabel" min="-2" max="-2" attributes="0"/>
                       <Component id="jLabel12" alignment="0" min="-2" max="-2" attributes="0"/>
                       <Component id="jLabel12" alignment="0" min="-2" max="-2" attributes="0"/>
                       <Component id="jLabel11" alignment="0" min="-2" max="-2" attributes="0"/>
                       <Component id="jLabel11" alignment="0" min="-2" max="-2" attributes="0"/>
                   </Group>
                   </Group>
-                  <EmptySpace max="-2" attributes="0"/>
+                  <EmptySpace max="32767" attributes="0"/>
               </Group>
               </Group>
           </Group>
           </Group>
         </DimensionLayout>
         </DimensionLayout>
@@ -124,7 +126,11 @@
                       <Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
                       <Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
                       <Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/>
                       <Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/>
                   </Group>
                   </Group>
-                  <EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
+                  <EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="3" attributes="0">
+                      <Component id="cursorPositionHeader" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="cursorPositionLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                  </Group>
               </Group>
               </Group>
           </Group>
           </Group>
         </DimensionLayout>
         </DimensionLayout>
@@ -226,6 +232,20 @@
             </Property>
             </Property>
           </Properties>
           </Properties>
         </Component>
         </Component>
+        <Component class="javax.swing.JLabel" name="cursorPositionHeader">
+          <Properties>
+            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+              <ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.cursorPositionHeader.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
+            </Property>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JLabel" name="cursorPositionLabel">
+          <Properties>
+            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+              <ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.cursorPositionLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
+            </Property>
+          </Properties>
+        </Component>
       </SubComponents>
       </SubComponents>
     </Container>
     </Container>
     <Container class="javax.swing.JToolBar" name="jToolBar1">
     <Container class="javax.swing.JToolBar" name="jToolBar1">

+ 32 - 8
jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java

@@ -13,6 +13,7 @@ import com.jme3.gde.core.scene.PreviewRequest;
 import com.jme3.gde.core.scene.SceneApplication;
 import com.jme3.gde.core.scene.SceneApplication;
 import com.jme3.gde.core.scene.SceneListener;
 import com.jme3.gde.core.scene.SceneListener;
 import com.jme3.gde.core.scene.SceneRequest;
 import com.jme3.gde.core.scene.SceneRequest;
+import com.jme3.gde.core.scene.controller.SceneToolController;
 import com.jme3.gde.core.sceneexplorer.SceneExplorerTopComponent;
 import com.jme3.gde.core.sceneexplorer.SceneExplorerTopComponent;
 import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode;
 import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode;
 import com.jme3.gde.core.sceneexplorer.nodes.JmeNode;
 import com.jme3.gde.core.sceneexplorer.nodes.JmeNode;
@@ -33,6 +34,7 @@ import java.util.Collection;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Callable;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 import javax.swing.ButtonGroup;
 import javax.swing.ButtonGroup;
+import javax.swing.SwingUtilities;
 import javax.swing.border.TitledBorder;
 import javax.swing.border.TitledBorder;
 import org.netbeans.api.progress.ProgressHandle;
 import org.netbeans.api.progress.ProgressHandle;
 import org.netbeans.api.settings.ConvertAsProperties;
 import org.netbeans.api.settings.ConvertAsProperties;
@@ -62,7 +64,9 @@ import org.openide.windows.WindowManager;
 @ConvertAsProperties(dtd = "-//com.jme3.gde.scenecomposer//SceneComposer//EN",
 @ConvertAsProperties(dtd = "-//com.jme3.gde.scenecomposer//SceneComposer//EN",
         autostore = false)
         autostore = false)
 @SuppressWarnings("unchecked")
 @SuppressWarnings("unchecked")
-public final class SceneComposerTopComponent extends TopComponent implements SceneListener, LookupListener {
+public final class SceneComposerTopComponent extends TopComponent implements
+        SceneListener, LookupListener, 
+        SceneToolController.SceneToolControllerListener {
 
 
     private static SceneComposerTopComponent instance;
     private static SceneComposerTopComponent instance;
     /**
     /**
@@ -72,7 +76,7 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
     private static final String PREFERRED_ID = "SceneComposerTopComponent";
     private static final String PREFERRED_ID = "SceneComposerTopComponent";
     private final Result<AbstractSceneExplorerNode> result;
     private final Result<AbstractSceneExplorerNode> result;
     ComposerCameraController camController;
     ComposerCameraController camController;
-    SceneComposerToolController toolController;
+    private SceneComposerToolController toolController;
     SceneEditorController editorController;
     SceneEditorController editorController;
     CameraPositionTrackerAppState cameraPositionTrackerAppState;
     CameraPositionTrackerAppState cameraPositionTrackerAppState;
     private SceneRequest sentRequest;
     private SceneRequest sentRequest;
@@ -111,6 +115,8 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
         jLabel10 = new javax.swing.JLabel();
         jLabel10 = new javax.swing.JLabel();
         jLabel11 = new javax.swing.JLabel();
         jLabel11 = new javax.swing.JLabel();
         jLabel12 = new javax.swing.JLabel();
         jLabel12 = new javax.swing.JLabel();
+        cursorPositionHeader = new javax.swing.JLabel();
+        cursorPositionLabel = new javax.swing.JLabel();
         jToolBar1 = new javax.swing.JToolBar();
         jToolBar1 = new javax.swing.JToolBar();
         transformationTypeComboBox = new javax.swing.JComboBox<>();
         transformationTypeComboBox = new javax.swing.JComboBox<>();
         jSeparator9 = new javax.swing.JToolBar.Separator();
         jSeparator9 = new javax.swing.JToolBar.Separator();
@@ -207,6 +213,10 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
 
 
         org.openide.awt.Mnemonics.setLocalizedText(jLabel12, org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.jLabel12.text")); // NOI18N
         org.openide.awt.Mnemonics.setLocalizedText(jLabel12, org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.jLabel12.text")); // NOI18N
 
 
+        org.openide.awt.Mnemonics.setLocalizedText(cursorPositionHeader, org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.cursorPositionHeader.text")); // NOI18N
+
+        org.openide.awt.Mnemonics.setLocalizedText(cursorPositionLabel, org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.cursorPositionLabel.text")); // NOI18N
+
         javax.swing.GroupLayout sceneInfoPanelLayout = new javax.swing.GroupLayout(sceneInfoPanel);
         javax.swing.GroupLayout sceneInfoPanelLayout = new javax.swing.GroupLayout(sceneInfoPanel);
         sceneInfoPanel.setLayout(sceneInfoPanelLayout);
         sceneInfoPanel.setLayout(sceneInfoPanelLayout);
         sceneInfoPanelLayout.setHorizontalGroup(
         sceneInfoPanelLayout.setHorizontalGroup(
@@ -228,12 +238,14 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
             .addGroup(sceneInfoPanelLayout.createSequentialGroup()
             .addGroup(sceneInfoPanelLayout.createSequentialGroup()
                 .addGroup(sceneInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                 .addGroup(sceneInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addComponent(jLabel9)
                     .addComponent(jLabel9)
-                    .addComponent(jLabel10))
+                    .addComponent(jLabel10)
+                    .addComponent(cursorPositionHeader))
                 .addGap(34, 34, 34)
                 .addGap(34, 34, 34)
                 .addGroup(sceneInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                 .addGroup(sceneInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(cursorPositionLabel)
                     .addComponent(jLabel12)
                     .addComponent(jLabel12)
                     .addComponent(jLabel11))
                     .addComponent(jLabel11))
-                .addContainerGap())
+                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
         );
         );
         sceneInfoPanelLayout.setVerticalGroup(
         sceneInfoPanelLayout.setVerticalGroup(
             sceneInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
             sceneInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -262,7 +274,10 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
                 .addGroup(sceneInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                 .addGroup(sceneInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(jLabel10)
                     .addComponent(jLabel10)
                     .addComponent(jLabel12))
                     .addComponent(jLabel12))
-                .addGap(22, 22, 22))
+                .addGap(8, 8, 8)
+                .addGroup(sceneInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(cursorPositionHeader)
+                    .addComponent(cursorPositionLabel)))
         );
         );
 
 
         jToolBar1.setFloatable(false);
         jToolBar1.setFloatable(false);
@@ -819,6 +834,8 @@ private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {/
     // Variables declaration - do not modify//GEN-BEGIN:variables
     // Variables declaration - do not modify//GEN-BEGIN:variables
     private javax.swing.JButton camToCursorSelectionButton;
     private javax.swing.JButton camToCursorSelectionButton;
     private javax.swing.JButton createPhysicsMeshButton;
     private javax.swing.JButton createPhysicsMeshButton;
+    private javax.swing.JLabel cursorPositionHeader;
+    private javax.swing.JLabel cursorPositionLabel;
     private javax.swing.JButton cursorToSelectionButton;
     private javax.swing.JButton cursorToSelectionButton;
     private javax.swing.JButton emitButton;
     private javax.swing.JButton emitButton;
     private javax.swing.JCheckBox fixedCheckBox;
     private javax.swing.JCheckBox fixedCheckBox;
@@ -1202,7 +1219,7 @@ private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {/
                 toolController.cleanup();
                 toolController.cleanup();
             }
             }
             toolController = new SceneComposerToolController(request.getToolNode(), request.getManager(), request.getJmeNode());
             toolController = new SceneComposerToolController(request.getToolNode(), request.getManager(), request.getJmeNode());
-
+            toolController.setToolListener(this);
             camController = new ComposerCameraController(SceneApplication.getApplication().getCamera(), request.getJmeNode());
             camController = new ComposerCameraController(SceneApplication.getApplication().getCamera(), request.getJmeNode());
             toolController.setEditorController(editorController);
             toolController.setEditorController(editorController);
             camController.setToolController(toolController);
             camController.setToolController(toolController);
@@ -1284,10 +1301,10 @@ private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {/
     public void sceneClosed(SceneRequest request) {
     public void sceneClosed(SceneRequest request) {
         if (request.equals(currentRequest)) {
         if (request.equals(currentRequest)) {
             setActivatedNodes(new org.openide.nodes.Node[]{});
             setActivatedNodes(new org.openide.nodes.Node[]{});
-            if (listener != null && request.getManager() != null) {
-//                request.getManager().removeClassPathEventListener(listener);
+            if(request.getManager() != null && listener != null) {
                 listener = null;
                 listener = null;
             }
             }
+
             SceneApplication.getApplication().removeSceneListener(this);
             SceneApplication.getApplication().removeSceneListener(this);
             SceneApplication.getApplication().getStateManager().detach(cameraPositionTrackerAppState);
             SceneApplication.getApplication().getStateManager().detach(cameraPositionTrackerAppState);
             currentRequest = null;
             currentRequest = null;
@@ -1308,4 +1325,11 @@ private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {/
     public SceneComposerToolController getToolController() {
     public SceneComposerToolController getToolController() {
         return toolController;
         return toolController;
     }
     }
+
+    @Override
+    public void onSetCursorLocation(final Vector3f location) {
+        SwingUtilities.invokeLater(() -> {
+            cursorPositionLabel.setText(location.toString());
+        });
+    }
 }
 }