From 21ac57b36a9e3b909853c7d64ac29b7ad72490a3 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 02 Sep 2019 16:52:19 -0400 Subject: [PATCH] Figure panel. --- GroupEditor.java | 616 ++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 379 insertions(+), 237 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index 953d129..ae9ebf2 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -29,9 +29,9 @@ { cButton skyboxButton; final String path = "cubemaps/" + f + "-skyboxes/" + s; - row.add(skyboxButton = GetButton(path + "/preview.jpg", !Grafreed.NIMBUSLAF)); + row.add(skyboxButton = GetButton(path + "/preview.jpg", !Globals.NIMBUSLAF)); //row.add(skyboxButton = GetButton(path + "/negx.jpg", !Grafreed.NIMBUSLAF)); - skyboxButton.setToolTipText(s); + skyboxButton.setToolTipText(s.equals("") ? "No background" : s); skyboxButton.addActionListener(new ActionListener() { @Override @@ -46,7 +46,7 @@ { cButton textureButton; final String path = "textures/" + f + "/" + c + "/"; // + t; - row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF)); + row.add(textureButton = GetButton(path + "icons/" + t, !Globals.NIMBUSLAF)); textureButton.setToolTipText(c + count); textureButton.addActionListener(new ActionListener() { @@ -73,7 +73,7 @@ cGridBag row5 = new cGridBag(); cGridBag row6 = new cGridBag(); - AddSkyboxButton("default", "rgb", row0); + AddSkyboxButton("default", "", row0); //AddSkyboxButton("default", "cornell", row0); AddSkyboxButton("penguins", "dust", row0); AddSkyboxButton("penguins", "tropic", row0); @@ -330,15 +330,24 @@ public void ChangeSkybox(String skybox) { - //cameraView.envyoff = false; - group.skyboxname = skybox; - group.skyboxext = "jpg"; - cameraView.repaint(); + if (skybox.endsWith("/")) + { + group.skyboxname = null; + group.skyboxext = null; + cameraView.repaint(); + } + else + { + //cameraView.envyoff = false; + group.skyboxname = skybox; + group.skyboxext = "jpg"; + cameraView.repaint(); + } } public void CreateSkyboxPanel(cGridBag skyboxPanel) { - JTabbedPane skyboxpane = new JTabbedPane(); + JTabbedPane skyboxpane = new JTabbedPane(JTabbedPane.LEFT); AddSkyboxTab0(skyboxpane); AddSkyboxTab1(skyboxpane); @@ -396,11 +405,15 @@ this.copy = this.group = group; //selectees = this.group.selectees; - if (copy.versionlist == null) - { - copy.versionlist = new Object3D[100]; - copy.versionindex = -1; - } + assert(false); + +// if (copy.versionlist == null) +// { +// copy.versionlist = new Object3D[100]; +// copy.versionindex = -1; +// +// //Save(true); +// } if(ui) SetupUI(objEditor); @@ -423,13 +436,13 @@ ((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true); - if (copy.versionlist == null) - { - copy.versionlist = new Object3D[100]; - copy.versionindex = -1; - - Save(true); - } +// if (copy.versionlist == null) +// { +// copy.versionlist = new Object3D[100]; +// copy.versionindex = -1; +// +// //Save(true); +// } } void CloneSelection(boolean supports) @@ -519,33 +532,35 @@ // menu.add("-"); duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate")); duplicateItem.addActionListener(this); - cloneItem = menu.add(new MenuItem("Clone")); + + cloneItem = oe.jTree.popup.add(new JMenuItem("Clone")); cloneItem.addActionListener(this); - if (Globals.ADVANCED) + //if (Globals.ADVANCED) { cloneSupportItem = menu.add(new MenuItem("Clone (+supports)")); cloneSupportItem.addActionListener(this); } + oe.jTree.popup.addSeparator(); menu.add("-"); - cutItem = menu.add(new MenuItem("Cut")); + cutItem = oe.jTree.popup.add(new JMenuItem("Cut")); cutItem.addActionListener(this); - copyItem = menu.add(new MenuItem("Copy")); + copyItem = oe.jTree.popup.add(new JMenuItem("Copy")); copyItem.addActionListener(this); pasteItem = menu.add(new MenuItem("Paste")); pasteItem.addActionListener(this); - menu.add("-"); - pasteIntoItem = menu.add(new MenuItem("Paste into")); + oe.jTree.popup.addSeparator(); + //menu.add("-"); + pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into")); pasteIntoItem.addActionListener(this); - pasteLinkItem = menu.add(new MenuItem("Paste link")); + pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link")); pasteLinkItem.addActionListener(this); - pasteCloneItem = menu.add(new MenuItem("Paste clone")); + pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone")); pasteCloneItem.addActionListener(this); -// pasteExpandItem = menu.add(new MenuItem("Paste expand")); +// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand")); // pasteExpandItem.addActionListener(this); - menu.add("-"); - deleteItem = menu.add(new MenuItem("Delete")); - deleteItem.addActionListener(this); + //menu.add("-"); + oe.jTree.popup.addSeparator(); if (Globals.ADVANCED) { @@ -631,11 +646,9 @@ oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest")); //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection")); //cameraMenu.add(switchViewItem = new MenuItem("Reverse View")); - editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf")); oe.cameraMenu.add("-"); openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy...")); openWindowItem.addActionListener(this); - editLeafItem.addActionListener(this); lookAtItem.addActionListener(this); //lookFromItem.addActinoListener(this); //switchViewItem.addActionListener(this); @@ -682,9 +695,8 @@ setMasterItem.addActionListener(this); } - oe.menuBar.add(menu = new Menu("Group")); -// grabItem = menu.add(new MenuItem("Grab")); -// grabItem.addActionListener(this); + oe.menuBar.add(menu = new Menu("Order")); + backItem = menu.add(new MenuItem("Back")); backItem.addActionListener(this); frontItem = menu.add(new MenuItem("Front")); @@ -692,13 +704,21 @@ // compositeItem = menu.add(new MenuItem("Composite")); // compositeItem.addActionListener(this); + grabItem = oe.jTree.popup.add(new JMenuItem("Group")); + grabItem.addActionListener(this); + if (Globals.ADVANCED) { hideItem = menu.add(new MenuItem("Hidden Group")); hideItem.addActionListener(this); } - ungroupItem = menu.add(new MenuItem("Ungroup")); + ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup")); ungroupItem.addActionListener(this); + + oe.jTree.popup.addSeparator(); + + deleteItem = oe.jTree.popup.add(new JMenuItem("Delete")); + deleteItem.addActionListener(this); // menu.add("-"); // @@ -735,9 +755,9 @@ shadowYItem.addActionListener(this); shadowZItem = menu.add(new MenuItem("Shadow Blue")); shadowZItem.addActionListener(this); + attributeItem = menu.add(new MenuItem("Attribute")); attributeItem.addActionListener(this); - if (Globals.ADVANCED) { menu.add("-"); @@ -749,11 +769,18 @@ pointflowItem.addActionListener(this); } menu.add("-"); + textureRatioRItem = menu.add(new MenuItem("Texture Ratio Red")); + textureRatioRItem.addActionListener(this); + textureRatioGItem = menu.add(new MenuItem("Texture Ratio Green")); + textureRatioGItem.addActionListener(this); + textureRatioBItem = menu.add(new MenuItem("Texture Ratio Blue")); + textureRatioBItem.addActionListener(this); + menu.add("-"); resetTransformItem = menu.add(new MenuItem("Reset Transform")); resetTransformItem.addActionListener(this); resetCentroidItem = menu.add(new MenuItem("Reset Centroid")); resetCentroidItem.addActionListener(this); - resetCentroidXZItem = menu.add(new MenuItem("Reset Centroid XY")); + resetCentroidXZItem = menu.add(new MenuItem("Reset Centroid XZ")); resetCentroidXZItem.addActionListener(this); transformGeometryItem = menu.add(new MenuItem("Transform Geometry")); transformGeometryItem.addActionListener(this); @@ -805,6 +832,8 @@ } oe.menuBar.add(menu = new Menu("Attributes")); + clearVersionsItem = menu.add(new MenuItem("Clear Versions")); + clearVersionsItem.addActionListener(this); clearMaterialsItem = menu.add(new MenuItem("Clear Materials")); clearMaterialsItem.addActionListener(this); resetAllItem = menu.add(new MenuItem("Reset All")); @@ -827,9 +856,9 @@ hideleavesItem.addActionListener(this); showleavesItem = menu.add(new MenuItem("Show Leaves")); showleavesItem.addActionListener(this); - markleavesItem = menu.add(new MenuItem("Mark Leaves")); + markleavesItem = menu.add(new MenuItem("Anim Leaves")); markleavesItem.addActionListener(this); - unmarkleavesItem = menu.add(new MenuItem("Unmark Leaves")); + unmarkleavesItem = menu.add(new MenuItem("Unanim Leaves")); unmarkleavesItem.addActionListener(this); rewindleavesItem = menu.add(new MenuItem("Rewind Leaves")); rewindleavesItem.addActionListener(this); @@ -883,6 +912,9 @@ shareGeometriesItem.addActionListener(this); mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries")); mergeGeometriesItem.addActionListener(this); + menu.add("-"); + editLeafItem = menu.add(new MenuItem("Edit leaf...")); + editLeafItem.addActionListener(this); if (Globals.ADVANCED) { // Pretty much the same as duplicate and clone. @@ -901,8 +933,10 @@ JTabbedPane resourcecontainer; cGridBag currenttab; - boolean added; // patch for jar + //boolean added; // patch for jar + int totalcount = 0; + int tabcount = 0; int colcount = 0; int rowcount = 0; @@ -918,28 +952,30 @@ // System.out.println(); if (//rowcount == 0 || - path.length == 1) + path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store")) { currenttab = new cGridBag(); - added = false; String tabname = path[0]; // String.valueOf((char)('A'+tabcount)); currenttab.setName(tabname); + //added = false; + resourcecontainer.add(currenttab); + resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname); rowcount = 1; colcount = 0; texturecount = 0; } - if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg")) + if (path.length > 2 && (path[2].toLowerCase().endsWith(".jpg") || path[2].toLowerCase().endsWith(".png"))) { - if (!added) + //if (!added) { - added = true; - resourcecontainer.add(currenttab); + //added = true; String tabname = path[0]; // String.valueOf((char)('A'+tabcount)); - resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname); + currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname)); } - AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab); + AddTextureButton(path[0], path[1], path[2], ++texturecount, currenttab); + totalcount++; if (++colcount >= columns) { @@ -965,6 +1001,8 @@ container.add(resourcecontainer); Grafreed.ParseResources("textures", this); + + // 935. System.out.println("Total = " + totalcount); } void SetupUI2(ObjEditor oe) @@ -984,11 +1022,6 @@ //new Exception().printStackTrace(); oe.radioPanel = new JPanel(new GridBagLayout()); - oe.aConstraints.weightx = 1; - oe.aConstraints.weighty = 0; - oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; - oe.aConstraints.gridwidth = 100; - oe.aConstraints.gridheight = 1; // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints); oe.buttonGroup = new ButtonGroup(); @@ -1009,9 +1042,9 @@ oe.radioPanel.add(dummyButton); oe.buttonGroup.add(dummyButton); */ - cGridBag copyOptionsPanel = new cGridBag(); + cGridBag versionManagerPanel = new cGridBag(); - copyOptionsPanel.preferredHeight = 2; + versionManagerPanel.preferredHeight = 4; //this.AddOptions(oe.toolbarPanel, oe.aConstraints); @@ -1021,62 +1054,102 @@ if (Globals.ADVANCED) { - oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - maxButton.setToolTipText("Maximize window"); - maxButton.addActionListener(this); +// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); +// maxButton.setToolTipText("Maximize window"); +// maxButton.addActionListener(this); } - oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - fullButton.setToolTipText("Full-screen window"); - fullButton.addActionListener(this); + cButton gcButton; - oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); +// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); +// gcButton.setToolTipText("Garbage collect"); +// gcButton.addActionListener(new ActionListener() +// { +// public void actionPerformed(ActionEvent e) +// { +// System.gc(); +// } +// }); + + oe.toolbarPanel.add(fullScreenButton = GetButton("icons/fullscreen.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + fullScreenButton.setToolTipText("Full-screen window"); + fullScreenButton.addActionListener(this); + + oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + collapseButton.setToolTipText("Collapse toolbar"); + collapseButton.addActionListener(this); + +// oe.toolbarPanel.add(maximize3DButton = GetButton("icons/square.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); +// maximize3DButton.setToolTipText("Maximize 3D view"); +// maximize3DButton.addActionListener(this); + + oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + twoButton.setToolTipText("Show 3D view only"); + twoButton.addActionListener(this); + this.fullscreenLayout = twoButton; + + oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + threeButton.setToolTipText("Show controls and 3D view"); + threeButton.addActionListener(this); + if (Globals.ADVANCED) + { + oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + sixButton.setToolTipText("Show 3D view and controls"); + sixButton.addActionListener(this); + } +// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); +// sevenButton.setToolTipText("3-column layout"); +// sevenButton.addActionListener(this); + // + + oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); screenfitButton.setToolTipText("Screen fit"); screenfitButton.addActionListener(this); - oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); restoreCameraButton.setToolTipText("Restore viewpoint"); restoreCameraButton.addActionListener(this); - copyOptionsPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + versionManagerPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); saveVersionButton.setToolTipText("Duplicate current version"); saveVersionButton.addActionListener(this); - copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + versionManagerPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); deleteVersionButton.setToolTipText("Delete current version"); deleteVersionButton.addActionListener(this); + deleteVersionButton.setEnabled(false); - copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + versionManagerPanel.add(previousVersionButton = GetButton("icons/undo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); previousVersionButton.setToolTipText("Previous version"); previousVersionButton.addActionListener(this); previousVersionButton.setEnabled(false); cGridBag updown = new cGridBag().setVertical(true); - updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + updown.add(restoreButton = GetButton("icons/restore.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); restoreButton.setToolTipText("Undo (restore current version)"); restoreButton.addActionListener(this); - //restoreButton.setEnabled(false); + restoreButton.setEnabled(false); - updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + updown.add(replaceButton = GetButton("icons/replace.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); replaceButton.setToolTipText("Save (replace current version)"); replaceButton.addActionListener(this); - //replaceButton.setEnabled(false); + replaceButton.setEnabled(false); - copyOptionsPanel.add(updown); + versionManagerPanel.add(updown); - copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + versionManagerPanel.add(nextVersionButton = GetButton("icons/redo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); nextVersionButton.setToolTipText("Next version"); nextVersionButton.addActionListener(this); nextVersionButton.setEnabled(false); + + oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + oneStepButton.setToolTipText("Animate one step forward"); + oneStepButton.addActionListener(this); oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints); liveCB.setToolTipText("Enable animation"); liveCB.addItemListener(this); - oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - oneStepButton.setToolTipText("Animate one step forward"); - oneStepButton.addActionListener(this); - oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints); fastCB.setToolTipText("Fast mode"); fastCB.addItemListener(this); @@ -1092,38 +1165,23 @@ if (Globals.ADVANCED) { - oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Globals.NIMBUSLAF)); //, oe.aConstraints); snapobjectButton.addActionListener(this); snapobjectButton.setToolTipText("Snap Object"); - oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); fourButton.addActionListener(this); fourButton.setToolTipText("Show control panel only"); } //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL)); - oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - twoButton.setToolTipText("Show 3D view only"); - twoButton.addActionListener(this); - this.fullscreenLayout = twoButton; - - oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - threeButton.setToolTipText("Show controls and 3D view"); - threeButton.addActionListener(this); - oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - sixButton.setToolTipText("Show 3D view and controls"); - sixButton.addActionListener(this); -// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); -// sevenButton.setToolTipText("3-column layout"); -// sevenButton.addActionListener(this); - // - oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); rootButton.setToolTipText("Open selection in new tab"); rootButton.addActionListener(this); - oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); closeButton.setToolTipText("Close tab"); closeButton.addActionListener(this); //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints); @@ -1132,38 +1190,38 @@ cGridBag row1 = new cGridBag(); // INSERT - row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - gridButton.setToolTipText("Create grid"); + row1.add(gridButton = GetButton("icons/grid.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + gridButton.setToolTipText("Create ground"); gridButton.addActionListener(this); - row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row1.add(boxButton = GetButton("icons/box.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); boxButton.setToolTipText("Create box"); boxButton.addActionListener(this); - row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - sphereButton.setToolTipText("Create sphere"); - sphereButton.addActionListener(this); - - row1.add(coneButton = GetButton("icons/cone.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - coneButton.setToolTipText("Create cone"); - coneButton.addActionListener(this); - - row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - torusButton.setToolTipText("Create torus"); - torusButton.addActionListener(this); - - row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row1.add(superButton = GetButton("icons/super.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); superButton.setToolTipText("Create superellipsoid"); superButton.addActionListener(this); - if (Globals.ADVANCED) + row1.add(sphereButton = GetButton("icons/sphere.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + sphereButton.setToolTipText("Create sphere"); + sphereButton.addActionListener(this); + + row1.add(coneButton = GetButton("icons/cone.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + coneButton.setToolTipText("Create cone"); + coneButton.addActionListener(this); + + row1.add(torusButton = GetButton("icons/torus.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); + torusButton.setToolTipText("Create torus"); + torusButton.addActionListener(this); + + if (false) //Globals.ADVANCED) { - oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); kleinButton.setToolTipText("Create Klein bottle"); kleinButton.addActionListener(this); } - row1.add(particlesButton = GetButton("icons/particles.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row1.add(particlesButton = GetButton("icons/particles.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); particlesButton.setToolTipText("Create particle system"); particlesButton.addActionListener(this); @@ -1171,31 +1229,31 @@ cGridBag row2 = new cGridBag(); - row2.add(groupButton = GetButton("icons/group.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(groupButton = GetButton("icons/group.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); groupButton.setToolTipText("Create group"); groupButton.addActionListener(this); - row2.add(compositeButton = GetButton("icons/composite.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(compositeButton = GetButton("icons/composite.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); compositeButton.setToolTipText("Create composite"); compositeButton.addActionListener(this); - row2.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(switchButton = GetButton("icons/switch.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); switchButton.setToolTipText("Create item switcher"); switchButton.addActionListener(this); - row2.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(loopButton = GetButton("icons/loop.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); loopButton.setToolTipText("Create loop"); loopButton.addActionListener(this); - row2.add(textureButton = GetButton("icons/texture.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(textureButton = GetButton("icons/texture.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); textureButton.setToolTipText("Create texture"); textureButton.addActionListener(this); - row2.add(overlayButton = GetButton("icons/overlay.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(overlayButton = GetButton("icons/overlay.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); overlayButton.setToolTipText("Create overlay"); overlayButton.addActionListener(this); - row2.add(lightButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + row2.add(lightButton = GetButton("icons/light-bulb.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); lightButton.setToolTipText("Create light"); lightButton.addActionListener(this); @@ -1205,6 +1263,11 @@ CreateTexturePanel(textures); + int tabCount = resourcecontainer.getTabCount(); + + if (tabCount > 0) + resourcecontainer.setSelectedIndex((int)(Math.random() * tabCount)); + oe.toolboxPanel.add(textures); textures.preferredHeight = 100; @@ -1212,11 +1275,11 @@ CreateSkyboxPanel(oe.skyboxPanel); // EDIT panel - editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); editButton.setToolTipText("Pin selection controls"); editButton.addActionListener(this); - editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); uneditButton.setToolTipText("Unpin and remove selection controls"); uneditButton.addActionListener(this); @@ -1224,7 +1287,7 @@ allParamsButton.setToolTipText("Show all controls"); allParamsButton.addActionListener(this); - editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); clearPanelButton.setToolTipText("Clear all controls"); clearPanelButton.addActionListener(this); @@ -1232,7 +1295,7 @@ //unselectButton.setToolTipText("Unselect"); //unselectButton.addActionListener(this); - editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); flashSelectionButton.setToolTipText("Highlight selection"); flashSelectionButton.addActionListener(this); @@ -1255,6 +1318,8 @@ cGridBag jSPPanel = new cGridBag(); + jSPPanel.preferredHeight = 20; + JScrollPane jSP; //ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints); jSPPanel.add(jSP = new JScrollPane(oe.jTree)); //, oe.aConstraints); @@ -1263,11 +1328,11 @@ oe.treePanel.add(jSPPanel); oe.treePanel.Return(); - oe.treePanel.add(copyOptionsPanel); + oe.treePanel.add(versionManagerPanel); oe.treePanel.Return(); - cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0); - versionSlider = (cNumberSlider)sliderPane.getComponent(1); - sliderPane.preferredHeight = 1; + versionSliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0); + versionSlider = (cNumberSlider)versionSliderPane.getComponent(1); + versionSliderPane.preferredHeight = 3; // mainPanel.setDividerLocation(0.1); //1.0); mainPanel.setResizeWeight(0.4); @@ -1425,6 +1490,14 @@ void EditObject(Object3D obj) { + //assert(obj instanceof Composite); + +// if (obj.versionlist == null) +// { +// obj.versionlist = new Object3D[100]; +// obj.versionindex = -1; +// } + cRadio radioButton = new cRadio(obj.name); // June 2019. Patch to avoid bug with transparency. @@ -1449,6 +1522,7 @@ oe.SetupViews(); + if (Globals.DEBUG) System.out.println("SetupViews"); DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer( oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ?? @@ -1815,7 +1889,12 @@ TreePath path; public TransferableTreePath(TreePath tp) { - path = tp; + Object[] objs = new Object[tp.getPathCount()]; + for (int i=0; i<objs.length; i++) + { + objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID(); + } + path = new TreePath(objs); } public synchronized DataFlavor[] getTransferDataFlavors() { @@ -2047,24 +2126,24 @@ switch(axis) { case 0 : - vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z; - vert2.x = minima.x; vert2.y = maxima.y; vert2.z = minima.z; - vert3.x = minima.x; vert3.y = minima.y; vert3.z = maxima.z; - vert4.x = minima.x; vert4.y = maxima.y; vert4.z = maxima.z; + vert1.x = minima.x + 0.001f; vert1.y = minima.y; vert1.z = minima.z; + vert2.x = minima.x + 0.001f; vert2.y = maxima.y; vert2.z = minima.z; + vert3.x = minima.x + 0.001f; vert3.y = minima.y; vert3.z = maxima.z; + vert4.x = minima.x + 0.001f; vert4.y = maxima.y; vert4.z = maxima.z; norm = cVector.X; break; case 1 : - vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z; - vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z; - vert3.x = minima.x; vert3.y = minima.y; vert3.z = maxima.z; - vert4.x = maxima.x; vert4.y = minima.y; vert4.z = maxima.z; + vert1.x = minima.x; vert1.y = minima.y + 0.001f; vert1.z = minima.z; + vert2.x = maxima.x; vert2.y = minima.y + 0.001f; vert2.z = minima.z; + vert3.x = minima.x; vert3.y = minima.y + 0.001f; vert3.z = maxima.z; + vert4.x = maxima.x; vert4.y = minima.y + 0.001f; vert4.z = maxima.z; norm = cVector.Y; break; case 2 : - vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z; - vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z; - vert3.x = minima.x; vert3.y = maxima.y; vert3.z = minima.z; - vert4.x = maxima.x; vert4.y = maxima.y; vert4.z = minima.z; + vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z + 0.001f; + vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z + 0.001f; + vert3.x = minima.x; vert3.y = maxima.y; vert3.z = minima.z + 0.001f; + vert4.x = maxima.x; vert4.y = maxima.y; vert4.z = minima.z + 0.001f; norm = cVector.Z; break; } @@ -2105,7 +2184,11 @@ shadow.material = new cMaterial(obj.material); shadow.material.diffuse = 0.0001f; shadow.material.specular = 0.0001f; - //shadow.projectedVertices[1].x = 300; + shadow.material.opacity = 0.75f; + + AllocProjectedVertices(shadow); + + shadow.projectedVertices[1].x = 300; makeSomething(shadow); } @@ -2626,27 +2709,35 @@ } else if (source == loopItem || source == loopButton) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf(); - csg.count = 5; group(csg); + csg.count = 5; Composite child = new cGroup("Branch"); csg.addChild(child); child.addChild(csg); + } } else if (source == doubleItem) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf("Fork"); - csg.count = 5; group(csg); + csg.count = 5; Composite child = new cGroup("Branch A"); csg.addChild(child); child.addChild(csg); child = new cGroup("Branch B"); csg.addChild(child); child.addChild(csg); + } } else if (source == tripleItem) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf("Trident"); csg.count = 4; group(csg); @@ -2659,6 +2750,7 @@ child = new cGroup(); csg.addChild(child); child.addChild(csg); + } } else if (source == computeAOItem) { @@ -2705,10 +2797,22 @@ { Maximize(); } else - if (source == fullButton) + if (source == fullScreenButton) { ToggleFullScreen(); } else + if (source == collapseButton) + { + this.expandedLayout = radio.layout; + CollapseToolbar(); + } else +// if (source == maximize3DButton) +// { +// this.expandedLayout = radio.layout; +// radio.layout = twoButton; +// CollapseToolbar(); +// Show3DView(); +// } else if (source == previousVersionButton) { // Go to previous version @@ -3282,22 +3386,34 @@ } else if (source == ungroupItem || source == ungroupButton) { - boolean hasRoot = false; + boolean canUngroup = true; for (int i=0; i<group.selection.size(); i++) { - if (group.selection.get(i) == group) + Object3D selectedItem = group.selection.get(i); + + if (selectedItem.Size() == 0) { - hasRoot = true; + // Cannot ungroup leaves + canUngroup = false; + break; + } + + if (selectedItem == group) + { + // Cannot ungroup root + canUngroup = false; break; } } - if (!hasRoot) + if (canUngroup) { for (int i=0; i<group.selection.size(); i++) { - Ungroup(group.selection.get(i)); + Object3D selectedItem = group.selection.get(i); + + Ungroup(selectedItem); } ClearSelection(false); @@ -3348,6 +3464,10 @@ if (source == clearMaterialsItem) { ClearMaterials(); + } else + if (source == clearVersionsItem) + { + ClearVersions(); } else if (source == liveleavesItem) { @@ -3488,6 +3608,18 @@ if (source == transformChildrenItem) { TransformChildren(); + } else + if (source == textureRatioRItem) + { + TextureRatio(0); + } else + if (source == textureRatioGItem) + { + TextureRatio(1); + } else + if (source == textureRatioBItem) + { + TextureRatio(2); } else if (source == resetTransformItem) { @@ -3660,38 +3792,7 @@ if (CameraPane.FULLSCREEN) fullscreenLayout = radio.layout; - // bug - //gridPanel.setDividerLocation(1.0); - //bigPanel.setDividerLocation(0.0); -// bigThree.remove(scenePanel); -// bigThree.remove(centralPanel); -// bigThree.remove(XYZPanel); -// aWindowConstraints.gridx = 0; -// aWindowConstraints.gridy = 0; -// aWindowConstraints.gridwidth = 1; -// // aConstraints.gridheight = 3; -// aWindowConstraints.fill = GridBagConstraints.VERTICAL; -// aWindowConstraints.weightx = 0; -// aWindowConstraints.weighty = 1; -// //bigThree.add(jtp, aWindowConstraints); -// aWindowConstraints.weightx = 1; -// aWindowConstraints.gridwidth = 3; -// // aConstraints.gridheight = 3; -// aWindowConstraints.gridx = 1; -// aWindowConstraints.fill = GridBagConstraints.BOTH; -// bigThree.add(centralPanel, aWindowConstraints); -// aWindowConstraints.weightx = 0; -// aWindowConstraints.gridx = 4; -// aWindowConstraints.gridwidth = 1; -// // aConstraints.gridheight = 3; -// aWindowConstraints.fill = GridBagConstraints.VERTICAL; -// //bigThree.add(XYZPanel, aWindowConstraints); -// scenePanel.setVisible(false); -// centralPanel.setVisible(true); -// XYZPanel.setVisible(false); - bigThree.ClearUI(); - bigThree.add(centralPanel); - bigThree.FlushUI(); + Show3DView(); cameraView.requestFocusInWindow(); @@ -3877,6 +3978,7 @@ } else if (source == rootButton) { + Replace(); Object3D obj; for (Enumeration e = group.selection.elements(); e.hasMoreElements();) { @@ -3891,6 +3993,9 @@ if (source == closeButton) { //System.out.println("CLOSE: " + buttonGroup.getSelection()); + if (copy.versionlist != null) + Replace(); + cRadio ab; for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) { @@ -3989,6 +4094,9 @@ } else if(source instanceof cRadio) { + if (copy.versionlist != null) + Replace(); + group.parent = keepparent; group.attributes = 0; //group.editWindow = null; @@ -4013,8 +4121,6 @@ copy = group; - SetUndoStates(); - //Globals.theRenderer.object = group; if(!useclient) { @@ -4042,6 +4148,32 @@ */ radio.layout.doClick(); + //assert(copy instanceof Composite); + + if (copy.versionlist == null) + { + copy.versionindex = -1; + + // Cannot work with loops + // To fix this issue, we first mark all nodes above the root, + // and check if any of these nodes are reachable below the root. + Grafreed.grafreed.universe.TagObjects(copy, true); + + if (copy instanceof Composite && !copy.HasTags()) + { + if (copy.versionlist == null) + copy.versionlist = new Object3D[100]; + + //Save(true); + } + else + copy.versionindex = -2; + + Grafreed.grafreed.universe.TagObjects(copy, false); + } + + SetVersionStates(); + ClearUnpinned(); //Grafreed.Assert(group != null); @@ -4155,6 +4287,18 @@ refreshContents(); } + void TextureRatio(int axis) + { + Object3D obj; + for (Enumeration e = group.selection.elements(); e.hasMoreElements();) + { + obj = (Object3D)e.nextElement(); + obj.TextureRatio(axis); + } + + refreshContents(); + } + void ResetTransform() { ResetTransform(-1); @@ -4170,42 +4314,8 @@ if (obj.toParent == null) continue; - if (mask == -1) - { - if (obj instanceof Camera) // jan 2014 - { - LA.matIdentity(obj.toParent); - LA.matIdentity(obj.fromParent); - } - else - { - obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent); - obj.fromParent = null; // LA.matIdentity(obj.fromParent); - } - TouchTransform(obj); - continue; - } - if ((mask&2) != 0) // Scale - { - obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1; - obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0; - obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0; - obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1; - obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0; - obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0; - } - if ((mask&4) != 0) // Rotation - { - // ? - } - if ((mask&1) != 0) // Translation - { - if (obj.toParent != null) - { - obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0; - obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0; - } - } + obj.ResetTransform(mask); + if (obj.parent == null) { System.out.println("NULL PARENT!"); @@ -4714,6 +4824,12 @@ { Object3D obj = group.selection.get(i); + if (obj.toParent == null) + { + obj.toParent = LA.newMatrix(); + obj.fromParent = LA.newMatrix(); + } + LA.matTranslate(obj.toParent, i * scale, 0, 0); LA.matTranslateInv(obj.fromParent, -i * scale, 0, 0); } @@ -5005,6 +5121,12 @@ refreshContents(); } + void ClearVersions() + { + group.selection.ClearVersions(); + refreshContents(); + } + void FlipV(boolean flip) { group.selection.FlipV(flip); @@ -5243,7 +5365,7 @@ if (tps != null && tps.length > 0 && tps[0].getLastPathComponent() instanceof Camera) // a camera { - if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crash the camera because of invalid lightspace + if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crashes the camera because of invalid lightspace { CameraPane.camerachangeframe = 0; // don't refuse it Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent()); @@ -5276,10 +5398,26 @@ flashSelectionButton.setEnabled(enabled); clearPanelButton.setEnabled(!listUI.isEmpty()); + + boolean allComposites = true; + + if (group.selection != null) + for (Enumeration e = group.selection.elements(); e.hasMoreElements();) + { + Object next = e.nextElement(); + if (!(next instanceof Composite)) // || (next instanceof GroupLeaf)) + { + allComposites = false; + break; + } + } + + rootButton.setEnabled(true); // allComposites); } void refreshContents(boolean cp) { + if (Globals.SHOWINFO) //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info")) if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING) { @@ -5290,7 +5428,7 @@ Object3D child = (Object3D) group.selection.get(i); objEditor.AddInfo(child, this, true); - System.err.println("info : " + child.GetPath()); +// System.err.println("info : " + child.GetPath()); } objEditor.SetText(); // jan 2014 @@ -6173,11 +6311,11 @@ private MenuItem lookAtItem; private MenuItem lookFromItem; private MenuItem switchViewItem; - private MenuItem cutItem; + private JMenuItem cutItem; private MenuItem undoItem; private MenuItem redoItem; private JMenuItem duplicateItem; - private MenuItem cloneItem; + private JMenuItem cloneItem; private MenuItem cloneSupportItem; private MenuItem overwriteGeoItem; private MenuItem overwriteMatItem; @@ -6198,13 +6336,13 @@ private MenuItem cloneGeometriesItem; private MenuItem shareGeometriesItem; private MenuItem mergeGeometriesItem; - private MenuItem copyItem; + private JMenuItem copyItem; private MenuItem pasteItem; - private MenuItem pasteIntoItem; - private MenuItem pasteLinkItem; - private MenuItem pasteCloneItem; - private MenuItem pasteExpandItem; - private MenuItem deleteItem; + private JMenuItem pasteIntoItem; + private JMenuItem pasteLinkItem; + private JMenuItem pasteCloneItem; + private JMenuItem pasteExpandItem; + private JMenuItem deleteItem; private MenuItem clearAllItem; private MenuItem genUVItem; private MenuItem genNormalsMESHItem; @@ -6230,6 +6368,7 @@ private MenuItem clipMeshItem; private MenuItem smoothMeshItem; private MenuItem clearMaterialsItem; + private MenuItem clearVersionsItem; private MenuItem liveleavesItem; private MenuItem unliveleavesItem; @@ -6253,13 +6392,16 @@ private MenuItem maxTexturesItem; private MenuItem panoTexturesItem; + private MenuItem textureRatioRItem; + private MenuItem textureRatioGItem; + private MenuItem textureRatioBItem; private MenuItem resetCentroidItem; private MenuItem resetCentroidXZItem; private MenuItem resetTransformItem; private MenuItem transformGeometryItem; private MenuItem transformChildrenItem; private MenuItem hideItem; - private MenuItem grabItem; + private JMenuItem grabItem; private MenuItem backItem; private MenuItem frontItem; private MenuItem cameraItem; @@ -6272,7 +6414,7 @@ private MenuItem switchTransfoItem; private MenuItem morphItem; private MenuItem linkerItem; - private MenuItem ungroupItem; + private JMenuItem ungroupItem; private MenuItem editItem; private MenuItem openWindowItem; private MenuItem editLeafItem; -- Gitblit v1.6.2