Normand Briere
2019-08-17 ecc1309a04b527c62ffe97e814daf050dbd025cd
GroupEditor.java
....@@ -31,7 +31,7 @@
3131 final String path = "cubemaps/" + f + "-skyboxes/" + s;
3232 row.add(skyboxButton = GetButton(path + "/preview.jpg", !Grafreed.NIMBUSLAF));
3333 //row.add(skyboxButton = GetButton(path + "/negx.jpg", !Grafreed.NIMBUSLAF));
34
- skyboxButton.setToolTipText(s);
34
+ skyboxButton.setToolTipText(s.equals("") ? "No background" : s);
3535 skyboxButton.addActionListener(new ActionListener()
3636 {
3737 @Override
....@@ -73,7 +73,7 @@
7373 cGridBag row5 = new cGridBag();
7474 cGridBag row6 = new cGridBag();
7575
76
- AddSkyboxButton("default", "rgb", row0);
76
+ AddSkyboxButton("default", "", row0);
7777 //AddSkyboxButton("default", "cornell", row0);
7878 AddSkyboxButton("penguins", "dust", row0);
7979 AddSkyboxButton("penguins", "tropic", row0);
....@@ -330,10 +330,19 @@
330330
331331 public void ChangeSkybox(String skybox)
332332 {
333
- //cameraView.envyoff = false;
334
- group.skyboxname = skybox;
335
- group.skyboxext = "jpg";
336
- cameraView.repaint();
333
+ if (skybox.endsWith("/"))
334
+ {
335
+ group.skyboxname = null;
336
+ group.skyboxext = null;
337
+ cameraView.repaint();
338
+ }
339
+ else
340
+ {
341
+ //cameraView.envyoff = false;
342
+ group.skyboxname = skybox;
343
+ group.skyboxext = "jpg";
344
+ cameraView.repaint();
345
+ }
337346 }
338347
339348 public void CreateSkyboxPanel(cGridBag skyboxPanel)
....@@ -406,12 +415,14 @@
406415 this.copy = this.group = group;
407416 //selectees = this.group.selectees;
408417
418
+ assert(false);
419
+
409420 if (copy.versionlist == null)
410421 {
411422 copy.versionlist = new Object3D[100];
412423 copy.versionindex = -1;
413424
414
- Save(true);
425
+ //Save(true);
415426 }
416427
417428 if(ui)
....@@ -440,7 +451,7 @@
440451 copy.versionlist = new Object3D[100];
441452 copy.versionindex = -1;
442453
443
- Save(true);
454
+ //Save(true);
444455 }
445456 }
446457
....@@ -531,33 +542,35 @@
531542 // menu.add("-");
532543 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
533544 duplicateItem.addActionListener(this);
534
- cloneItem = menu.add(new MenuItem("Clone"));
545
+
546
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
535547 cloneItem.addActionListener(this);
536
- if (Globals.ADVANCED)
548
+ //if (Globals.ADVANCED)
537549 {
538550 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
539551 cloneSupportItem.addActionListener(this);
540552 }
553
+ oe.jTree.popup.addSeparator();
541554 menu.add("-");
542
- cutItem = menu.add(new MenuItem("Cut"));
555
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
543556 cutItem.addActionListener(this);
544
- copyItem = menu.add(new MenuItem("Copy"));
557
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
545558 copyItem.addActionListener(this);
546559 pasteItem = menu.add(new MenuItem("Paste"));
547560 pasteItem.addActionListener(this);
548561
549
- menu.add("-");
550
- 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"));
551565 pasteIntoItem.addActionListener(this);
552
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
566
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
553567 pasteLinkItem.addActionListener(this);
554
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
568
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
555569 pasteCloneItem.addActionListener(this);
556
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
570
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
557571 // pasteExpandItem.addActionListener(this);
558
- menu.add("-");
559
- deleteItem = menu.add(new MenuItem("Delete"));
560
- deleteItem.addActionListener(this);
572
+ //menu.add("-");
573
+ oe.jTree.popup.addSeparator();
561574
562575 if (Globals.ADVANCED)
563576 {
....@@ -692,9 +705,8 @@
692705 setMasterItem.addActionListener(this);
693706 }
694707
695
- oe.menuBar.add(menu = new Menu("Group"));
696
-// grabItem = menu.add(new MenuItem("Grab"));
697
-// grabItem.addActionListener(this);
708
+ oe.menuBar.add(menu = new Menu("Order"));
709
+
698710 backItem = menu.add(new MenuItem("Back"));
699711 backItem.addActionListener(this);
700712 frontItem = menu.add(new MenuItem("Front"));
....@@ -702,13 +714,21 @@
702714 // compositeItem = menu.add(new MenuItem("Composite"));
703715 // compositeItem.addActionListener(this);
704716
717
+ grabItem = oe.jTree.popup.add(new JMenuItem("Group"));
718
+ grabItem.addActionListener(this);
719
+
705720 if (Globals.ADVANCED)
706721 {
707722 hideItem = menu.add(new MenuItem("Hidden Group"));
708723 hideItem.addActionListener(this);
709724 }
710
- ungroupItem = menu.add(new MenuItem("Ungroup"));
725
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
711726 ungroupItem.addActionListener(this);
727
+
728
+ oe.jTree.popup.addSeparator();
729
+
730
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
731
+ deleteItem.addActionListener(this);
712732
713733 // menu.add("-");
714734 //
....@@ -914,7 +934,7 @@
914934
915935 JTabbedPane resourcecontainer;
916936 cGridBag currenttab;
917
- boolean added; // patch for jar
937
+ //boolean added; // patch for jar
918938
919939 int tabcount = 0;
920940 int colcount = 0;
....@@ -931,12 +951,14 @@
931951 // System.out.println();
932952
933953 if (//rowcount == 0 ||
934
- path.length == 1)
954
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
935955 {
936956 currenttab = new cGridBag();
937
- added = false;
938957 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
939958 currenttab.setName(tabname);
959
+ //added = false;
960
+ resourcecontainer.add(currenttab);
961
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
940962 rowcount = 1;
941963 colcount = 0;
942964 texturecount = 0;
....@@ -944,12 +966,11 @@
944966
945967 if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
946968 {
947
- if (!added)
969
+ //if (!added)
948970 {
949
- added = true;
950
- resourcecontainer.add(currenttab);
971
+ //added = true;
951972 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
952
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
973
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
953974 }
954975
955976 AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
....@@ -1034,8 +1055,8 @@
10341055 // maxButton.addActionListener(this);
10351056 }
10361057
1037
-// cButton gcButton;
1038
-//
1058
+ cButton gcButton;
1059
+
10391060 // oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10401061 // gcButton.setToolTipText("Garbage collect");
10411062 // gcButton.addActionListener(new ActionListener()
....@@ -1050,7 +1071,7 @@
10501071 collapseButton.setToolTipText("Collapse toolbar");
10511072 collapseButton.addActionListener(this);
10521073
1053
- oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1074
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/empty.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10541075 maximize3DButton.setToolTipText("Maximize 3D view");
10551076 maximize3DButton.addActionListener(this);
10561077
....@@ -1092,6 +1113,7 @@
10921113 copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10931114 deleteVersionButton.setToolTipText("Delete current version");
10941115 deleteVersionButton.addActionListener(this);
1116
+ deleteVersionButton.setEnabled(false);
10951117
10961118 copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10971119 previousVersionButton.setToolTipText("Previous version");
....@@ -1102,12 +1124,12 @@
11021124 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11031125 restoreButton.setToolTipText("Undo (restore current version)");
11041126 restoreButton.addActionListener(this);
1105
- //restoreButton.setEnabled(false);
1127
+ restoreButton.setEnabled(false);
11061128
11071129 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11081130 replaceButton.setToolTipText("Save (replace current version)");
11091131 replaceButton.addActionListener(this);
1110
- //replaceButton.setEnabled(false);
1132
+ replaceButton.setEnabled(false);
11111133
11121134 copyOptionsPanel.add(updown);
11131135
....@@ -1172,6 +1194,10 @@
11721194 boxButton.setToolTipText("Create box");
11731195 boxButton.addActionListener(this);
11741196
1197
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1198
+ superButton.setToolTipText("Create superellipsoid");
1199
+ superButton.addActionListener(this);
1200
+
11751201 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11761202 sphereButton.setToolTipText("Create sphere");
11771203 sphereButton.addActionListener(this);
....@@ -1183,10 +1209,6 @@
11831209 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11841210 torusButton.setToolTipText("Create torus");
11851211 torusButton.addActionListener(this);
1186
-
1187
- row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1188
- superButton.setToolTipText("Create superellipsoid");
1189
- superButton.addActionListener(this);
11901212
11911213 if (Globals.ADVANCED)
11921214 {
....@@ -1236,6 +1258,8 @@
12361258 cGridBag textures = new cGridBag();
12371259
12381260 CreateTexturePanel(textures);
1261
+
1262
+ resourcecontainer.setSelectedIndex((int)(Math.random() * resourcecontainer.getTabCount()));
12391263
12401264 oe.toolboxPanel.add(textures);
12411265
....@@ -1459,11 +1483,11 @@
14591483 {
14601484 assert(obj instanceof Composite);
14611485
1462
- if (obj.versionlist == null)
1463
- {
1464
- obj.versionlist = new Object3D[100];
1465
- obj.versionindex = -1;
1466
- }
1486
+// if (obj.versionlist == null)
1487
+// {
1488
+// obj.versionlist = new Object3D[100];
1489
+// obj.versionindex = -1;
1490
+// }
14671491
14681492 cRadio radioButton = new cRadio(obj.name);
14691493
....@@ -1489,6 +1513,7 @@
14891513
14901514 oe.SetupViews();
14911515
1516
+ if (Globals.DEBUG)
14921517 System.out.println("SetupViews");
14931518 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
14941519 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -2150,7 +2175,11 @@
21502175 shadow.material = new cMaterial(obj.material);
21512176 shadow.material.diffuse = 0.0001f;
21522177 shadow.material.specular = 0.0001f;
2153
- //shadow.projectedVertices[1].x = 300;
2178
+ shadow.material.opacity = 0.75f;
2179
+
2180
+ AllocProjectedVertices(shadow);
2181
+
2182
+ shadow.projectedVertices[1].x = 300;
21542183
21552184 makeSomething(shadow);
21562185 }
....@@ -2671,27 +2700,35 @@
26712700 } else
26722701 if (source == loopItem || source == loopButton)
26732702 {
2703
+ if (!group.selection.isEmpty())
2704
+ {
26742705 Composite csg = new GroupLeaf();
26752706 csg.count = 5;
2676
- group(csg);
26772707 Composite child = new cGroup("Branch");
26782708 csg.addChild(child);
26792709 child.addChild(csg);
2710
+ group(csg);
2711
+ }
26802712 } else
26812713 if (source == doubleItem)
26822714 {
2715
+ if (!group.selection.isEmpty())
2716
+ {
26832717 Composite csg = new GroupLeaf("Fork");
26842718 csg.count = 5;
2685
- group(csg);
26862719 Composite child = new cGroup("Branch A");
26872720 csg.addChild(child);
26882721 child.addChild(csg);
26892722 child = new cGroup("Branch B");
26902723 csg.addChild(child);
26912724 child.addChild(csg);
2725
+ group(csg);
2726
+ }
26922727 } else
26932728 if (source == tripleItem)
26942729 {
2730
+ if (!group.selection.isEmpty())
2731
+ {
26952732 Composite csg = new GroupLeaf("Trident");
26962733 csg.count = 4;
26972734 group(csg);
....@@ -2704,6 +2741,7 @@
27042741 child = new cGroup();
27052742 csg.addChild(child);
27062743 child.addChild(csg);
2744
+ }
27072745 } else
27082746 if (source == computeAOItem)
27092747 {
....@@ -3339,22 +3377,34 @@
33393377 } else
33403378 if (source == ungroupItem || source == ungroupButton)
33413379 {
3342
- boolean hasRoot = false;
3380
+ boolean canUngroup = true;
33433381
33443382 for (int i=0; i<group.selection.size(); i++)
33453383 {
3346
- if (group.selection.get(i) == group)
3384
+ Object3D selectedItem = group.selection.get(i);
3385
+
3386
+ if (selectedItem.Size() == 0)
33473387 {
3348
- 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;
33493397 break;
33503398 }
33513399 }
33523400
3353
- if (!hasRoot)
3401
+ if (canUngroup)
33543402 {
33553403 for (int i=0; i<group.selection.size(); i++)
33563404 {
3357
- Ungroup(group.selection.get(i));
3405
+ Object3D selectedItem = group.selection.get(i);
3406
+
3407
+ Ungroup(selectedItem);
33583408 }
33593409
33603410 ClearSelection(false);
....@@ -4067,7 +4117,20 @@
40674117 */
40684118 radio.layout.doClick();
40694119
4070
- SetUndoStates();
4120
+ assert(copy instanceof Composite);
4121
+
4122
+ if (copy.versionlist == null)
4123
+ {
4124
+ copy.versionlist = new Object3D[100];
4125
+ copy.versionindex = -1;
4126
+
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);
4131
+ }
4132
+
4133
+ SetVersionStates();
40714134
40724135 ClearUnpinned();
40734136
....@@ -5306,9 +5369,11 @@
53065369
53075370 boolean allComposites = true;
53085371
5372
+ if (group.selection != null)
53095373 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
53105374 {
5311
- if (!(e.nextElement() instanceof Composite))
5375
+ Object next = e.nextElement();
5376
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
53125377 {
53135378 allComposites = false;
53145379 break;
....@@ -6213,11 +6278,11 @@
62136278 private MenuItem lookAtItem;
62146279 private MenuItem lookFromItem;
62156280 private MenuItem switchViewItem;
6216
- private MenuItem cutItem;
6281
+ private JMenuItem cutItem;
62176282 private MenuItem undoItem;
62186283 private MenuItem redoItem;
62196284 private JMenuItem duplicateItem;
6220
- private MenuItem cloneItem;
6285
+ private JMenuItem cloneItem;
62216286 private MenuItem cloneSupportItem;
62226287 private MenuItem overwriteGeoItem;
62236288 private MenuItem overwriteMatItem;
....@@ -6238,13 +6303,13 @@
62386303 private MenuItem cloneGeometriesItem;
62396304 private MenuItem shareGeometriesItem;
62406305 private MenuItem mergeGeometriesItem;
6241
- private MenuItem copyItem;
6306
+ private JMenuItem copyItem;
62426307 private MenuItem pasteItem;
6243
- private MenuItem pasteIntoItem;
6244
- private MenuItem pasteLinkItem;
6245
- private MenuItem pasteCloneItem;
6246
- private MenuItem pasteExpandItem;
6247
- private MenuItem deleteItem;
6308
+ private JMenuItem pasteIntoItem;
6309
+ private JMenuItem pasteLinkItem;
6310
+ private JMenuItem pasteCloneItem;
6311
+ private JMenuItem pasteExpandItem;
6312
+ private JMenuItem deleteItem;
62486313 private MenuItem clearAllItem;
62496314 private MenuItem genUVItem;
62506315 private MenuItem genNormalsMESHItem;
....@@ -6299,7 +6364,7 @@
62996364 private MenuItem transformGeometryItem;
63006365 private MenuItem transformChildrenItem;
63016366 private MenuItem hideItem;
6302
- private MenuItem grabItem;
6367
+ private JMenuItem grabItem;
63036368 private MenuItem backItem;
63046369 private MenuItem frontItem;
63056370 private MenuItem cameraItem;
....@@ -6312,7 +6377,7 @@
63126377 private MenuItem switchTransfoItem;
63136378 private MenuItem morphItem;
63146379 private MenuItem linkerItem;
6315
- private MenuItem ungroupItem;
6380
+ private JMenuItem ungroupItem;
63166381 private MenuItem editItem;
63176382 private MenuItem openWindowItem;
63186383 private MenuItem editLeafItem;