/**
* Copyright (c) 2003-2009, Xith3D Project Group all rights reserved.
*
* Portions based on the Java3D interface, Copyright by Sun Microsystems.
* Many thanks to the developers of Java3D and Sun Microsystems for their
* innovation and design.
*
* 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 the 'Xith3D Project Group' 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) A
* RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE
*/
package org.xith3d.loaders.models.impl.cal3d.browser;
import org.jagatoo.loaders.models.cal3d.core.CalCoreAnimation;
import org.xith3d.loaders.models.impl.cal3d.Cal3dModel;
/**
*
* @author Dave
*/
public class AnimControlPanel extends javax.swing.JPanel {
private static final long serialVersionUID = 6992357433479133417L;
private Cal3dModel character;
private String id;
//private CalCoreAnimation anim;
/** Creates new form AnimCycleControlPanel */
public AnimControlPanel(Cal3dModel character, String id, CalCoreAnimation anim) {
this.character = character;
this.id = id;
//this.anim = anim;
initComponents();
}
/** 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.
*/
private void initComponents () {
java.awt.GridBagConstraints gridBagConstraints;
idLabel = new javax.swing.JLabel ();
blendSlider = new javax.swing.JSlider ();
scrubSlider = new javax.swing.JSlider ();
scrubCheckBox = new javax.swing.JLabel ();
jLabel1 = new javax.swing.JLabel ();
jPanel1 = new javax.swing.JPanel ();
jButton1 = new javax.swing.JButton ();
bindKeyButton = new javax.swing.JButton ();
actionButton = new javax.swing.JButton ();
setLayout (new java.awt.GridBagLayout ());
idLabel.setBackground (new java.awt.Color (204, 204, 255));
idLabel.setFont (new java.awt.Font ("MS Sans Serif", 3, 11));
idLabel.setForeground (new java.awt.Color (0, 0, 153));
idLabel.setText ("Anim Id");
idLabel.setBorder (new javax.swing.border.BevelBorder (javax.swing.border.BevelBorder.RAISED));
idLabel.setText (id);
gridBagConstraints = new java.awt.GridBagConstraints ();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
add (idLabel, gridBagConstraints);
blendSlider.setValue (0);
blendSlider.addChangeListener (new javax.swing.event.ChangeListener () {
public void stateChanged (javax.swing.event.ChangeEvent evt) {
blendSliderStateChanged (evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints ();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
add (blendSlider, gridBagConstraints);
scrubSlider.setValue (0);
scrubSlider.addChangeListener (new javax.swing.event.ChangeListener () {
public void stateChanged (javax.swing.event.ChangeEvent evt) {
scrubSliderStateChanged (evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints ();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
add (scrubSlider, gridBagConstraints);
//scrubCheckBox.setBackground(new java.awt.Color(204, 204, 255));
//scrubCheckBox.setFont(new java.awt.Font("MS Sans Serif", 3, 11));
//scrubCheckBox.setForeground(new java.awt.Color(0, 0, 153));
scrubCheckBox.setText ("Freeze: ");
//scrubCheckBox.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
//scrubCheckBox.setText(id);
/*scrubCheckBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
scrubCheckBoxActionPerformed(evt);
}
});*/
gridBagConstraints = new java.awt.GridBagConstraints ();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
add (scrubCheckBox, gridBagConstraints);
jLabel1.setText ("Weight: ");
gridBagConstraints = new java.awt.GridBagConstraints ();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
add (jLabel1, gridBagConstraints);
jButton1.setText ("Clear");
jButton1.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
jButton1ActionPerformed (evt);
}
});
jPanel1.add (jButton1);
/*
bindKeyButton.setText("No Keybinding");
bindKeyButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
bindKeyButtonActionPerformed(evt);
}
});
jPanel1.add(bindKeyButton);
*/
actionButton.setText ("Do Action");
actionButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
actionButtonActionPerformed (evt);
}
});
jPanel1.add (actionButton);
gridBagConstraints = new java.awt.GridBagConstraints ();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
add (jPanel1, gridBagConstraints);
}
@SuppressWarnings("unused")
private void bindKeyButtonActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
character.getInternalModel().getMixer().clearCycle(id, 0f);
}
private void scrubSliderStateChanged(javax.swing.event.ChangeEvent evt) {
//character.getInternalModel ().getMixer ().freezeCycle (id, scrubSlider.getValue () / 100f);
character.getInternalModel().getMixer().scrubToPosition(id,scrubSlider.getValue()/100f);
}
private void actionButtonActionPerformed(java.awt.event.ActionEvent evt) {
character.getInternalModel().getMixer().executeAction(id, 0, 0);
}
private void blendSliderStateChanged(javax.swing.event.ChangeEvent evt) {
float blend = blendSlider.getValue () / 100f;
character.getInternalModel().getMixer().blendCycle(id, blend, 0f);
}
public void keyPressed () {
character.getInternalModel().getMixer().executeAction(id, 0, 0);
}
// Variables declaration - do not modify
private javax.swing.JButton actionButton;
@SuppressWarnings("unused")
private javax.swing.JButton bindKeyButton;
private javax.swing.JSlider blendSlider;
private javax.swing.JLabel idLabel;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
//private javax.swing.JCheckBox scrubCheckBox;
private javax.swing.JLabel scrubCheckBox;
private javax.swing.JSlider scrubSlider;
// End of variables declaration
}