Normand Briere
2019-08-16 64e20f390e4b8e58bd0006dde8fa10fba1dac1d5
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)
....@@ -531,33 +540,35 @@
531540 // menu.add("-");
532541 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
533542 duplicateItem.addActionListener(this);
534
- cloneItem = menu.add(new MenuItem("Clone"));
543
+
544
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
535545 cloneItem.addActionListener(this);
536
- if (Globals.ADVANCED)
546
+ //if (Globals.ADVANCED)
537547 {
538548 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
539549 cloneSupportItem.addActionListener(this);
540550 }
551
+ oe.jTree.popup.addSeparator();
541552 menu.add("-");
542
- cutItem = menu.add(new MenuItem("Cut"));
553
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
543554 cutItem.addActionListener(this);
544
- copyItem = menu.add(new MenuItem("Copy"));
555
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
545556 copyItem.addActionListener(this);
546557 pasteItem = menu.add(new MenuItem("Paste"));
547558 pasteItem.addActionListener(this);
548559
549
- menu.add("-");
550
- pasteIntoItem = menu.add(new MenuItem("Paste into"));
560
+ oe.jTree.popup.addSeparator();
561
+ //menu.add("-");
562
+ pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into"));
551563 pasteIntoItem.addActionListener(this);
552
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
564
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
553565 pasteLinkItem.addActionListener(this);
554
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
566
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
555567 pasteCloneItem.addActionListener(this);
556
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
568
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
557569 // pasteExpandItem.addActionListener(this);
558
- menu.add("-");
559
- deleteItem = menu.add(new MenuItem("Delete"));
560
- deleteItem.addActionListener(this);
570
+ //menu.add("-");
571
+ oe.jTree.popup.addSeparator();
561572
562573 if (Globals.ADVANCED)
563574 {
....@@ -692,9 +703,8 @@
692703 setMasterItem.addActionListener(this);
693704 }
694705
695
- oe.menuBar.add(menu = new Menu("Group"));
696
-// grabItem = menu.add(new MenuItem("Grab"));
697
-// grabItem.addActionListener(this);
706
+ oe.menuBar.add(menu = new Menu("Order"));
707
+
698708 backItem = menu.add(new MenuItem("Back"));
699709 backItem.addActionListener(this);
700710 frontItem = menu.add(new MenuItem("Front"));
....@@ -702,13 +712,21 @@
702712 // compositeItem = menu.add(new MenuItem("Composite"));
703713 // compositeItem.addActionListener(this);
704714
715
+ grabItem = oe.jTree.popup.add(new JMenuItem("Group"));
716
+ grabItem.addActionListener(this);
717
+
705718 if (Globals.ADVANCED)
706719 {
707720 hideItem = menu.add(new MenuItem("Hidden Group"));
708721 hideItem.addActionListener(this);
709722 }
710
- ungroupItem = menu.add(new MenuItem("Ungroup"));
723
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
711724 ungroupItem.addActionListener(this);
725
+
726
+ oe.jTree.popup.addSeparator();
727
+
728
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
729
+ deleteItem.addActionListener(this);
712730
713731 // menu.add("-");
714732 //
....@@ -914,7 +932,7 @@
914932
915933 JTabbedPane resourcecontainer;
916934 cGridBag currenttab;
917
- boolean added; // patch for jar
935
+ //boolean added; // patch for jar
918936
919937 int tabcount = 0;
920938 int colcount = 0;
....@@ -931,12 +949,14 @@
931949 // System.out.println();
932950
933951 if (//rowcount == 0 ||
934
- path.length == 1)
952
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
935953 {
936954 currenttab = new cGridBag();
937
- added = false;
938955 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
939956 currenttab.setName(tabname);
957
+ //added = false;
958
+ resourcecontainer.add(currenttab);
959
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
940960 rowcount = 1;
941961 colcount = 0;
942962 texturecount = 0;
....@@ -944,12 +964,11 @@
944964
945965 if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
946966 {
947
- if (!added)
967
+ //if (!added)
948968 {
949
- added = true;
950
- resourcecontainer.add(currenttab);
969
+ //added = true;
951970 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
952
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
971
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
953972 }
954973
955974 AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
....@@ -1034,8 +1053,8 @@
10341053 // maxButton.addActionListener(this);
10351054 }
10361055
1037
-// cButton gcButton;
1038
-//
1056
+ cButton gcButton;
1057
+
10391058 // oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10401059 // gcButton.setToolTipText("Garbage collect");
10411060 // gcButton.addActionListener(new ActionListener()
....@@ -1050,7 +1069,7 @@
10501069 collapseButton.setToolTipText("Collapse toolbar");
10511070 collapseButton.addActionListener(this);
10521071
1053
- oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1072
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/empty.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10541073 maximize3DButton.setToolTipText("Maximize 3D view");
10551074 maximize3DButton.addActionListener(this);
10561075
....@@ -1172,6 +1191,10 @@
11721191 boxButton.setToolTipText("Create box");
11731192 boxButton.addActionListener(this);
11741193
1194
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1195
+ superButton.setToolTipText("Create superellipsoid");
1196
+ superButton.addActionListener(this);
1197
+
11751198 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11761199 sphereButton.setToolTipText("Create sphere");
11771200 sphereButton.addActionListener(this);
....@@ -1183,10 +1206,6 @@
11831206 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11841207 torusButton.setToolTipText("Create torus");
11851208 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);
11901209
11911210 if (Globals.ADVANCED)
11921211 {
....@@ -1459,11 +1478,11 @@
14591478 {
14601479 assert(obj instanceof Composite);
14611480
1462
- if (obj.versionlist == null)
1463
- {
1464
- obj.versionlist = new Object3D[100];
1465
- obj.versionindex = -1;
1466
- }
1481
+// if (obj.versionlist == null)
1482
+// {
1483
+// obj.versionlist = new Object3D[100];
1484
+// obj.versionindex = -1;
1485
+// }
14671486
14681487 cRadio radioButton = new cRadio(obj.name);
14691488
....@@ -1489,6 +1508,7 @@
14891508
14901509 oe.SetupViews();
14911510
1511
+ if (Globals.DEBUG)
14921512 System.out.println("SetupViews");
14931513 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
14941514 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -2150,7 +2170,11 @@
21502170 shadow.material = new cMaterial(obj.material);
21512171 shadow.material.diffuse = 0.0001f;
21522172 shadow.material.specular = 0.0001f;
2153
- //shadow.projectedVertices[1].x = 300;
2173
+ shadow.material.opacity = 0.75f;
2174
+
2175
+ AllocProjectedVertices(shadow);
2176
+
2177
+ shadow.projectedVertices[1].x = 300;
21542178
21552179 makeSomething(shadow);
21562180 }
....@@ -2671,27 +2695,35 @@
26712695 } else
26722696 if (source == loopItem || source == loopButton)
26732697 {
2698
+ if (!group.selection.isEmpty())
2699
+ {
26742700 Composite csg = new GroupLeaf();
26752701 csg.count = 5;
2676
- group(csg);
26772702 Composite child = new cGroup("Branch");
26782703 csg.addChild(child);
26792704 child.addChild(csg);
2705
+ group(csg);
2706
+ }
26802707 } else
26812708 if (source == doubleItem)
26822709 {
2710
+ if (!group.selection.isEmpty())
2711
+ {
26832712 Composite csg = new GroupLeaf("Fork");
26842713 csg.count = 5;
2685
- group(csg);
26862714 Composite child = new cGroup("Branch A");
26872715 csg.addChild(child);
26882716 child.addChild(csg);
26892717 child = new cGroup("Branch B");
26902718 csg.addChild(child);
26912719 child.addChild(csg);
2720
+ group(csg);
2721
+ }
26922722 } else
26932723 if (source == tripleItem)
26942724 {
2725
+ if (!group.selection.isEmpty())
2726
+ {
26952727 Composite csg = new GroupLeaf("Trident");
26962728 csg.count = 4;
26972729 group(csg);
....@@ -2704,6 +2736,7 @@
27042736 child = new cGroup();
27052737 csg.addChild(child);
27062738 child.addChild(csg);
2739
+ }
27072740 } else
27082741 if (source == computeAOItem)
27092742 {
....@@ -3339,22 +3372,34 @@
33393372 } else
33403373 if (source == ungroupItem || source == ungroupButton)
33413374 {
3342
- boolean hasRoot = false;
3375
+ boolean canUngroup = true;
33433376
33443377 for (int i=0; i<group.selection.size(); i++)
33453378 {
3346
- if (group.selection.get(i) == group)
3379
+ Object3D selectedItem = group.selection.get(i);
3380
+
3381
+ if (selectedItem.Size() == 0)
33473382 {
3348
- hasRoot = true;
3383
+ // Cannot ungroup leaves
3384
+ canUngroup = false;
3385
+ break;
3386
+ }
3387
+
3388
+ if (selectedItem == group)
3389
+ {
3390
+ // Cannot ungroup root
3391
+ canUngroup = false;
33493392 break;
33503393 }
33513394 }
33523395
3353
- if (!hasRoot)
3396
+ if (canUngroup)
33543397 {
33553398 for (int i=0; i<group.selection.size(); i++)
33563399 {
3357
- Ungroup(group.selection.get(i));
3400
+ Object3D selectedItem = group.selection.get(i);
3401
+
3402
+ Ungroup(selectedItem);
33583403 }
33593404
33603405 ClearSelection(false);
....@@ -4067,7 +4112,20 @@
40674112 */
40684113 radio.layout.doClick();
40694114
4070
- SetUndoStates();
4115
+ assert(copy instanceof Composite);
4116
+
4117
+ if (copy.versionlist == null)
4118
+ {
4119
+ copy.versionlist = new Object3D[100];
4120
+ copy.versionindex = -1;
4121
+
4122
+ // Cannot work with loops
4123
+ // To fix this issue, first mark all nodes above the root,
4124
+ // and check if any of these nodes are reachable below the root.
4125
+ //Save(true);
4126
+ }
4127
+
4128
+ SetVersionStates();
40714129
40724130 ClearUnpinned();
40734131
....@@ -5306,9 +5364,11 @@
53065364
53075365 boolean allComposites = true;
53085366
5367
+ if (group.selection != null)
53095368 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
53105369 {
5311
- if (!(e.nextElement() instanceof Composite))
5370
+ Object next = e.nextElement();
5371
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
53125372 {
53135373 allComposites = false;
53145374 break;
....@@ -6213,11 +6273,11 @@
62136273 private MenuItem lookAtItem;
62146274 private MenuItem lookFromItem;
62156275 private MenuItem switchViewItem;
6216
- private MenuItem cutItem;
6276
+ private JMenuItem cutItem;
62176277 private MenuItem undoItem;
62186278 private MenuItem redoItem;
62196279 private JMenuItem duplicateItem;
6220
- private MenuItem cloneItem;
6280
+ private JMenuItem cloneItem;
62216281 private MenuItem cloneSupportItem;
62226282 private MenuItem overwriteGeoItem;
62236283 private MenuItem overwriteMatItem;
....@@ -6238,13 +6298,13 @@
62386298 private MenuItem cloneGeometriesItem;
62396299 private MenuItem shareGeometriesItem;
62406300 private MenuItem mergeGeometriesItem;
6241
- private MenuItem copyItem;
6301
+ private JMenuItem copyItem;
62426302 private MenuItem pasteItem;
6243
- private MenuItem pasteIntoItem;
6244
- private MenuItem pasteLinkItem;
6245
- private MenuItem pasteCloneItem;
6246
- private MenuItem pasteExpandItem;
6247
- private MenuItem deleteItem;
6303
+ private JMenuItem pasteIntoItem;
6304
+ private JMenuItem pasteLinkItem;
6305
+ private JMenuItem pasteCloneItem;
6306
+ private JMenuItem pasteExpandItem;
6307
+ private JMenuItem deleteItem;
62486308 private MenuItem clearAllItem;
62496309 private MenuItem genUVItem;
62506310 private MenuItem genNormalsMESHItem;
....@@ -6299,7 +6359,7 @@
62996359 private MenuItem transformGeometryItem;
63006360 private MenuItem transformChildrenItem;
63016361 private MenuItem hideItem;
6302
- private MenuItem grabItem;
6362
+ private JMenuItem grabItem;
63036363 private MenuItem backItem;
63046364 private MenuItem frontItem;
63056365 private MenuItem cameraItem;
....@@ -6312,7 +6372,7 @@
63126372 private MenuItem switchTransfoItem;
63136373 private MenuItem morphItem;
63146374 private MenuItem linkerItem;
6315
- private MenuItem ungroupItem;
6375
+ private JMenuItem ungroupItem;
63166376 private MenuItem editItem;
63176377 private MenuItem openWindowItem;
63186378 private MenuItem editLeafItem;