- Add physics play/pause buttons (WIP, all objects are added/removed when pressing play/pause)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8602 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent 0776fbf94a
commit 95d2b2d710
  1. 28
      sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java
  2. 3
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/Bundle.properties
  3. 56
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.form
  4. 56
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java
  5. BIN
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/pause.gif
  6. BIN
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/play.gif

@ -26,6 +26,7 @@ package com.jme3.gde.core.scene;
import com.jme3.app.Application;
import com.jme3.app.StatsView;
import com.jme3.bullet.BulletAppState;
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.gde.core.Installer;
@ -118,6 +119,7 @@ public class SceneApplication extends Application implements LookupProvider, Loo
private AwtPanel panel;
private ViewPort overlayView;
boolean useCanvas = false;
private BulletAppState physicsState;
public SceneApplication() {
progressHandle.start(7);
@ -457,6 +459,11 @@ public class SceneApplication extends Application implements LookupProvider, Loo
}
}
checkSave();
if (physicsState != null) {
physicsState.getPhysicsSpace().removeAll(rootNode);
getStateManager().detach(physicsState);
physicsState=null;
}
currentSceneRequest.setDisplayed(false);
}
toolsNode.detachAllChildren();
@ -562,6 +569,27 @@ public class SceneApplication extends Application implements LookupProvider, Loo
}
});
}
public void setPhysicsEnabled(final boolean enabled){
enqueue(new Callable() {
public Object call() throws Exception {
if (enabled) {
if(physicsState==null){
physicsState = new BulletAppState();
getStateManager().attach(physicsState);
physicsState.getPhysicsSpace().addAll(rootNode);
}
}else{
if(physicsState!=null){
physicsState.getPhysicsSpace().removeAll(rootNode);
getStateManager().detach(physicsState);
}
}
return null;
}
});
}
/**
* @return the currentSceneRequest

@ -50,3 +50,6 @@ SceneComposerTopComponent.sceneInfoPanel.border.title=no scene loaded
SceneComposerTopComponent.jLabel5.text=Effects :
SceneComposerTopComponent.emitButton.toolTipText=Emit all particles of all particle emitters from the selected Node
SceneComposerTopComponent.emitButton.text=Emit All Particles
SceneComposerTopComponent.jLabel6.text=Physics:
SceneComposerTopComponent.jButton2.text=
SceneComposerTopComponent.jButton3.text=

@ -33,7 +33,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="sceneInfoPanel" max="32767" attributes="0"/>
</Group>
<Component id="jToolBar1" alignment="0" pref="737" max="32767" attributes="0"/>
<Component id="jToolBar1" alignment="0" pref="766" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -77,7 +77,7 @@
<Component id="sceneInfoLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="sceneInfoLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="106" max="32767" attributes="0"/>
<EmptySpace pref="107" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -349,6 +349,48 @@
</Component>
<Component class="javax.swing.JToolBar$Separator" name="jSeparator1">
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Lucida Grande" size="10" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.jLabel6.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButton2">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/jme3/gde/scenecomposer/play.gif"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.jButton2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton3">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/jme3/gde/scenecomposer/pause.gif"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.jButton3.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JPanel" name="jPanel3">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
@ -359,12 +401,12 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="321" max="32767" attributes="0"/>
<EmptySpace min="0" pref="131" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="23" max="32767" attributes="0"/>
<EmptySpace min="0" pref="21" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
@ -388,8 +430,8 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jToolBar2" alignment="0" pref="342" max="32767" attributes="1"/>
<Component id="jToolBar3" alignment="0" pref="342" max="32767" attributes="0"/>
<Component id="jToolBar2" alignment="0" pref="377" max="32767" attributes="1"/>
<Component id="jToolBar3" alignment="0" pref="377" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
@ -399,7 +441,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="emitButton" pref="267" max="32767" attributes="0"/>
</Group>
<Component id="jSeparator6" alignment="0" pref="322" max="32767" attributes="0"/>
<Component id="jSeparator6" alignment="0" pref="337" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>

@ -107,6 +107,9 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
jLabel2 = new javax.swing.JLabel();
camToCursorSelectionButton = new javax.swing.JButton();
jSeparator1 = new javax.swing.JToolBar.Separator();
jLabel6 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel();
jToolBar2 = new javax.swing.JToolBar();
@ -145,7 +148,7 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
.addComponent(sceneInfoLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(sceneInfoLabel2)
.addContainerGap(106, Short.MAX_VALUE))
.addContainerGap(107, Short.MAX_VALUE))
);
jToolBar1.setBackground(new java.awt.Color(204, 204, 204));
@ -300,17 +303,45 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
jToolBar1.add(camToCursorSelectionButton);
jToolBar1.add(jSeparator1);
jLabel6.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.jLabel6.text")); // NOI18N
jToolBar1.add(jLabel6);
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/scenecomposer/play.gif"))); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jButton2, org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.jButton2.text")); // NOI18N
jButton2.setFocusable(false);
jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jToolBar1.add(jButton2);
jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/scenecomposer/pause.gif"))); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jButton3, org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.jButton3.text")); // NOI18N
jButton3.setFocusable(false);
jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jToolBar1.add(jButton3);
jPanel3.setBackground(new java.awt.Color(204, 204, 204));
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 321, Short.MAX_VALUE)
.addGap(0, 131, Short.MAX_VALUE)
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 23, Short.MAX_VALUE)
.addGap(0, 21, Short.MAX_VALUE)
);
jToolBar1.add(jPanel3);
@ -381,8 +412,8 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)
.addComponent(jToolBar3, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)
.addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
.addComponent(jToolBar3, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -391,7 +422,7 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(emitButton, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE))
.addComponent(jSeparator6, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE))
.addComponent(jSeparator6, javax.swing.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE))
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
@ -417,7 +448,7 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(sceneInfoPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 737, Short.MAX_VALUE)
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 766, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -515,6 +546,14 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
toolController.showEditTool(tool);
}//GEN-LAST:event_scaleButtonActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
SceneApplication.getApplication().setPhysicsEnabled(true);
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
SceneApplication.getApplication().setPhysicsEnabled(false);
}//GEN-LAST:event_jButton3ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton camToCursorSelectionButton;
private javax.swing.JButton createPhysicsMeshButton;
@ -523,12 +562,15 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
private javax.swing.JCheckBox fixedCheckBox;
private javax.swing.JSpinner heightSpinner;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JToolBar.Separator jSeparator1;

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Loading…
Cancel
Save