import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import grafeme.ui.*; class cSpringEditor extends ObjEditor implements ItemListener, ChangeListener, ObjectUI, ActionListener { cSpringEditor(cSpring inBP, GroupEditor callee) { super(inBP, callee); objEditor = callee.GetEditor(); spring = (cSpring) inBP; SetupUI2(objEditor); } // TEMP? cSpringEditor(cSpring inClient, Object3D localCopy, GroupEditor callee) { this(inClient, localCopy, null, callee); } cSpringEditor(cSpring inBP, ObjectUI p, GroupEditor callee) { super(inBP, callee); objEditor = callee.GetEditor(); spring = (cMesh) inBP; parent = p; SetupUI2(callee.objEditor); } cSpringEditor(cSpring inBP, Object3D copy, ObjectUI p, GroupEditor callee) { super(inBP, copy, p, callee); objEditor = this; spring = (cMesh) copy; parent = p; SetupUI2(objEditor); } void SetupUI2(ObjEditor oe) { super.SetupUI2(oe); firstrowPanel = new cGridBag(); //// oe.ctrlPanel.add(animate = new JCheckBox("Live", spring.live), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); //// ObjEditor.aConstraints.gridx += 1; freezeButton = AddButton(firstrowPanel, "Freeze"); // oe.ctrlPanel.add(freezeButton = new cButton("Freeze"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; //// oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); //// ObjEditor.aConstraints.gridx += 1; avoiderButton = AddButton(firstrowPanel, "Avoid"); // oe.ctrlPanel.add(avoiderButton = new cButton("Avoid"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; autofreeze = AddCheckBox(firstrowPanel, "Blow", spring.IsAutoFreeze()); // oe.ctrlPanel.add(autofreeze = new JCheckBox("Blow", spring.IsAutoFreeze()), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; // Return(); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridx = 0; //// oe.ctrlPanel.add(resetButton = new cButton("Reset"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); //// ObjEditor.aConstraints.gridx += 1; fastnormals = AddCheckBox(firstrowPanel, "Fast", spring.IsFastNormals()); // oe.ctrlPanel.add(fastnormals = new JCheckBox("Fast", spring.IsFastNormals()), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; springs = AddCheckBox(firstrowPanel, "Show", spring.showsprings); // oe.ctrlPanel.add(springs = new JCheckBox("Springs", spring.showsprings), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; info = AddCheckBox(firstrowPanel, "Info", spring.ShowInfo()); // oe.ctrlPanel.add(info = new JCheckBox("Info", spring.ShowInfo()), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); oe.ctrlPanel.add(firstrowPanel); oe.ctrlPanel.Return(); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridx = 0; stiffnessPanel = AddSlider(oe.ctrlPanel, "Stiffness:", 0, 20.0, Math.log(spring.K+1), 1); // ObjEditor.aConstraints.anchor = GridBagConstraints.WEST; // ObjEditor.aConstraints.gridwidth = 1; // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // oe.ctrlPanel.add(stiffnessLabel = new JLabel("Stiffness"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // stiffnessLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(stiffnessField = new NumberSlider(0, 20.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; stiffnessField = (cNumberSlider)stiffnessPanel.getComponent(1); oe.ctrlPanel.Return(); massPanel = AddSlider(oe.ctrlPanel, "Mass:", 0, 20.0, Math.log(spring.M+1), 1); // oe.ctrlPanel.add(massLabel = new JLabel("Mass"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // massLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(massField = new NumberSlider(0, 20.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; massField = (cNumberSlider)massPanel.getComponent(1); oe.ctrlPanel.Return(); gravityPanel = AddSlider(oe.ctrlPanel, "Gravity:", 0, 20.0, Math.log(spring.G.acceleration+1), 1); // oe.ctrlPanel.add(gravityLabel = new JLabel("Gravity"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // gravityLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(gravityField = new NumberSlider(0, 20.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; gravityField = (cNumberSlider)gravityPanel.getComponent(1); oe.ctrlPanel.Return(); normalPanel = AddSlider(oe.ctrlPanel, "Normal:", 0, 20.0, Math.log(spring.normalpush+1), 1); // oe.ctrlPanel.add(normalLabel = new JLabel("Normal"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // normalLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(normalField = new NumberSlider(0, 20.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; normalField = (cNumberSlider)normalPanel.getComponent(1); oe.ctrlPanel.Return(); restlengthPanel = AddSlider(oe.ctrlPanel, "Restlength:", 0, 2.0, spring.restlengthFactor, 1); /**/ // oe.ctrlPanel.add(thicknessLabel = new JLabel("Restlength"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // thicknessLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(restlengthField = new NumberSlider(0, 2.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; restlengthField = (cNumberSlider)restlengthPanel.getComponent(1); oe.ctrlPanel.Return(); distortionPanel = AddSlider(oe.ctrlPanel, "Distortion:", 0, 2.0, spring.distortion, 1); // oe.ctrlPanel.add(distortionLabel = new JLabel("Distortion"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // distortionLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(distortionField = new NumberSlider(0, 2.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; distortionField = (cNumberSlider)distortionPanel.getComponent(1); oe.ctrlPanel.Return(); /**/ limitPanel = AddSlider(oe.ctrlPanel, "Limit:", 0, 20.0, Math.log(spring.limit+1), 1); // oe.ctrlPanel.add(limitLabel = new JLabel("Limit"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // limitLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(limitField = new NumberSlider(0, 20.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; limitField = (cNumberSlider)limitPanel.getComponent(1); oe.ctrlPanel.Return(); viscosityPanel = AddSlider(oe.ctrlPanel, "Viscosity:", 0, 20.0, Math.log(spring.W.wind+1), 1); // oe.ctrlPanel.add(viscosityLabel = new JLabel("Viscosity"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // viscosityLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(viscosityField = new NumberSlider(0, 20.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; viscosityField = (cNumberSlider)viscosityPanel.getComponent(1); oe.ctrlPanel.Return(); fluidspeedPanel = AddSlider(oe.ctrlPanel, "Speed:", 0, 20.0, Math.log(spring.W.speed+1), 1); // oe.ctrlPanel.add(fluidspeedLabel = new JLabel("Speed"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // fluidspeedLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(fluidspeedField = new NumberSlider(0, 20.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; fluidspeedField = (cNumberSlider)fluidspeedPanel.getComponent(1); oe.ctrlPanel.Return(); liftPanel = AddSlider(oe.ctrlPanel, "Lift:", 0, 1.0, spring.W.lift, 1); // oe.ctrlPanel.add(liftLabel = new JLabel("Lift"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // liftLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(liftField = new NumberSlider(0.0, 1.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; liftField = (cNumberSlider)liftPanel.getComponent(1); oe.ctrlPanel.Return(); frictionPanel = AddSlider(oe.ctrlPanel, "Friction:", 0, 1.0, spring.friction, 1); // oe.ctrlPanel.add(frictionLabel = new JLabel("Friction"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // frictionLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(frictionField = new NumberSlider(0.0, 1.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; frictionField = (cNumberSlider)frictionPanel.getComponent(1); oe.ctrlPanel.Return(); timestepPanel = AddSlider(oe.ctrlPanel, "Timestep:", 0, 1.0, spring.timestep, 1); // oe.ctrlPanel.add(timestepLabel = new JLabel("Timestep"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // timestepLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(timestepField = new NumberSlider(0.0, 1.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; timestepField = (cNumberSlider)timestepPanel.getComponent(1); oe.ctrlPanel.Return(); poseslownessPanel = AddSlider(oe.ctrlPanel, "Slowness:", 0, 100.0, spring.slowness, 1); // oe.ctrlPanel.add(poseslownessLabel = new JLabel("Slowness"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // timestepLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(poseslownessField = new NumberSlider(0.0, 100.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; poseslownessField = (cNumberSlider)poseslownessPanel.getComponent(1); oe.ctrlPanel.Return(); dampingPanel = AddSlider(oe.ctrlPanel, "Damping:", 0, 20.0, -Math.log(spring.damping)*10, 1); // oe.ctrlPanel.add(dampingLabel = new JLabel("Damping"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // dampingLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(dampingField = new NumberSlider(0.0, 20.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; dampingField = (cNumberSlider)dampingPanel.getComponent(1); oe.ctrlPanel.Return(); solidityPanel = AddSlider(oe.ctrlPanel, "Solidity:", 0, 20.0, Math.log(spring.solidity+1), 1); // oe.ctrlPanel.add(solidityLabel = new JLabel("Solidity"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // solidityLabel.setHorizontalAlignment(SwingConstants.TRAILING); // ObjEditor.aConstraints.fill = GridBagConstraints.HORIZONTAL; // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // oe.ctrlPanel.add(solidityField = new NumberSlider(0.0, 20.0), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridwidth = 1; // //ObjEditor.aConstraints.fill = 0; // ObjEditor.aConstraints.gridx -= 1; solidityField = (cNumberSlider)solidityPanel.getComponent(1); oe.ctrlPanel.Return(); //System.out.println("K = " + spring.K + "; G = " + spring.G.acceleration + "; H = " + spring.H + "; V = " + spring.W.wind); // stiffnessField.setFloat(Math.log(spring.K+1)); // stiffnessField.addChangeListener(this); // massField.setFloat(Math.log(spring.M+1)); //spring.M); // massField.addChangeListener(this); // gravityField.setFloat(Math.log(spring.G.acceleration+1)); // gravityField.addChangeListener(this); // normalField.setFloat(Math.log(spring.normalpusH+1)); // normalField.addChangeListener(this); // limitField.setFloat(Math.log(spring.limit+1)); // limitField.addChangeListener(this); // restlengthField.setFloat(spring.restlengthFactor); // restlengthField.addChangeListener(this); // distortionField.setFloat(spring.distortion); // distortionField.addChangeListener(this); // viscosityField.setFloat(Math.log(spring.W.wind+1)); // viscosityField.addChangeListener(this); // fluidspeedField.setFloat(Math.log(spring.W.speed+1)); // fluidspeedField.addChangeListener(this); // liftField.setFloat(spring.W.lift); // liftField.addChangeListener(this); // frictionField.setFloat(spring.friction); // frictionField.addChangeListener(this); // timestepField.setFloat(spring.timestep); // elastic); // timestepField.addChangeListener(this); // poseslownessField.setFloat(spring.slowness); // poseslownessField.addChangeListener(this); // dampingField.setFloat(-Math.log(spring.damping)*10); // dampingField.addChangeListener(this); // solidityField.setFloat(Math.log(spring.solidity+1)); // solidityField.addChangeListener(this); secondrowPanel = new cGridBag(); // ObjEditor.aConstraints.gridwidth = 1; // ObjEditor.aConstraints.anchor = GridBagConstraints.WEST; // oe.ctrlPanel.add(revertButton = new cButton("Revert"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; revertButton = AddButton(secondrowPanel, "Revert"); // oe.ctrlPanel.add(epsequal = new JCheckBox("Eps", spring.IsEpsEqual()), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; epsequal = AddCheckBox(secondrowPanel, "Eps", spring.IsEpsEqual()); // oe.ctrlPanel.add(linkUV = new JCheckBox("link UV", spring.IsLinkUV()), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridx = 0; linkUV = AddCheckBox(secondrowPanel, "UV", spring.IsLinkUV()); // oe.ctrlPanel.add(poseCB = new JCheckBox("Change:", spring.IsPoseMesh()), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; poseCB = AddCheckBox(secondrowPanel, "Loop", spring.IsPoseMesh()); // oe.ctrlPanel.add(poseButton = new cButton("Pose"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridx = 0; poseButton = AddButton(secondrowPanel, "Pose"); oe.ctrlPanel.add(secondrowPanel); oe.ctrlPanel.Return(); posePanel = AddSlider(oe.ctrlPanel, "Pose:", 0, spring.posegroup==null?0:spring.posegroup.size()-1, spring.poseid); poseField = (cNumberSlider)posePanel.getComponent(1); oe.ctrlPanel.Return(); thirdrowPanel = new cGridBag(); // oe.ctrlPanel.add(solid = new JCheckBox("Solid", spring.IsSolid()), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; solid = AddCheckBox(thirdrowPanel, "3D", spring.IsSolid()); // oe.ctrlPanel.add(soft = new JCheckBox("Soft", spring.IsSoft()), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridx = 0; soft = AddCheckBox(thirdrowPanel, "Soft", spring.IsSoft()); // oe.ctrlPanel.add(fold = new JCheckBox("Fold", spring.IsFold()), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; fold = AddCheckBox(thirdrowPanel, "Fold", spring.IsFold()); // oe.ctrlPanel.add(unfold = new JCheckBox("Unfold", spring.IsUnfold()), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; unfold = AddCheckBox(thirdrowPanel, "Unf", spring.IsUnfold()); // oe.ctrlPanel.add(normalizeCounts = new JCheckBox("Counts", spring.IsNormalize()), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridx = 0; normalizeCounts = AddCheckBox(thirdrowPanel, "Cnt", spring.IsNormalize()); // Invariants?... oe.ctrlPanel.add(updatehandles = new JCheckBox("Update handles", spring.IsUpdateHandles()), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; oe.ctrlPanel.add(thirdrowPanel); oe.ctrlPanel.Return(); // oe.ctrlPanel.add(freezeButton = new cButton(" Freeze "), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; // oe.ctrlPanel.add(stepButton = new cButton(" Step "), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; // oe.ctrlPanel.add(thick = new JCheckBox("Thick", spring.thick), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; // oe.ctrlPanel.add(single = new JCheckBox("Single", spring.singlelayer), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2); // ObjEditor.aConstraints.gridx += 1; // animate.addItemListener(this); // thick.addItemListener(this); // single.addItemListener(this); // springs.addItemListener(this); // epsequal.addItemListener(this); // linkUV.addItemListener(this); // solid.addItemListener(this); // soft.addItemListener(this); // fold.addItemListener(this); // unfold.addItemListener(this); // poseCB.addItemListener(this); // if (info != null) // info.addItemListener(this); // autofreeze.addItemListener(this); // fastnormals.addItemListener(this); // // updatehandles.addItemListener(this); // normalizeCounts.addItemListener(this); // ObjEditor.aConstraints.gridy += 1; // ObjEditor.aConstraints.gridx = 0; //// resetButton.addActionListener(this); // revertButton.addActionListener(this); // freezeButton.addActionListener(this); //// stepButton.addActionListener(this); // // avoiderButton.addActionListener(this); // poseButton.addActionListener(this); } void Clear() { objEditor.Clear(); spring = null; } public void itemStateChanged(ItemEvent e) { // spring.live = animate.isSelected(); //spring.thick = thick.isSelected(); //spring.singlelayer = single.isSelected(); spring.showsprings = springs.isSelected(); spring.SetEpsEqual(epsequal.isSelected()); spring.SetLinkUV(linkUV.isSelected()); spring.SetSolid(solid.isSelected()); spring.SetSoft(soft.isSelected()); if (info != null) spring.SetShowInfo(info.isSelected()); spring.SetFold(fold.isSelected()); spring.SetUnfold(unfold.isSelected()); spring.SetPoseMesh(poseCB.isSelected()); spring.SetAutoFreeze(autofreeze.isSelected()); spring.SetFastNormals(fastnormals.isSelected()); // spring.SetUpdateHandles(updatehandles.isSelected()); spring.SetNormalize(normalizeCounts.isSelected()); super.itemStateChanged(e); objEditor.refreshContents(); } public void actionPerformed(ActionEvent e) { if (e.getSource() == revertButton) { spring.RevertMeshes(); objEditor.refreshContents(); } else if (e.getSource() == resetButton) { //spring.FreezeCopy(); spring.ResetAll(); // spring.Phys.InitNormals(); // INVARIANTS!!! objEditor.refreshContents(); } else if (e.getSource() == freezeButton) { // consider the current geometry as the original one spring.live = false; liveCB.setSelected(spring.live); spring.Freeze(); objEditor.refreshContents(); } else // if (e.getSource() == stepButton) // { // spring.Step(); // spring.Touch(); // objEditor.refreshContents(); // } else // GraphreeD.clipboard if (e.getSource() == avoiderButton) { if (GetEditor().copy.selection != null && GetEditor().copy.selection.size() == 1) { if (!(spring.W instanceof cSpring.ActingForces)) spring.W = spring.new ActingForces(); ((cSpring.ActingForces)spring.W).forces.clear(); spring.W.AddForce(spring.new Avoider(GetEditor().copy.selection.get(0))); } else { if (spring.W instanceof cSpring.ActingForces) ((cSpring.ActingForces)spring.W).forces.clear(); } /* if (spring.Phys == null) // || spring.IsAutoFreeze()) spring.InitPhysics(); spring.Phys.ResetClosestPoints(); */ objEditor.refreshContents(); } else // if (e.getSource() == poseButton) { if (spring.Phys == null) // || spring.IsAutoFreeze()) spring.InitPhysics(); if (GetEditor().copy.selection != null && GetEditor().copy.selection.size() == 1) { spring.Phys.SetPose(GetEditor().copy.selection.get(0)); } else spring.Phys.SetPose(null); objEditor.refreshContents(); } else // { super.actionPerformed(e); } } public void stateChanged(ChangeEvent e) { if (e.getSource() == stiffnessField || e.getSource() == massField || e.getSource() == gravityField || e.getSource() == normalField || e.getSource() == limitField || e.getSource() == restlengthField || e.getSource() == distortionField || e.getSource() == viscosityField || e.getSource() == fluidspeedField || e.getSource() == liftField || e.getSource() == frictionField || e.getSource() == dampingField || e.getSource() == solidityField || e.getSource() == timestepField || e.getSource() == poseslownessField) { applySelf(); objEditor.refreshContents(); } else { if (e.getSource() == poseField) { spring.poseid = poseField.getInteger(); } //System.out.println("STATE = " + e); //super.stateChanged(e); } } public void applySelf() { double k = Math.exp(stiffnessField.getFloat()) - 1; double m = Math.exp(massField.getFloat()) - 1; double g = Math.exp(gravityField.getFloat()) - 1; double d = Math.exp(normalField.getFloat()) - 1; double L = Math.exp(limitField.getFloat()) - 1; double t = restlengthField.getFloat(); double h = distortionField.getFloat(); double v = Math.exp(viscosityField.getFloat()) - 1; double s = Math.exp(fluidspeedField.getFloat()) - 1; double l = liftField.getFloat(); double f = frictionField.getFloat(); double e = timestepField.getFloat(); double p = poseslownessField.getFloat(); double D = dampingField.getFloat(); double S = Math.exp(solidityField.getFloat()) - 1; /* if (spring.K != k || spring.G.acceleration != g || spring.H != h || spring.W.wind != v || spring.limit != m || spring.thickness != t) */ { //System.out.println("K = " + k + "; G = " + g + "; H = " + h + "; V = " + v + "; L = " + m); spring.K = k; spring.M = m; spring.G.acceleration = g; spring.normalpush = d; // * Math.sqrt(m/k); spring.limit = L; spring.restlengthFactor = t; spring.W.wind = v; spring.W.speed = s; // System.out.println("speed = " + s); spring.W.lift = l; spring.friction = f; spring.timestep = e; // elastic = e; spring.damping = Math.exp(-D/10); spring.distortion = h; spring.solidity = S; spring.slowness = p; spring.ResetDelta(); } // june 2013 super.applySelf(); } public void closeUI() { ObjEditor oe = objEditor; // Remove(stiffnessField); // Remove(massField); // Remove(gravityField); // Remove(normalField); // Remove(limitField); // Remove(restlengthField); // Remove(distortionField); // Remove(viscosityField); // Remove(fluidspeedField); // Remove(liftField); // Remove(frictionField); // Remove(timestepField); // Remove(poseslownessField); // Remove(dampingField); // Remove(solidityField); objEditor.ctrlPanel.remove(firstrowPanel); objEditor.ctrlPanel.remove(secondrowPanel); objEditor.ctrlPanel.remove(thirdrowPanel); objEditor.ctrlPanel.remove(stiffnessPanel); objEditor.ctrlPanel.remove(massPanel); objEditor.ctrlPanel.remove(gravityPanel); objEditor.ctrlPanel.remove(normalPanel); objEditor.ctrlPanel.remove(limitPanel); objEditor.ctrlPanel.remove(restlengthPanel); objEditor.ctrlPanel.remove(distortionPanel); objEditor.ctrlPanel.remove(viscosityPanel); objEditor.ctrlPanel.remove(fluidspeedPanel); objEditor.ctrlPanel.remove(liftPanel); objEditor.ctrlPanel.remove(frictionPanel); objEditor.ctrlPanel.remove(timestepPanel); objEditor.ctrlPanel.remove(poseslownessPanel); objEditor.ctrlPanel.remove(dampingPanel); objEditor.ctrlPanel.remove(solidityPanel); objEditor.ctrlPanel.remove(posePanel); // stiffnessField.removeChangeListener(this); // massField.removeChangeListener(this); // gravityField.removeChangeListener(this); // normalField.removeChangeListener(this); // limitField.removeChangeListener(this); // restlengthField.removeChangeListener(this); // distortionField.removeChangeListener(this); // viscosityField.removeChangeListener(this); // fluidspeedField.removeChangeListener(this); // liftField.removeChangeListener(this); // frictionField.removeChangeListener(this); // timestepField.removeChangeListener(this); // poseslownessField.removeChangeListener(this); // dampingField.removeChangeListener(this); // solidityField.removeChangeListener(this); // //// resetButton.removeActionListener(this); // revertButton.removeActionListener(this); // freezeButton.removeActionListener(this); //// stepButton.removeActionListener(this); Remove(revertButton); Remove(freezeButton); Remove(avoiderButton); Remove(poseButton); // // avoiderButton.removeActionListener(this); // poseButton.removeActionListener(this); // //// animate.removeItemListener(this); // //thick.removeItemListener(this); // //single.removeItemListener(this); // //// oe.ctrlPanel.remove(animate); // //oe.ctrlPanel.remove(thick); // //oe.ctrlPanel.remove(single); // oe.ctrlPanel.remove(springs); // // oe.ctrlPanel.remove(epsequal); // oe.ctrlPanel.remove(linkUV); // oe.ctrlPanel.remove(solid); // oe.ctrlPanel.remove(soft); // oe.ctrlPanel.remove(fold); // oe.ctrlPanel.remove(unfold); // oe.ctrlPanel.remove(poseCB); // if (info != null) // oe.ctrlPanel.remove(info); // oe.ctrlPanel.remove(freezeButton); // oe.ctrlPanel.remove(autofreeze); // oe.ctrlPanel.remove(fastnormals); // // oe.ctrlPanel.remove(updatehandles); // oe.ctrlPanel.remove(normalizeCounts); Remove(info); Remove(epsequal); Remove(springs); Remove(linkUV); Remove(solid); Remove(soft); Remove(fold); Remove(unfold); Remove(poseCB); Remove(freezeButton); Remove(autofreeze); Remove(fastnormals); Remove(normalizeCounts); // // oe.ctrlPanel.remove(stiffnessField); // oe.ctrlPanel.remove(stiffnessLabel); // oe.ctrlPanel.remove(massField); // oe.ctrlPanel.remove(massLabel); // oe.ctrlPanel.remove(gravityField); // oe.ctrlPanel.remove(gravityLabel); // oe.ctrlPanel.remove(normalField); // oe.ctrlPanel.remove(normalLabel); // oe.ctrlPanel.remove(limitField); // oe.ctrlPanel.remove(limitLabel); // oe.ctrlPanel.remove(restlengthField); // oe.ctrlPanel.remove(thicknessLabel); // oe.ctrlPanel.remove(distortionField); // oe.ctrlPanel.remove(distortionLabel); // oe.ctrlPanel.remove(viscosityField); // oe.ctrlPanel.remove(viscosityLabel); // oe.ctrlPanel.remove(fluidspeedField); // oe.ctrlPanel.remove(fluidspeedLabel); // oe.ctrlPanel.remove(liftField); // oe.ctrlPanel.remove(liftLabel); // oe.ctrlPanel.remove(frictionField); // oe.ctrlPanel.remove(frictionLabel); // oe.ctrlPanel.remove(timestepField); // oe.ctrlPanel.remove(timestepLabel); // oe.ctrlPanel.remove(poseslownessField); // oe.ctrlPanel.remove(poseslownessLabel); // oe.ctrlPanel.remove(dampingField); // oe.ctrlPanel.remove(dampingLabel); // oe.ctrlPanel.remove(solidityField); // oe.ctrlPanel.remove(solidityLabel); // //// oe.ctrlPanel.remove(resetButton); // oe.ctrlPanel.remove(revertButton); //// oe.ctrlPanel.remove(stepButton); // // oe.ctrlPanel.remove(avoiderButton); // oe.ctrlPanel.remove(poseButton); Remove(poseField); super.closeUI(); } public ObjEditor GetEditor() { return objEditor; } void refreshContents2() { objEditor.refreshContents(); } cSpring spring; JLabel stiffnessLabel; JLabel massLabel; JLabel gravityLabel; JLabel normalLabel; JLabel mgravityLabel; JLabel fluidspeedLabel; JLabel viscosityLabel; JLabel floorLabel; JLabel limitLabel; JLabel thicknessLabel; JLabel distortionLabel; JLabel frictionLabel; JLabel timestepLabel; JLabel poseslownessLabel; JLabel dampingLabel; JLabel liftLabel; JLabel solidityLabel; cNumberSlider stiffnessField; cNumberSlider massField; cNumberSlider gravityField; cNumberSlider normalField; cNumberSlider fluidspeedField; cNumberSlider viscosityField; cNumberSlider limitField; cNumberSlider restlengthField; cNumberSlider distortionField; cNumberSlider frictionField; cNumberSlider timestepField; cNumberSlider poseslownessField; cNumberSlider dampingField; cNumberSlider liftField; cNumberSlider solidityField; cNumberSlider poseField; cGridBag firstrowPanel; cGridBag secondrowPanel; cGridBag thirdrowPanel; cGridBag stiffnessPanel; cGridBag massPanel; cGridBag gravityPanel; cGridBag normalPanel; cGridBag fluidspeedPanel; cGridBag viscosityPanel; cGridBag limitPanel; cGridBag restlengthPanel; cGridBag distortionPanel; cGridBag dampingPanel; cGridBag frictionPanel; cGridBag liftPanel; cGridBag poseslownessPanel; cGridBag solidityPanel; cGridBag timestepPanel; cGridBag posePanel; // JCheckBox animate; JCheckBox thick; JCheckBox single; JCheckBox springs; JCheckBox linkUV; JCheckBox epsequal; JCheckBox solid; JCheckBox soft; JCheckBox info; JCheckBox fold; JCheckBox unfold; JCheckBox autofreeze; JCheckBox fastnormals; // JCheckBox updatehandles; JCheckBox normalizeCounts; cButton revertButton; // cButton resetButton; cButton freezeButton; cButton stepButton; cButton avoiderButton; JCheckBox poseCB; cButton poseButton; ObjectUI parent; }