Normand Briere
2019-08-17 5892f05411c3d4dce2d8a59e0966dc2e1843a971
GroupEditor.java
....@@ -415,12 +415,14 @@
415415 this.copy = this.group = group;
416416 //selectees = this.group.selectees;
417417
418
+ assert(false);
419
+
418420 if (copy.versionlist == null)
419421 {
420422 copy.versionlist = new Object3D[100];
421423 copy.versionindex = -1;
422424
423
- Save(true);
425
+ //Save(true);
424426 }
425427
426428 if(ui)
....@@ -449,7 +451,7 @@
449451 copy.versionlist = new Object3D[100];
450452 copy.versionindex = -1;
451453
452
- Save(true);
454
+ //Save(true);
453455 }
454456 }
455457
....@@ -540,33 +542,35 @@
540542 // menu.add("-");
541543 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
542544 duplicateItem.addActionListener(this);
543
- cloneItem = menu.add(new MenuItem("Clone"));
545
+
546
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
544547 cloneItem.addActionListener(this);
545
- if (Globals.ADVANCED)
548
+ //if (Globals.ADVANCED)
546549 {
547550 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
548551 cloneSupportItem.addActionListener(this);
549552 }
553
+ oe.jTree.popup.addSeparator();
550554 menu.add("-");
551
- cutItem = menu.add(new MenuItem("Cut"));
555
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
552556 cutItem.addActionListener(this);
553
- copyItem = menu.add(new MenuItem("Copy"));
557
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
554558 copyItem.addActionListener(this);
555559 pasteItem = menu.add(new MenuItem("Paste"));
556560 pasteItem.addActionListener(this);
557561
558
- menu.add("-");
559
- pasteIntoItem = menu.add(new MenuItem("Paste into"));
562
+ oe.jTree.popup.addSeparator();
563
+ //menu.add("-");
564
+ pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into"));
560565 pasteIntoItem.addActionListener(this);
561
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
566
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
562567 pasteLinkItem.addActionListener(this);
563
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
568
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
564569 pasteCloneItem.addActionListener(this);
565
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
570
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
566571 // pasteExpandItem.addActionListener(this);
567
- menu.add("-");
568
- deleteItem = menu.add(new MenuItem("Delete"));
569
- deleteItem.addActionListener(this);
572
+ //menu.add("-");
573
+ oe.jTree.popup.addSeparator();
570574
571575 if (Globals.ADVANCED)
572576 {
....@@ -701,9 +705,8 @@
701705 setMasterItem.addActionListener(this);
702706 }
703707
704
- oe.menuBar.add(menu = new Menu("Group"));
705
-// grabItem = menu.add(new MenuItem("Grab"));
706
-// grabItem.addActionListener(this);
708
+ oe.menuBar.add(menu = new Menu("Order"));
709
+
707710 backItem = menu.add(new MenuItem("Back"));
708711 backItem.addActionListener(this);
709712 frontItem = menu.add(new MenuItem("Front"));
....@@ -711,13 +714,21 @@
711714 // compositeItem = menu.add(new MenuItem("Composite"));
712715 // compositeItem.addActionListener(this);
713716
717
+ grabItem = oe.jTree.popup.add(new JMenuItem("Group"));
718
+ grabItem.addActionListener(this);
719
+
714720 if (Globals.ADVANCED)
715721 {
716722 hideItem = menu.add(new MenuItem("Hidden Group"));
717723 hideItem.addActionListener(this);
718724 }
719
- ungroupItem = menu.add(new MenuItem("Ungroup"));
725
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
720726 ungroupItem.addActionListener(this);
727
+
728
+ oe.jTree.popup.addSeparator();
729
+
730
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
731
+ deleteItem.addActionListener(this);
721732
722733 // menu.add("-");
723734 //
....@@ -923,7 +934,7 @@
923934
924935 JTabbedPane resourcecontainer;
925936 cGridBag currenttab;
926
- boolean added; // patch for jar
937
+ //boolean added; // patch for jar
927938
928939 int tabcount = 0;
929940 int colcount = 0;
....@@ -940,12 +951,14 @@
940951 // System.out.println();
941952
942953 if (//rowcount == 0 ||
943
- path.length == 1)
954
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
944955 {
945956 currenttab = new cGridBag();
946
- added = false;
947957 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
948958 currenttab.setName(tabname);
959
+ //added = false;
960
+ resourcecontainer.add(currenttab);
961
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
949962 rowcount = 1;
950963 colcount = 0;
951964 texturecount = 0;
....@@ -953,12 +966,11 @@
953966
954967 if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
955968 {
956
- if (!added)
969
+ //if (!added)
957970 {
958
- added = true;
959
- resourcecontainer.add(currenttab);
971
+ //added = true;
960972 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
961
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
973
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
962974 }
963975
964976 AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
....@@ -1028,7 +1040,7 @@
10281040 */
10291041 cGridBag copyOptionsPanel = new cGridBag();
10301042
1031
- copyOptionsPanel.preferredHeight = 2;
1043
+ copyOptionsPanel.preferredHeight = 3;
10321044
10331045 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
10341046
....@@ -1043,8 +1055,8 @@
10431055 // maxButton.addActionListener(this);
10441056 }
10451057
1046
-// cButton gcButton;
1047
-//
1058
+ cButton gcButton;
1059
+
10481060 // oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10491061 // gcButton.setToolTipText("Garbage collect");
10501062 // gcButton.addActionListener(new ActionListener()
....@@ -1059,7 +1071,7 @@
10591071 collapseButton.setToolTipText("Collapse toolbar");
10601072 collapseButton.addActionListener(this);
10611073
1062
- oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1074
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/empty.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10631075 maximize3DButton.setToolTipText("Maximize 3D view");
10641076 maximize3DButton.addActionListener(this);
10651077
....@@ -1101,6 +1113,7 @@
11011113 copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11021114 deleteVersionButton.setToolTipText("Delete current version");
11031115 deleteVersionButton.addActionListener(this);
1116
+ deleteVersionButton.setEnabled(false);
11041117
11051118 copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11061119 previousVersionButton.setToolTipText("Previous version");
....@@ -1111,12 +1124,12 @@
11111124 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11121125 restoreButton.setToolTipText("Undo (restore current version)");
11131126 restoreButton.addActionListener(this);
1114
- //restoreButton.setEnabled(false);
1127
+ restoreButton.setEnabled(false);
11151128
11161129 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11171130 replaceButton.setToolTipText("Save (replace current version)");
11181131 replaceButton.addActionListener(this);
1119
- //replaceButton.setEnabled(false);
1132
+ replaceButton.setEnabled(false);
11201133
11211134 copyOptionsPanel.add(updown);
11221135
....@@ -1181,6 +1194,10 @@
11811194 boxButton.setToolTipText("Create box");
11821195 boxButton.addActionListener(this);
11831196
1197
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1198
+ superButton.setToolTipText("Create superellipsoid");
1199
+ superButton.addActionListener(this);
1200
+
11841201 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11851202 sphereButton.setToolTipText("Create sphere");
11861203 sphereButton.addActionListener(this);
....@@ -1192,10 +1209,6 @@
11921209 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11931210 torusButton.setToolTipText("Create torus");
11941211 torusButton.addActionListener(this);
1195
-
1196
- row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1197
- superButton.setToolTipText("Create superellipsoid");
1198
- superButton.addActionListener(this);
11991212
12001213 if (Globals.ADVANCED)
12011214 {
....@@ -1245,6 +1258,8 @@
12451258 cGridBag textures = new cGridBag();
12461259
12471260 CreateTexturePanel(textures);
1261
+
1262
+ resourcecontainer.setSelectedIndex((int)(Math.random() * resourcecontainer.getTabCount()));
12481263
12491264 oe.toolboxPanel.add(textures);
12501265
....@@ -1308,7 +1323,7 @@
13081323 oe.treePanel.Return();
13091324 cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
13101325 versionSlider = (cNumberSlider)sliderPane.getComponent(1);
1311
- sliderPane.preferredHeight = 1;
1326
+ sliderPane.preferredHeight = 2;
13121327
13131328 // mainPanel.setDividerLocation(0.1); //1.0);
13141329 mainPanel.setResizeWeight(0.4);
....@@ -1498,6 +1513,7 @@
14981513
14991514 oe.SetupViews();
15001515
1516
+ if (Globals.DEBUG)
15011517 System.out.println("SetupViews");
15021518 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
15031519 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -2159,7 +2175,11 @@
21592175 shadow.material = new cMaterial(obj.material);
21602176 shadow.material.diffuse = 0.0001f;
21612177 shadow.material.specular = 0.0001f;
2162
- //shadow.projectedVertices[1].x = 300;
2178
+ shadow.material.opacity = 0.75f;
2179
+
2180
+ AllocProjectedVertices(shadow);
2181
+
2182
+ shadow.projectedVertices[1].x = 300;
21632183
21642184 makeSomething(shadow);
21652185 }
....@@ -2680,27 +2700,35 @@
26802700 } else
26812701 if (source == loopItem || source == loopButton)
26822702 {
2703
+ if (!group.selection.isEmpty())
2704
+ {
26832705 Composite csg = new GroupLeaf();
26842706 csg.count = 5;
2685
- group(csg);
26862707 Composite child = new cGroup("Branch");
26872708 csg.addChild(child);
26882709 child.addChild(csg);
2710
+ group(csg);
2711
+ }
26892712 } else
26902713 if (source == doubleItem)
26912714 {
2715
+ if (!group.selection.isEmpty())
2716
+ {
26922717 Composite csg = new GroupLeaf("Fork");
26932718 csg.count = 5;
2694
- group(csg);
26952719 Composite child = new cGroup("Branch A");
26962720 csg.addChild(child);
26972721 child.addChild(csg);
26982722 child = new cGroup("Branch B");
26992723 csg.addChild(child);
27002724 child.addChild(csg);
2725
+ group(csg);
2726
+ }
27012727 } else
27022728 if (source == tripleItem)
27032729 {
2730
+ if (!group.selection.isEmpty())
2731
+ {
27042732 Composite csg = new GroupLeaf("Trident");
27052733 csg.count = 4;
27062734 group(csg);
....@@ -2713,6 +2741,7 @@
27132741 child = new cGroup();
27142742 csg.addChild(child);
27152743 child.addChild(csg);
2744
+ }
27162745 } else
27172746 if (source == computeAOItem)
27182747 {
....@@ -3348,22 +3377,34 @@
33483377 } else
33493378 if (source == ungroupItem || source == ungroupButton)
33503379 {
3351
- boolean hasRoot = false;
3380
+ boolean canUngroup = true;
33523381
33533382 for (int i=0; i<group.selection.size(); i++)
33543383 {
3355
- if (group.selection.get(i) == group)
3384
+ Object3D selectedItem = group.selection.get(i);
3385
+
3386
+ if (selectedItem.Size() == 0)
33563387 {
3357
- hasRoot = true;
3388
+ // Cannot ungroup leaves
3389
+ canUngroup = false;
3390
+ break;
3391
+ }
3392
+
3393
+ if (selectedItem == group)
3394
+ {
3395
+ // Cannot ungroup root
3396
+ canUngroup = false;
33583397 break;
33593398 }
33603399 }
33613400
3362
- if (!hasRoot)
3401
+ if (canUngroup)
33633402 {
33643403 for (int i=0; i<group.selection.size(); i++)
33653404 {
3366
- Ungroup(group.selection.get(i));
3405
+ Object3D selectedItem = group.selection.get(i);
3406
+
3407
+ Ungroup(selectedItem);
33673408 }
33683409
33693410 ClearSelection(false);
....@@ -4083,7 +4124,10 @@
40834124 copy.versionlist = new Object3D[100];
40844125 copy.versionindex = -1;
40854126
4086
- Save(true);
4127
+ // Cannot work with loops
4128
+ // To fix this issue, first mark all nodes above the root,
4129
+ // and check if any of these nodes are reachable below the root.
4130
+ //Save(true);
40874131 }
40884132
40894133 SetVersionStates();
....@@ -5325,9 +5369,11 @@
53255369
53265370 boolean allComposites = true;
53275371
5372
+ if (group.selection != null)
53285373 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
53295374 {
5330
- if (!(e.nextElement() instanceof Composite))
5375
+ Object next = e.nextElement();
5376
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
53315377 {
53325378 allComposites = false;
53335379 break;
....@@ -6232,11 +6278,11 @@
62326278 private MenuItem lookAtItem;
62336279 private MenuItem lookFromItem;
62346280 private MenuItem switchViewItem;
6235
- private MenuItem cutItem;
6281
+ private JMenuItem cutItem;
62366282 private MenuItem undoItem;
62376283 private MenuItem redoItem;
62386284 private JMenuItem duplicateItem;
6239
- private MenuItem cloneItem;
6285
+ private JMenuItem cloneItem;
62406286 private MenuItem cloneSupportItem;
62416287 private MenuItem overwriteGeoItem;
62426288 private MenuItem overwriteMatItem;
....@@ -6257,13 +6303,13 @@
62576303 private MenuItem cloneGeometriesItem;
62586304 private MenuItem shareGeometriesItem;
62596305 private MenuItem mergeGeometriesItem;
6260
- private MenuItem copyItem;
6306
+ private JMenuItem copyItem;
62616307 private MenuItem pasteItem;
6262
- private MenuItem pasteIntoItem;
6263
- private MenuItem pasteLinkItem;
6264
- private MenuItem pasteCloneItem;
6265
- private MenuItem pasteExpandItem;
6266
- private MenuItem deleteItem;
6308
+ private JMenuItem pasteIntoItem;
6309
+ private JMenuItem pasteLinkItem;
6310
+ private JMenuItem pasteCloneItem;
6311
+ private JMenuItem pasteExpandItem;
6312
+ private JMenuItem deleteItem;
62676313 private MenuItem clearAllItem;
62686314 private MenuItem genUVItem;
62696315 private MenuItem genNormalsMESHItem;
....@@ -6318,7 +6364,7 @@
63186364 private MenuItem transformGeometryItem;
63196365 private MenuItem transformChildrenItem;
63206366 private MenuItem hideItem;
6321
- private MenuItem grabItem;
6367
+ private JMenuItem grabItem;
63226368 private MenuItem backItem;
63236369 private MenuItem frontItem;
63246370 private MenuItem cameraItem;
....@@ -6331,7 +6377,7 @@
63316377 private MenuItem switchTransfoItem;
63326378 private MenuItem morphItem;
63336379 private MenuItem linkerItem;
6334
- private MenuItem ungroupItem;
6380
+ private JMenuItem ungroupItem;
63356381 private MenuItem editItem;
63366382 private MenuItem openWindowItem;
63376383 private MenuItem editLeafItem;