Normand Briere
2019-08-17 d5d6485126da83b06645e90e3e4ce66659a56009
GroupEditor.java
....@@ -16,6 +16,7 @@
1616 //import buoy.widget.BFileChooser;
1717
1818 class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
19
+ Grafreed.iResourceCallBack,
1920 ObjectUI,
2021 Runnable,
2122 ActionListener,
....@@ -30,7 +31,7 @@
3031 final String path = "cubemaps/" + f + "-skyboxes/" + s;
3132 row.add(skyboxButton = GetButton(path + "/preview.jpg", !Grafreed.NIMBUSLAF));
3233 //row.add(skyboxButton = GetButton(path + "/negx.jpg", !Grafreed.NIMBUSLAF));
33
- skyboxButton.setToolTipText(s);
34
+ skyboxButton.setToolTipText(s.equals("") ? "No background" : s);
3435 skyboxButton.addActionListener(new ActionListener()
3536 {
3637 @Override
....@@ -41,6 +42,22 @@
4142 });
4243 }
4344
45
+ public void AddTextureButton(String f, String c, final String t, int count, cGridBag row)
46
+ {
47
+ cButton textureButton;
48
+ final String path = "textures/" + f + "/" + c + "/"; // + t;
49
+ row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF));
50
+ textureButton.setToolTipText(c + count);
51
+ textureButton.addActionListener(new ActionListener()
52
+ {
53
+ @Override
54
+ public void actionPerformed(ActionEvent e)
55
+ {
56
+ ChangeTexture(path + t);
57
+ }
58
+ });
59
+ }
60
+
4461 public void AddSkyboxTab0(JTabbedPane skyboxpanel)
4562 {
4663 cGridBag tab0 = new cGridBag().setVertical(true);
....@@ -56,7 +73,7 @@
5673 cGridBag row5 = new cGridBag();
5774 cGridBag row6 = new cGridBag();
5875
59
- AddSkyboxButton("default", "rgb", row0);
76
+ AddSkyboxButton("default", "", row0);
6077 //AddSkyboxButton("default", "cornell", row0);
6178 AddSkyboxButton("penguins", "dust", row0);
6279 AddSkyboxButton("penguins", "tropic", row0);
....@@ -311,14 +328,56 @@
311328 }
312329 }
313330
314
- public void ChangeSkybox(String name)
331
+ public void ChangeSkybox(String skybox)
315332 {
316
- //cameraView.envyoff = false;
317
- group.skyboxname = name;
318
- group.skyboxext = "jpg";
319
- 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
+ }
346
+ }
347
+
348
+ public void CreateSkyboxPanel(cGridBag skyboxPanel)
349
+ {
350
+ JTabbedPane skyboxpane = new JTabbedPane();
351
+
352
+ AddSkyboxTab0(skyboxpane);
353
+ AddSkyboxTab1(skyboxpane);
354
+ AddSkyboxTab2(skyboxpane);
355
+ AddSkyboxTab3(skyboxpane);
356
+
357
+ skyboxPanel.add(skyboxpane);
320358 }
321359
360
+ public void ChangeTexture(String texture)
361
+ {
362
+ for (int i=0; i<group.selection.size(); i++)
363
+ {
364
+ Object3D obj = group.selection.get(i);
365
+ obj.SetPigmentTexture("@" + texture);
366
+ }
367
+
368
+ refreshContents();
369
+ }
370
+
371
+ public void Show3DView()
372
+ {
373
+ // bug
374
+ //gridPanel.setDividerLocation(1.0);
375
+ //bigPanel.setDividerLocation(0.0);
376
+ bigThree.ClearUI();
377
+ bigThree.add(centralPanel);
378
+ bigThree.FlushUI();
379
+ }
380
+
322381 //ObjEditor objEditor;
323382 public void closeUI2()
324383 {
....@@ -356,10 +415,14 @@
356415 this.copy = this.group = group;
357416 //selectees = this.group.selectees;
358417
418
+ assert(false);
419
+
359420 if (copy.versionlist == null)
360421 {
361422 copy.versionlist = new Object3D[100];
362423 copy.versionindex = -1;
424
+
425
+ //Save(true);
363426 }
364427
365428 if(ui)
....@@ -388,7 +451,7 @@
388451 copy.versionlist = new Object3D[100];
389452 copy.versionindex = -1;
390453
391
- Save(true);
454
+ //Save(true);
392455 }
393456 }
394457
....@@ -479,33 +542,35 @@
479542 // menu.add("-");
480543 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
481544 duplicateItem.addActionListener(this);
482
- cloneItem = menu.add(new MenuItem("Clone"));
545
+
546
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
483547 cloneItem.addActionListener(this);
484
- if (Globals.ADVANCED)
548
+ //if (Globals.ADVANCED)
485549 {
486550 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
487551 cloneSupportItem.addActionListener(this);
488552 }
553
+ oe.jTree.popup.addSeparator();
489554 menu.add("-");
490
- cutItem = menu.add(new MenuItem("Cut"));
555
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
491556 cutItem.addActionListener(this);
492
- copyItem = menu.add(new MenuItem("Copy"));
557
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
493558 copyItem.addActionListener(this);
494559 pasteItem = menu.add(new MenuItem("Paste"));
495560 pasteItem.addActionListener(this);
496561
497
- menu.add("-");
498
- 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"));
499565 pasteIntoItem.addActionListener(this);
500
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
566
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
501567 pasteLinkItem.addActionListener(this);
502
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
568
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
503569 pasteCloneItem.addActionListener(this);
504
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
570
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
505571 // pasteExpandItem.addActionListener(this);
506
- menu.add("-");
507
- deleteItem = menu.add(new MenuItem("Delete"));
508
- deleteItem.addActionListener(this);
572
+ //menu.add("-");
573
+ oe.jTree.popup.addSeparator();
509574
510575 if (Globals.ADVANCED)
511576 {
....@@ -591,11 +656,9 @@
591656 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
592657 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
593658 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
594
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
595659 oe.cameraMenu.add("-");
596660 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
597661 openWindowItem.addActionListener(this);
598
- editLeafItem.addActionListener(this);
599662 lookAtItem.addActionListener(this);
600663 //lookFromItem.addActinoListener(this);
601664 //switchViewItem.addActionListener(this);
....@@ -642,9 +705,8 @@
642705 setMasterItem.addActionListener(this);
643706 }
644707
645
- oe.menuBar.add(menu = new Menu("Group"));
646
-// grabItem = menu.add(new MenuItem("Grab"));
647
-// grabItem.addActionListener(this);
708
+ oe.menuBar.add(menu = new Menu("Order"));
709
+
648710 backItem = menu.add(new MenuItem("Back"));
649711 backItem.addActionListener(this);
650712 frontItem = menu.add(new MenuItem("Front"));
....@@ -652,13 +714,21 @@
652714 // compositeItem = menu.add(new MenuItem("Composite"));
653715 // compositeItem.addActionListener(this);
654716
717
+ grabItem = oe.jTree.popup.add(new JMenuItem("Group"));
718
+ grabItem.addActionListener(this);
719
+
655720 if (Globals.ADVANCED)
656721 {
657722 hideItem = menu.add(new MenuItem("Hidden Group"));
658723 hideItem.addActionListener(this);
659724 }
660
- ungroupItem = menu.add(new MenuItem("Ungroup"));
725
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
661726 ungroupItem.addActionListener(this);
727
+
728
+ oe.jTree.popup.addSeparator();
729
+
730
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
731
+ deleteItem.addActionListener(this);
662732
663733 // menu.add("-");
664734 //
....@@ -843,6 +913,9 @@
843913 shareGeometriesItem.addActionListener(this);
844914 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
845915 mergeGeometriesItem.addActionListener(this);
916
+ menu.add("-");
917
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
918
+ editLeafItem.addActionListener(this);
846919 if (Globals.ADVANCED)
847920 {
848921 // Pretty much the same as duplicate and clone.
....@@ -859,6 +932,74 @@
859932 buildToolsMenu(menu);
860933 }
861934
935
+ JTabbedPane resourcecontainer;
936
+ cGridBag currenttab;
937
+ //boolean added; // patch for jar
938
+
939
+ int tabcount = 0;
940
+ int colcount = 0;
941
+ int rowcount = 0;
942
+ int texturecount = 0;
943
+
944
+ int columns = 5;
945
+ int rows = 7;
946
+
947
+ public void ResourceCallBack(String[] path)
948
+ {
949
+// for (int i = 0; i < path.length; i++)
950
+// System.out.print(path[i] + "/");
951
+// System.out.println();
952
+
953
+ if (//rowcount == 0 ||
954
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
955
+ {
956
+ currenttab = new cGridBag();
957
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
958
+ currenttab.setName(tabname);
959
+ //added = false;
960
+ resourcecontainer.add(currenttab);
961
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
962
+ rowcount = 1;
963
+ colcount = 0;
964
+ texturecount = 0;
965
+ }
966
+
967
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
968
+ {
969
+ //if (!added)
970
+ {
971
+ //added = true;
972
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
973
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
974
+ }
975
+
976
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
977
+
978
+ if (++colcount >= columns)
979
+ {
980
+ colcount = 0;
981
+ currenttab.Return();
982
+
983
+ if (rowcount++ >= rows)
984
+ {
985
+ rowcount = 0;
986
+ }
987
+ }
988
+ }
989
+ else
990
+ {
991
+// if (!path[path.length-1].equals("icons"))
992
+// resourcecontainer.Return();
993
+ }
994
+ }
995
+
996
+ void CreateTexturePanel(cGridBag container)
997
+ {
998
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
999
+ container.add(resourcecontainer);
1000
+
1001
+ Grafreed.ParseResources("textures", this);
1002
+ }
8621003
8631004 void SetupUI2(ObjEditor oe)
8641005 {
....@@ -877,11 +1018,6 @@
8771018 //new Exception().printStackTrace();
8781019
8791020 oe.radioPanel = new JPanel(new GridBagLayout());
880
- oe.aConstraints.weightx = 1;
881
- oe.aConstraints.weighty = 0;
882
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
883
- oe.aConstraints.gridwidth = 100;
884
- oe.aConstraints.gridheight = 1;
8851021 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8861022
8871023 oe.buttonGroup = new ButtonGroup();
....@@ -902,9 +1038,9 @@
9021038 oe.radioPanel.add(dummyButton);
9031039 oe.buttonGroup.add(dummyButton);
9041040 */
905
- cGridBag copyOptionsPanel = new cGridBag();
1041
+ cGridBag versionManagerPanel = new cGridBag();
9061042
907
- copyOptionsPanel.preferredHeight = 2;
1043
+ versionManagerPanel.preferredHeight = 4;
9081044
9091045 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
9101046
....@@ -914,10 +1050,49 @@
9141050
9151051 if (Globals.ADVANCED)
9161052 {
917
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
918
- maxButton.setToolTipText("Maximize window");
919
- 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);
9201056 }
1057
+
1058
+ cButton gcButton;
1059
+
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
+// });
1069
+
1070
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1071
+ collapseButton.setToolTipText("Collapse toolbar");
1072
+ collapseButton.addActionListener(this);
1073
+
1074
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/square.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1075
+ maximize3DButton.setToolTipText("Maximize 3D view");
1076
+ maximize3DButton.addActionListener(this);
1077
+
1078
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1079
+ twoButton.setToolTipText("Show 3D view only");
1080
+ twoButton.addActionListener(this);
1081
+ this.fullscreenLayout = twoButton;
1082
+
1083
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1084
+ threeButton.setToolTipText("Show controls and 3D view");
1085
+ threeButton.addActionListener(this);
1086
+ if (Globals.ADVANCED)
1087
+ {
1088
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1089
+ sixButton.setToolTipText("Show 3D view and controls");
1090
+ sixButton.addActionListener(this);
1091
+ }
1092
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1093
+// sevenButton.setToolTipText("3-column layout");
1094
+// sevenButton.addActionListener(this);
1095
+ //
9211096
9221097 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9231098 fullButton.setToolTipText("Full-screen window");
....@@ -931,15 +1106,16 @@
9311106 restoreCameraButton.setToolTipText("Restore viewpoint");
9321107 restoreCameraButton.addActionListener(this);
9331108
934
- copyOptionsPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1109
+ versionManagerPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9351110 saveVersionButton.setToolTipText("Duplicate current version");
9361111 saveVersionButton.addActionListener(this);
9371112
938
- copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1113
+ versionManagerPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9391114 deleteVersionButton.setToolTipText("Delete current version");
9401115 deleteVersionButton.addActionListener(this);
1116
+ deleteVersionButton.setEnabled(false);
9411117
942
- copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1118
+ versionManagerPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9431119 previousVersionButton.setToolTipText("Previous version");
9441120 previousVersionButton.addActionListener(this);
9451121 previousVersionButton.setEnabled(false);
....@@ -948,28 +1124,28 @@
9481124 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9491125 restoreButton.setToolTipText("Undo (restore current version)");
9501126 restoreButton.addActionListener(this);
951
- //restoreButton.setEnabled(false);
1127
+ restoreButton.setEnabled(false);
9521128
9531129 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9541130 replaceButton.setToolTipText("Save (replace current version)");
9551131 replaceButton.addActionListener(this);
956
- //replaceButton.setEnabled(false);
1132
+ replaceButton.setEnabled(false);
9571133
958
- copyOptionsPanel.add(updown);
1134
+ versionManagerPanel.add(updown);
9591135
960
- copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1136
+ versionManagerPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9611137 nextVersionButton.setToolTipText("Next version");
9621138 nextVersionButton.addActionListener(this);
9631139 nextVersionButton.setEnabled(false);
1140
+
1141
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1142
+ oneStepButton.setToolTipText("Animate one step forward");
1143
+ oneStepButton.addActionListener(this);
9641144
9651145 oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
9661146 liveCB.setToolTipText("Enable animation");
9671147 liveCB.addItemListener(this);
9681148
969
- oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
970
- oneStepButton.setToolTipText("Animate one step forward");
971
- oneStepButton.addActionListener(this);
972
-
9731149 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9741150 fastCB.setToolTipText("Fast mode");
9751151 fastCB.addItemListener(this);
....@@ -996,21 +1172,6 @@
9961172
9971173 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
9981174
999
- oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1000
- twoButton.setToolTipText("Show 3D view only");
1001
- twoButton.addActionListener(this);
1002
- this.fullscreenLayout = twoButton;
1003
-
1004
- oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1005
- threeButton.setToolTipText("Show controls and 3D view");
1006
- threeButton.addActionListener(this);
1007
- oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1008
- sixButton.setToolTipText("Show 3D view and controls");
1009
- sixButton.addActionListener(this);
1010
-// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1011
-// sevenButton.setToolTipText("3-column layout");
1012
-// sevenButton.addActionListener(this);
1013
- //
10141175
10151176 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10161177 rootButton.setToolTipText("Open selection in new tab");
....@@ -1026,12 +1187,16 @@
10261187
10271188 // INSERT
10281189 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1029
- gridButton.setToolTipText("Create grid");
1190
+ gridButton.setToolTipText("Create ground");
10301191 gridButton.addActionListener(this);
10311192
10321193 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10331194 boxButton.setToolTipText("Create box");
10341195 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);
10351200
10361201 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10371202 sphereButton.setToolTipText("Create sphere");
....@@ -1044,10 +1209,6 @@
10441209 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10451210 torusButton.setToolTipText("Create torus");
10461211 torusButton.addActionListener(this);
1047
-
1048
- row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1049
- superButton.setToolTipText("Create superellipsoid");
1050
- superButton.addActionListener(this);
10511212
10521213 if (Globals.ADVANCED)
10531214 {
....@@ -1094,19 +1255,17 @@
10941255
10951256 oe.toolboxPanel.add(row2);
10961257
1097
- // ENVYMAPS
1098
- cGridBag skyboxpane = new cGridBag();
1099
- skyboxpane.preferredHeight = 100;
1258
+ cGridBag textures = new cGridBag();
11001259
1101
- oe.toolboxPanel.add(skyboxpane);
1260
+ CreateTexturePanel(textures);
11021261
1103
- JTabbedPane skyboxpanel = new JTabbedPane();
1104
- skyboxpane.add(skyboxpanel);
1262
+ resourcecontainer.setSelectedIndex((int)(Math.random() * resourcecontainer.getTabCount()));
11051263
1106
- AddSkyboxTab0(skyboxpanel);
1107
- AddSkyboxTab1(skyboxpanel);
1108
- AddSkyboxTab2(skyboxpanel);
1109
- AddSkyboxTab3(skyboxpanel);
1264
+ oe.toolboxPanel.add(textures);
1265
+
1266
+ textures.preferredHeight = 100;
1267
+
1268
+ CreateSkyboxPanel(oe.skyboxPanel);
11101269
11111270 // EDIT panel
11121271 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1118,16 +1277,16 @@
11181277 uneditButton.addActionListener(this);
11191278
11201279 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1121
- allParamsButton.setToolTipText("Show all controle");
1280
+ allParamsButton.setToolTipText("Show all controls");
11221281 allParamsButton.addActionListener(this);
11231282
11241283 editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- clearPanelButton.setToolTipText("Clear edit panel");
1284
+ clearPanelButton.setToolTipText("Clear all controls");
11261285 clearPanelButton.addActionListener(this);
11271286
1128
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1129
- unselectButton.setToolTipText("Unselect");
1130
- unselectButton.addActionListener(this);
1287
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1288
+ //unselectButton.setToolTipText("Unselect");
1289
+ //unselectButton.addActionListener(this);
11311290
11321291 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11331292 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -1152,6 +1311,8 @@
11521311
11531312 cGridBag jSPPanel = new cGridBag();
11541313
1314
+ jSPPanel.preferredHeight = 20;
1315
+
11551316 JScrollPane jSP;
11561317 //ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints);
11571318 jSPPanel.add(jSP = new JScrollPane(oe.jTree)); //, oe.aConstraints);
....@@ -1160,11 +1321,11 @@
11601321 oe.treePanel.add(jSPPanel);
11611322 oe.treePanel.Return();
11621323
1163
- oe.treePanel.add(copyOptionsPanel);
1324
+ oe.treePanel.add(versionManagerPanel);
11641325 oe.treePanel.Return();
1165
- cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
1166
- versionSlider = (cNumberSlider)sliderPane.getComponent(1);
1167
- sliderPane.preferredHeight = 1;
1326
+ versionSliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
1327
+ versionSlider = (cNumberSlider)versionSliderPane.getComponent(1);
1328
+ versionSliderPane.preferredHeight = 3;
11681329
11691330 // mainPanel.setDividerLocation(0.1); //1.0);
11701331 mainPanel.setResizeWeight(0.4);
....@@ -1322,6 +1483,14 @@
13221483
13231484 void EditObject(Object3D obj)
13241485 {
1486
+ assert(obj instanceof Composite);
1487
+
1488
+// if (obj.versionlist == null)
1489
+// {
1490
+// obj.versionlist = new Object3D[100];
1491
+// obj.versionindex = -1;
1492
+// }
1493
+
13251494 cRadio radioButton = new cRadio(obj.name);
13261495
13271496 // June 2019. Patch to avoid bug with transparency.
....@@ -1346,6 +1515,7 @@
13461515
13471516 oe.SetupViews();
13481517
1518
+ if (Globals.DEBUG)
13491519 System.out.println("SetupViews");
13501520 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
13511521 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -1712,7 +1882,12 @@
17121882 TreePath path;
17131883
17141884 public TransferableTreePath(TreePath tp) {
1715
- path = tp;
1885
+ Object[] objs = new Object[tp.getPathCount()];
1886
+ for (int i=0; i<objs.length; i++)
1887
+ {
1888
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1889
+ }
1890
+ path = new TreePath(objs);
17161891 }
17171892
17181893 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2002,7 +2177,11 @@
20022177 shadow.material = new cMaterial(obj.material);
20032178 shadow.material.diffuse = 0.0001f;
20042179 shadow.material.specular = 0.0001f;
2005
- //shadow.projectedVertices[1].x = 300;
2180
+ shadow.material.opacity = 0.75f;
2181
+
2182
+ AllocProjectedVertices(shadow);
2183
+
2184
+ shadow.projectedVertices[1].x = 300;
20062185
20072186 makeSomething(shadow);
20082187 }
....@@ -2523,27 +2702,35 @@
25232702 } else
25242703 if (source == loopItem || source == loopButton)
25252704 {
2705
+ if (!group.selection.isEmpty())
2706
+ {
25262707 Composite csg = new GroupLeaf();
25272708 csg.count = 5;
2528
- group(csg);
25292709 Composite child = new cGroup("Branch");
25302710 csg.addChild(child);
25312711 child.addChild(csg);
2712
+ group(csg);
2713
+ }
25322714 } else
25332715 if (source == doubleItem)
25342716 {
2717
+ if (!group.selection.isEmpty())
2718
+ {
25352719 Composite csg = new GroupLeaf("Fork");
25362720 csg.count = 5;
2537
- group(csg);
25382721 Composite child = new cGroup("Branch A");
25392722 csg.addChild(child);
25402723 child.addChild(csg);
25412724 child = new cGroup("Branch B");
25422725 csg.addChild(child);
25432726 child.addChild(csg);
2727
+ group(csg);
2728
+ }
25442729 } else
25452730 if (source == tripleItem)
25462731 {
2732
+ if (!group.selection.isEmpty())
2733
+ {
25472734 Composite csg = new GroupLeaf("Trident");
25482735 csg.count = 4;
25492736 group(csg);
....@@ -2556,6 +2743,7 @@
25562743 child = new cGroup();
25572744 csg.addChild(child);
25582745 child.addChild(csg);
2746
+ }
25592747 } else
25602748 if (source == computeAOItem)
25612749 {
....@@ -2605,6 +2793,18 @@
26052793 if (source == fullButton)
26062794 {
26072795 ToggleFullScreen();
2796
+ } else
2797
+ if (source == collapseButton)
2798
+ {
2799
+ this.expandedLayout = radio.layout;
2800
+ CollapseToolbar();
2801
+ } else
2802
+ if (source == maximize3DButton)
2803
+ {
2804
+ this.expandedLayout = radio.layout;
2805
+ radio.layout = twoButton;
2806
+ Show3DView();
2807
+ CollapseToolbar();
26082808 } else
26092809 if (source == previousVersionButton)
26102810 {
....@@ -3179,22 +3379,34 @@
31793379 } else
31803380 if (source == ungroupItem || source == ungroupButton)
31813381 {
3182
- boolean hasRoot = false;
3382
+ boolean canUngroup = true;
31833383
31843384 for (int i=0; i<group.selection.size(); i++)
31853385 {
3186
- if (group.selection.get(i) == group)
3386
+ Object3D selectedItem = group.selection.get(i);
3387
+
3388
+ if (selectedItem.Size() == 0)
31873389 {
3188
- hasRoot = true;
3390
+ // Cannot ungroup leaves
3391
+ canUngroup = false;
3392
+ break;
3393
+ }
3394
+
3395
+ if (selectedItem == group)
3396
+ {
3397
+ // Cannot ungroup root
3398
+ canUngroup = false;
31893399 break;
31903400 }
31913401 }
31923402
3193
- if (!hasRoot)
3403
+ if (canUngroup)
31943404 {
31953405 for (int i=0; i<group.selection.size(); i++)
31963406 {
3197
- Ungroup(group.selection.get(i));
3407
+ Object3D selectedItem = group.selection.get(i);
3408
+
3409
+ Ungroup(selectedItem);
31983410 }
31993411
32003412 ClearSelection(false);
....@@ -3557,38 +3769,7 @@
35573769 if (CameraPane.FULLSCREEN)
35583770 fullscreenLayout = radio.layout;
35593771
3560
- // bug
3561
- //gridPanel.setDividerLocation(1.0);
3562
- //bigPanel.setDividerLocation(0.0);
3563
-// bigThree.remove(scenePanel);
3564
-// bigThree.remove(centralPanel);
3565
-// bigThree.remove(XYZPanel);
3566
-// aWindowConstraints.gridx = 0;
3567
-// aWindowConstraints.gridy = 0;
3568
-// aWindowConstraints.gridwidth = 1;
3569
-// // aConstraints.gridheight = 3;
3570
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3571
-// aWindowConstraints.weightx = 0;
3572
-// aWindowConstraints.weighty = 1;
3573
-// //bigThree.add(jtp, aWindowConstraints);
3574
-// aWindowConstraints.weightx = 1;
3575
-// aWindowConstraints.gridwidth = 3;
3576
-// // aConstraints.gridheight = 3;
3577
-// aWindowConstraints.gridx = 1;
3578
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3579
-// bigThree.add(centralPanel, aWindowConstraints);
3580
-// aWindowConstraints.weightx = 0;
3581
-// aWindowConstraints.gridx = 4;
3582
-// aWindowConstraints.gridwidth = 1;
3583
-// // aConstraints.gridheight = 3;
3584
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3585
-// //bigThree.add(XYZPanel, aWindowConstraints);
3586
-// scenePanel.setVisible(false);
3587
-// centralPanel.setVisible(true);
3588
-// XYZPanel.setVisible(false);
3589
- bigThree.ClearUI();
3590
- bigThree.add(centralPanel);
3591
- bigThree.FlushUI();
3772
+ Show3DView();
35923773
35933774 cameraView.requestFocusInWindow();
35943775
....@@ -3774,6 +3955,7 @@
37743955 } else
37753956 if (source == rootButton)
37763957 {
3958
+ Replace();
37773959 Object3D obj;
37783960 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37793961 {
....@@ -3788,6 +3970,8 @@
37883970 if (source == closeButton)
37893971 {
37903972 //System.out.println("CLOSE: " + buttonGroup.getSelection());
3973
+ Replace();
3974
+
37913975 cRadio ab;
37923976 for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
37933977 {
....@@ -3886,6 +4070,8 @@
38864070 } else
38874071 if(source instanceof cRadio)
38884072 {
4073
+ Replace();
4074
+
38894075 group.parent = keepparent;
38904076 group.attributes = 0;
38914077 //group.editWindow = null;
....@@ -3910,8 +4096,6 @@
39104096
39114097 copy = group;
39124098
3913
- SetUndoStates();
3914
-
39154099 //Globals.theRenderer.object = group;
39164100 if(!useclient)
39174101 {
....@@ -3939,6 +4123,29 @@
39394123 */
39404124 radio.layout.doClick();
39414125
4126
+ assert(copy instanceof Composite);
4127
+
4128
+ if (copy.versionlist == null)
4129
+ {
4130
+ copy.versionindex = -1;
4131
+
4132
+ // Cannot work with loops
4133
+ // To fix this issue, we first mark all nodes above the root,
4134
+ // and check if any of these nodes are reachable below the root.
4135
+ Grafreed.grafreed.universe.TagObjects(copy, true);
4136
+
4137
+ if (!copy.HasTags())
4138
+ {
4139
+ copy.versionlist = new Object3D[100];
4140
+
4141
+ Save(true);
4142
+ }
4143
+
4144
+ Grafreed.grafreed.universe.TagObjects(copy, false);
4145
+ }
4146
+
4147
+ SetVersionStates();
4148
+
39424149 ClearUnpinned();
39434150
39444151 //Grafreed.Assert(group != null);
....@@ -4082,7 +4289,7 @@
40824289 TouchTransform(obj);
40834290 continue;
40844291 }
4085
- if ((mask&2) != 0) // Scale
4292
+ if ((mask&2) != 0) // Scale/rotation
40864293 {
40874294 obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
40884295 obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
....@@ -4090,10 +4297,6 @@
40904297 obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
40914298 obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
40924299 obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
4093
- }
4094
- if ((mask&4) != 0) // Rotation
4095
- {
4096
- // ?
40974300 }
40984301 if ((mask&1) != 0) // Translation
40994302 {
....@@ -5169,15 +5372,31 @@
51695372 {
51705373 editButton.setEnabled(enabled);
51715374 uneditButton.setEnabled(enabled);
5172
- unselectButton.setEnabled(enabled);
5375
+ //unselectButton.setEnabled(enabled);
51735376 flashSelectionButton.setEnabled(enabled);
51745377
51755378 clearPanelButton.setEnabled(!listUI.isEmpty());
5379
+
5380
+ boolean allComposites = true;
5381
+
5382
+ if (group.selection != null)
5383
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5384
+ {
5385
+ Object next = e.nextElement();
5386
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
5387
+ {
5388
+ allComposites = false;
5389
+ break;
5390
+ }
5391
+ }
5392
+
5393
+ rootButton.setEnabled(allComposites);
51765394 }
51775395
51785396 void refreshContents(boolean cp)
51795397 {
5180
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5398
+ if (false)
5399
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51815400 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51825401 {
51835402 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5187,7 +5406,7 @@
51875406 Object3D child = (Object3D) group.selection.get(i);
51885407
51895408 objEditor.AddInfo(child, this, true);
5190
- System.err.println("info : " + child.GetPath());
5409
+// System.err.println("info : " + child.GetPath());
51915410 }
51925411
51935412 objEditor.SetText(); // jan 2014
....@@ -6070,11 +6289,11 @@
60706289 private MenuItem lookAtItem;
60716290 private MenuItem lookFromItem;
60726291 private MenuItem switchViewItem;
6073
- private MenuItem cutItem;
6292
+ private JMenuItem cutItem;
60746293 private MenuItem undoItem;
60756294 private MenuItem redoItem;
60766295 private JMenuItem duplicateItem;
6077
- private MenuItem cloneItem;
6296
+ private JMenuItem cloneItem;
60786297 private MenuItem cloneSupportItem;
60796298 private MenuItem overwriteGeoItem;
60806299 private MenuItem overwriteMatItem;
....@@ -6095,13 +6314,13 @@
60956314 private MenuItem cloneGeometriesItem;
60966315 private MenuItem shareGeometriesItem;
60976316 private MenuItem mergeGeometriesItem;
6098
- private MenuItem copyItem;
6317
+ private JMenuItem copyItem;
60996318 private MenuItem pasteItem;
6100
- private MenuItem pasteIntoItem;
6101
- private MenuItem pasteLinkItem;
6102
- private MenuItem pasteCloneItem;
6103
- private MenuItem pasteExpandItem;
6104
- private MenuItem deleteItem;
6319
+ private JMenuItem pasteIntoItem;
6320
+ private JMenuItem pasteLinkItem;
6321
+ private JMenuItem pasteCloneItem;
6322
+ private JMenuItem pasteExpandItem;
6323
+ private JMenuItem deleteItem;
61056324 private MenuItem clearAllItem;
61066325 private MenuItem genUVItem;
61076326 private MenuItem genNormalsMESHItem;
....@@ -6156,7 +6375,7 @@
61566375 private MenuItem transformGeometryItem;
61576376 private MenuItem transformChildrenItem;
61586377 private MenuItem hideItem;
6159
- private MenuItem grabItem;
6378
+ private JMenuItem grabItem;
61606379 private MenuItem backItem;
61616380 private MenuItem frontItem;
61626381 private MenuItem cameraItem;
....@@ -6169,7 +6388,7 @@
61696388 private MenuItem switchTransfoItem;
61706389 private MenuItem morphItem;
61716390 private MenuItem linkerItem;
6172
- private MenuItem ungroupItem;
6391
+ private JMenuItem ungroupItem;
61736392 private MenuItem editItem;
61746393 private MenuItem openWindowItem;
61756394 private MenuItem editLeafItem;