diff --git a/sdk/BasicGameTemplate/nbproject/genfiles.properties b/sdk/BasicGameTemplate/nbproject/genfiles.properties index 5dadef18d..61613e16b 100644 --- a/sdk/BasicGameTemplate/nbproject/genfiles.properties +++ b/sdk/BasicGameTemplate/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=94bf7c61 -build.xml.script.CRC32=79a29eb7 -build.xml.stylesheet.CRC32=958a1d3e@1.32.1.45 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=94bf7c61 -nbproject/build-impl.xml.script.CRC32=0f295843 -nbproject/build-impl.xml.stylesheet.CRC32=f33e10ff@1.38.2.45 +build.xml.data.CRC32=94bf7c61 +build.xml.script.CRC32=79a29eb7 +build.xml.stylesheet.CRC32=958a1d3e@1.32.1.45 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=13834f8c +nbproject/build-impl.xml.script.CRC32=d1cfc99b +nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46 diff --git a/sdk/BasicGameTemplate/nbproject/project.xml b/sdk/BasicGameTemplate/nbproject/project.xml index c95f6b19b..3dd779d54 100644 --- a/sdk/BasicGameTemplate/nbproject/project.xml +++ b/sdk/BasicGameTemplate/nbproject/project.xml @@ -1,13 +1,18 @@ - - - org.netbeans.modules.java.j2seproject - - - BasicGameTemplate - - - - - - - + + + org.netbeans.modules.java.j2seproject + + + + + + + + BasicGameTemplate + + + + + + + diff --git a/sdk/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties b/sdk/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties index 839389341..ba85ed099 100644 --- a/sdk/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties +++ b/sdk/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties @@ -1,6 +1,6 @@ #Updated by build script #Sat, 27 Aug 2011 22:46:29 +0200 -currentVersion=jMonkeyEngine SDK 3.0RC2 +currentVersion=jMonkeyEngine SDK 3.0RC2-pre-svn LBL_splash_window_title=Starting jMonkeyEngine SDK SPLASH_HEIGHT=350 SPLASH_WIDTH=500 diff --git a/sdk/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties b/sdk/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties index c12b6c599..d819c9dbb 100644 --- a/sdk/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties +++ b/sdk/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties @@ -1,4 +1,4 @@ #Updated by build script #Sat, 27 Aug 2011 22:46:29 +0200 -CTL_MainWindow_Title=jMonkeyEngine SDK 3.0RC2 -CTL_MainWindow_Title_No_Project=jMonkeyEngine SDK 3.0RC2 +CTL_MainWindow_Title=jMonkeyEngine SDK 3.0RC2-pre-svn +CTL_MainWindow_Title_No_Project=jMonkeyEngine SDK 3.0RC2-pre-svn diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeAnimControl.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeAnimControl.java index c60becdf7..8838ac1b0 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeAnimControl.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeAnimControl.java @@ -196,6 +196,7 @@ public class JmeAnimControl extends AbstractSceneExplorerNode { } public void refreshChildren() { + ((JmeAnimChildren)this.jmeChildren).refreshChildren(true); for (Object node : getChildren().getNodes()) { JmeAnimation anim = (JmeAnimation) node; ((JmeTrackChildren) anim.getChildren()).refreshChildren(true); diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeAnimation.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeAnimation.java index 40dcc8a15..1ac051cf6 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeAnimation.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeAnimation.java @@ -40,6 +40,7 @@ import com.jme3.gde.core.icons.IconList; import com.jme3.gde.core.properties.AnimationProperty; import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.sceneexplorer.nodes.actions.ChannelDialog; +import com.jme3.gde.core.sceneexplorer.nodes.actions.ExtractSubAnimationDialog; import com.jme3.gde.core.sceneexplorer.nodes.actions.impl.tracks.AudioTrackWizardAction; import com.jme3.gde.core.sceneexplorer.nodes.actions.impl.tracks.EffectTrackWizardAction; import java.awt.Image; @@ -49,6 +50,7 @@ import java.io.IOException; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import javax.swing.Action; +import javax.swing.JOptionPane; import org.openide.awt.Actions; import org.openide.loaders.DataObject; import org.openide.nodes.Node; @@ -138,7 +140,6 @@ public class JmeAnimation extends AbstractSceneExplorerNode { sheet.put(set); return sheet; - } public void setChanged() { @@ -151,7 +152,8 @@ public class JmeAnimation extends AbstractSceneExplorerNode { return new Action[]{Actions.alwaysEnabled(new PlayAction(), playing ? "Stop" : "Play", "", false), Actions.alwaysEnabled(new PlayBackParamsAction(), "Playback parameters", "", false), Actions.alwaysEnabled(new EffectTrackWizardAction(jmeControl.getLookup().lookup(AnimControl.class).getSpatial(), this), "Add Effect Track", "", false), - Actions.alwaysEnabled(new AudioTrackWizardAction(jmeControl.getLookup().lookup(AnimControl.class).getSpatial(), this), "Add Audio Track", "", false) + Actions.alwaysEnabled(new AudioTrackWizardAction(jmeControl.getLookup().lookup(AnimControl.class).getSpatial(), this), "Add Audio Track", "", false), + Actions.alwaysEnabled(new ExtractAnimationAction(), "Extract sub-animation", "", true) }; } @@ -264,7 +266,7 @@ public class JmeAnimation extends AbstractSceneExplorerNode { public void run() { stop(); } - }); + }); } ac.removeListener(this); @@ -344,6 +346,27 @@ public class JmeAnimation extends AbstractSceneExplorerNode { } } + + class ExtractAnimationAction implements ActionListener { + + ExtractSubAnimationDialog dialog = new ExtractSubAnimationDialog(); + + public void actionPerformed(ActionEvent e) { + try { + dialog.setAnimControl(JmeAnimation.this.jmeControl); + dialog.setAnimation(JmeAnimation.this.animation); + //animation + dialog.setLocationRelativeTo(null); + dialog.setVisible(true); + + JmeAnimation.this.jmeControl.fireSave(true); + JmeAnimation.this.jmeControl.refresh(true); + JmeAnimation.this.jmeControl.refreshChildren(); + } catch (Exception ex) { + JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + } // class AddTrackAction implements ActionListener { // // public void actionPerformed(ActionEvent e) { diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/Bundle.properties b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/Bundle.properties index 02a4b8e79..35832d86b 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/Bundle.properties +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/Bundle.properties @@ -21,3 +21,19 @@ ChannelDialog.jTextField1.text=jTextField1 ChannelDialog.jButton1.text=Ok ChannelDialog.jButton2.text=Cancel ChannelDialog.jButton2.actionCommand=Cancel +ExctractSubAnimationDialog.AccessibleContext.accessibleName=Extract sub animation +ExctractSubAnimationDialog.border.title=Extract sub animation +ExtractSubAnimationDialog._btnCancel.actionCommand=Cancel +ExtractSubAnimationDialog._btnCancel.text=Cancel +ExtractSubAnimationDialog._btnOk.text=Ok +ExtractSubAnimationDialog._radFromFile.text=From file +ExtractSubAnimationDialog._radManual.text=Manual +ExtractSubAnimationDialog._txtEndFrame.text=0 +ExtractSubAnimationDialog._txtStartFrame.text=0 +ExtractSubAnimationDialog.jLabel3.text=End Frame +ExtractSubAnimationDialog._txtName.text=extract_animation +ExtractSubAnimationDialog.jLabel2.text=Start Frame +ExtractSubAnimationDialog.jLabel1.text=New animation name +ExtractSubAnimationDialog.jLabel4.text=CSV File +ExtractSubAnimationDialog._btnBrowse.text=browse +ExtractSubAnimationDialog._txtCsvFilename.text= diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/ExtractSubAnimationDialog.form b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/ExtractSubAnimationDialog.form new file mode 100644 index 000000000..d22960701 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/ExtractSubAnimationDialog.form @@ -0,0 +1,276 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/ExtractSubAnimationDialog.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/ExtractSubAnimationDialog.java new file mode 100644 index 000000000..f57f703e3 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/ExtractSubAnimationDialog.java @@ -0,0 +1,460 @@ + /* + * Copyright (c) 2009-2012 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.gde.core.sceneexplorer.nodes.actions; + +import com.jme3.animation.AnimControl; +import com.jme3.animation.Animation; +import com.jme3.animation.BoneTrack; +import com.jme3.animation.Track; +import com.jme3.gde.core.scene.SceneApplication; +import com.jme3.gde.core.sceneexplorer.nodes.JmeAnimControl; +import com.jme3.math.Quaternion; +import com.jme3.math.Transform; +import com.jme3.math.Vector3f; +import java.awt.Cursor; +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; +import javax.swing.filechooser.FileNameExtensionFilter; +import org.openide.util.Exceptions; + +/** + * + * @author tsr + */ +public class ExtractSubAnimationDialog extends javax.swing.JDialog { + + Animation _animation; + JmeAnimControl _animControl; + private int _splitAnimationCount; + + /** + * Creates new form ChannelDialog + */ + public ExtractSubAnimationDialog() { + super((java.awt.Frame) null, true); + + initComponents(); + _radioGroup.add(_radFromFile); + _radioGroup.add(_radManual); + + _radManual.setSelected(true); + _txtCsvFilename.setEnabled(false); + _btnBrowse.setEnabled(false); + _splitAnimationCount = 0; + } + + public void setAnimation(Animation animation) { + _animation = animation; + _txtStartFrame.setValue(0); + if (animation.getTracks().length <= 0) { + throw new IllegalArgumentException("No Tracks found"); + } + if (animation.getTracks()[0].getClass() != BoneTrack.class) { + throw new UnsupportedOperationException("Only Bonetracks are supported"); + } + + _txtEndFrame.setValue(((BoneTrack) animation.getTracks()[0]).getTimes().length); + } + + public void setAnimControl(JmeAnimControl control) { + _animControl = control; + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + _radioGroup = new javax.swing.ButtonGroup(); + jPanel1 = new javax.swing.JPanel(); + javax.swing.JLabel jLabel1 = new javax.swing.JLabel(); + javax.swing.JLabel jLabel2 = new javax.swing.JLabel(); + _txtName = new javax.swing.JTextField(); + javax.swing.JLabel jLabel3 = new javax.swing.JLabel(); + _txtStartFrame = new javax.swing.JFormattedTextField(); + _txtEndFrame = new javax.swing.JFormattedTextField(); + _radManual = new javax.swing.JRadioButton(); + _radFromFile = new javax.swing.JRadioButton(); + javax.swing.JLabel jLabel4 = new javax.swing.JLabel(); + _txtCsvFilename = new javax.swing.JTextField(); + _btnBrowse = new javax.swing.JButton(); + _btnOk = new javax.swing.JButton(); + _btnCancel = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExctractSubAnimationDialog.border.title"))); // NOI18N + jPanel1.setName(""); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog.jLabel1.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog.jLabel2.text")); // NOI18N + + _txtName.setText(org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog._txtName.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog.jLabel3.text")); // NOI18N + + _txtStartFrame.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + _txtStartFrame.setText(org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog._txtStartFrame.text")); // NOI18N + + _txtEndFrame.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + _txtEndFrame.setText(org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog._txtEndFrame.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(_radManual, org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog._radManual.text")); // NOI18N + _radManual.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onRadioClick(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(_radFromFile, org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog._radFromFile.text")); // NOI18N + _radFromFile.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onRadioClick(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog.jLabel4.text")); // NOI18N + + _txtCsvFilename.setText(org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog._txtCsvFilename.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(_btnBrowse, org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog._btnBrowse.text")); // NOI18N + _btnBrowse.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onBrowseClick(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(21, 21, 21) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel2) + .addComponent(jLabel3) + .addComponent(jLabel4) + .addComponent(jLabel1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(_txtName) + .addComponent(_txtStartFrame) + .addComponent(_txtEndFrame) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(_txtCsvFilename, javax.swing.GroupLayout.PREFERRED_SIZE, 455, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE) + .addComponent(_btnBrowse)))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(_radManual) + .addComponent(_radFromFile)) + .addGap(0, 0, Short.MAX_VALUE))) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(_radManual) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(_txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(_txtStartFrame, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(_txtEndFrame, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(_radFromFile) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(_txtCsvFilename, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(_btnBrowse))) + ); + + org.openide.awt.Mnemonics.setLocalizedText(_btnOk, org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog._btnOk.text")); // NOI18N + _btnOk.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onOkClick(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(_btnCancel, org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog._btnCancel.text")); // NOI18N + _btnCancel.setActionCommand(org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExtractSubAnimationDialog._btnCancel.actionCommand")); // NOI18N + _btnCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + onCancelClick(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(_btnCancel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(_btnOk))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(_btnOk) + .addComponent(_btnCancel)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jPanel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ExtractSubAnimationDialog.class, "ExctractSubAnimationDialog.AccessibleContext.accessibleName")); // NOI18N + + pack(); + }// //GEN-END:initComponents + + private void onOkClick(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onOkClick + this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + this.setEnabled(false); + + new SwingWorker() { + @Override + protected void done() { + super.done(); + try { + if (get() == true) { + ExtractSubAnimationDialog.this.setCursor(Cursor.getDefaultCursor()); + setVisible(false); + } + + ExtractSubAnimationDialog.this.setEnabled(true); + } catch (InterruptedException ex) { + Exceptions.printStackTrace(ex); + } catch (ExecutionException ex) { + Exceptions.printStackTrace(ex); + } + } + + @Override + protected Boolean doInBackground() throws Exception { + try { + if (_radManual.isSelected()) { + splitAnimation(_txtName.getText(), (Integer) _txtStartFrame.getValue(), (Integer) _txtEndFrame.getValue()); + } else { + processCsv(_txtCsvFilename.getText()); + } + + return true; + } catch (IllegalStateException ex) { + final Exception l_ex = ex; + SwingUtilities.invokeLater(new Runnable() { + public void run() { + ExtractSubAnimationDialog.this.setCursor(Cursor.getDefaultCursor()); + JOptionPane.showMessageDialog(ExtractSubAnimationDialog.this, l_ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }); + return false; + } + } + }.execute(); + }//GEN-LAST:event_onOkClick + + private void processCsv(String filename) { + BufferedReader l_reader = null; + try { + String l_line; + + l_reader = new BufferedReader(new FileReader(filename)); + //read each l_line of text file + while ((l_line = l_reader.readLine()) != null) { + String[] l_parts = l_line.split(";"); + + if (l_parts.length != 3) { + throw new IllegalStateException("Wrong structure of Csv. Need to be 'name;start frame;end frame'"); + } + + splitAnimation(l_parts[0], Integer.parseInt(l_parts[1]), Integer.parseInt(l_parts[2])); + } + } catch (FileNotFoundException ex) { + throw new IllegalStateException("Could not find csv"); + } catch (IOException ex) { + throw new IllegalStateException("Error reading csv"); + } finally { + if (l_reader != null) { + try { + l_reader.close(); + } catch (Exception ex) { + } + } + } + } + + private void splitAnimation(String name, int start, int end) { + final int l_start = start; + final int l_end = end; + final String l_name = name; + + if ("".equals(name) || name == null) { + throw new IllegalStateException("Please enter name for new animation"); + } + + if (_animControl.getLookup().lookup(AnimControl.class).getAnim(l_name) != null) { + throw new IllegalStateException("Please enter unique name for new animation"); + } + + if (start >= end) { + throw new IllegalStateException("Start frame must not be greater than end frame"); + } + + if (end >= ((BoneTrack) _animation.getTracks()[0]).getTimes().length) { + throw new IllegalStateException("End frame must not be greater than source animation end frame"); + } + + try { + SceneApplication.getApplication().enqueue(new Callable() { + public Void call() throws Exception { + Animation l_newAnim; + float l_newTimes[]; + Vector3f l_newTranslations[]; + Quaternion l_newRotations[]; + Vector3f l_newScales[]; + float l_newLength; + Track[] l_tracks = new Track[_animation.getTracks().length]; + + l_newLength = (_animation.getLength() / (float) ((BoneTrack) _animation.getTracks()[0]).getTimes().length) * (float) (l_end - l_start); + l_newAnim = new Animation(l_name, l_newLength); + + for (int j = 0; j < _animation.getTracks().length; j++) { + BoneTrack l_track = (BoneTrack) _animation.getTracks()[j]; + l_newTimes = new float[l_end - l_start]; + l_newTranslations = new Vector3f[l_end - l_start]; + l_newRotations = new Quaternion[l_end - l_start]; + l_newScales = new Vector3f[l_end - l_start]; + + for (int i = l_start; i < l_end; i++) { + int l_newFrame = i - l_start; + + Vector3f l_trans = l_track.getTranslations()[i]; + Vector3f l_scale = l_track.getScales()[i]; + Quaternion l_rot = l_track.getRotations()[i]; + + l_newTimes[l_newFrame] = l_track.getTimes()[i] - l_track.getTimes()[l_start]; + l_newTranslations[l_newFrame] = l_trans.clone(); + l_newRotations[l_newFrame] = l_rot.clone(); + l_newScales[l_newFrame] = l_scale.clone(); + } + + l_tracks[j] = new BoneTrack(l_track.getTargetBoneIndex(), l_newTimes, l_newTranslations, l_newRotations, l_newScales); + } + + l_newAnim.setTracks(l_tracks); + _animControl.getLookup().lookup(AnimControl.class).addAnim(l_newAnim); + + return null; + } + }).get(); + } catch (InterruptedException ex) { + Exceptions.printStackTrace(ex); + } catch (ExecutionException ex) { + Exceptions.printStackTrace(ex); + } + } + + private void onCancelClick(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onCancelClick + setVisible(false); + }//GEN-LAST:event_onCancelClick + + private void onBrowseClick(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onBrowseClick + JFileChooser l_chooser = new JFileChooser(); + FileNameExtensionFilter l_filter = new FileNameExtensionFilter( + "CSV Animation Split file", "csv"); + l_chooser.setFileFilter(l_filter); + + if (l_chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + _txtCsvFilename.setText(l_chooser.getSelectedFile().getPath()); + } + }//GEN-LAST:event_onBrowseClick + + private void onRadioClick(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onRadioClick + if (_radManual.isSelected()) { + _txtCsvFilename.setEnabled(false); + _btnBrowse.setEnabled(false); + _txtName.setEnabled(true); + _txtStartFrame.setEnabled(true); + _txtEndFrame.setEnabled(true); + } else { + _txtCsvFilename.setEnabled(true); + _btnBrowse.setEnabled(true); + _txtName.setEnabled(false); + _txtStartFrame.setEnabled(false); + _txtEndFrame.setEnabled(false); + } + }//GEN-LAST:event_onRadioClick + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton _btnBrowse; + private javax.swing.JButton _btnCancel; + private javax.swing.JButton _btnOk; + private javax.swing.JRadioButton _radFromFile; + private javax.swing.JRadioButton _radManual; + private javax.swing.ButtonGroup _radioGroup; + private javax.swing.JTextField _txtCsvFilename; + private javax.swing.JFormattedTextField _txtEndFrame; + private javax.swing.JTextField _txtName; + private javax.swing.JFormattedTextField _txtStartFrame; + private javax.swing.JPanel jPanel1; + // End of variables declaration//GEN-END:variables +}