Normand Briere
2019-08-23 60cec91731a350fe67e9b5ffe7a00d70e9026314
GroupEditor.java
....@@ -29,9 +29,9 @@
2929 {
3030 cButton skyboxButton;
3131 final String path = "cubemaps/" + f + "-skyboxes/" + s;
32
- row.add(skyboxButton = GetButton(path + "/preview.jpg", !Grafreed.NIMBUSLAF));
32
+ row.add(skyboxButton = GetButton(path + "/preview.jpg", !Globals.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
....@@ -46,7 +46,7 @@
4646 {
4747 cButton textureButton;
4848 final String path = "textures/" + f + "/" + c + "/"; // + t;
49
- row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF));
49
+ row.add(textureButton = GetButton(path + "icons/" + t, !Globals.NIMBUSLAF));
5050 textureButton.setToolTipText(c + count);
5151 textureButton.addActionListener(new ActionListener()
5252 {
....@@ -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,15 +330,24 @@
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)
340349 {
341
- JTabbedPane skyboxpane = new JTabbedPane();
350
+ JTabbedPane skyboxpane = new JTabbedPane(JTabbedPane.LEFT);
342351
343352 AddSkyboxTab0(skyboxpane);
344353 AddSkyboxTab1(skyboxpane);
....@@ -406,11 +415,15 @@
406415 this.copy = this.group = group;
407416 //selectees = this.group.selectees;
408417
409
- if (copy.versionlist == null)
410
- {
411
- copy.versionlist = new Object3D[100];
412
- copy.versionindex = -1;
413
- }
418
+ assert(false);
419
+
420
+// if (copy.versionlist == null)
421
+// {
422
+// copy.versionlist = new Object3D[100];
423
+// copy.versionindex = -1;
424
+//
425
+// //Save(true);
426
+// }
414427
415428 if(ui)
416429 SetupUI(objEditor);
....@@ -433,13 +446,13 @@
433446
434447 ((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true);
435448
436
- if (copy.versionlist == null)
437
- {
438
- copy.versionlist = new Object3D[100];
439
- copy.versionindex = -1;
440
-
441
- Save(true);
442
- }
449
+// if (copy.versionlist == null)
450
+// {
451
+// copy.versionlist = new Object3D[100];
452
+// copy.versionindex = -1;
453
+//
454
+// //Save(true);
455
+// }
443456 }
444457
445458 void CloneSelection(boolean supports)
....@@ -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 //
....@@ -815,6 +835,8 @@
815835 }
816836
817837 oe.menuBar.add(menu = new Menu("Attributes"));
838
+ clearVersionsItem = menu.add(new MenuItem("Clear Versions"));
839
+ clearVersionsItem.addActionListener(this);
818840 clearMaterialsItem = menu.add(new MenuItem("Clear Materials"));
819841 clearMaterialsItem.addActionListener(this);
820842 resetAllItem = menu.add(new MenuItem("Reset All"));
....@@ -837,9 +859,9 @@
837859 hideleavesItem.addActionListener(this);
838860 showleavesItem = menu.add(new MenuItem("Show Leaves"));
839861 showleavesItem.addActionListener(this);
840
- markleavesItem = menu.add(new MenuItem("Mark Leaves"));
862
+ markleavesItem = menu.add(new MenuItem("Anim Leaves"));
841863 markleavesItem.addActionListener(this);
842
- unmarkleavesItem = menu.add(new MenuItem("Unmark Leaves"));
864
+ unmarkleavesItem = menu.add(new MenuItem("Unanim Leaves"));
843865 unmarkleavesItem.addActionListener(this);
844866 rewindleavesItem = menu.add(new MenuItem("Rewind Leaves"));
845867 rewindleavesItem.addActionListener(this);
....@@ -893,6 +915,9 @@
893915 shareGeometriesItem.addActionListener(this);
894916 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
895917 mergeGeometriesItem.addActionListener(this);
918
+ menu.add("-");
919
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
920
+ editLeafItem.addActionListener(this);
896921 if (Globals.ADVANCED)
897922 {
898923 // Pretty much the same as duplicate and clone.
....@@ -911,8 +936,10 @@
911936
912937 JTabbedPane resourcecontainer;
913938 cGridBag currenttab;
914
- boolean added; // patch for jar
939
+ //boolean added; // patch for jar
915940
941
+ int totalcount = 0;
942
+
916943 int tabcount = 0;
917944 int colcount = 0;
918945 int rowcount = 0;
....@@ -928,28 +955,30 @@
928955 // System.out.println();
929956
930957 if (//rowcount == 0 ||
931
- path.length == 1)
958
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
932959 {
933960 currenttab = new cGridBag();
934
- added = false;
935961 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
936962 currenttab.setName(tabname);
963
+ //added = false;
964
+ resourcecontainer.add(currenttab);
965
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
937966 rowcount = 1;
938967 colcount = 0;
939968 texturecount = 0;
940969 }
941970
942
- if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
971
+ if (path.length > 2 && (path[2].toLowerCase().endsWith(".jpg") || path[2].toLowerCase().endsWith(".png")))
943972 {
944
- if (!added)
973
+ //if (!added)
945974 {
946
- added = true;
947
- resourcecontainer.add(currenttab);
975
+ //added = true;
948976 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
949
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
977
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
950978 }
951979
952
- AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
980
+ AddTextureButton(path[0], path[1], path[2], ++texturecount, currenttab);
981
+ totalcount++;
953982
954983 if (++colcount >= columns)
955984 {
....@@ -975,6 +1004,8 @@
9751004 container.add(resourcecontainer);
9761005
9771006 Grafreed.ParseResources("textures", this);
1007
+
1008
+ // 935. System.out.println("Total = " + totalcount);
9781009 }
9791010
9801011 void SetupUI2(ObjEditor oe)
....@@ -1014,9 +1045,9 @@
10141045 oe.radioPanel.add(dummyButton);
10151046 oe.buttonGroup.add(dummyButton);
10161047 */
1017
- cGridBag copyOptionsPanel = new cGridBag();
1048
+ cGridBag versionManagerPanel = new cGridBag();
10181049
1019
- copyOptionsPanel.preferredHeight = 2;
1050
+ versionManagerPanel.preferredHeight = 4;
10201051
10211052 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
10221053
....@@ -1026,42 +1057,42 @@
10261057
10271058 if (Globals.ADVANCED)
10281059 {
1029
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1030
- maxButton.setToolTipText("Maximize window");
1031
- maxButton.addActionListener(this);
1060
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1061
+// maxButton.setToolTipText("Maximize window");
1062
+// maxButton.addActionListener(this);
10321063 }
10331064
10341065 cButton gcButton;
10351066
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
- });
1067
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1068
+// gcButton.setToolTipText("Garbage collect");
1069
+// gcButton.addActionListener(new ActionListener()
1070
+// {
1071
+// public void actionPerformed(ActionEvent e)
1072
+// {
1073
+// System.gc();
1074
+// }
1075
+// });
10451076
1046
- oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1077
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10471078 collapseButton.setToolTipText("Collapse toolbar");
10481079 collapseButton.addActionListener(this);
10491080
1050
- oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1081
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/square.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10511082 maximize3DButton.setToolTipText("Maximize 3D view");
10521083 maximize3DButton.addActionListener(this);
10531084
1054
- oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1085
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10551086 twoButton.setToolTipText("Show 3D view only");
10561087 twoButton.addActionListener(this);
10571088 this.fullscreenLayout = twoButton;
10581089
1059
- oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1090
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10601091 threeButton.setToolTipText("Show controls and 3D view");
10611092 threeButton.addActionListener(this);
10621093 if (Globals.ADVANCED)
10631094 {
1064
- oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1095
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10651096 sixButton.setToolTipText("Show 3D view and controls");
10661097 sixButton.addActionListener(this);
10671098 }
....@@ -1070,50 +1101,51 @@
10701101 // sevenButton.addActionListener(this);
10711102 //
10721103
1073
- oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1104
+ oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10741105 fullButton.setToolTipText("Full-screen window");
10751106 fullButton.addActionListener(this);
10761107
1077
- oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1108
+ oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10781109 screenfitButton.setToolTipText("Screen fit");
10791110 screenfitButton.addActionListener(this);
10801111
1081
- oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1112
+ oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10821113 restoreCameraButton.setToolTipText("Restore viewpoint");
10831114 restoreCameraButton.addActionListener(this);
10841115
1085
- copyOptionsPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1116
+ versionManagerPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10861117 saveVersionButton.setToolTipText("Duplicate current version");
10871118 saveVersionButton.addActionListener(this);
10881119
1089
- copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1120
+ versionManagerPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10901121 deleteVersionButton.setToolTipText("Delete current version");
10911122 deleteVersionButton.addActionListener(this);
1123
+ deleteVersionButton.setEnabled(false);
10921124
1093
- copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
+ versionManagerPanel.add(previousVersionButton = GetButton("icons/undo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10941126 previousVersionButton.setToolTipText("Previous version");
10951127 previousVersionButton.addActionListener(this);
10961128 previousVersionButton.setEnabled(false);
10971129
10981130 cGridBag updown = new cGridBag().setVertical(true);
1099
- updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1131
+ updown.add(restoreButton = GetButton("icons/restore.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11001132 restoreButton.setToolTipText("Undo (restore current version)");
11011133 restoreButton.addActionListener(this);
1102
- //restoreButton.setEnabled(false);
1134
+ restoreButton.setEnabled(false);
11031135
1104
- updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1136
+ updown.add(replaceButton = GetButton("icons/replace.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11051137 replaceButton.setToolTipText("Save (replace current version)");
11061138 replaceButton.addActionListener(this);
1107
- //replaceButton.setEnabled(false);
1139
+ replaceButton.setEnabled(false);
11081140
1109
- copyOptionsPanel.add(updown);
1141
+ versionManagerPanel.add(updown);
11101142
1111
- copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1143
+ versionManagerPanel.add(nextVersionButton = GetButton("icons/redo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11121144 nextVersionButton.setToolTipText("Next version");
11131145 nextVersionButton.addActionListener(this);
11141146 nextVersionButton.setEnabled(false);
11151147
1116
- oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1148
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11171149 oneStepButton.setToolTipText("Animate one step forward");
11181150 oneStepButton.addActionListener(this);
11191151
....@@ -1136,11 +1168,11 @@
11361168
11371169 if (Globals.ADVANCED)
11381170 {
1139
- oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1171
+ oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11401172 snapobjectButton.addActionListener(this);
11411173 snapobjectButton.setToolTipText("Snap Object");
11421174
1143
- oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1175
+ oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11441176 fourButton.addActionListener(this);
11451177 fourButton.setToolTipText("Show control panel only");
11461178 }
....@@ -1148,11 +1180,11 @@
11481180 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
11491181
11501182
1151
- oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1183
+ oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11521184 rootButton.setToolTipText("Open selection in new tab");
11531185 rootButton.addActionListener(this);
11541186
1155
- oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1187
+ oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11561188 closeButton.setToolTipText("Close tab");
11571189 closeButton.addActionListener(this);
11581190 //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
....@@ -1161,38 +1193,38 @@
11611193 cGridBag row1 = new cGridBag();
11621194
11631195 // INSERT
1164
- row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1165
- gridButton.setToolTipText("Create grid");
1196
+ row1.add(gridButton = GetButton("icons/grid.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1197
+ gridButton.setToolTipText("Create ground");
11661198 gridButton.addActionListener(this);
11671199
1168
- row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1200
+ row1.add(boxButton = GetButton("icons/box.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11691201 boxButton.setToolTipText("Create box");
11701202 boxButton.addActionListener(this);
11711203
1172
- row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1173
- sphereButton.setToolTipText("Create sphere");
1174
- sphereButton.addActionListener(this);
1175
-
1176
- row1.add(coneButton = GetButton("icons/cone.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1177
- coneButton.setToolTipText("Create cone");
1178
- coneButton.addActionListener(this);
1179
-
1180
- row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1181
- torusButton.setToolTipText("Create torus");
1182
- torusButton.addActionListener(this);
1183
-
1184
- row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1204
+ row1.add(superButton = GetButton("icons/super.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11851205 superButton.setToolTipText("Create superellipsoid");
11861206 superButton.addActionListener(this);
11871207
1208
+ row1.add(sphereButton = GetButton("icons/sphere.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1209
+ sphereButton.setToolTipText("Create sphere");
1210
+ sphereButton.addActionListener(this);
1211
+
1212
+ row1.add(coneButton = GetButton("icons/cone.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1213
+ coneButton.setToolTipText("Create cone");
1214
+ coneButton.addActionListener(this);
1215
+
1216
+ row1.add(torusButton = GetButton("icons/torus.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1217
+ torusButton.setToolTipText("Create torus");
1218
+ torusButton.addActionListener(this);
1219
+
11881220 if (Globals.ADVANCED)
11891221 {
1190
- oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1222
+ oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11911223 kleinButton.setToolTipText("Create Klein bottle");
11921224 kleinButton.addActionListener(this);
11931225 }
11941226
1195
- row1.add(particlesButton = GetButton("icons/particles.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1227
+ row1.add(particlesButton = GetButton("icons/particles.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11961228 particlesButton.setToolTipText("Create particle system");
11971229 particlesButton.addActionListener(this);
11981230
....@@ -1200,31 +1232,31 @@
12001232
12011233 cGridBag row2 = new cGridBag();
12021234
1203
- row2.add(groupButton = GetButton("icons/group.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1235
+ row2.add(groupButton = GetButton("icons/group.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
12041236 groupButton.setToolTipText("Create group");
12051237 groupButton.addActionListener(this);
12061238
1207
- row2.add(compositeButton = GetButton("icons/composite.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1239
+ row2.add(compositeButton = GetButton("icons/composite.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
12081240 compositeButton.setToolTipText("Create composite");
12091241 compositeButton.addActionListener(this);
12101242
1211
- row2.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1243
+ row2.add(switchButton = GetButton("icons/switch.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
12121244 switchButton.setToolTipText("Create item switcher");
12131245 switchButton.addActionListener(this);
12141246
1215
- row2.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1247
+ row2.add(loopButton = GetButton("icons/loop.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
12161248 loopButton.setToolTipText("Create loop");
12171249 loopButton.addActionListener(this);
12181250
1219
- row2.add(textureButton = GetButton("icons/texture.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1251
+ row2.add(textureButton = GetButton("icons/texture.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
12201252 textureButton.setToolTipText("Create texture");
12211253 textureButton.addActionListener(this);
12221254
1223
- row2.add(overlayButton = GetButton("icons/overlay.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1255
+ row2.add(overlayButton = GetButton("icons/overlay.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
12241256 overlayButton.setToolTipText("Create overlay");
12251257 overlayButton.addActionListener(this);
12261258
1227
- row2.add(lightButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1259
+ row2.add(lightButton = GetButton("icons/light-bulb.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
12281260 lightButton.setToolTipText("Create light");
12291261 lightButton.addActionListener(this);
12301262
....@@ -1234,6 +1266,11 @@
12341266
12351267 CreateTexturePanel(textures);
12361268
1269
+ int tabCount = resourcecontainer.getTabCount();
1270
+
1271
+ if (tabCount > 0)
1272
+ resourcecontainer.setSelectedIndex((int)(Math.random() * tabCount));
1273
+
12371274 oe.toolboxPanel.add(textures);
12381275
12391276 textures.preferredHeight = 100;
....@@ -1241,11 +1278,11 @@
12411278 CreateSkyboxPanel(oe.skyboxPanel);
12421279
12431280 // EDIT panel
1244
- editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1281
+ editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
12451282 editButton.setToolTipText("Pin selection controls");
12461283 editButton.addActionListener(this);
12471284
1248
- editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1285
+ editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
12491286 uneditButton.setToolTipText("Unpin and remove selection controls");
12501287 uneditButton.addActionListener(this);
12511288
....@@ -1253,7 +1290,7 @@
12531290 allParamsButton.setToolTipText("Show all controls");
12541291 allParamsButton.addActionListener(this);
12551292
1256
- editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1293
+ editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
12571294 clearPanelButton.setToolTipText("Clear all controls");
12581295 clearPanelButton.addActionListener(this);
12591296
....@@ -1261,7 +1298,7 @@
12611298 //unselectButton.setToolTipText("Unselect");
12621299 //unselectButton.addActionListener(this);
12631300
1264
- editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1301
+ editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
12651302 flashSelectionButton.setToolTipText("Highlight selection");
12661303 flashSelectionButton.addActionListener(this);
12671304
....@@ -1284,6 +1321,8 @@
12841321
12851322 cGridBag jSPPanel = new cGridBag();
12861323
1324
+ jSPPanel.preferredHeight = 20;
1325
+
12871326 JScrollPane jSP;
12881327 //ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints);
12891328 jSPPanel.add(jSP = new JScrollPane(oe.jTree)); //, oe.aConstraints);
....@@ -1292,11 +1331,11 @@
12921331 oe.treePanel.add(jSPPanel);
12931332 oe.treePanel.Return();
12941333
1295
- oe.treePanel.add(copyOptionsPanel);
1334
+ oe.treePanel.add(versionManagerPanel);
12961335 oe.treePanel.Return();
1297
- cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
1298
- versionSlider = (cNumberSlider)sliderPane.getComponent(1);
1299
- sliderPane.preferredHeight = 1;
1336
+ versionSliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
1337
+ versionSlider = (cNumberSlider)versionSliderPane.getComponent(1);
1338
+ versionSliderPane.preferredHeight = 3;
13001339
13011340 // mainPanel.setDividerLocation(0.1); //1.0);
13021341 mainPanel.setResizeWeight(0.4);
....@@ -1454,6 +1493,14 @@
14541493
14551494 void EditObject(Object3D obj)
14561495 {
1496
+ assert(obj instanceof Composite);
1497
+
1498
+// if (obj.versionlist == null)
1499
+// {
1500
+// obj.versionlist = new Object3D[100];
1501
+// obj.versionindex = -1;
1502
+// }
1503
+
14571504 cRadio radioButton = new cRadio(obj.name);
14581505
14591506 // June 2019. Patch to avoid bug with transparency.
....@@ -1478,6 +1525,7 @@
14781525
14791526 oe.SetupViews();
14801527
1528
+ if (Globals.DEBUG)
14811529 System.out.println("SetupViews");
14821530 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
14831531 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -2081,24 +2129,24 @@
20812129 switch(axis)
20822130 {
20832131 case 0 :
2084
- vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z;
2085
- vert2.x = minima.x; vert2.y = maxima.y; vert2.z = minima.z;
2086
- vert3.x = minima.x; vert3.y = minima.y; vert3.z = maxima.z;
2087
- vert4.x = minima.x; vert4.y = maxima.y; vert4.z = maxima.z;
2132
+ vert1.x = minima.x + 0.001f; vert1.y = minima.y; vert1.z = minima.z;
2133
+ vert2.x = minima.x + 0.001f; vert2.y = maxima.y; vert2.z = minima.z;
2134
+ vert3.x = minima.x + 0.001f; vert3.y = minima.y; vert3.z = maxima.z;
2135
+ vert4.x = minima.x + 0.001f; vert4.y = maxima.y; vert4.z = maxima.z;
20882136 norm = cVector.X;
20892137 break;
20902138 case 1 :
2091
- vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z;
2092
- vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z;
2093
- vert3.x = minima.x; vert3.y = minima.y; vert3.z = maxima.z;
2094
- vert4.x = maxima.x; vert4.y = minima.y; vert4.z = maxima.z;
2139
+ vert1.x = minima.x; vert1.y = minima.y + 0.001f; vert1.z = minima.z;
2140
+ vert2.x = maxima.x; vert2.y = minima.y + 0.001f; vert2.z = minima.z;
2141
+ vert3.x = minima.x; vert3.y = minima.y + 0.001f; vert3.z = maxima.z;
2142
+ vert4.x = maxima.x; vert4.y = minima.y + 0.001f; vert4.z = maxima.z;
20952143 norm = cVector.Y;
20962144 break;
20972145 case 2 :
2098
- vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z;
2099
- vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z;
2100
- vert3.x = minima.x; vert3.y = maxima.y; vert3.z = minima.z;
2101
- vert4.x = maxima.x; vert4.y = maxima.y; vert4.z = minima.z;
2146
+ vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z + 0.001f;
2147
+ vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z + 0.001f;
2148
+ vert3.x = minima.x; vert3.y = maxima.y; vert3.z = minima.z + 0.001f;
2149
+ vert4.x = maxima.x; vert4.y = maxima.y; vert4.z = minima.z + 0.001f;
21022150 norm = cVector.Z;
21032151 break;
21042152 }
....@@ -2139,7 +2187,11 @@
21392187 shadow.material = new cMaterial(obj.material);
21402188 shadow.material.diffuse = 0.0001f;
21412189 shadow.material.specular = 0.0001f;
2142
- //shadow.projectedVertices[1].x = 300;
2190
+ shadow.material.opacity = 0.75f;
2191
+
2192
+ AllocProjectedVertices(shadow);
2193
+
2194
+ shadow.projectedVertices[1].x = 300;
21432195
21442196 makeSomething(shadow);
21452197 }
....@@ -2660,27 +2712,35 @@
26602712 } else
26612713 if (source == loopItem || source == loopButton)
26622714 {
2715
+ if (!group.selection.isEmpty())
2716
+ {
26632717 Composite csg = new GroupLeaf();
26642718 csg.count = 5;
2665
- group(csg);
26662719 Composite child = new cGroup("Branch");
26672720 csg.addChild(child);
26682721 child.addChild(csg);
2722
+ group(csg);
2723
+ }
26692724 } else
26702725 if (source == doubleItem)
26712726 {
2727
+ if (!group.selection.isEmpty())
2728
+ {
26722729 Composite csg = new GroupLeaf("Fork");
26732730 csg.count = 5;
2674
- group(csg);
26752731 Composite child = new cGroup("Branch A");
26762732 csg.addChild(child);
26772733 child.addChild(csg);
26782734 child = new cGroup("Branch B");
26792735 csg.addChild(child);
26802736 child.addChild(csg);
2737
+ group(csg);
2738
+ }
26812739 } else
26822740 if (source == tripleItem)
26832741 {
2742
+ if (!group.selection.isEmpty())
2743
+ {
26842744 Composite csg = new GroupLeaf("Trident");
26852745 csg.count = 4;
26862746 group(csg);
....@@ -2693,6 +2753,7 @@
26932753 child = new cGroup();
26942754 csg.addChild(child);
26952755 child.addChild(csg);
2756
+ }
26962757 } else
26972758 if (source == computeAOItem)
26982759 {
....@@ -3328,22 +3389,34 @@
33283389 } else
33293390 if (source == ungroupItem || source == ungroupButton)
33303391 {
3331
- boolean hasRoot = false;
3392
+ boolean canUngroup = true;
33323393
33333394 for (int i=0; i<group.selection.size(); i++)
33343395 {
3335
- if (group.selection.get(i) == group)
3396
+ Object3D selectedItem = group.selection.get(i);
3397
+
3398
+ if (selectedItem.Size() == 0)
33363399 {
3337
- hasRoot = true;
3400
+ // Cannot ungroup leaves
3401
+ canUngroup = false;
3402
+ break;
3403
+ }
3404
+
3405
+ if (selectedItem == group)
3406
+ {
3407
+ // Cannot ungroup root
3408
+ canUngroup = false;
33383409 break;
33393410 }
33403411 }
33413412
3342
- if (!hasRoot)
3413
+ if (canUngroup)
33433414 {
33443415 for (int i=0; i<group.selection.size(); i++)
33453416 {
3346
- Ungroup(group.selection.get(i));
3417
+ Object3D selectedItem = group.selection.get(i);
3418
+
3419
+ Ungroup(selectedItem);
33473420 }
33483421
33493422 ClearSelection(false);
....@@ -3394,6 +3467,10 @@
33943467 if (source == clearMaterialsItem)
33953468 {
33963469 ClearMaterials();
3470
+ } else
3471
+ if (source == clearVersionsItem)
3472
+ {
3473
+ ClearVersions();
33973474 } else
33983475 if (source == liveleavesItem)
33993476 {
....@@ -3892,6 +3969,7 @@
38923969 } else
38933970 if (source == rootButton)
38943971 {
3972
+ Replace();
38953973 Object3D obj;
38963974 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
38973975 {
....@@ -3906,6 +3984,8 @@
39063984 if (source == closeButton)
39073985 {
39083986 //System.out.println("CLOSE: " + buttonGroup.getSelection());
3987
+ Replace();
3988
+
39093989 cRadio ab;
39103990 for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
39113991 {
....@@ -4004,6 +4084,8 @@
40044084 } else
40054085 if(source instanceof cRadio)
40064086 {
4087
+ Replace();
4088
+
40074089 group.parent = keepparent;
40084090 group.attributes = 0;
40094091 //group.editWindow = null;
....@@ -4028,8 +4110,6 @@
40284110
40294111 copy = group;
40304112
4031
- SetUndoStates();
4032
-
40334113 //Globals.theRenderer.object = group;
40344114 if(!useclient)
40354115 {
....@@ -4057,6 +4137,31 @@
40574137 */
40584138 radio.layout.doClick();
40594139
4140
+ assert(copy instanceof Composite);
4141
+
4142
+ if (copy.versionlist == null)
4143
+ {
4144
+ copy.versionindex = -1;
4145
+
4146
+ // Cannot work with loops
4147
+ // To fix this issue, we first mark all nodes above the root,
4148
+ // and check if any of these nodes are reachable below the root.
4149
+ Grafreed.grafreed.universe.TagObjects(copy, true);
4150
+
4151
+ if (copy.versionlist == null && !copy.HasTags())
4152
+ {
4153
+ copy.versionlist = new Object3D[100];
4154
+
4155
+ //Save(true);
4156
+ }
4157
+ else
4158
+ copy.versionindex = -2;
4159
+
4160
+ Grafreed.grafreed.universe.TagObjects(copy, false);
4161
+ }
4162
+
4163
+ SetVersionStates();
4164
+
40604165 ClearUnpinned();
40614166
40624167 //Grafreed.Assert(group != null);
....@@ -4200,7 +4305,7 @@
42004305 TouchTransform(obj);
42014306 continue;
42024307 }
4203
- if ((mask&2) != 0) // Scale
4308
+ if ((mask&2) != 0) // Scale/rotation
42044309 {
42054310 obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
42064311 obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
....@@ -4208,10 +4313,6 @@
42084313 obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
42094314 obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
42104315 obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
4211
- }
4212
- if ((mask&4) != 0) // Rotation
4213
- {
4214
- // ?
42154316 }
42164317 if ((mask&1) != 0) // Translation
42174318 {
....@@ -5020,6 +5121,12 @@
50205121 refreshContents();
50215122 }
50225123
5124
+ void ClearVersions()
5125
+ {
5126
+ group.selection.ClearVersions();
5127
+ refreshContents();
5128
+ }
5129
+
50235130 void FlipV(boolean flip)
50245131 {
50255132 group.selection.FlipV(flip);
....@@ -5291,10 +5398,26 @@
52915398 flashSelectionButton.setEnabled(enabled);
52925399
52935400 clearPanelButton.setEnabled(!listUI.isEmpty());
5401
+
5402
+ boolean allComposites = true;
5403
+
5404
+ if (group.selection != null)
5405
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5406
+ {
5407
+ Object next = e.nextElement();
5408
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
5409
+ {
5410
+ allComposites = false;
5411
+ break;
5412
+ }
5413
+ }
5414
+
5415
+ rootButton.setEnabled(allComposites);
52945416 }
52955417
52965418 void refreshContents(boolean cp)
52975419 {
5420
+ if (Globals.ADVANCED)
52985421 //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
52995422 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
53005423 {
....@@ -6188,11 +6311,11 @@
61886311 private MenuItem lookAtItem;
61896312 private MenuItem lookFromItem;
61906313 private MenuItem switchViewItem;
6191
- private MenuItem cutItem;
6314
+ private JMenuItem cutItem;
61926315 private MenuItem undoItem;
61936316 private MenuItem redoItem;
61946317 private JMenuItem duplicateItem;
6195
- private MenuItem cloneItem;
6318
+ private JMenuItem cloneItem;
61966319 private MenuItem cloneSupportItem;
61976320 private MenuItem overwriteGeoItem;
61986321 private MenuItem overwriteMatItem;
....@@ -6213,13 +6336,13 @@
62136336 private MenuItem cloneGeometriesItem;
62146337 private MenuItem shareGeometriesItem;
62156338 private MenuItem mergeGeometriesItem;
6216
- private MenuItem copyItem;
6339
+ private JMenuItem copyItem;
62176340 private MenuItem pasteItem;
6218
- private MenuItem pasteIntoItem;
6219
- private MenuItem pasteLinkItem;
6220
- private MenuItem pasteCloneItem;
6221
- private MenuItem pasteExpandItem;
6222
- private MenuItem deleteItem;
6341
+ private JMenuItem pasteIntoItem;
6342
+ private JMenuItem pasteLinkItem;
6343
+ private JMenuItem pasteCloneItem;
6344
+ private JMenuItem pasteExpandItem;
6345
+ private JMenuItem deleteItem;
62236346 private MenuItem clearAllItem;
62246347 private MenuItem genUVItem;
62256348 private MenuItem genNormalsMESHItem;
....@@ -6245,6 +6368,7 @@
62456368 private MenuItem clipMeshItem;
62466369 private MenuItem smoothMeshItem;
62476370 private MenuItem clearMaterialsItem;
6371
+ private MenuItem clearVersionsItem;
62486372
62496373 private MenuItem liveleavesItem;
62506374 private MenuItem unliveleavesItem;
....@@ -6274,7 +6398,7 @@
62746398 private MenuItem transformGeometryItem;
62756399 private MenuItem transformChildrenItem;
62766400 private MenuItem hideItem;
6277
- private MenuItem grabItem;
6401
+ private JMenuItem grabItem;
62786402 private MenuItem backItem;
62796403 private MenuItem frontItem;
62806404 private MenuItem cameraItem;
....@@ -6287,7 +6411,7 @@
62876411 private MenuItem switchTransfoItem;
62886412 private MenuItem morphItem;
62896413 private MenuItem linkerItem;
6290
- private MenuItem ungroupItem;
6414
+ private JMenuItem ungroupItem;
62916415 private MenuItem editItem;
62926416 private MenuItem openWindowItem;
62936417 private MenuItem editLeafItem;