From 64e20f390e4b8e58bd0006dde8fa10fba1dac1d5 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Fri, 16 Aug 2019 13:25:19 -0400 Subject: [PATCH] Fix box and VR keys. --- GroupEditor.java | 136 +++++++++++++++++++++++++++++---------------- 1 files changed, 88 insertions(+), 48 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index 9f3c422..cff60a6 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -540,33 +540,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) { @@ -701,9 +703,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")); @@ -711,13 +712,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("-"); // @@ -923,7 +932,7 @@ JTabbedPane resourcecontainer; cGridBag currenttab; - boolean added; // patch for jar + //boolean added; // patch for jar int tabcount = 0; int colcount = 0; @@ -940,12 +949,14 @@ // 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; @@ -953,12 +964,11 @@ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg")) { - 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); @@ -1059,7 +1069,7 @@ collapseButton.setToolTipText("Collapse toolbar"); collapseButton.addActionListener(this); - oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + oe.toolbarPanel.add(maximize3DButton = GetButton("icons/empty.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); maximize3DButton.setToolTipText("Maximize 3D view"); maximize3DButton.addActionListener(this); @@ -1181,6 +1191,10 @@ boxButton.setToolTipText("Create box"); boxButton.addActionListener(this); + row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + superButton.setToolTipText("Create superellipsoid"); + superButton.addActionListener(this); + row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); sphereButton.setToolTipText("Create sphere"); sphereButton.addActionListener(this); @@ -1192,10 +1206,6 @@ 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); - superButton.setToolTipText("Create superellipsoid"); - superButton.addActionListener(this); if (Globals.ADVANCED) { @@ -1498,6 +1508,7 @@ oe.SetupViews(); + if (Globals.DEBUG) System.out.println("SetupViews"); DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer( oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ?? @@ -2159,7 +2170,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); } @@ -2680,27 +2695,35 @@ } else if (source == loopItem || source == loopButton) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf(); csg.count = 5; - group(csg); Composite child = new cGroup("Branch"); csg.addChild(child); child.addChild(csg); + group(csg); + } } else if (source == doubleItem) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf("Fork"); csg.count = 5; - group(csg); Composite child = new cGroup("Branch A"); csg.addChild(child); child.addChild(csg); child = new cGroup("Branch B"); csg.addChild(child); child.addChild(csg); + group(csg); + } } else if (source == tripleItem) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf("Trident"); csg.count = 4; group(csg); @@ -2713,6 +2736,7 @@ child = new cGroup(); csg.addChild(child); child.addChild(csg); + } } else if (source == computeAOItem) { @@ -3348,22 +3372,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); @@ -4083,7 +4119,10 @@ copy.versionlist = new Object3D[100]; copy.versionindex = -1; - Save(true); + // Cannot work with loops + // To fix this issue, first mark all nodes above the root, + // and check if any of these nodes are reachable below the root. + //Save(true); } SetVersionStates(); @@ -5328,7 +5367,8 @@ 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; @@ -6233,11 +6273,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; @@ -6258,13 +6298,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; @@ -6319,7 +6359,7 @@ private MenuItem transformGeometryItem; private MenuItem transformChildrenItem; private MenuItem hideItem; - private MenuItem grabItem; + private JMenuItem grabItem; private MenuItem backItem; private MenuItem frontItem; private MenuItem cameraItem; @@ -6332,7 +6372,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