Normand Briere
2019-08-17 d5d6485126da83b06645e90e3e4ce66659a56009
GroupEditor.java
....@@ -16,7 +16,7 @@
1616 //import buoy.widget.BFileChooser;
1717
1818 class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
19
- Grafreed.iResourceCallBack,
19
+ Grafreed.iResourceCallBack,
2020 ObjectUI,
2121 Runnable,
2222 ActionListener,
....@@ -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
....@@ -42,6 +42,22 @@
4242 });
4343 }
4444
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
+
4561 public void AddSkyboxTab0(JTabbedPane skyboxpanel)
4662 {
4763 cGridBag tab0 = new cGridBag().setVertical(true);
....@@ -57,7 +73,7 @@
5773 cGridBag row5 = new cGridBag();
5874 cGridBag row6 = new cGridBag();
5975
60
- AddSkyboxButton("default", "rgb", row0);
76
+ AddSkyboxButton("default", "", row0);
6177 //AddSkyboxButton("default", "cornell", row0);
6278 AddSkyboxButton("penguins", "dust", row0);
6379 AddSkyboxButton("penguins", "tropic", row0);
....@@ -312,26 +328,56 @@
312328 }
313329 }
314330
315
- public void CallBack(String[] path)
316
- {
317
- for (int i = 0; i < path.length; i++)
318
- {
319
- System.out.print(path[i] + "/");
320
- }
321
-
322
- System.out.println();
323
- }
324
-
325331 public void ChangeSkybox(String skybox)
326332 {
327
- //cameraView.envyoff = false;
328
- group.skyboxname = skybox;
329
- group.skyboxext = "jpg";
330
- 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
+ }
331347
332
- Grafreed.ParseResources("textures", this);
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);
333358 }
334359
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
+
335381 //ObjEditor objEditor;
336382 public void closeUI2()
337383 {
....@@ -369,10 +415,14 @@
369415 this.copy = this.group = group;
370416 //selectees = this.group.selectees;
371417
418
+ assert(false);
419
+
372420 if (copy.versionlist == null)
373421 {
374422 copy.versionlist = new Object3D[100];
375423 copy.versionindex = -1;
424
+
425
+ //Save(true);
376426 }
377427
378428 if(ui)
....@@ -401,7 +451,7 @@
401451 copy.versionlist = new Object3D[100];
402452 copy.versionindex = -1;
403453
404
- Save(true);
454
+ //Save(true);
405455 }
406456 }
407457
....@@ -492,33 +542,35 @@
492542 // menu.add("-");
493543 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
494544 duplicateItem.addActionListener(this);
495
- cloneItem = menu.add(new MenuItem("Clone"));
545
+
546
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
496547 cloneItem.addActionListener(this);
497
- if (Globals.ADVANCED)
548
+ //if (Globals.ADVANCED)
498549 {
499550 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
500551 cloneSupportItem.addActionListener(this);
501552 }
553
+ oe.jTree.popup.addSeparator();
502554 menu.add("-");
503
- cutItem = menu.add(new MenuItem("Cut"));
555
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
504556 cutItem.addActionListener(this);
505
- copyItem = menu.add(new MenuItem("Copy"));
557
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
506558 copyItem.addActionListener(this);
507559 pasteItem = menu.add(new MenuItem("Paste"));
508560 pasteItem.addActionListener(this);
509561
510
- menu.add("-");
511
- 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"));
512565 pasteIntoItem.addActionListener(this);
513
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
566
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
514567 pasteLinkItem.addActionListener(this);
515
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
568
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
516569 pasteCloneItem.addActionListener(this);
517
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
570
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
518571 // pasteExpandItem.addActionListener(this);
519
- menu.add("-");
520
- deleteItem = menu.add(new MenuItem("Delete"));
521
- deleteItem.addActionListener(this);
572
+ //menu.add("-");
573
+ oe.jTree.popup.addSeparator();
522574
523575 if (Globals.ADVANCED)
524576 {
....@@ -604,11 +656,9 @@
604656 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
605657 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
606658 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
607
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
608659 oe.cameraMenu.add("-");
609660 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
610661 openWindowItem.addActionListener(this);
611
- editLeafItem.addActionListener(this);
612662 lookAtItem.addActionListener(this);
613663 //lookFromItem.addActinoListener(this);
614664 //switchViewItem.addActionListener(this);
....@@ -655,9 +705,8 @@
655705 setMasterItem.addActionListener(this);
656706 }
657707
658
- oe.menuBar.add(menu = new Menu("Group"));
659
-// grabItem = menu.add(new MenuItem("Grab"));
660
-// grabItem.addActionListener(this);
708
+ oe.menuBar.add(menu = new Menu("Order"));
709
+
661710 backItem = menu.add(new MenuItem("Back"));
662711 backItem.addActionListener(this);
663712 frontItem = menu.add(new MenuItem("Front"));
....@@ -665,13 +714,21 @@
665714 // compositeItem = menu.add(new MenuItem("Composite"));
666715 // compositeItem.addActionListener(this);
667716
717
+ grabItem = oe.jTree.popup.add(new JMenuItem("Group"));
718
+ grabItem.addActionListener(this);
719
+
668720 if (Globals.ADVANCED)
669721 {
670722 hideItem = menu.add(new MenuItem("Hidden Group"));
671723 hideItem.addActionListener(this);
672724 }
673
- ungroupItem = menu.add(new MenuItem("Ungroup"));
725
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
674726 ungroupItem.addActionListener(this);
727
+
728
+ oe.jTree.popup.addSeparator();
729
+
730
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
731
+ deleteItem.addActionListener(this);
675732
676733 // menu.add("-");
677734 //
....@@ -856,6 +913,9 @@
856913 shareGeometriesItem.addActionListener(this);
857914 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
858915 mergeGeometriesItem.addActionListener(this);
916
+ menu.add("-");
917
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
918
+ editLeafItem.addActionListener(this);
859919 if (Globals.ADVANCED)
860920 {
861921 // Pretty much the same as duplicate and clone.
....@@ -872,6 +932,74 @@
872932 buildToolsMenu(menu);
873933 }
874934
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
+ }
8751003
8761004 void SetupUI2(ObjEditor oe)
8771005 {
....@@ -890,11 +1018,6 @@
8901018 //new Exception().printStackTrace();
8911019
8921020 oe.radioPanel = new JPanel(new GridBagLayout());
893
- oe.aConstraints.weightx = 1;
894
- oe.aConstraints.weighty = 0;
895
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
896
- oe.aConstraints.gridwidth = 100;
897
- oe.aConstraints.gridheight = 1;
8981021 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8991022
9001023 oe.buttonGroup = new ButtonGroup();
....@@ -915,9 +1038,9 @@
9151038 oe.radioPanel.add(dummyButton);
9161039 oe.buttonGroup.add(dummyButton);
9171040 */
918
- cGridBag copyOptionsPanel = new cGridBag();
1041
+ cGridBag versionManagerPanel = new cGridBag();
9191042
920
- copyOptionsPanel.preferredHeight = 2;
1043
+ versionManagerPanel.preferredHeight = 4;
9211044
9221045 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
9231046
....@@ -927,10 +1050,49 @@
9271050
9281051 if (Globals.ADVANCED)
9291052 {
930
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
931
- maxButton.setToolTipText("Maximize window");
932
- 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);
9331056 }
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
+ //
9341096
9351097 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9361098 fullButton.setToolTipText("Full-screen window");
....@@ -944,15 +1106,16 @@
9441106 restoreCameraButton.setToolTipText("Restore viewpoint");
9451107 restoreCameraButton.addActionListener(this);
9461108
947
- 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);
9481110 saveVersionButton.setToolTipText("Duplicate current version");
9491111 saveVersionButton.addActionListener(this);
9501112
951
- copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1113
+ versionManagerPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9521114 deleteVersionButton.setToolTipText("Delete current version");
9531115 deleteVersionButton.addActionListener(this);
1116
+ deleteVersionButton.setEnabled(false);
9541117
955
- copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1118
+ versionManagerPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9561119 previousVersionButton.setToolTipText("Previous version");
9571120 previousVersionButton.addActionListener(this);
9581121 previousVersionButton.setEnabled(false);
....@@ -961,28 +1124,28 @@
9611124 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9621125 restoreButton.setToolTipText("Undo (restore current version)");
9631126 restoreButton.addActionListener(this);
964
- //restoreButton.setEnabled(false);
1127
+ restoreButton.setEnabled(false);
9651128
9661129 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9671130 replaceButton.setToolTipText("Save (replace current version)");
9681131 replaceButton.addActionListener(this);
969
- //replaceButton.setEnabled(false);
1132
+ replaceButton.setEnabled(false);
9701133
971
- copyOptionsPanel.add(updown);
1134
+ versionManagerPanel.add(updown);
9721135
973
- copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1136
+ versionManagerPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9741137 nextVersionButton.setToolTipText("Next version");
9751138 nextVersionButton.addActionListener(this);
9761139 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);
9771144
9781145 oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
9791146 liveCB.setToolTipText("Enable animation");
9801147 liveCB.addItemListener(this);
9811148
982
- oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
983
- oneStepButton.setToolTipText("Animate one step forward");
984
- oneStepButton.addActionListener(this);
985
-
9861149 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9871150 fastCB.setToolTipText("Fast mode");
9881151 fastCB.addItemListener(this);
....@@ -1009,21 +1172,6 @@
10091172
10101173 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
10111174
1012
- oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1013
- twoButton.setToolTipText("Show 3D view only");
1014
- twoButton.addActionListener(this);
1015
- this.fullscreenLayout = twoButton;
1016
-
1017
- oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1018
- threeButton.setToolTipText("Show controls and 3D view");
1019
- threeButton.addActionListener(this);
1020
- oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1021
- sixButton.setToolTipText("Show 3D view and controls");
1022
- sixButton.addActionListener(this);
1023
-// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1024
-// sevenButton.setToolTipText("3-column layout");
1025
-// sevenButton.addActionListener(this);
1026
- //
10271175
10281176 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10291177 rootButton.setToolTipText("Open selection in new tab");
....@@ -1039,12 +1187,16 @@
10391187
10401188 // INSERT
10411189 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1042
- gridButton.setToolTipText("Create grid");
1190
+ gridButton.setToolTipText("Create ground");
10431191 gridButton.addActionListener(this);
10441192
10451193 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10461194 boxButton.setToolTipText("Create box");
10471195 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);
10481200
10491201 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10501202 sphereButton.setToolTipText("Create sphere");
....@@ -1057,10 +1209,6 @@
10571209 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10581210 torusButton.setToolTipText("Create torus");
10591211 torusButton.addActionListener(this);
1060
-
1061
- row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1062
- superButton.setToolTipText("Create superellipsoid");
1063
- superButton.addActionListener(this);
10641212
10651213 if (Globals.ADVANCED)
10661214 {
....@@ -1107,19 +1255,17 @@
11071255
11081256 oe.toolboxPanel.add(row2);
11091257
1110
- // ENVYMAPS
1111
- cGridBag skyboxpane = new cGridBag();
1112
- skyboxpane.preferredHeight = 100;
1258
+ cGridBag textures = new cGridBag();
11131259
1114
- oe.skyboxPanel.add(skyboxpane);
1260
+ CreateTexturePanel(textures);
11151261
1116
- JTabbedPane skyboxpanel = new JTabbedPane();
1117
- skyboxpane.add(skyboxpanel);
1262
+ resourcecontainer.setSelectedIndex((int)(Math.random() * resourcecontainer.getTabCount()));
11181263
1119
- AddSkyboxTab0(skyboxpanel);
1120
- AddSkyboxTab1(skyboxpanel);
1121
- AddSkyboxTab2(skyboxpanel);
1122
- AddSkyboxTab3(skyboxpanel);
1264
+ oe.toolboxPanel.add(textures);
1265
+
1266
+ textures.preferredHeight = 100;
1267
+
1268
+ CreateSkyboxPanel(oe.skyboxPanel);
11231269
11241270 // EDIT panel
11251271 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1131,11 +1277,11 @@
11311277 uneditButton.addActionListener(this);
11321278
11331279 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1134
- allParamsButton.setToolTipText("Show all controle");
1280
+ allParamsButton.setToolTipText("Show all controls");
11351281 allParamsButton.addActionListener(this);
11361282
11371283 editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1138
- clearPanelButton.setToolTipText("Clear edit panel");
1284
+ clearPanelButton.setToolTipText("Clear all controls");
11391285 clearPanelButton.addActionListener(this);
11401286
11411287 //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1165,6 +1311,8 @@
11651311
11661312 cGridBag jSPPanel = new cGridBag();
11671313
1314
+ jSPPanel.preferredHeight = 20;
1315
+
11681316 JScrollPane jSP;
11691317 //ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints);
11701318 jSPPanel.add(jSP = new JScrollPane(oe.jTree)); //, oe.aConstraints);
....@@ -1173,11 +1321,11 @@
11731321 oe.treePanel.add(jSPPanel);
11741322 oe.treePanel.Return();
11751323
1176
- oe.treePanel.add(copyOptionsPanel);
1324
+ oe.treePanel.add(versionManagerPanel);
11771325 oe.treePanel.Return();
1178
- cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
1179
- versionSlider = (cNumberSlider)sliderPane.getComponent(1);
1180
- sliderPane.preferredHeight = 1;
1326
+ versionSliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
1327
+ versionSlider = (cNumberSlider)versionSliderPane.getComponent(1);
1328
+ versionSliderPane.preferredHeight = 3;
11811329
11821330 // mainPanel.setDividerLocation(0.1); //1.0);
11831331 mainPanel.setResizeWeight(0.4);
....@@ -1335,6 +1483,14 @@
13351483
13361484 void EditObject(Object3D obj)
13371485 {
1486
+ assert(obj instanceof Composite);
1487
+
1488
+// if (obj.versionlist == null)
1489
+// {
1490
+// obj.versionlist = new Object3D[100];
1491
+// obj.versionindex = -1;
1492
+// }
1493
+
13381494 cRadio radioButton = new cRadio(obj.name);
13391495
13401496 // June 2019. Patch to avoid bug with transparency.
....@@ -1359,6 +1515,7 @@
13591515
13601516 oe.SetupViews();
13611517
1518
+ if (Globals.DEBUG)
13621519 System.out.println("SetupViews");
13631520 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
13641521 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -1725,7 +1882,12 @@
17251882 TreePath path;
17261883
17271884 public TransferableTreePath(TreePath tp) {
1728
- 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);
17291891 }
17301892
17311893 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2015,7 +2177,11 @@
20152177 shadow.material = new cMaterial(obj.material);
20162178 shadow.material.diffuse = 0.0001f;
20172179 shadow.material.specular = 0.0001f;
2018
- //shadow.projectedVertices[1].x = 300;
2180
+ shadow.material.opacity = 0.75f;
2181
+
2182
+ AllocProjectedVertices(shadow);
2183
+
2184
+ shadow.projectedVertices[1].x = 300;
20192185
20202186 makeSomething(shadow);
20212187 }
....@@ -2536,27 +2702,35 @@
25362702 } else
25372703 if (source == loopItem || source == loopButton)
25382704 {
2705
+ if (!group.selection.isEmpty())
2706
+ {
25392707 Composite csg = new GroupLeaf();
25402708 csg.count = 5;
2541
- group(csg);
25422709 Composite child = new cGroup("Branch");
25432710 csg.addChild(child);
25442711 child.addChild(csg);
2712
+ group(csg);
2713
+ }
25452714 } else
25462715 if (source == doubleItem)
25472716 {
2717
+ if (!group.selection.isEmpty())
2718
+ {
25482719 Composite csg = new GroupLeaf("Fork");
25492720 csg.count = 5;
2550
- group(csg);
25512721 Composite child = new cGroup("Branch A");
25522722 csg.addChild(child);
25532723 child.addChild(csg);
25542724 child = new cGroup("Branch B");
25552725 csg.addChild(child);
25562726 child.addChild(csg);
2727
+ group(csg);
2728
+ }
25572729 } else
25582730 if (source == tripleItem)
25592731 {
2732
+ if (!group.selection.isEmpty())
2733
+ {
25602734 Composite csg = new GroupLeaf("Trident");
25612735 csg.count = 4;
25622736 group(csg);
....@@ -2569,6 +2743,7 @@
25692743 child = new cGroup();
25702744 csg.addChild(child);
25712745 child.addChild(csg);
2746
+ }
25722747 } else
25732748 if (source == computeAOItem)
25742749 {
....@@ -2618,6 +2793,18 @@
26182793 if (source == fullButton)
26192794 {
26202795 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();
26212808 } else
26222809 if (source == previousVersionButton)
26232810 {
....@@ -3192,22 +3379,34 @@
31923379 } else
31933380 if (source == ungroupItem || source == ungroupButton)
31943381 {
3195
- boolean hasRoot = false;
3382
+ boolean canUngroup = true;
31963383
31973384 for (int i=0; i<group.selection.size(); i++)
31983385 {
3199
- if (group.selection.get(i) == group)
3386
+ Object3D selectedItem = group.selection.get(i);
3387
+
3388
+ if (selectedItem.Size() == 0)
32003389 {
3201
- 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;
32023399 break;
32033400 }
32043401 }
32053402
3206
- if (!hasRoot)
3403
+ if (canUngroup)
32073404 {
32083405 for (int i=0; i<group.selection.size(); i++)
32093406 {
3210
- Ungroup(group.selection.get(i));
3407
+ Object3D selectedItem = group.selection.get(i);
3408
+
3409
+ Ungroup(selectedItem);
32113410 }
32123411
32133412 ClearSelection(false);
....@@ -3570,38 +3769,7 @@
35703769 if (CameraPane.FULLSCREEN)
35713770 fullscreenLayout = radio.layout;
35723771
3573
- // bug
3574
- //gridPanel.setDividerLocation(1.0);
3575
- //bigPanel.setDividerLocation(0.0);
3576
-// bigThree.remove(scenePanel);
3577
-// bigThree.remove(centralPanel);
3578
-// bigThree.remove(XYZPanel);
3579
-// aWindowConstraints.gridx = 0;
3580
-// aWindowConstraints.gridy = 0;
3581
-// aWindowConstraints.gridwidth = 1;
3582
-// // aConstraints.gridheight = 3;
3583
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3584
-// aWindowConstraints.weightx = 0;
3585
-// aWindowConstraints.weighty = 1;
3586
-// //bigThree.add(jtp, aWindowConstraints);
3587
-// aWindowConstraints.weightx = 1;
3588
-// aWindowConstraints.gridwidth = 3;
3589
-// // aConstraints.gridheight = 3;
3590
-// aWindowConstraints.gridx = 1;
3591
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3592
-// bigThree.add(centralPanel, aWindowConstraints);
3593
-// aWindowConstraints.weightx = 0;
3594
-// aWindowConstraints.gridx = 4;
3595
-// aWindowConstraints.gridwidth = 1;
3596
-// // aConstraints.gridheight = 3;
3597
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3598
-// //bigThree.add(XYZPanel, aWindowConstraints);
3599
-// scenePanel.setVisible(false);
3600
-// centralPanel.setVisible(true);
3601
-// XYZPanel.setVisible(false);
3602
- bigThree.ClearUI();
3603
- bigThree.add(centralPanel);
3604
- bigThree.FlushUI();
3772
+ Show3DView();
36053773
36063774 cameraView.requestFocusInWindow();
36073775
....@@ -3787,6 +3955,7 @@
37873955 } else
37883956 if (source == rootButton)
37893957 {
3958
+ Replace();
37903959 Object3D obj;
37913960 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37923961 {
....@@ -3801,6 +3970,8 @@
38013970 if (source == closeButton)
38023971 {
38033972 //System.out.println("CLOSE: " + buttonGroup.getSelection());
3973
+ Replace();
3974
+
38043975 cRadio ab;
38053976 for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
38063977 {
....@@ -3899,6 +4070,8 @@
38994070 } else
39004071 if(source instanceof cRadio)
39014072 {
4073
+ Replace();
4074
+
39024075 group.parent = keepparent;
39034076 group.attributes = 0;
39044077 //group.editWindow = null;
....@@ -3923,8 +4096,6 @@
39234096
39244097 copy = group;
39254098
3926
- SetUndoStates();
3927
-
39284099 //Globals.theRenderer.object = group;
39294100 if(!useclient)
39304101 {
....@@ -3952,6 +4123,29 @@
39524123 */
39534124 radio.layout.doClick();
39544125
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
+
39554149 ClearUnpinned();
39564150
39574151 //Grafreed.Assert(group != null);
....@@ -4095,7 +4289,7 @@
40954289 TouchTransform(obj);
40964290 continue;
40974291 }
4098
- if ((mask&2) != 0) // Scale
4292
+ if ((mask&2) != 0) // Scale/rotation
40994293 {
41004294 obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
41014295 obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
....@@ -4103,10 +4297,6 @@
41034297 obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
41044298 obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
41054299 obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
4106
- }
4107
- if ((mask&4) != 0) // Rotation
4108
- {
4109
- // ?
41104300 }
41114301 if ((mask&1) != 0) // Translation
41124302 {
....@@ -5186,10 +5376,26 @@
51865376 flashSelectionButton.setEnabled(enabled);
51875377
51885378 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);
51895394 }
51905395
51915396 void refreshContents(boolean cp)
51925397 {
5398
+ if (false)
51935399 //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51945400 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51955401 {
....@@ -5200,7 +5406,7 @@
52005406 Object3D child = (Object3D) group.selection.get(i);
52015407
52025408 objEditor.AddInfo(child, this, true);
5203
- System.err.println("info : " + child.GetPath());
5409
+// System.err.println("info : " + child.GetPath());
52045410 }
52055411
52065412 objEditor.SetText(); // jan 2014
....@@ -6083,11 +6289,11 @@
60836289 private MenuItem lookAtItem;
60846290 private MenuItem lookFromItem;
60856291 private MenuItem switchViewItem;
6086
- private MenuItem cutItem;
6292
+ private JMenuItem cutItem;
60876293 private MenuItem undoItem;
60886294 private MenuItem redoItem;
60896295 private JMenuItem duplicateItem;
6090
- private MenuItem cloneItem;
6296
+ private JMenuItem cloneItem;
60916297 private MenuItem cloneSupportItem;
60926298 private MenuItem overwriteGeoItem;
60936299 private MenuItem overwriteMatItem;
....@@ -6108,13 +6314,13 @@
61086314 private MenuItem cloneGeometriesItem;
61096315 private MenuItem shareGeometriesItem;
61106316 private MenuItem mergeGeometriesItem;
6111
- private MenuItem copyItem;
6317
+ private JMenuItem copyItem;
61126318 private MenuItem pasteItem;
6113
- private MenuItem pasteIntoItem;
6114
- private MenuItem pasteLinkItem;
6115
- private MenuItem pasteCloneItem;
6116
- private MenuItem pasteExpandItem;
6117
- private MenuItem deleteItem;
6319
+ private JMenuItem pasteIntoItem;
6320
+ private JMenuItem pasteLinkItem;
6321
+ private JMenuItem pasteCloneItem;
6322
+ private JMenuItem pasteExpandItem;
6323
+ private JMenuItem deleteItem;
61186324 private MenuItem clearAllItem;
61196325 private MenuItem genUVItem;
61206326 private MenuItem genNormalsMESHItem;
....@@ -6169,7 +6375,7 @@
61696375 private MenuItem transformGeometryItem;
61706376 private MenuItem transformChildrenItem;
61716377 private MenuItem hideItem;
6172
- private MenuItem grabItem;
6378
+ private JMenuItem grabItem;
61736379 private MenuItem backItem;
61746380 private MenuItem frontItem;
61756381 private MenuItem cameraItem;
....@@ -6182,7 +6388,7 @@
61826388 private MenuItem switchTransfoItem;
61836389 private MenuItem morphItem;
61846390 private MenuItem linkerItem;
6185
- private MenuItem ungroupItem;
6391
+ private JMenuItem ungroupItem;
61866392 private MenuItem editItem;
61876393 private MenuItem openWindowItem;
61886394 private MenuItem editLeafItem;