From b3ae4e889872ca0b9ca76f1d17b2f0b961226729 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 05 Aug 2019 21:48:55 -0400 Subject: [PATCH] Fix physics UI --- ObjEditor.java | 1195 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 1,048 insertions(+), 147 deletions(-) diff --git a/ObjEditor.java b/ObjEditor.java index 9fcd4b1..c2efc4b 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -4,6 +4,7 @@ import java.awt.*; import java.awt.event.*; +import java.awt.image.BufferedImage; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; @@ -13,6 +14,9 @@ import javax.swing.plaf.metal.MetalLookAndFeel; //import javax.swing.plaf.ColorUIResource; //import javax.swing.plaf.metal.DefaultMetalTheme; + +import javax.swing.plaf.basic.BasicSplitPaneDivider; +import javax.swing.plaf.basic.BasicSplitPaneUI; //import javax.media.opengl.GLCanvas; @@ -37,6 +41,79 @@ JFrame frame; static ObjEditor theFrame; + + public cGridBag GetSeparator() + { + cGridBag separator = new cGridBag(); + separator.add(new JSeparator()); + separator.preferredHeight = 5; + return separator; + } + + cButton GetButton(String name, boolean border) + { + ImageIcon icon = GetIcon(name); + return new cButton(icon, border); + } + + cLabel GetLabel(String name, boolean border) + { + //ImageIcon icon = GetIcon(name); + return new cLabel(GetImage(name), border); + } + + cToggleButton GetToggleButton(String name, boolean border) + { + ImageIcon icon = GetIcon(name); + return new cToggleButton(icon, border); + } + + cCheckBox GetCheckBox(String name, boolean border) + { + ImageIcon icon = GetIcon(name); + return new cCheckBox(icon, border); + } + + ImageIcon GetIcon(String name) + { + try + { + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); + +// if (image.getWidth() > 48 && image.getHeight() > 48) +// { +// BufferedImage resized = new BufferedImage(48, 48, image.getType()); +// Graphics2D g = resized.createGraphics(); +// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); +// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); +// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null); +// g.dispose(); +// +// image = resized; +// } + + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); + return icon; + } + catch (Exception e) + { + return null; + } + } + + BufferedImage GetImage(String name) + { + try + { + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); + + return image; + } + catch (Exception e) + { + return null; + } + } // SCRIPT @@ -147,7 +224,7 @@ objEditor.ctrlPanel.remove(namePanel); - if (!GroupEditor.allparams) + if (!allparams) return; // objEditor.ctrlPanel.remove(liveCB); @@ -219,6 +296,12 @@ client = inClient; copy = client; + if (copy.versionlist == null) + { + copy.versionlist = new Object3D[100]; + copy.versionindex = -1; + } + // "this" is not called: SetupUI2(objEditor); } @@ -232,6 +315,12 @@ client = inClient; copy = client; + if (copy.versionlist == null) + { + copy.versionlist = new Object3D[100]; + copy.versionindex = -1; + } + SetupUI2(callee.GetEditor()); } @@ -246,7 +335,7 @@ //localCopy.parent = null; frame = new JFrame(); - frame.setUndecorated(true); + frame.setUndecorated(false); objEditor = this; this.callee = callee; @@ -264,6 +353,12 @@ copy = localCopy; copy.editWindow = this; + if (copy.versionlist == null) + { +// copy.versions = new byte[100][]; +// copy.versionindex = -1; + } + SetupMenu(); //SetupName(objEditor); // new @@ -277,12 +372,17 @@ return frame.action(event, obj); } + // Cannot work without static + static boolean allparams = true; + + static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>(); + void SetupMenu() { frame.setMenuBar(menuBar = new MenuBar()); menuBar.add(fileMenu = new Menu("File")); fileMenu.add(newItem = new MenuItem("New")); - fileMenu.add(loadItem = new MenuItem("Open...")); + fileMenu.add(openItem = new MenuItem("Open...")); //oe.menuBar.add(menu = new Menu("Include")); Menu menu = new Menu("Import"); @@ -314,7 +414,7 @@ } newItem.addActionListener(this); - loadItem.addActionListener(this); + openItem.addActionListener(this); saveItem.addActionListener(this); saveAsItem.addActionListener(this); exportAsItem.addActionListener(this); @@ -323,13 +423,40 @@ closeItem.addActionListener(this); objectPanel = new JTabbedPane(); + + ChangeListener changeListener = new ChangeListener() + { + public void stateChanged(ChangeEvent changeEvent) + { +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed) +// { +// if (latestObject != null) +// { +// refreshContents(true); +// SetMaterial(latestObject); +// } +// +// materialFlushed = true; +// } +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit")) +// { +// if (listUI.size() == 0) +// EditSelection(false); +// } + + refreshContents(false); // To refresh Info tab + } + }; + objectPanel.addChangeListener(changeListener); + toolbarPanel = new JPanel(); toolbarPanel.setName("Toolbar"); + treePanel = new cGridBag(); treePanel.setName("Tree"); editPanel = new cGridBag().setVertical(true); - editPanel.setName("Edit"); + //editPanel.setName("Edit"); ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); @@ -337,23 +464,27 @@ editPanel.add(editCommandsPanel); editPanel.add(ctrlPanel); - materialPanel = new cGridBag().setVertical(true); + toolboxPanel = new cGridBag().setVertical(true); + //toolboxPanel.setName("Toolbox"); - materialPanel.setName("Material"); + materialPanel = new cGridBag().setVertical(false); + //materialPanel.setName("Material"); + /*JTextPane*/ infoarea = createTextPane(); doc = infoarea.getStyledDocument(); infoarea.setEditable(true); SetText(); + // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f)); // infoarea.setOpaque(false); // //infoarea.setForeground(textcolor); // TEXTAREA infoarea.setLineWrap(true); // TEXTAREA infoarea.setWrapStyleWord(true); infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); - infoPanel.setPreferredSize(new Dimension(50, 200)); - infoPanel.setName("Info"); + infoPanel.setPreferredSize(new Dimension(1, 1)); + //infoPanel.setName("Info"); //infoPanel.setLayout(new BorderLayout()); //infoPanel.add(createTextPane()); @@ -364,7 +495,14 @@ mainPanel.setDividerSize(9); mainPanel.setDividerLocation(0.5); //1.0); mainPanel.setResizeWeight(0.5); - + +//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5)); + BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider(); + divider.setDividerSize(15); + divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!")); + + mainPanel.setUI(new BasicSplitPaneUI()); + //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5)); //mainPanel.setLayout(new GridBagLayout()); toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); @@ -595,8 +733,8 @@ } } -static GraphicsDevice device = GraphicsEnvironment - .getLocalGraphicsEnvironment().getScreenDevices()[0]; +//static GraphicsDevice device = GraphicsEnvironment +// .getLocalGraphicsEnvironment().getScreenDevices()[0]; Rectangle keeprect; cRadio radio; @@ -612,13 +750,24 @@ boolean maximized; + cButton fullscreenLayout; + void Minimize() { frame.setState(Frame.ICONIFIED); + frame.validate(); } +// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={} +// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={} +// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={} void Maximize() { + if (CameraPane.FULLSCREEN) + { + ToggleFullScreen(); + } + if (maximized) { frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); @@ -626,20 +775,36 @@ else { keeprect = frame.getBounds(); - Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); - Dimension rect2 = frame.getToolkit().getScreenSize(); - frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); +// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); +// Dimension rect2 = frame.getToolkit().getScreenSize(); +// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); // frame.setState(Frame.MAXIMIZED_BOTH); + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); } maximized ^= true; + + frame.validate(); } + + cButton minButton; + cButton maxButton; + cButton fullButton; void ToggleFullScreen() { - if (CameraPane.FULLSCREEN) +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); + + cameraView.ToggleFullScreen(); + + if (!CameraPane.FULLSCREEN) { device.setFullScreenWindow(null); + frame.dispose(); + frame.setUndecorated(false); + frame.validate(); + frame.setVisible(true); + //frame.setVisible(false); // frame.removeNotify(); // frame.setUndecorated(false); @@ -649,7 +814,7 @@ // X frame.getContentPane().remove(/*"Center",*/bigThree); // X framePanel.add(bigThree); // X frame.getContentPane().add(/*"Center",*/framePanel); - framePanel.setDividerLocation(1); + framePanel.setDividerLocation(46); //frame.setVisible(true); radio.layout = keepButton; @@ -664,7 +829,12 @@ // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, // frame.getToolkit().getScreenSize().height); //frame.setVisible(false); + + frame.dispose(); + frame.setUndecorated(true); device.setFullScreenWindow(frame); + frame.validate(); + frame.setVisible(true); // frame.removeNotify(); // frame.setUndecorated(true); // frame.addNotify(); @@ -673,13 +843,37 @@ // X frame.getContentPane().add(/*"Center",*/bigThree); framePanel.setDividerLocation(0); - radio.layout = twoButton; + radio.layout = fullscreenLayout; radio.layout.doClick(); //frame.setVisible(true); } - - cameraView.ToggleFullScreen(); + frame.validate(); + + cameraView.requestFocusInWindow(); } + + private Object3D CompressCopy() + { + boolean temp = CameraPane.SWITCH; + CameraPane.SWITCH = false; + + copy.ExtractBigData(versiontable); + // if (copy == client) + + Object3D versions[] = copy.versionlist; + copy.versionlist = null; + + //byte[] compress = Compress(copy); + Object3D compress = (Object3D)Grafreed.clone(copy); + + copy.versionlist = versions; + + copy.RestoreBigData(versiontable); + + CameraPane.SWITCH = temp; + + return compress; + } private JTextPane createTextPane() { @@ -802,6 +996,7 @@ { SetupMaterial(materialPanel); } + //SetupName(); //SetupViews(); } @@ -811,7 +1006,7 @@ // NumberSlider vDivsField; // JCheckBox endcaps; JCheckBox liveCB; - JCheckBox selectCB; + JCheckBox selectableCB; JCheckBox hideCB; JCheckBox link2masterCB; JCheckBox markCB; @@ -819,7 +1014,12 @@ JCheckBox speedupCB; JCheckBox rewindCB; JCheckBox flipVCB; + + cCheckBox toggleTextureCB; + cCheckBox toggleSwitchCB; + JComboBox texresMenu; + JButton resetButton; JButton stepButton; JButton stepAllButton; @@ -1006,38 +1206,42 @@ namePanel = new cGridBag(); nameField = AddText(namePanel, copy.GetName()); - namePanel.add(nameField); + namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); oe.ctrlPanel.add(namePanel); oe.ctrlPanel.Return(); - if (!GroupEditor.allparams) + if (!allparams) return; setupPanel = new cGridBag().setVertical(false); liveCB = AddCheckBox(setupPanel, "Live", copy.live); liveCB.setToolTipText("Animate object"); - selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); - selectCB.setToolTipText("Make object selectable"); + selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); + selectableCB.setToolTipText("Make object selectable"); // Return(); + hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); hideCB.setToolTipText("Hide object"); markCB = AddCheckBox(setupPanel, "Mark", copy.marked); - markCB.setToolTipText("Set the animation target transform"); + markCB.setToolTipText("As animation target transform"); + + ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); setupPanel2 = new cGridBag().setVertical(false); rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); rewindCB.setToolTipText("Rewind animation"); - randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); - randomCB.setToolTipText("Randomly Rewind or Go back and forth"); + randomCB = AddCheckBox(setupPanel2, "Random", copy.random); + randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); + link2masterCB.setToolTipText("Attach to support"); + if (Globals.ADVANCED) { - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); - link2masterCB.setToolTipText("Attach to support"); speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); speedupCB.setToolTipText("Option motion capture"); } @@ -1311,6 +1515,7 @@ XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll); XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll); XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll); + //XYZPanel.setName("XYZ"); /* gridPanel = new JPanel(); //new BorderLayout()); @@ -1348,13 +1553,30 @@ //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //tmp.setName("Edit"); objectPanel.add(materialPanel); + objectPanel.setIconAt(0, GetIcon("icons/material.png")); + objectPanel.setToolTipTextAt(0, "Material"); + + objectPanel.add(toolboxPanel); + objectPanel.setIconAt(1, GetIcon("icons/primitives.png")); + objectPanel.setToolTipTextAt(1, "Objects & backgrounds"); + // JPanel north = new JPanel(new BorderLayout()); // north.setName("Edit"); // north.add(ctrlPanel, BorderLayout.NORTH); // objectPanel.add(north); objectPanel.add(editPanel); - objectPanel.add(infoPanel); - + objectPanel.setIconAt(2, GetIcon("icons/write.png")); + objectPanel.setToolTipTextAt(2, "Edit controls"); + + //if (Globals.ADVANCED) + objectPanel.add(infoPanel); + objectPanel.setIconAt(3, GetIcon("icons/info.png")); + objectPanel.setToolTipTextAt(3, "Information"); + + objectPanel.add(XYZPanel); + objectPanel.setIconAt(4, GetIcon("icons/XYZ.png")); + objectPanel.setToolTipTextAt(4, "XYZ/RGB transform"); + /* aConstraints.gridx = 0; aConstraints.gridwidth = 1; @@ -1362,7 +1584,7 @@ aConstraints.gridy += 1; aConstraints.gridwidth = 1; mainPanel.add(objectPanel, aConstraints); - */ + */ scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, @@ -1374,14 +1596,12 @@ scrollpane.addMouseWheelListener(this); // Default not fast enough /*JTabbedPane*/ scenePanel = new cGridBag(); - scenePanel.preferredWidth = 6; + scenePanel.preferredWidth = 5; JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.add(scrollpane); - tabbedPane.add(FSPane = new cFileSystemPane(this)); - - optionsPanel = new cGridBag().setVertical(true); + optionsPanel = new cGridBag().setVertical(false); optionsPanel.setName("Options"); @@ -1389,6 +1609,8 @@ tabbedPane.add(optionsPanel); + tabbedPane.add(FSPane = new cFileSystemPane(this)); + scenePanel.add(tabbedPane); /* @@ -1452,7 +1674,7 @@ bigThree = new cGridBag(); bigThree.addComponent(scenePanel); bigThree.addComponent(centralPanel); - bigThree.addComponent(XYZPanel); + //bigThree.addComponent(XYZPanel); // // SIDE EFFECT!!! // aConstraints.gridx = 0; @@ -1461,9 +1683,9 @@ // aConstraints.gridheight = 1; framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); - framePanel.setContinuousLayout(true); - framePanel.setOneTouchExpandable(true); - framePanel.setDividerLocation(0.8); + framePanel.setContinuousLayout(false); + framePanel.setOneTouchExpandable(false); + //.setDividerLocation(0.8); //framePanel.setDividerSize(15); //framePanel.setResizeWeight(0.15); framePanel.setName("Frame"); @@ -1481,16 +1703,18 @@ // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); frame.setSize(1280, 860); - frame.setVisible(true); - + cameraView.requestFocusInWindow(); gridPanel.setDividerLocation(1.0); + + frame.validate(); + + frame.setVisible(true); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { Close(); @@ -1513,12 +1737,384 @@ ctrlPanel.removeAll(); } - void SetupMaterial(cGridBag panel) + void SetupMaterial(cGridBag materialpanel) { - /* + cGridBag presetpanel = new cGridBag().setVertical(true); + + cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF); + skin.setToolTipText("Skin"); + skin.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[0].get(0); + cMaterial material = object.material; + + // Skin + colorField.setFloat(material.color); + saturationField.setFloat(material.modulation); + subsurfaceField.setFloat(material.subsurface); + selfshadowField.setFloat(material.diffuseness); + diffusenessField.setFloat(material.factor); + shininessField.setFloat(material.shininess); + shadowbiasField.setFloat(material.shadowbias); + diffuseField.setFloat(material.diffuse); + specularField.setFloat(material.specular); + + bumpField.setFloat(object.projectedVertices[0].x / 1000.0); + noiseField.setFloat(object.projectedVertices[0].y / 1000.0); + powerField.setFloat(object.projectedVertices[2].x / 1000.0); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(skin); + + cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF); + lambert.setToolTipText("Diffuse"); + lambert.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[2].get(0); + cMaterial material = object.material; + + diffusenessField.setFloat(material.factor); + selfshadowField.setFloat(material.diffuseness); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(lambert); + + cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF); + diffuse2.setToolTipText("Diffuse2"); + diffuse2.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[3].get(0); + cMaterial material = object.material; + + diffusenessField.setFloat(material.factor); + selfshadowField.setFloat(material.diffuseness); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(diffuse2); + + cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF); + diffusemoon.setToolTipText("Moon"); + diffusemoon.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[4].get(0); + cMaterial material = object.material; + + diffusenessField.setFloat(material.factor); + selfshadowField.setFloat(material.diffuseness); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(diffusemoon); + + cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF); + diffusemoon2.setToolTipText("Moon2"); + diffusemoon2.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[5].get(0); + cMaterial material = object.material; + + diffusenessField.setFloat(material.factor); + selfshadowField.setFloat(material.diffuseness); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(diffusemoon2); + + cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF); + diffusemoon3.setToolTipText("Moon3"); + diffusemoon3.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[6].get(0); + cMaterial material = object.material; + + diffusenessField.setFloat(material.factor); + selfshadowField.setFloat(material.diffuseness); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(diffusemoon3); + + cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF); + diffusesheen.setToolTipText("Sheen"); + diffusesheen.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[7].get(0); + cMaterial material = object.material; + + sheenField.setFloat(material.sheen); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(diffusesheen); + + cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF); + rough.setToolTipText("Rough metal"); + rough.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[1].get(0); + cMaterial material = object.material; + + shininessField.setFloat(material.shininess); + velvetField.setFloat(material.velvet); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(rough); + + cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF); + rough2.setToolTipText("Medium metal"); + rough2.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[13].get(0); + cMaterial material = object.material; + + shininessField.setFloat(material.shininess); + lightareaField.setFloat(material.lightarea); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(rough2); + + cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF); + shini0.setToolTipText("Shiny"); + shini0.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[14].get(0); + cMaterial material = object.material; + + shininessField.setFloat(material.shininess); + lightareaField.setFloat(material.lightarea); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(shini0); + + cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF); + shini1.setToolTipText("Shiny2"); + shini1.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[11].get(0); + cMaterial material = object.material; + + shininessField.setFloat(material.shininess); + lightareaField.setFloat(material.lightarea); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(shini1); + + cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF); + shini2.setToolTipText("Shiny3"); + shini2.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[12].get(0); + cMaterial material = object.material; + + shininessField.setFloat(material.shininess); + lightareaField.setFloat(material.lightarea); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(shini2); + + cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF); + aniso.setToolTipText("AnisoU"); + aniso.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[8].get(0); + cMaterial material = object.material; + + anisoField.setFloat(material.aniso); + anisoVField.setFloat(material.anisoV); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(aniso); + + cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF); + aniso2.setToolTipText("AnisoV"); + aniso2.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[9].get(0); + cMaterial material = object.material; + + anisoField.setFloat(material.aniso); + anisoVField.setFloat(material.anisoV); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(aniso2); + + cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF); + aniso3.setToolTipText("AnisoUV"); + aniso3.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[10].get(0); + cMaterial material = object.material; + + anisoField.setFloat(material.aniso); + anisoVField.setFloat(material.anisoV); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(aniso3); + + cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF); + velvet0.setToolTipText("Velvet"); + velvet0.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[15].get(0); + cMaterial material = object.material; + + diffusenessField.setFloat(material.factor); + selfshadowField.setFloat(material.diffuseness); + sheenField.setFloat(material.sheen); + shininessField.setFloat(material.shininess); + velvetField.setFloat(material.velvet); + shiftField.setFloat(material.shift); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(velvet0); + + cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF); + bump0.setToolTipText("Bump texture"); + bump0.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[16].get(0); + cMaterial material = object.material; + + bumpField.setFloat(object.projectedVertices[0].x / 1000.0); + noiseField.setFloat(object.projectedVertices[0].y / 1000.0); + powerField.setFloat(object.projectedVertices[2].x / 1000.0); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(bump0); + + cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF); + halo.setToolTipText("Halo"); + halo.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[17].get(0); + cMaterial material = object.material; + + opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(halo); + + cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF); + candle.setToolTipText("Candle"); + candle.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[18].get(0); + cMaterial material = object.material; + + subsurfaceField.setFloat(material.subsurface); + shadowbiasField.setFloat(material.shadowbias); + ambientField.setFloat(material.ambient); + specularField.setFloat(material.specular); + lightareaField.setFloat(material.lightarea); + shininessField.setFloat(material.shininess); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(candle); + + cGridBag panel = new cGridBag().setVertical(true); + + presetpanel.preferredWidth = 1; + + materialpanel.add(presetpanel); + materialpanel.add(panel); + + panel.preferredWidth = 8; + + /* ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints); materialLabel.setHorizontalAlignment(SwingConstants.TRAILING); - */ + */ cGridBag editBar = new cGridBag().setVertical(false); @@ -1552,45 +2148,50 @@ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); cGridBag colorSection = new cGridBag().setVertical(true); + + cGridBag huepanel = new cGridBag(); + cGridBag huelabel = new cGridBag(); + skin = GetLabel("icons/hue.png", false); + skin.fit = true; + huelabel.add(skin); + huelabel.preferredWidth = 20; + huepanel.add(new cGridBag()); // Label + huepanel.add(huelabel); // Field/slider + + huepanel.preferredHeight = 7; + + colorSection.add(huepanel); cGridBag color = new cGridBag(); - color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints); - colorLabel.setHorizontalAlignment(SwingConstants.TRAILING); - color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); + + color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints); + colorLabel.setHorizontalAlignment(SwingConstants.TRAILING); + color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints); + //colorField.preferredWidth = 200; colorSection.add(color); cGridBag modulation = new cGridBag(); modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints); modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING); - modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); + modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints); colorSection.add(modulation); + cGridBag opacity = new cGridBag(); + opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); + opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); + opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints); + colorSection.add(opacity); + + colorSection.add(GetSeparator()); + cGridBag texture = new cGridBag(); texture.add(textureLabel = new JLabel("Texture")); // , aConstraints); textureLabel.setHorizontalAlignment(SwingConstants.TRAILING); texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); colorSection.add(texture); - cGridBag anisoU = new cGridBag(); - anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); - anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); - anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); - colorSection.add(anisoU); - - cGridBag anisoV = new cGridBag(); - anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); - anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); - anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); - colorSection.add(anisoV); - - cGridBag shadowbias = new cGridBag(); - shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); - shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); - shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); - colorSection.add(shadowbias); - - panel.add(new JSeparator()); + panel.add(GetSeparator()); panel.add(colorSection); @@ -1640,7 +2241,13 @@ fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); diffuseSection.add(fakedepth); - panel.add(new JSeparator()); + cGridBag shadowbias = new cGridBag(); + shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); + shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); + shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); + diffuseSection.add(shadowbias); + + panel.add(GetSeparator()); panel.add(diffuseSection); @@ -1690,42 +2297,48 @@ // aConstraints.gridy += 1; // aConstraints.gridwidth = 1; + cGridBag anisoU = new cGridBag(); + anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); + anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); + anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); + specularSection.add(anisoU); - panel.add(new JSeparator()); + cGridBag anisoV = new cGridBag(); + anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); + anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); + anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); + specularSection.add(anisoV); + + + panel.add(GetSeparator()); panel.add(specularSection); //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); - cGridBag globalSection = new cGridBag().setVertical(true); + //cGridBag globalSection = new cGridBag().setVertical(true); cGridBag camera = new cGridBag(); camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints); cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING); camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); - globalSection.add(camera); + colorSection.add(camera); cGridBag ambient = new cGridBag(); ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints); ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING); ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); - globalSection.add(ambient); + colorSection.add(ambient); cGridBag backlit = new cGridBag(); backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints); backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); - globalSection.add(backlit); + colorSection.add(backlit); - cGridBag opacity = new cGridBag(); - opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); - opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); - opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); - globalSection.add(opacity); - - panel.add(new JSeparator()); + //panel.add(new JSeparator()); - panel.add(globalSection); + //panel.add(globalSection); //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); @@ -1767,7 +2380,7 @@ opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints); textureSection.add(opacityPower); - panel.add(new JSeparator()); + panel.add(GetSeparator()); panel.add(textureSection); @@ -1832,8 +2445,9 @@ // 3D models if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) { - lastConverter = new com.jmex.model.converters.MaxToJme(); - LoadFile(filename, lastConverter); + //lastConverter = new com.jmex.model.converters.MaxToJme(); + //LoadFile(filename, lastConverter); + LoadObjFile(filename); // New 3ds loader continue; } if (filename.endsWith(".dae") || filename.endsWith(".DAE")) @@ -2559,6 +3173,7 @@ LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); } + //cJME.count++; //cJME.count %= 12; if (gc) @@ -2742,6 +3357,7 @@ } } } + cFileSystemPane FSPane; void SetMaterial(cMaterial mat, Object3D.cVector2[] others) @@ -2751,7 +3367,7 @@ freezematerial = true; colorField.setFloat(mat.color); - modulationField.setFloat(mat.modulation); + saturationField.setFloat(mat.modulation); metalnessField.setFloat(mat.metalness); diffuseField.setFloat(mat.diffuse); specularField.setFloat(mat.specular); @@ -2795,11 +3411,14 @@ } } } + freezematerial = false; } void SetMaterial(Object3D object) { + latestObject = object; + cMaterial mat = object.material; if (mat == null) @@ -2911,12 +3530,17 @@ // } /**/ - if (deselect) + if (deselect || child == null) { //group.deselectAll(); //freeze = true; GetTree().clearSelection(); //freeze = false; + + if (child == null) + { + return; + } } //group.addSelectee(child); @@ -2985,7 +3609,7 @@ cameraView.ToggleDL(); cameraView.repaint(); return; - } else if (event.getSource() == toggleTextureItem) + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) { cameraView.ToggleTexture(); // june 2013 copy.HardTouch(); @@ -3024,7 +3648,7 @@ frame.validate(); return; - } else if (event.getSource() == toggleSwitchItem) + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) { cameraView.ToggleSwitch(); cameraView.repaint(); @@ -3054,8 +3678,9 @@ } else if (event.getSource() == liveCB) { copy.live ^= true; + objEditor.refreshContents(true); // To show item colors return; - } else if (event.getSource() == selectCB) + } else if (event.getSource() == selectableCB) { copy.dontselect ^= true; return; @@ -3063,7 +3688,7 @@ { copy.hide ^= true; copy.Touch(); // display list issue - objEditor.refreshContents(); + objEditor.refreshContents(true); // To show item colors return; } else if (event.getSource() == link2masterCB) { @@ -3240,9 +3865,9 @@ { Close(); //return true; - } else if (source == loadItem) + } else if (source == openItem) { - load(); + Open(); //return true; } else if (source == newItem) { @@ -3267,6 +3892,10 @@ { generatePOV(); //return true; + } else if (event.getSource() == archiveItem) + { + cTools.Archive(frame); + return; } else if (source == zBufferItem) { try @@ -3315,11 +3944,12 @@ static public byte[] Compress(Object3D o) { + // Slower to actually compress. try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); - ObjectOutputStream out = new ObjectOutputStream(zstream); +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); Object3D parent = o.parent; o.parent = null; @@ -3330,10 +3960,14 @@ out.flush(); - zstream.close(); + baos //zstream + .close(); out.close(); - return baos.toByteArray(); + byte[] bytes = baos.toByteArray(); + + System.out.println("save #bytes = " + bytes.length); + return bytes; } catch (Exception e) { System.err.println(e); @@ -3343,13 +3977,16 @@ static public Object Uncompress(byte[] bytes) { - System.out.println("#bytes = " + bytes.length); + System.out.println("restore #bytes = " + bytes.length); try { ByteArrayInputStream bais = new ByteArrayInputStream(bytes); - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); - ObjectInputStream in = new ObjectInputStream(istream); + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); + ObjectInputStream in = new ObjectInputStream(bais); // istream); Object obj = in.readObject(); + + bais //istream + .close(); in.close(); return obj; @@ -3404,37 +4041,95 @@ return null; } - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); public void Save() { + //Save(true); + Replace(); + SetUndoStates(); + } + + private boolean Equal(byte[] compress, byte[] name) + { + if (compress.length != name.length) + { + return false; + } + + for (int i=compress.length; --i>=0;) + { + if (compress[i] != name[i]) + return false; + } + + return true; + } + + java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); + + void DeleteVersion() + { + for (int i = copy.versionindex; i < copy.versionlist.length-1; i++) + { + copy.versionlist[i] = copy.versionlist[i+1]; + } + + CopyChanged(); + + SetUndoStates(); + } + + public boolean Save(boolean user) + { + System.err.println("Save"); + //Replace(); + cRadio tab = GetCurrentTab(); - boolean temp = CameraPane.SWITCH; - CameraPane.SWITCH = false; + Object3D compress = CompressCopy(); // Saved version. No need for "Replace"? - copy.ExtractBigData(hashtable); + boolean thesame = false; + +// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) +// { +// thesame = true; +// } //EditorFrame.m_MainFrame.requestFocusInWindow(); - tab.graphs[tab.undoindex++] = Compress(copy); - - copy.RestoreBigData(hashtable); - - CameraPane.SWITCH = temp; - - //assert(hashtable.isEmpty()); - - for (int i = tab.undoindex; i < tab.graphs.length; i++) + if (!thesame) { - tab.graphs[i] = null; + for (int i = copy.versionlist.length; --i > copy.versionindex+1;) + { + copy.versionlist[i] = copy.versionlist[i-1]; + } + + //tab.user[tab.versionindex] = user; + //boolean increment = true; // tab.graphs[tab.versionindex] == null; + + copy.versionlist[++copy.versionindex] = compress; + + // if (increment) + // tab.versionindex++; } + //copy.RestoreBigData(versiontable); + + //assert(hashtable.isEmpty()); + +// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++) +// { +// //tab.user[i] = false; +// copy.versionlist[i] = null; +// } + + SetUndoStates(); + // test save if (false) { try { - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); ObjectOutputStream p = new ObjectOutputStream(ostream); p.writeObject(copy); @@ -3447,26 +4142,68 @@ e.printStackTrace(); } } + + return !thesame; + } + + boolean flashIt = true; + + void RefreshSelection() + { + Object3D selection = new Object3D(); + + for (int i = 0; i < copy.selection.size(); i++) + { + Object3D elem = copy.selection.elementAt(i); + + Object3D obj = copy.GetObject(elem.GetUUID()); + + if (obj == null) + { + copy.selection.remove(i--); + } + else + { + selection.add(obj); + copy.selection.setElementAt(obj, i); + } + } + + flashIt = false; + GetTree().clearSelection(); + for (int i = 0; i < selection.size(); i++) + GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath()); + flashIt = true; + + //refreshContents(false); } - void CopyChanged(Object3D obj) + void CopyChanged() { + Object3D obj = copy.versionlist[copy.versionindex]; + + SetUndoStates(); + boolean temp = CameraPane.SWITCH; CameraPane.SWITCH = false; - copy.ExtractBigData(hashtable); + copy.ExtractBigData(versiontable); copy.clear(); + copy.skyboxname = obj.skyboxname; + copy.skyboxext = obj.skyboxext; + for (int i=0; i<obj.Size(); i++) { copy.add(obj.get(i)); } - copy.RestoreBigData(hashtable); + copy.RestoreBigData(versiontable); CameraPane.SWITCH = temp; + RefreshSelection(); //assert(hashtable.isEmpty()); copy.Touch(); @@ -3487,43 +4224,139 @@ } } - refreshContents(); + refreshContents(true); } - public void Undo() + cButton previousVersionButton; + cButton restoreButton; + cButton replaceButton; + cButton nextVersionButton; + cButton saveVersionButton; + cButton deleteVersionButton; + + boolean muteSlider; + + int VersionCount() + { + int count = 0; + + for (int i = copy.versionlist.length; --i >= 0;) + { + if (copy.versionlist[i] != null) + count++; + } + + return count; + } + + void SetUndoStates() { cRadio tab = GetCurrentTab(); - if (tab.undoindex == 0) + restoreButton.setEnabled(true); // copy.versionindex != -1); + replaceButton.setEnabled(true); // copy.versionindex != -1); + + previousVersionButton.setEnabled(copy.versionindex > 0); + nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null); + + deleteVersionButton.setEnabled(//copy.versionindex > 0 && + copy.versionlist[copy.versionindex + 1] != null); + + muteSlider = true; + versionSlider.setMaximum(VersionCount() - 1); + versionSlider.setInteger(copy.versionindex); + muteSlider = false; + } + + public boolean PreviousVersion() + { + // Option? + Replace(); + + System.err.println("Undo"); + + cRadio tab = GetCurrentTab(); + + if (copy.versionindex == 0) { java.awt.Toolkit.getDefaultToolkit().beep(); - return; + return false; } - if (tab.graphs[tab.undoindex] == null) - { - Save(); - tab.undoindex -= 1; - } +// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex]) +// { +// if (Save(false)) +// tab.versionindex -= 1; +// else +// { +// if (tab.versionindex <= 0) +// return false; +// else +// tab.versionindex -= 1; +// } +// } - tab.undoindex -= 1; + copy.versionindex -= 1; - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); + CopyChanged(); + + return true; } - public void Redo() + public boolean Restore() { + System.err.println("Restore"); + cRadio tab = GetCurrentTab(); - if (tab.graphs[tab.undoindex + 1] == null) + if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null) + { + java.awt.Toolkit.getDefaultToolkit().beep(); + return false; + } + + //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); + CopyChanged(); + + return true; + } + + public boolean Replace() + { + System.err.println("Replace"); + + cRadio tab = GetCurrentTab(); + + if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null) + { + // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); + return false; + } + + copy.versionlist[copy.versionindex] = CompressCopy(); + + return true; + } + + public void NextVersion() + { + // Option? + Replace(); + + cRadio tab = GetCurrentTab(); + + if (copy.versionlist[copy.versionindex + 1] == null) { java.awt.Toolkit.getDefaultToolkit().beep(); return; } - tab.undoindex += 1; + copy.versionindex += 1; - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); + CopyChanged(); + + //if (!tab.user[tab.versionindex]) + // tab.graphs[tab.versionindex] = null; } void ImportGFD() @@ -3675,7 +4508,7 @@ assert false; } - void EditSelection() + void EditSelection(boolean newWindow) { } @@ -3734,7 +4567,7 @@ //copy.material = new cMaterial(copy.GetMaterial()); current.color = (float) colorField.getFloat(); - current.modulation = (float) modulationField.getFloat(); + current.modulation = (float) saturationField.getFloat(); current.metalness = (float) metalnessField.getFloat(); current.diffuse = (float) diffuseField.getFloat(); current.specular = (float) specularField.getFloat(); @@ -3767,7 +4600,7 @@ cMaterial mat = copy.material; colorField.SetToolTipValue((mat.color)); - modulationField.SetToolTipValue((mat.modulation)); + saturationField.SetToolTipValue((mat.modulation)); metalnessField.SetToolTipValue((mat.metalness)); diffuseField.SetToolTipValue((mat.diffuse)); specularField.SetToolTipValue((mat.specular)); @@ -3819,9 +4652,26 @@ //copy.Touch(); } + cNumberSlider versionSlider; + public void stateChanged(ChangeEvent e) { // assert(false); + if (e.getSource() == versionSlider) + { + if (muteSlider) + return; + + int version = versionSlider.getInteger(); + + if (copy.versionlist[version] != null) + { + copy.versionindex = version; + CopyChanged(); + } + + return; + } if (freezematerial) { @@ -3857,6 +4707,12 @@ { //System.out.println("stateChanged = " + this); materialtouched = true; + + if (e.getSource() == colorField && saturationField.getFloat() == 0.001) + { + saturationField.setFloat(1); + } + applySelf(); //System.out.println("this = " + this); //System.out.println("PARENT = " + parent); @@ -4156,6 +5012,7 @@ { if (GetTree() != null) { + GetTree().revalidate(); GetTree().repaint(); } @@ -4164,13 +5021,17 @@ ctrlPanel.validate(); // ? new ctrlPanel.repaint(); } + + if (previousVersionButton != null && copy.versionlist != null) + SetUndoStates(); } static TweenManager tweenManager = new TweenManager(); void makeSomething(Object3D thing, boolean resetmodel) // deselect) { - Save(); + if (Globals.REPLACEONMAKE) // && resetmodel) + Save(); //Tween.set(thing, 0).target(1).start(tweenManager); //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); // if (thing instanceof GenericJointDemo) @@ -4257,6 +5118,12 @@ { ResetModel(); Select(thing.GetTreePath(), true, false); // unselect... false); + + if (thing.Size() == 0) + { + //EditSelection(false); + } + refreshContents(); } @@ -4405,7 +5272,9 @@ readobj.ResetDisplayList(); } catch (Exception e) { - //e.printStackTrace(); + if (!e.toString().contains("GZIP")) + e.printStackTrace(); + try { java.io.FileInputStream istream = new java.io.FileInputStream(fullname); @@ -4479,11 +5348,14 @@ if (readobj != null) { - Save(); + //if (Globals.SAVEONMAKE) // A new object cannot share meshes + // Save(); try { //readobj.deepCopySelf(copy); copy.clear(); // june 2014 + copy.skyboxname = readobj.skyboxname; + copy.skyboxext = readobj.skyboxext; for (int i = 0; i < readobj.size(); i++) { Object3D child = readobj.get(i); // reserve(i); @@ -4524,6 +5396,7 @@ } } catch (ClassCastException e) { + e.printStackTrace(); assert (false); Composite c = (Composite) copy; c.children.clear(); @@ -4534,17 +5407,28 @@ c.addChild(csg); } + copy.versionlist = readobj.versionlist; + copy.versionindex = readobj.versionindex; + + if (copy.versionlist == null) + { + copy.versionlist = new Object3D[100]; + copy.versionindex = -1; + } + + //? SetUndoStates(); + ResetModel(); copy.HardTouch(); // recompile? refreshContents(); } } - void load() // throws ClassNotFoundException + void Open() // throws ClassNotFoundException { if (Grafreed.standAlone) { - FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD); + FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD); browser.show(); String filename = browser.getFile(); if (filename != null && filename.length() > 0) @@ -4643,6 +5527,7 @@ //ps.print(buffer.toString()); } catch (IOException e) { + e.printStackTrace(); } } @@ -4657,6 +5542,8 @@ String filename = browser.getFile(); if (filename != null && filename.length() > 0) { + if (!filename.endsWith(".gfd")) + filename += ".gfd"; lastname = browser.getDirectory() + filename; save(); } @@ -4823,7 +5710,7 @@ MenuBar menuBar; Menu fileMenu; MenuItem newItem; - MenuItem loadItem; + MenuItem openItem; MenuItem saveItem; MenuItem saveAsItem; MenuItem exportAsItem; @@ -4846,22 +5733,36 @@ CheckboxMenuItem toggleSwitchItem; CheckboxMenuItem toggleRootItem; CheckboxMenuItem animationItem; + MenuItem archiveItem; CheckboxMenuItem toggleHandleItem; CheckboxMenuItem togglePaintItem; JSplitPane mainPanel; JScrollPane scrollpane; + JPanel toolbarPanel; + cGridBag treePanel; + JPanel radioPanel; ButtonGroup buttonGroup; - cGridBag ctrlPanel; + + cGridBag toolboxPanel; cGridBag materialPanel; + cGridBag ctrlPanel; + JScrollPane infoPanel; + cGridBag optionsPanel; + JTabbedPane objectPanel; + boolean materialFlushed; + Object3D latestObject; + cGridBag XYZPanel; + JSplitPane gridPanel; JSplitPane bigPanel; + cGridBag bigThree; cGridBag scenePanel; cGridBag centralPanel; @@ -4919,7 +5820,7 @@ JLabel colorLabel; cNumberSlider colorField; JLabel modulationLabel; - cNumberSlider modulationField; + cNumberSlider saturationField; JLabel metalnessLabel; cNumberSlider metalnessField; JLabel diffuseLabel; @@ -4976,7 +5877,7 @@ cNumberSlider fogField; JLabel opacityPowerLabel; cNumberSlider opacityPowerField; - JTree jTree; + cTree jTree; //ObjectUI parent; cNumberSlider normalpushField; -- Gitblit v1.6.2