From cbe4e90105d07d7d3fecabffaa01342403aa2ae3 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Thu, 19 Sep 2019 20:54:00 -0400 Subject: [PATCH] Better navigation. --- GroupEditor.java | 486 ++++++++++++++++++++++++++++++++--------------------- 1 files changed, 291 insertions(+), 195 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index b32dee9..d328971 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -29,7 +29,7 @@ { 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.equals("") ? "No background" : s); skyboxButton.addActionListener(new ActionListener() @@ -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() { @@ -347,7 +347,7 @@ public void CreateSkyboxPanel(cGridBag skyboxPanel) { - JTabbedPane skyboxpane = new JTabbedPane(); + JTabbedPane skyboxpane = new JTabbedPane(JTabbedPane.LEFT); AddSkyboxTab0(skyboxpane); AddSkyboxTab1(skyboxpane); @@ -366,16 +366,6 @@ } refreshContents(); - } - - public void Show3DView() - { - // bug - //gridPanel.setDividerLocation(1.0); - //bigPanel.setDividerLocation(0.0); - bigThree.ClearUI(); - bigThree.add(centralPanel); - bigThree.FlushUI(); } //ObjEditor objEditor; @@ -415,13 +405,15 @@ this.copy = this.group = group; //selectees = this.group.selectees; - if (copy.versionlist == null) - { - copy.versionlist = new Object3D[100]; - copy.versionindex = -1; - - Save(true); - } + assert(false); + +// if (copy.versionlist == null) +// { +// copy.versionlist = new Object3D[100]; +// copy.versionindex = -1; +// +// //Save(true); +// } if(ui) SetupUI(objEditor); @@ -444,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) @@ -491,11 +483,16 @@ Object3D parent = obj.parent; obj.parent = null; + // Object3D support = obj.support; // obj.support = null; if (!supports) obj.SaveSupports(); + Object3D clone = (Object3D)Grafreed.clone(obj); + + clone.ResetUUIDs(); + obj.parent = parent; // obj.support = support; // clone.support = support; // aout 2013 @@ -565,13 +562,12 @@ pasteLinkItem.addActionListener(this); pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone")); pasteCloneItem.addActionListener(this); -// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand")); -// pasteExpandItem.addActionListener(this); +// CRASH + pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand")); +// + pasteExpandItem.addActionListener(this); //menu.add("-"); oe.jTree.popup.addSeparator(); - - deleteItem = oe.jTree.popup.add(new JMenuItem("Delete")); - deleteItem.addActionListener(this); if (Globals.ADVANCED) { @@ -706,15 +702,17 @@ 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")); frontItem.addActionListener(this); // compositeItem = menu.add(new MenuItem("Composite")); // compositeItem.addActionListener(this); + + grabItem = oe.jTree.popup.add(new JMenuItem("Group")); + grabItem.addActionListener(this); if (Globals.ADVANCED) { @@ -723,6 +721,11 @@ } 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("-"); // @@ -759,9 +762,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("-"); @@ -773,11 +776,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); @@ -793,7 +803,7 @@ genNormalsCADItem.addActionListener(this); genNormalsMESHItem = menu.add(new MenuItem("Mesh Normals")); genNormalsMESHItem.addActionListener(this); - if (Globals.ADVANCED) + //if (Globals.ADVANCED) { genNormalsMINEItem = menu.add(new MenuItem("Stitch Normals")); genNormalsMINEItem.addActionListener(this); @@ -829,6 +839,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")); @@ -851,9 +863,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); @@ -928,8 +940,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; @@ -940,33 +954,40 @@ public void ResourceCallBack(String[] path) { - for (int i = 0; i < path.length; i++) - System.out.print(path[i] + "/"); - System.out.println(); +// for (int i = 0; i < path.length; i++) +// System.out.print(path[i] + "/"); +// 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 " + 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); + columns = 5; + + if (path[0].contains("D&R") || path[0].contains("Paint")) + columns = 4; + + AddTextureButton(path[0], path[1], path[2], ++texturecount, currenttab); + totalcount++; if (++colcount >= columns) { @@ -992,6 +1013,8 @@ container.add(resourcecontainer); Grafreed.ParseResources("textures", this); + + // 935. System.out.println("Total = " + totalcount); } void SetupUI2(ObjEditor oe) @@ -1031,9 +1054,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); @@ -1060,25 +1083,29 @@ // } // }); - oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + 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("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - maximize3DButton.setToolTipText("Maximize 3D view"); - maximize3DButton.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", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + 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", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + 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", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); sixButton.setToolTipText("Show 3D view and controls"); sixButton.addActionListener(this); } @@ -1087,50 +1114,47 @@ // sevenButton.addActionListener(this); // - oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - fullButton.setToolTipText("Full-screen window"); - fullButton.addActionListener(this); - - oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + 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", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Globals.NIMBUSLAF)); //, oe.aConstraints); oneStepButton.setToolTipText("Animate one step forward"); oneStepButton.addActionListener(this); @@ -1153,11 +1177,11 @@ 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"); } @@ -1165,83 +1189,85 @@ //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL)); - 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); //clearButton.addActionListener(this); cGridBag row1 = new cGridBag(); + row1.preferredHeight = 8; // INSERT - row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + 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); oe.toolboxPanel.add(row1); cGridBag row2 = new cGridBag(); + row2.preferredHeight = 8; - 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); @@ -1251,6 +1277,11 @@ CreateTexturePanel(textures); + int tabCount = resourcecontainer.getTabCount(); + + if (tabCount > 0) + resourcecontainer.setSelectedIndex((int)(Math.random() * tabCount)); + oe.toolboxPanel.add(textures); textures.preferredHeight = 100; @@ -1258,11 +1289,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); @@ -1270,7 +1301,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); @@ -1278,7 +1309,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); @@ -1301,6 +1332,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); @@ -1309,11 +1342,12 @@ 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); @@ -1370,7 +1404,7 @@ // supportCB.setToolTipText("Enable rigging"); // supportCB.addItemListener(this); - panel.add(freezeCB = new cCheckBox("Freeze", Globals.FREEZEONMOVE)); //, constraints); + panel.add(freezeCB = new cCheckBox("Fast cam", Globals.FREEZEONMOVE)); //, constraints); freezeCB.setToolTipText("Fast moving camera"); freezeCB.addItemListener(this); @@ -1379,9 +1413,12 @@ panel.Return(); + if (Globals.ADVANCED) + { panel.add(crowdCB = new cCheckBox("Crowd", Globals.CROWD)); //, constraints); crowdCB.setToolTipText("Used for crowds"); crowdCB.addItemListener(this); + } panel.add(smoothCB = new cCheckBox("Inertia", CameraPane.INERTIA)); //, constraints); smoothCB.setToolTipText("Snapping delay"); @@ -1394,30 +1431,26 @@ minshaderCB.setToolTipText("Minimal fast shader"); minshaderCB.addItemListener(this); -// constraints.gridy += 1; // panel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), constraints); // speakerMocapCB.addItemListener(this); - panel.Return(); - if (false) { // handled in scripts - //constraints.gridy += 1; panel.add(speakerCameraCB = new cCheckBox("Cam", CameraPane.SPEAKERCAMERA)); //, constraints); speakerCameraCB.addItemListener(this); - //constraints.gridy += 1; panel.add(speakerFocusCB = new cCheckBox("Focus", CameraPane.SPEAKERFOCUS)); //, constraints); speakerFocusCB.addItemListener(this); - //constraints.gridy += 1; - panel.add(smoothfocusCB = new cCheckBox("Smooth", CameraPane.SMOOTHFOCUS)); //, constraints); - smoothfocusCB.addItemListener(this); panel.Return(); } -//constraints.gridx += 1; + panel.add(smoothfocusCB = new cCheckBox("Smooth", CameraPane.SMOOTHFOCUS)); //, constraints); + smoothfocusCB.addItemListener(this); + + panel.Return(); + //panel.add(debugCB = new cCheckBox("Debug", CameraPane.DEBUG), constraints); // debugCB.addItemListener(this); @@ -1471,7 +1504,7 @@ void EditObject(Object3D obj) { - assert(obj instanceof Composite); + //assert(obj instanceof Composite); // if (obj.versionlist == null) // { @@ -1503,6 +1536,7 @@ oe.SetupViews(); + if (Globals.DEBUG) System.out.println("SetupViews"); DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer( oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ?? @@ -2055,7 +2089,7 @@ Object3D obj = (Object3D)group.selection.elementAt(0); objEditor.ScreenFit(obj, false); - cameraView.pingthread.StepToTarget(true); + cameraView.pingthread.StepToTarget(); //true); refreshContents(); } @@ -2092,7 +2126,7 @@ obj.parent.TransformToWorld(maxima); //, maxima); } - Object3D shadow = new Object3D("Shadow " + obj.name); + Object3D shadow = new Object3D("Shadow" + obj.name); shadow.toParent = LA.newMatrix(); shadow.fromParent = LA.newMatrix(); @@ -2106,24 +2140,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; } @@ -2164,7 +2198,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); } @@ -2688,11 +2726,11 @@ if (!group.selection.isEmpty()) { Composite csg = new GroupLeaf(); + group(csg); csg.count = 5; Composite child = new cGroup("Branch"); csg.addChild(child); child.addChild(csg); - group(csg); } } else if (source == doubleItem) @@ -2700,6 +2738,7 @@ if (!group.selection.isEmpty()) { Composite csg = new GroupLeaf("Fork"); + group(csg); csg.count = 5; Composite child = new cGroup("Branch A"); csg.addChild(child); @@ -2707,7 +2746,6 @@ child = new cGroup("Branch B"); csg.addChild(child); child.addChild(csg); - group(csg); } } else if (source == tripleItem) @@ -2773,7 +2811,7 @@ { Maximize(); } else - if (source == fullButton) + if (source == fullScreenButton) { ToggleFullScreen(); } else @@ -2782,13 +2820,13 @@ this.expandedLayout = radio.layout; CollapseToolbar(); } else - if (source == maximize3DButton) - { - this.expandedLayout = radio.layout; - radio.layout = twoButton; - Show3DView(); - CollapseToolbar(); - } else +// if (source == maximize3DButton) +// { +// this.expandedLayout = radio.layout; +// radio.layout = twoButton; +// CollapseToolbar(); +// Show3DView(); +// } else if (source == previousVersionButton) { // Go to previous version @@ -2816,7 +2854,7 @@ if (source == saveVersionButton) { // Save a new version - if (!Save(true)) + if (!DuplicateVersion()) //true)) java.awt.Toolkit.getDefaultToolkit().beep(); } else if (source == deleteVersionButton) @@ -3441,6 +3479,10 @@ { ClearMaterials(); } else + if (source == clearVersionsItem) + { + ClearVersions(); + } else if (source == liveleavesItem) { LiveLeaves(true); @@ -3580,6 +3622,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) { @@ -3953,6 +4007,9 @@ if (source == closeButton) { //System.out.println("CLOSE: " + buttonGroup.getSelection()); + if (copy.versionlist != null) + Replace(); + cRadio ab; for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) { @@ -4051,6 +4108,9 @@ } else if(source instanceof cRadio) { + if (copy.versionlist != null) + Replace(); + group.parent = keepparent; group.attributes = 0; //group.editWindow = null; @@ -4102,14 +4162,28 @@ */ radio.layout.doClick(); - assert(copy instanceof Composite); + //assert(copy instanceof Composite); if (copy.versionlist == null) { - copy.versionlist = new Object3D[100]; copy.versionindex = -1; - Save(true); + // 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(); @@ -4227,9 +4301,46 @@ 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); + } + + void ScaleSelection(int scale) + { + Object3D obj; + for (Enumeration e = group.selection.elements(); e.hasMoreElements();) + { + obj = (Object3D)e.nextElement(); + + if (obj.toParent == null) + continue; + + obj.Scale(scale); + + if (obj.parent == null) + { + System.out.println("NULL PARENT!"); + // new Exception().printStackTrace(); + } + else + TouchTransform(obj); + //obj.parent.Touch(); + } + + refreshContents(); } void ResetTransform(int mask) @@ -4242,42 +4353,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!"); @@ -4786,10 +4863,17 @@ { 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); } + Globals.lighttouched = true; refreshContents(); } @@ -5077,6 +5161,12 @@ refreshContents(); } + void ClearVersions() + { + group.selection.ClearVersions(); + refreshContents(); + } + void FlipV(boolean flip) { group.selection.FlipV(flip); @@ -5315,10 +5405,10 @@ 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()); + Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent(), true); } // Globals.theRenderer.renderCamera = Globals.theRenderer.manipCamera; // Globals.theRenderer.eyeCamera = Globals.theRenderer.manipCamera; @@ -5354,18 +5444,20 @@ if (group.selection != null) for (Enumeration e = group.selection.elements(); e.hasMoreElements();) { - if (!(e.nextElement() instanceof Composite)) + Object next = e.nextElement(); + if (!(next instanceof Composite)) // || (next instanceof GroupLeaf)) { allComposites = false; break; } } - rootButton.setEnabled(allComposites); + 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) { @@ -6316,6 +6408,7 @@ private MenuItem clipMeshItem; private MenuItem smoothMeshItem; private MenuItem clearMaterialsItem; + private MenuItem clearVersionsItem; private MenuItem liveleavesItem; private MenuItem unliveleavesItem; @@ -6339,13 +6432,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; -- Gitblit v1.6.2