Normand Briere
2019-08-16 83d0c2fa0bd2e96448f776144e1a89cdb1bb6998
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 {
....@@ -1459,11 +1481,11 @@
14591481 {
14601482 assert(obj instanceof Composite);
14611483
1462
- if (obj.versionlist == null)
1463
- {
1464
- obj.versionlist = new Object3D[100];
1465
- obj.versionindex = -1;
1466
- }
1484
+// if (obj.versionlist == null)
1485
+// {
1486
+// obj.versionlist = new Object3D[100];
1487
+// obj.versionindex = -1;
1488
+// }
14671489
14681490 cRadio radioButton = new cRadio(obj.name);
14691491
....@@ -1489,6 +1511,7 @@
14891511
14901512 oe.SetupViews();
14911513
1514
+ if (Globals.DEBUG)
14921515 System.out.println("SetupViews");
14931516 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
14941517 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -2150,7 +2173,11 @@
21502173 shadow.material = new cMaterial(obj.material);
21512174 shadow.material.diffuse = 0.0001f;
21522175 shadow.material.specular = 0.0001f;
2153
- //shadow.projectedVertices[1].x = 300;
2176
+ shadow.material.opacity = 0.75f;
2177
+
2178
+ AllocProjectedVertices(shadow);
2179
+
2180
+ shadow.projectedVertices[1].x = 300;
21542181
21552182 makeSomething(shadow);
21562183 }
....@@ -2671,27 +2698,35 @@
26712698 } else
26722699 if (source == loopItem || source == loopButton)
26732700 {
2701
+ if (!group.selection.isEmpty())
2702
+ {
26742703 Composite csg = new GroupLeaf();
26752704 csg.count = 5;
2676
- group(csg);
26772705 Composite child = new cGroup("Branch");
26782706 csg.addChild(child);
26792707 child.addChild(csg);
2708
+ group(csg);
2709
+ }
26802710 } else
26812711 if (source == doubleItem)
26822712 {
2713
+ if (!group.selection.isEmpty())
2714
+ {
26832715 Composite csg = new GroupLeaf("Fork");
26842716 csg.count = 5;
2685
- group(csg);
26862717 Composite child = new cGroup("Branch A");
26872718 csg.addChild(child);
26882719 child.addChild(csg);
26892720 child = new cGroup("Branch B");
26902721 csg.addChild(child);
26912722 child.addChild(csg);
2723
+ group(csg);
2724
+ }
26922725 } else
26932726 if (source == tripleItem)
26942727 {
2728
+ if (!group.selection.isEmpty())
2729
+ {
26952730 Composite csg = new GroupLeaf("Trident");
26962731 csg.count = 4;
26972732 group(csg);
....@@ -2704,6 +2739,7 @@
27042739 child = new cGroup();
27052740 csg.addChild(child);
27062741 child.addChild(csg);
2742
+ }
27072743 } else
27082744 if (source == computeAOItem)
27092745 {
....@@ -3339,22 +3375,34 @@
33393375 } else
33403376 if (source == ungroupItem || source == ungroupButton)
33413377 {
3342
- boolean hasRoot = false;
3378
+ boolean canUngroup = true;
33433379
33443380 for (int i=0; i<group.selection.size(); i++)
33453381 {
3346
- if (group.selection.get(i) == group)
3382
+ Object3D selectedItem = group.selection.get(i);
3383
+
3384
+ if (selectedItem.Size() == 0)
33473385 {
3348
- hasRoot = true;
3386
+ // Cannot ungroup leaves
3387
+ canUngroup = false;
3388
+ break;
3389
+ }
3390
+
3391
+ if (selectedItem == group)
3392
+ {
3393
+ // Cannot ungroup root
3394
+ canUngroup = false;
33493395 break;
33503396 }
33513397 }
33523398
3353
- if (!hasRoot)
3399
+ if (canUngroup)
33543400 {
33553401 for (int i=0; i<group.selection.size(); i++)
33563402 {
3357
- Ungroup(group.selection.get(i));
3403
+ Object3D selectedItem = group.selection.get(i);
3404
+
3405
+ Ungroup(selectedItem);
33583406 }
33593407
33603408 ClearSelection(false);
....@@ -4067,7 +4115,20 @@
40674115 */
40684116 radio.layout.doClick();
40694117
4070
- SetUndoStates();
4118
+ assert(copy instanceof Composite);
4119
+
4120
+ if (copy.versionlist == null)
4121
+ {
4122
+ copy.versionlist = new Object3D[100];
4123
+ copy.versionindex = -1;
4124
+
4125
+ // Cannot work with loops
4126
+ // To fix this issue, first mark all nodes above the root,
4127
+ // and check if any of these nodes are reachable below the root.
4128
+ //Save(true);
4129
+ }
4130
+
4131
+ SetVersionStates();
40714132
40724133 ClearUnpinned();
40734134
....@@ -5306,9 +5367,11 @@
53065367
53075368 boolean allComposites = true;
53085369
5370
+ if (group.selection != null)
53095371 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
53105372 {
5311
- if (!(e.nextElement() instanceof Composite))
5373
+ Object next = e.nextElement();
5374
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
53125375 {
53135376 allComposites = false;
53145377 break;
....@@ -6213,11 +6276,11 @@
62136276 private MenuItem lookAtItem;
62146277 private MenuItem lookFromItem;
62156278 private MenuItem switchViewItem;
6216
- private MenuItem cutItem;
6279
+ private JMenuItem cutItem;
62176280 private MenuItem undoItem;
62186281 private MenuItem redoItem;
62196282 private JMenuItem duplicateItem;
6220
- private MenuItem cloneItem;
6283
+ private JMenuItem cloneItem;
62216284 private MenuItem cloneSupportItem;
62226285 private MenuItem overwriteGeoItem;
62236286 private MenuItem overwriteMatItem;
....@@ -6238,13 +6301,13 @@
62386301 private MenuItem cloneGeometriesItem;
62396302 private MenuItem shareGeometriesItem;
62406303 private MenuItem mergeGeometriesItem;
6241
- private MenuItem copyItem;
6304
+ private JMenuItem copyItem;
62426305 private MenuItem pasteItem;
6243
- private MenuItem pasteIntoItem;
6244
- private MenuItem pasteLinkItem;
6245
- private MenuItem pasteCloneItem;
6246
- private MenuItem pasteExpandItem;
6247
- private MenuItem deleteItem;
6306
+ private JMenuItem pasteIntoItem;
6307
+ private JMenuItem pasteLinkItem;
6308
+ private JMenuItem pasteCloneItem;
6309
+ private JMenuItem pasteExpandItem;
6310
+ private JMenuItem deleteItem;
62486311 private MenuItem clearAllItem;
62496312 private MenuItem genUVItem;
62506313 private MenuItem genNormalsMESHItem;
....@@ -6299,7 +6362,7 @@
62996362 private MenuItem transformGeometryItem;
63006363 private MenuItem transformChildrenItem;
63016364 private MenuItem hideItem;
6302
- private MenuItem grabItem;
6365
+ private JMenuItem grabItem;
63036366 private MenuItem backItem;
63046367 private MenuItem frontItem;
63056368 private MenuItem cameraItem;
....@@ -6312,7 +6375,7 @@
63126375 private MenuItem switchTransfoItem;
63136376 private MenuItem morphItem;
63146377 private MenuItem linkerItem;
6315
- private MenuItem ungroupItem;
6378
+ private JMenuItem ungroupItem;
63166379 private MenuItem editItem;
63176380 private MenuItem openWindowItem;
63186381 private MenuItem editLeafItem;