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)
....@@ -410,6 +419,8 @@
410419 {
411420 copy.versionlist = new Object3D[100];
412421 copy.versionindex = -1;
422
+
423
+ Save(true);
413424 }
414425
415426 if(ui)
....@@ -529,33 +540,35 @@
529540 // menu.add("-");
530541 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
531542 duplicateItem.addActionListener(this);
532
- cloneItem = menu.add(new MenuItem("Clone"));
543
+
544
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
533545 cloneItem.addActionListener(this);
534
- if (Globals.ADVANCED)
546
+ //if (Globals.ADVANCED)
535547 {
536548 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
537549 cloneSupportItem.addActionListener(this);
538550 }
551
+ oe.jTree.popup.addSeparator();
539552 menu.add("-");
540
- cutItem = menu.add(new MenuItem("Cut"));
553
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
541554 cutItem.addActionListener(this);
542
- copyItem = menu.add(new MenuItem("Copy"));
555
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
543556 copyItem.addActionListener(this);
544557 pasteItem = menu.add(new MenuItem("Paste"));
545558 pasteItem.addActionListener(this);
546559
547
- menu.add("-");
548
- 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"));
549563 pasteIntoItem.addActionListener(this);
550
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
564
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
551565 pasteLinkItem.addActionListener(this);
552
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
566
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
553567 pasteCloneItem.addActionListener(this);
554
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
568
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
555569 // pasteExpandItem.addActionListener(this);
556
- menu.add("-");
557
- deleteItem = menu.add(new MenuItem("Delete"));
558
- deleteItem.addActionListener(this);
570
+ //menu.add("-");
571
+ oe.jTree.popup.addSeparator();
559572
560573 if (Globals.ADVANCED)
561574 {
....@@ -641,11 +654,9 @@
641654 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
642655 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
643656 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
644
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
645657 oe.cameraMenu.add("-");
646658 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
647659 openWindowItem.addActionListener(this);
648
- editLeafItem.addActionListener(this);
649660 lookAtItem.addActionListener(this);
650661 //lookFromItem.addActinoListener(this);
651662 //switchViewItem.addActionListener(this);
....@@ -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 //
....@@ -893,6 +911,9 @@
893911 shareGeometriesItem.addActionListener(this);
894912 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
895913 mergeGeometriesItem.addActionListener(this);
914
+ menu.add("-");
915
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
916
+ editLeafItem.addActionListener(this);
896917 if (Globals.ADVANCED)
897918 {
898919 // Pretty much the same as duplicate and clone.
....@@ -911,7 +932,7 @@
911932
912933 JTabbedPane resourcecontainer;
913934 cGridBag currenttab;
914
- boolean added; // patch for jar
935
+ //boolean added; // patch for jar
915936
916937 int tabcount = 0;
917938 int colcount = 0;
....@@ -928,12 +949,14 @@
928949 // System.out.println();
929950
930951 if (//rowcount == 0 ||
931
- path.length == 1)
952
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
932953 {
933954 currenttab = new cGridBag();
934
- added = false;
935955 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
936956 currenttab.setName(tabname);
957
+ //added = false;
958
+ resourcecontainer.add(currenttab);
959
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
937960 rowcount = 1;
938961 colcount = 0;
939962 texturecount = 0;
....@@ -941,12 +964,11 @@
941964
942965 if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
943966 {
944
- if (!added)
967
+ //if (!added)
945968 {
946
- added = true;
947
- resourcecontainer.add(currenttab);
969
+ //added = true;
948970 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
949
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
971
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
950972 }
951973
952974 AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
....@@ -1026,28 +1048,28 @@
10261048
10271049 if (Globals.ADVANCED)
10281050 {
1029
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1030
- maxButton.setToolTipText("Maximize window");
1031
- maxButton.addActionListener(this);
1051
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1052
+// maxButton.setToolTipText("Maximize window");
1053
+// maxButton.addActionListener(this);
10321054 }
10331055
10341056 cButton gcButton;
10351057
1036
- oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1037
- gcButton.setToolTipText("Garbage collect");
1038
- gcButton.addActionListener(new ActionListener()
1039
- {
1040
- public void actionPerformed(ActionEvent e)
1041
- {
1042
- System.gc();
1043
- }
1044
- });
1058
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1059
+// gcButton.setToolTipText("Garbage collect");
1060
+// gcButton.addActionListener(new ActionListener()
1061
+// {
1062
+// public void actionPerformed(ActionEvent e)
1063
+// {
1064
+// System.gc();
1065
+// }
1066
+// });
10451067
10461068 oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10471069 collapseButton.setToolTipText("Collapse toolbar");
10481070 collapseButton.addActionListener(this);
10491071
1050
- oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1072
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/empty.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10511073 maximize3DButton.setToolTipText("Maximize 3D view");
10521074 maximize3DButton.addActionListener(this);
10531075
....@@ -1162,12 +1184,16 @@
11621184
11631185 // INSERT
11641186 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1165
- gridButton.setToolTipText("Create grid");
1187
+ gridButton.setToolTipText("Create ground");
11661188 gridButton.addActionListener(this);
11671189
11681190 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11691191 boxButton.setToolTipText("Create box");
11701192 boxButton.addActionListener(this);
1193
+
1194
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1195
+ superButton.setToolTipText("Create superellipsoid");
1196
+ superButton.addActionListener(this);
11711197
11721198 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11731199 sphereButton.setToolTipText("Create sphere");
....@@ -1180,10 +1206,6 @@
11801206 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11811207 torusButton.setToolTipText("Create torus");
11821208 torusButton.addActionListener(this);
1183
-
1184
- row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1185
- superButton.setToolTipText("Create superellipsoid");
1186
- superButton.addActionListener(this);
11871209
11881210 if (Globals.ADVANCED)
11891211 {
....@@ -1454,6 +1476,14 @@
14541476
14551477 void EditObject(Object3D obj)
14561478 {
1479
+ assert(obj instanceof Composite);
1480
+
1481
+// if (obj.versionlist == null)
1482
+// {
1483
+// obj.versionlist = new Object3D[100];
1484
+// obj.versionindex = -1;
1485
+// }
1486
+
14571487 cRadio radioButton = new cRadio(obj.name);
14581488
14591489 // June 2019. Patch to avoid bug with transparency.
....@@ -1478,6 +1508,7 @@
14781508
14791509 oe.SetupViews();
14801510
1511
+ if (Globals.DEBUG)
14811512 System.out.println("SetupViews");
14821513 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
14831514 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -2139,7 +2170,11 @@
21392170 shadow.material = new cMaterial(obj.material);
21402171 shadow.material.diffuse = 0.0001f;
21412172 shadow.material.specular = 0.0001f;
2142
- //shadow.projectedVertices[1].x = 300;
2173
+ shadow.material.opacity = 0.75f;
2174
+
2175
+ AllocProjectedVertices(shadow);
2176
+
2177
+ shadow.projectedVertices[1].x = 300;
21432178
21442179 makeSomething(shadow);
21452180 }
....@@ -2660,27 +2695,35 @@
26602695 } else
26612696 if (source == loopItem || source == loopButton)
26622697 {
2698
+ if (!group.selection.isEmpty())
2699
+ {
26632700 Composite csg = new GroupLeaf();
26642701 csg.count = 5;
2665
- group(csg);
26662702 Composite child = new cGroup("Branch");
26672703 csg.addChild(child);
26682704 child.addChild(csg);
2705
+ group(csg);
2706
+ }
26692707 } else
26702708 if (source == doubleItem)
26712709 {
2710
+ if (!group.selection.isEmpty())
2711
+ {
26722712 Composite csg = new GroupLeaf("Fork");
26732713 csg.count = 5;
2674
- group(csg);
26752714 Composite child = new cGroup("Branch A");
26762715 csg.addChild(child);
26772716 child.addChild(csg);
26782717 child = new cGroup("Branch B");
26792718 csg.addChild(child);
26802719 child.addChild(csg);
2720
+ group(csg);
2721
+ }
26812722 } else
26822723 if (source == tripleItem)
26832724 {
2725
+ if (!group.selection.isEmpty())
2726
+ {
26842727 Composite csg = new GroupLeaf("Trident");
26852728 csg.count = 4;
26862729 group(csg);
....@@ -2693,6 +2736,7 @@
26932736 child = new cGroup();
26942737 csg.addChild(child);
26952738 child.addChild(csg);
2739
+ }
26962740 } else
26972741 if (source == computeAOItem)
26982742 {
....@@ -3328,22 +3372,34 @@
33283372 } else
33293373 if (source == ungroupItem || source == ungroupButton)
33303374 {
3331
- boolean hasRoot = false;
3375
+ boolean canUngroup = true;
33323376
33333377 for (int i=0; i<group.selection.size(); i++)
33343378 {
3335
- if (group.selection.get(i) == group)
3379
+ Object3D selectedItem = group.selection.get(i);
3380
+
3381
+ if (selectedItem.Size() == 0)
33363382 {
3337
- 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;
33383392 break;
33393393 }
33403394 }
33413395
3342
- if (!hasRoot)
3396
+ if (canUngroup)
33433397 {
33443398 for (int i=0; i<group.selection.size(); i++)
33453399 {
3346
- Ungroup(group.selection.get(i));
3400
+ Object3D selectedItem = group.selection.get(i);
3401
+
3402
+ Ungroup(selectedItem);
33473403 }
33483404
33493405 ClearSelection(false);
....@@ -3892,6 +3948,7 @@
38923948 } else
38933949 if (source == rootButton)
38943950 {
3951
+ Replace();
38953952 Object3D obj;
38963953 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
38973954 {
....@@ -4028,8 +4085,6 @@
40284085
40294086 copy = group;
40304087
4031
- SetUndoStates();
4032
-
40334088 //Globals.theRenderer.object = group;
40344089 if(!useclient)
40354090 {
....@@ -4057,6 +4112,21 @@
40574112 */
40584113 radio.layout.doClick();
40594114
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();
4129
+
40604130 ClearUnpinned();
40614131
40624132 //Grafreed.Assert(group != null);
....@@ -5291,6 +5361,21 @@
52915361 flashSelectionButton.setEnabled(enabled);
52925362
52935363 clearPanelButton.setEnabled(!listUI.isEmpty());
5364
+
5365
+ boolean allComposites = true;
5366
+
5367
+ if (group.selection != null)
5368
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5369
+ {
5370
+ Object next = e.nextElement();
5371
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
5372
+ {
5373
+ allComposites = false;
5374
+ break;
5375
+ }
5376
+ }
5377
+
5378
+ rootButton.setEnabled(allComposites);
52945379 }
52955380
52965381 void refreshContents(boolean cp)
....@@ -6188,11 +6273,11 @@
61886273 private MenuItem lookAtItem;
61896274 private MenuItem lookFromItem;
61906275 private MenuItem switchViewItem;
6191
- private MenuItem cutItem;
6276
+ private JMenuItem cutItem;
61926277 private MenuItem undoItem;
61936278 private MenuItem redoItem;
61946279 private JMenuItem duplicateItem;
6195
- private MenuItem cloneItem;
6280
+ private JMenuItem cloneItem;
61966281 private MenuItem cloneSupportItem;
61976282 private MenuItem overwriteGeoItem;
61986283 private MenuItem overwriteMatItem;
....@@ -6213,13 +6298,13 @@
62136298 private MenuItem cloneGeometriesItem;
62146299 private MenuItem shareGeometriesItem;
62156300 private MenuItem mergeGeometriesItem;
6216
- private MenuItem copyItem;
6301
+ private JMenuItem copyItem;
62176302 private MenuItem pasteItem;
6218
- private MenuItem pasteIntoItem;
6219
- private MenuItem pasteLinkItem;
6220
- private MenuItem pasteCloneItem;
6221
- private MenuItem pasteExpandItem;
6222
- private MenuItem deleteItem;
6303
+ private JMenuItem pasteIntoItem;
6304
+ private JMenuItem pasteLinkItem;
6305
+ private JMenuItem pasteCloneItem;
6306
+ private JMenuItem pasteExpandItem;
6307
+ private JMenuItem deleteItem;
62236308 private MenuItem clearAllItem;
62246309 private MenuItem genUVItem;
62256310 private MenuItem genNormalsMESHItem;
....@@ -6274,7 +6359,7 @@
62746359 private MenuItem transformGeometryItem;
62756360 private MenuItem transformChildrenItem;
62766361 private MenuItem hideItem;
6277
- private MenuItem grabItem;
6362
+ private JMenuItem grabItem;
62786363 private MenuItem backItem;
62796364 private MenuItem frontItem;
62806365 private MenuItem cameraItem;
....@@ -6287,7 +6372,7 @@
62876372 private MenuItem switchTransfoItem;
62886373 private MenuItem morphItem;
62896374 private MenuItem linkerItem;
6290
- private MenuItem ungroupItem;
6375
+ private JMenuItem ungroupItem;
62916376 private MenuItem editItem;
62926377 private MenuItem openWindowItem;
62936378 private MenuItem editLeafItem;