Normand Briere
2019-08-17 5892f05411c3d4dce2d8a59e0966dc2e1843a971
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,10 +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;
424
+
425
+ //Save(true);
413426 }
414427
415428 if(ui)
....@@ -438,7 +451,7 @@
438451 copy.versionlist = new Object3D[100];
439452 copy.versionindex = -1;
440453
441
- Save(true);
454
+ //Save(true);
442455 }
443456 }
444457
....@@ -529,33 +542,35 @@
529542 // menu.add("-");
530543 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
531544 duplicateItem.addActionListener(this);
532
- cloneItem = menu.add(new MenuItem("Clone"));
545
+
546
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
533547 cloneItem.addActionListener(this);
534
- if (Globals.ADVANCED)
548
+ //if (Globals.ADVANCED)
535549 {
536550 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
537551 cloneSupportItem.addActionListener(this);
538552 }
553
+ oe.jTree.popup.addSeparator();
539554 menu.add("-");
540
- cutItem = menu.add(new MenuItem("Cut"));
555
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
541556 cutItem.addActionListener(this);
542
- copyItem = menu.add(new MenuItem("Copy"));
557
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
543558 copyItem.addActionListener(this);
544559 pasteItem = menu.add(new MenuItem("Paste"));
545560 pasteItem.addActionListener(this);
546561
547
- menu.add("-");
548
- 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"));
549565 pasteIntoItem.addActionListener(this);
550
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
566
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
551567 pasteLinkItem.addActionListener(this);
552
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
568
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
553569 pasteCloneItem.addActionListener(this);
554
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
570
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
555571 // pasteExpandItem.addActionListener(this);
556
- menu.add("-");
557
- deleteItem = menu.add(new MenuItem("Delete"));
558
- deleteItem.addActionListener(this);
572
+ //menu.add("-");
573
+ oe.jTree.popup.addSeparator();
559574
560575 if (Globals.ADVANCED)
561576 {
....@@ -641,11 +656,9 @@
641656 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
642657 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
643658 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
644
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
645659 oe.cameraMenu.add("-");
646660 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
647661 openWindowItem.addActionListener(this);
648
- editLeafItem.addActionListener(this);
649662 lookAtItem.addActionListener(this);
650663 //lookFromItem.addActinoListener(this);
651664 //switchViewItem.addActionListener(this);
....@@ -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 //
....@@ -893,6 +913,9 @@
893913 shareGeometriesItem.addActionListener(this);
894914 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
895915 mergeGeometriesItem.addActionListener(this);
916
+ menu.add("-");
917
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
918
+ editLeafItem.addActionListener(this);
896919 if (Globals.ADVANCED)
897920 {
898921 // Pretty much the same as duplicate and clone.
....@@ -911,7 +934,7 @@
911934
912935 JTabbedPane resourcecontainer;
913936 cGridBag currenttab;
914
- boolean added; // patch for jar
937
+ //boolean added; // patch for jar
915938
916939 int tabcount = 0;
917940 int colcount = 0;
....@@ -928,12 +951,14 @@
928951 // System.out.println();
929952
930953 if (//rowcount == 0 ||
931
- path.length == 1)
954
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
932955 {
933956 currenttab = new cGridBag();
934
- added = false;
935957 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
936958 currenttab.setName(tabname);
959
+ //added = false;
960
+ resourcecontainer.add(currenttab);
961
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
937962 rowcount = 1;
938963 colcount = 0;
939964 texturecount = 0;
....@@ -941,12 +966,11 @@
941966
942967 if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
943968 {
944
- if (!added)
969
+ //if (!added)
945970 {
946
- added = true;
947
- resourcecontainer.add(currenttab);
971
+ //added = true;
948972 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
949
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
973
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
950974 }
951975
952976 AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
....@@ -1016,7 +1040,7 @@
10161040 */
10171041 cGridBag copyOptionsPanel = new cGridBag();
10181042
1019
- copyOptionsPanel.preferredHeight = 2;
1043
+ copyOptionsPanel.preferredHeight = 3;
10201044
10211045 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
10221046
....@@ -1026,28 +1050,28 @@
10261050
10271051 if (Globals.ADVANCED)
10281052 {
1029
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1030
- maxButton.setToolTipText("Maximize window");
1031
- maxButton.addActionListener(this);
1053
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1054
+// maxButton.setToolTipText("Maximize window");
1055
+// maxButton.addActionListener(this);
10321056 }
10331057
10341058 cButton gcButton;
10351059
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
- });
1060
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1061
+// gcButton.setToolTipText("Garbage collect");
1062
+// gcButton.addActionListener(new ActionListener()
1063
+// {
1064
+// public void actionPerformed(ActionEvent e)
1065
+// {
1066
+// System.gc();
1067
+// }
1068
+// });
10451069
10461070 oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10471071 collapseButton.setToolTipText("Collapse toolbar");
10481072 collapseButton.addActionListener(this);
10491073
1050
- oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1074
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/empty.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10511075 maximize3DButton.setToolTipText("Maximize 3D view");
10521076 maximize3DButton.addActionListener(this);
10531077
....@@ -1089,6 +1113,7 @@
10891113 copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10901114 deleteVersionButton.setToolTipText("Delete current version");
10911115 deleteVersionButton.addActionListener(this);
1116
+ deleteVersionButton.setEnabled(false);
10921117
10931118 copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10941119 previousVersionButton.setToolTipText("Previous version");
....@@ -1099,12 +1124,12 @@
10991124 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11001125 restoreButton.setToolTipText("Undo (restore current version)");
11011126 restoreButton.addActionListener(this);
1102
- //restoreButton.setEnabled(false);
1127
+ restoreButton.setEnabled(false);
11031128
11041129 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11051130 replaceButton.setToolTipText("Save (replace current version)");
11061131 replaceButton.addActionListener(this);
1107
- //replaceButton.setEnabled(false);
1132
+ replaceButton.setEnabled(false);
11081133
11091134 copyOptionsPanel.add(updown);
11101135
....@@ -1162,12 +1187,16 @@
11621187
11631188 // INSERT
11641189 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1165
- gridButton.setToolTipText("Create grid");
1190
+ gridButton.setToolTipText("Create ground");
11661191 gridButton.addActionListener(this);
11671192
11681193 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11691194 boxButton.setToolTipText("Create box");
11701195 boxButton.addActionListener(this);
1196
+
1197
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1198
+ superButton.setToolTipText("Create superellipsoid");
1199
+ superButton.addActionListener(this);
11711200
11721201 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11731202 sphereButton.setToolTipText("Create sphere");
....@@ -1180,10 +1209,6 @@
11801209 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11811210 torusButton.setToolTipText("Create torus");
11821211 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);
11871212
11881213 if (Globals.ADVANCED)
11891214 {
....@@ -1233,6 +1258,8 @@
12331258 cGridBag textures = new cGridBag();
12341259
12351260 CreateTexturePanel(textures);
1261
+
1262
+ resourcecontainer.setSelectedIndex((int)(Math.random() * resourcecontainer.getTabCount()));
12361263
12371264 oe.toolboxPanel.add(textures);
12381265
....@@ -1296,7 +1323,7 @@
12961323 oe.treePanel.Return();
12971324 cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
12981325 versionSlider = (cNumberSlider)sliderPane.getComponent(1);
1299
- sliderPane.preferredHeight = 1;
1326
+ sliderPane.preferredHeight = 2;
13001327
13011328 // mainPanel.setDividerLocation(0.1); //1.0);
13021329 mainPanel.setResizeWeight(0.4);
....@@ -1454,6 +1481,14 @@
14541481
14551482 void EditObject(Object3D obj)
14561483 {
1484
+ assert(obj instanceof Composite);
1485
+
1486
+// if (obj.versionlist == null)
1487
+// {
1488
+// obj.versionlist = new Object3D[100];
1489
+// obj.versionindex = -1;
1490
+// }
1491
+
14571492 cRadio radioButton = new cRadio(obj.name);
14581493
14591494 // June 2019. Patch to avoid bug with transparency.
....@@ -1478,6 +1513,7 @@
14781513
14791514 oe.SetupViews();
14801515
1516
+ if (Globals.DEBUG)
14811517 System.out.println("SetupViews");
14821518 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
14831519 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -2139,7 +2175,11 @@
21392175 shadow.material = new cMaterial(obj.material);
21402176 shadow.material.diffuse = 0.0001f;
21412177 shadow.material.specular = 0.0001f;
2142
- //shadow.projectedVertices[1].x = 300;
2178
+ shadow.material.opacity = 0.75f;
2179
+
2180
+ AllocProjectedVertices(shadow);
2181
+
2182
+ shadow.projectedVertices[1].x = 300;
21432183
21442184 makeSomething(shadow);
21452185 }
....@@ -2660,27 +2700,35 @@
26602700 } else
26612701 if (source == loopItem || source == loopButton)
26622702 {
2703
+ if (!group.selection.isEmpty())
2704
+ {
26632705 Composite csg = new GroupLeaf();
26642706 csg.count = 5;
2665
- group(csg);
26662707 Composite child = new cGroup("Branch");
26672708 csg.addChild(child);
26682709 child.addChild(csg);
2710
+ group(csg);
2711
+ }
26692712 } else
26702713 if (source == doubleItem)
26712714 {
2715
+ if (!group.selection.isEmpty())
2716
+ {
26722717 Composite csg = new GroupLeaf("Fork");
26732718 csg.count = 5;
2674
- group(csg);
26752719 Composite child = new cGroup("Branch A");
26762720 csg.addChild(child);
26772721 child.addChild(csg);
26782722 child = new cGroup("Branch B");
26792723 csg.addChild(child);
26802724 child.addChild(csg);
2725
+ group(csg);
2726
+ }
26812727 } else
26822728 if (source == tripleItem)
26832729 {
2730
+ if (!group.selection.isEmpty())
2731
+ {
26842732 Composite csg = new GroupLeaf("Trident");
26852733 csg.count = 4;
26862734 group(csg);
....@@ -2693,6 +2741,7 @@
26932741 child = new cGroup();
26942742 csg.addChild(child);
26952743 child.addChild(csg);
2744
+ }
26962745 } else
26972746 if (source == computeAOItem)
26982747 {
....@@ -3328,22 +3377,34 @@
33283377 } else
33293378 if (source == ungroupItem || source == ungroupButton)
33303379 {
3331
- boolean hasRoot = false;
3380
+ boolean canUngroup = true;
33323381
33333382 for (int i=0; i<group.selection.size(); i++)
33343383 {
3335
- if (group.selection.get(i) == group)
3384
+ Object3D selectedItem = group.selection.get(i);
3385
+
3386
+ if (selectedItem.Size() == 0)
33363387 {
3337
- 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;
33383397 break;
33393398 }
33403399 }
33413400
3342
- if (!hasRoot)
3401
+ if (canUngroup)
33433402 {
33443403 for (int i=0; i<group.selection.size(); i++)
33453404 {
3346
- Ungroup(group.selection.get(i));
3405
+ Object3D selectedItem = group.selection.get(i);
3406
+
3407
+ Ungroup(selectedItem);
33473408 }
33483409
33493410 ClearSelection(false);
....@@ -3892,6 +3953,7 @@
38923953 } else
38933954 if (source == rootButton)
38943955 {
3956
+ Replace();
38953957 Object3D obj;
38963958 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
38973959 {
....@@ -4028,8 +4090,6 @@
40284090
40294091 copy = group;
40304092
4031
- SetUndoStates();
4032
-
40334093 //Globals.theRenderer.object = group;
40344094 if(!useclient)
40354095 {
....@@ -4057,6 +4117,21 @@
40574117 */
40584118 radio.layout.doClick();
40594119
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();
4134
+
40604135 ClearUnpinned();
40614136
40624137 //Grafreed.Assert(group != null);
....@@ -5291,6 +5366,21 @@
52915366 flashSelectionButton.setEnabled(enabled);
52925367
52935368 clearPanelButton.setEnabled(!listUI.isEmpty());
5369
+
5370
+ boolean allComposites = true;
5371
+
5372
+ if (group.selection != null)
5373
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5374
+ {
5375
+ Object next = e.nextElement();
5376
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
5377
+ {
5378
+ allComposites = false;
5379
+ break;
5380
+ }
5381
+ }
5382
+
5383
+ rootButton.setEnabled(allComposites);
52945384 }
52955385
52965386 void refreshContents(boolean cp)
....@@ -6188,11 +6278,11 @@
61886278 private MenuItem lookAtItem;
61896279 private MenuItem lookFromItem;
61906280 private MenuItem switchViewItem;
6191
- private MenuItem cutItem;
6281
+ private JMenuItem cutItem;
61926282 private MenuItem undoItem;
61936283 private MenuItem redoItem;
61946284 private JMenuItem duplicateItem;
6195
- private MenuItem cloneItem;
6285
+ private JMenuItem cloneItem;
61966286 private MenuItem cloneSupportItem;
61976287 private MenuItem overwriteGeoItem;
61986288 private MenuItem overwriteMatItem;
....@@ -6213,13 +6303,13 @@
62136303 private MenuItem cloneGeometriesItem;
62146304 private MenuItem shareGeometriesItem;
62156305 private MenuItem mergeGeometriesItem;
6216
- private MenuItem copyItem;
6306
+ private JMenuItem copyItem;
62176307 private MenuItem pasteItem;
6218
- private MenuItem pasteIntoItem;
6219
- private MenuItem pasteLinkItem;
6220
- private MenuItem pasteCloneItem;
6221
- private MenuItem pasteExpandItem;
6222
- private MenuItem deleteItem;
6308
+ private JMenuItem pasteIntoItem;
6309
+ private JMenuItem pasteLinkItem;
6310
+ private JMenuItem pasteCloneItem;
6311
+ private JMenuItem pasteExpandItem;
6312
+ private JMenuItem deleteItem;
62236313 private MenuItem clearAllItem;
62246314 private MenuItem genUVItem;
62256315 private MenuItem genNormalsMESHItem;
....@@ -6274,7 +6364,7 @@
62746364 private MenuItem transformGeometryItem;
62756365 private MenuItem transformChildrenItem;
62766366 private MenuItem hideItem;
6277
- private MenuItem grabItem;
6367
+ private JMenuItem grabItem;
62786368 private MenuItem backItem;
62796369 private MenuItem frontItem;
62806370 private MenuItem cameraItem;
....@@ -6287,7 +6377,7 @@
62876377 private MenuItem switchTransfoItem;
62886378 private MenuItem morphItem;
62896379 private MenuItem linkerItem;
6290
- private MenuItem ungroupItem;
6380
+ private JMenuItem ungroupItem;
62916381 private MenuItem editItem;
62926382 private MenuItem openWindowItem;
62936383 private MenuItem editLeafItem;