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 | 693 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 601 insertions(+), 92 deletions(-) diff --git a/ObjEditor.java b/ObjEditor.java index f3f020f..c2efc4b 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -41,11 +41,25 @@ 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) @@ -60,26 +74,40 @@ return new cCheckBox(icon, border); } - private ImageIcon GetIcon(String name) + ImageIcon GetIcon(String name) { try { BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); - if (image.getWidth() != 24 && image.getHeight() != 24) - { - BufferedImage resized = new BufferedImage(24, 24, 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, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); - g.dispose(); - - image = resized; - } +// 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) { @@ -268,9 +296,9 @@ client = inClient; copy = client; - if (copy.versions == null) + if (copy.versionlist == null) { - copy.versions = new byte[100][]; + copy.versionlist = new Object3D[100]; copy.versionindex = -1; } @@ -287,9 +315,9 @@ client = inClient; copy = client; - if (copy.versions == null) + if (copy.versionlist == null) { - copy.versions = new byte[100][]; + copy.versionlist = new Object3D[100]; copy.versionindex = -1; } @@ -325,7 +353,7 @@ copy = localCopy; copy.editWindow = this; - if (copy.versions == null) + if (copy.versionlist == null) { // copy.versions = new byte[100][]; // copy.versionindex = -1; @@ -436,10 +464,10 @@ editPanel.add(editCommandsPanel); editPanel.add(ctrlPanel); - toolboxPanel = new cGridBag().setVertical(false); + toolboxPanel = new cGridBag().setVertical(true); //toolboxPanel.setName("Toolbox"); - materialPanel = new cGridBag().setVertical(true); + materialPanel = new cGridBag().setVertical(false); //materialPanel.setName("Material"); /*JTextPane*/ @@ -820,9 +848,11 @@ //frame.setVisible(true); } frame.validate(); + + cameraView.requestFocusInWindow(); } - private byte[] CompressCopy() + private Object3D CompressCopy() { boolean temp = CameraPane.SWITCH; CameraPane.SWITCH = false; @@ -830,12 +860,13 @@ copy.ExtractBigData(versiontable); // if (copy == client) - byte[] versions[] = copy.versions; - copy.versions = null; + Object3D versions[] = copy.versionlist; + copy.versionlist = null; - byte[] compress = Compress(copy); + //byte[] compress = Compress(copy); + Object3D compress = (Object3D)Grafreed.clone(copy); - copy.versions = versions; + copy.versionlist = versions; copy.RestoreBigData(versiontable); @@ -965,6 +996,7 @@ { SetupMaterial(materialPanel); } + //SetupName(); //SetupViews(); } @@ -1194,6 +1226,8 @@ hideCB.setToolTipText("Hide object"); markCB = AddCheckBox(setupPanel, "Mark", copy.marked); markCB.setToolTipText("As animation target transform"); + + ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); setupPanel2 = new cGridBag().setVertical(false); @@ -1520,23 +1554,29 @@ //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.setIconAt(1, GetIcon("icons/write.png")); + objectPanel.setIconAt(2, GetIcon("icons/write.png")); + objectPanel.setToolTipTextAt(2, "Edit controls"); //if (Globals.ADVANCED) objectPanel.add(infoPanel); - objectPanel.setIconAt(2, GetIcon("icons/info.png")); + objectPanel.setIconAt(3, GetIcon("icons/info.png")); + objectPanel.setToolTipTextAt(3, "Information"); objectPanel.add(XYZPanel); - objectPanel.setIconAt(3, GetIcon("icons/XYZ.png")); + objectPanel.setIconAt(4, GetIcon("icons/XYZ.png")); + objectPanel.setToolTipTextAt(4, "XYZ/RGB transform"); - objectPanel.add(toolboxPanel); - objectPanel.setIconAt(4, GetIcon("icons/primitives.png")); - /* aConstraints.gridx = 0; aConstraints.gridwidth = 1; @@ -1675,7 +1715,6 @@ frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { Close(); @@ -1698,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); @@ -1737,27 +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); - panel.add(new JSeparator()); + panel.add(GetSeparator()); panel.add(colorSection); @@ -1813,7 +2247,7 @@ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); diffuseSection.add(shadowbias); - panel.add(new JSeparator()); + panel.add(GetSeparator()); panel.add(diffuseSection); @@ -1876,7 +2310,7 @@ specularSection.add(anisoV); - panel.add(new JSeparator()); + panel.add(GetSeparator()); panel.add(specularSection); @@ -1901,12 +2335,6 @@ backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); 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); - colorSection.add(opacity); //panel.add(new JSeparator()); @@ -1952,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); @@ -2939,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); @@ -3250,6 +3678,7 @@ } else if (event.getSource() == liveCB) { copy.live ^= true; + objEditor.refreshContents(true); // To show item colors return; } else if (event.getSource() == selectableCB) { @@ -3259,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) { @@ -3515,6 +3944,7 @@ static public byte[] Compress(Object3D o) { + // Slower to actually compress. try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -3616,6 +4046,7 @@ { //Save(true); Replace(); + SetUndoStates(); } private boolean Equal(byte[] compress, byte[] name) @@ -3636,29 +4067,46 @@ 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(); - byte[] compress = CompressCopy(); + Object3D compress = CompressCopy(); // Saved version. No need for "Replace"? boolean thesame = false; - // Quick heuristic using length. Works only when stream is compressed. - if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) - { - thesame = true; - } +// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) +// { +// thesame = true; +// } //EditorFrame.m_MainFrame.requestFocusInWindow(); if (!thesame) { + 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.versions[++copy.versionindex] = compress; + copy.versionlist[++copy.versionindex] = compress; // if (increment) // tab.versionindex++; @@ -3668,11 +4116,11 @@ //assert(hashtable.isEmpty()); - for (int i = copy.versionindex+1; i < copy.versions.length; i++) - { - //tab.user[i] = false; - copy.versions[i] = null; - } +// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++) +// { +// //tab.user[i] = false; +// copy.versionlist[i] = null; +// } SetUndoStates(); @@ -3697,9 +4145,43 @@ return !thesame; } - - void CopyChanged(Object3D obj) + + 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 = copy.versionlist[copy.versionindex]; + SetUndoStates(); boolean temp = CameraPane.SWITCH; @@ -3709,6 +4191,9 @@ copy.clear(); + copy.skyboxname = obj.skyboxname; + copy.skyboxext = obj.skyboxext; + for (int i=0; i<obj.Size(); i++) { copy.add(obj.get(i)); @@ -3718,6 +4203,7 @@ CameraPane.SWITCH = temp; + RefreshSelection(); //assert(hashtable.isEmpty()); copy.Touch(); @@ -3738,13 +4224,15 @@ } } - refreshContents(); + refreshContents(true); } - cButton undoButton; + cButton previousVersionButton; cButton restoreButton; cButton replaceButton; - cButton redoButton; + cButton nextVersionButton; + cButton saveVersionButton; + cButton deleteVersionButton; boolean muteSlider; @@ -3752,9 +4240,9 @@ { int count = 0; - for (int i = copy.versions.length; --i >= 0;) + for (int i = copy.versionlist.length; --i >= 0;) { - if (copy.versions[i] != null) + if (copy.versionlist[i] != null) count++; } @@ -3765,11 +4253,14 @@ { cRadio tab = GetCurrentTab(); - restoreButton.setEnabled(copy.versionindex != -1); - replaceButton.setEnabled(copy.versionindex != -1); + restoreButton.setEnabled(true); // copy.versionindex != -1); + replaceButton.setEnabled(true); // copy.versionindex != -1); - undoButton.setEnabled(copy.versionindex > 0); - redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); + 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); @@ -3777,7 +4268,7 @@ muteSlider = false; } - public boolean Undo() + public boolean PreviousVersion() { // Option? Replace(); @@ -3807,7 +4298,7 @@ copy.versionindex -= 1; - CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); + CopyChanged(); return true; } @@ -3818,13 +4309,14 @@ cRadio tab = GetCurrentTab(); - if (copy.versionindex == -1 || copy.versions[copy.versionindex] == 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((Object3D)Uncompress(copy.versions[copy.versionindex])); + CopyChanged(); return true; } @@ -3835,25 +4327,25 @@ cRadio tab = GetCurrentTab(); - if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) + if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null) { // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); return false; } - copy.versions[copy.versionindex] = CompressCopy(); + copy.versionlist[copy.versionindex] = CompressCopy(); return true; } - public void Redo() + public void NextVersion() { // Option? Replace(); cRadio tab = GetCurrentTab(); - if (copy.versions[copy.versionindex + 1] == null) + if (copy.versionlist[copy.versionindex + 1] == null) { java.awt.Toolkit.getDefaultToolkit().beep(); return; @@ -3861,7 +4353,7 @@ copy.versionindex += 1; - CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); + CopyChanged(); //if (!tab.user[tab.versionindex]) // tab.graphs[tab.versionindex] = null; @@ -4075,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(); @@ -4108,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)); @@ -4172,9 +4664,10 @@ int version = versionSlider.getInteger(); - if (copy.versions[version] != null) + if (copy.versionlist[version] != null) { - CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version])); + copy.versionindex = version; + CopyChanged(); } return; @@ -4214,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); @@ -4513,6 +5012,7 @@ { if (GetTree() != null) { + GetTree().revalidate(); GetTree().repaint(); } @@ -4521,6 +5021,9 @@ ctrlPanel.validate(); // ? new ctrlPanel.repaint(); } + + if (previousVersionButton != null && copy.versionlist != null) + SetUndoStates(); } static TweenManager tweenManager = new TweenManager(); @@ -4769,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); @@ -4849,6 +5354,8 @@ { //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); @@ -4889,6 +5396,7 @@ } } catch (ClassCastException e) { + e.printStackTrace(); assert (false); Composite c = (Composite) copy; c.children.clear(); @@ -4899,12 +5407,12 @@ c.addChild(csg); } - copy.versions = readobj.versions; + copy.versionlist = readobj.versionlist; copy.versionindex = readobj.versionindex; - if (copy.versions == null) + if (copy.versionlist == null) { - copy.versions = new byte[100][]; + copy.versionlist = new Object3D[100]; copy.versionindex = -1; } @@ -4920,7 +5428,7 @@ { 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) @@ -5019,6 +5527,7 @@ //ps.print(buffer.toString()); } catch (IOException e) { + e.printStackTrace(); } } @@ -5311,7 +5820,7 @@ JLabel colorLabel; cNumberSlider colorField; JLabel modulationLabel; - cNumberSlider modulationField; + cNumberSlider saturationField; JLabel metalnessLabel; cNumberSlider metalnessField; JLabel diffuseLabel; -- Gitblit v1.6.2