Normand Briere
2019-08-23 60cec91731a350fe67e9b5ffe7a00d70e9026314
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,
....@@ -28,9 +29,9 @@
2829 {
2930 cButton skyboxButton;
3031 final String path = "cubemaps/" + f + "-skyboxes/" + s;
31
- row.add(skyboxButton = GetButton(path + "/preview.jpg", !Grafreed.NIMBUSLAF));
32
+ row.add(skyboxButton = GetButton(path + "/preview.jpg", !Globals.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, !Globals.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(JTabbedPane.LEFT);
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,11 +415,15 @@
356415 this.copy = this.group = group;
357416 //selectees = this.group.selectees;
358417
359
- if (copy.versions == null)
360
- {
361
- copy.versions = new byte[100][];
362
- copy.versionindex = -1;
363
- }
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
+// }
364427
365428 if(ui)
366429 SetupUI(objEditor);
....@@ -383,13 +446,13 @@
383446
384447 ((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true);
385448
386
- if (copy.versions == null)
387
- {
388
- copy.versions = new byte[100][];
389
- copy.versionindex = -1;
390
-
391
- Save(true);
392
- }
449
+// if (copy.versionlist == null)
450
+// {
451
+// copy.versionlist = new Object3D[100];
452
+// copy.versionindex = -1;
453
+//
454
+// //Save(true);
455
+// }
393456 }
394457
395458 void CloneSelection(boolean supports)
....@@ -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 //
....@@ -765,6 +835,8 @@
765835 }
766836
767837 oe.menuBar.add(menu = new Menu("Attributes"));
838
+ clearVersionsItem = menu.add(new MenuItem("Clear Versions"));
839
+ clearVersionsItem.addActionListener(this);
768840 clearMaterialsItem = menu.add(new MenuItem("Clear Materials"));
769841 clearMaterialsItem.addActionListener(this);
770842 resetAllItem = menu.add(new MenuItem("Reset All"));
....@@ -787,9 +859,9 @@
787859 hideleavesItem.addActionListener(this);
788860 showleavesItem = menu.add(new MenuItem("Show Leaves"));
789861 showleavesItem.addActionListener(this);
790
- markleavesItem = menu.add(new MenuItem("Mark Leaves"));
862
+ markleavesItem = menu.add(new MenuItem("Anim Leaves"));
791863 markleavesItem.addActionListener(this);
792
- unmarkleavesItem = menu.add(new MenuItem("Unmark Leaves"));
864
+ unmarkleavesItem = menu.add(new MenuItem("Unanim Leaves"));
793865 unmarkleavesItem.addActionListener(this);
794866 rewindleavesItem = menu.add(new MenuItem("Rewind Leaves"));
795867 rewindleavesItem.addActionListener(this);
....@@ -843,6 +915,9 @@
843915 shareGeometriesItem.addActionListener(this);
844916 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
845917 mergeGeometriesItem.addActionListener(this);
918
+ menu.add("-");
919
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
920
+ editLeafItem.addActionListener(this);
846921 if (Globals.ADVANCED)
847922 {
848923 // Pretty much the same as duplicate and clone.
....@@ -859,6 +934,79 @@
859934 buildToolsMenu(menu);
860935 }
861936
937
+ JTabbedPane resourcecontainer;
938
+ cGridBag currenttab;
939
+ //boolean added; // patch for jar
940
+
941
+ int totalcount = 0;
942
+
943
+ int tabcount = 0;
944
+ int colcount = 0;
945
+ int rowcount = 0;
946
+ int texturecount = 0;
947
+
948
+ int columns = 5;
949
+ int rows = 7;
950
+
951
+ public void ResourceCallBack(String[] path)
952
+ {
953
+// for (int i = 0; i < path.length; i++)
954
+// System.out.print(path[i] + "/");
955
+// System.out.println();
956
+
957
+ if (//rowcount == 0 ||
958
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
959
+ {
960
+ currenttab = new cGridBag();
961
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
962
+ currenttab.setName(tabname);
963
+ //added = false;
964
+ resourcecontainer.add(currenttab);
965
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
966
+ rowcount = 1;
967
+ colcount = 0;
968
+ texturecount = 0;
969
+ }
970
+
971
+ if (path.length > 2 && (path[2].toLowerCase().endsWith(".jpg") || path[2].toLowerCase().endsWith(".png")))
972
+ {
973
+ //if (!added)
974
+ {
975
+ //added = true;
976
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
977
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
978
+ }
979
+
980
+ AddTextureButton(path[0], path[1], path[2], ++texturecount, currenttab);
981
+ totalcount++;
982
+
983
+ if (++colcount >= columns)
984
+ {
985
+ colcount = 0;
986
+ currenttab.Return();
987
+
988
+ if (rowcount++ >= rows)
989
+ {
990
+ rowcount = 0;
991
+ }
992
+ }
993
+ }
994
+ else
995
+ {
996
+// if (!path[path.length-1].equals("icons"))
997
+// resourcecontainer.Return();
998
+ }
999
+ }
1000
+
1001
+ void CreateTexturePanel(cGridBag container)
1002
+ {
1003
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
1004
+ container.add(resourcecontainer);
1005
+
1006
+ Grafreed.ParseResources("textures", this);
1007
+
1008
+ // 935. System.out.println("Total = " + totalcount);
1009
+ }
8621010
8631011 void SetupUI2(ObjEditor oe)
8641012 {
....@@ -877,11 +1025,6 @@
8771025 //new Exception().printStackTrace();
8781026
8791027 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;
8851028 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8861029
8871030 oe.buttonGroup = new ButtonGroup();
....@@ -902,9 +1045,9 @@
9021045 oe.radioPanel.add(dummyButton);
9031046 oe.buttonGroup.add(dummyButton);
9041047 */
905
- cGridBag copyOptionsPanel = new cGridBag();
1048
+ cGridBag versionManagerPanel = new cGridBag();
9061049
907
- copyOptionsPanel.preferredHeight = 2;
1050
+ versionManagerPanel.preferredHeight = 4;
9081051
9091052 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
9101053
....@@ -914,58 +1057,102 @@
9141057
9151058 if (Globals.ADVANCED)
9161059 {
917
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
918
- maxButton.setToolTipText("Maximize window");
919
- 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);
9201063 }
9211064
922
- oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1065
+ cButton gcButton;
1066
+
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
+// });
1076
+
1077
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1078
+ collapseButton.setToolTipText("Collapse toolbar");
1079
+ collapseButton.addActionListener(this);
1080
+
1081
+ oe.toolbarPanel.add(maximize3DButton = GetButton("icons/square.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1082
+ maximize3DButton.setToolTipText("Maximize 3D view");
1083
+ maximize3DButton.addActionListener(this);
1084
+
1085
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1086
+ twoButton.setToolTipText("Show 3D view only");
1087
+ twoButton.addActionListener(this);
1088
+ this.fullscreenLayout = twoButton;
1089
+
1090
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1091
+ threeButton.setToolTipText("Show controls and 3D view");
1092
+ threeButton.addActionListener(this);
1093
+ if (Globals.ADVANCED)
1094
+ {
1095
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1096
+ sixButton.setToolTipText("Show 3D view and controls");
1097
+ sixButton.addActionListener(this);
1098
+ }
1099
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1100
+// sevenButton.setToolTipText("3-column layout");
1101
+// sevenButton.addActionListener(this);
1102
+ //
1103
+
1104
+ oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
9231105 fullButton.setToolTipText("Full-screen window");
9241106 fullButton.addActionListener(this);
9251107
926
- 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);
9271109 screenfitButton.setToolTipText("Screen fit");
9281110 screenfitButton.addActionListener(this);
9291111
930
- 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);
9311113 restoreCameraButton.setToolTipText("Restore viewpoint");
9321114 restoreCameraButton.addActionListener(this);
9331115
934
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
935
- saveButton.setToolTipText("New version");
936
- saveButton.addActionListener(this);
1116
+ versionManagerPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1117
+ saveVersionButton.setToolTipText("Duplicate current version");
1118
+ saveVersionButton.addActionListener(this);
9371119
938
- copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
939
- undoButton.setToolTipText("Previous version");
940
- undoButton.addActionListener(this);
941
- undoButton.setEnabled(false);
1120
+ versionManagerPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1121
+ deleteVersionButton.setToolTipText("Delete current version");
1122
+ deleteVersionButton.addActionListener(this);
1123
+ deleteVersionButton.setEnabled(false);
1124
+
1125
+ versionManagerPanel.add(previousVersionButton = GetButton("icons/undo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1126
+ previousVersionButton.setToolTipText("Previous version");
1127
+ previousVersionButton.addActionListener(this);
1128
+ previousVersionButton.setEnabled(false);
9421129
9431130 cGridBag updown = new cGridBag().setVertical(true);
944
- updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
945
- restoreButton.setToolTipText("Restore current");
1131
+ updown.add(restoreButton = GetButton("icons/restore.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1132
+ restoreButton.setToolTipText("Undo (restore current version)");
9461133 restoreButton.addActionListener(this);
9471134 restoreButton.setEnabled(false);
9481135
949
- updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
950
- replaceButton.setToolTipText("Replace current");
1136
+ updown.add(replaceButton = GetButton("icons/replace.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1137
+ replaceButton.setToolTipText("Save (replace current version)");
9511138 replaceButton.addActionListener(this);
9521139 replaceButton.setEnabled(false);
9531140
954
- copyOptionsPanel.add(updown);
1141
+ versionManagerPanel.add(updown);
9551142
956
- copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
957
- redoButton.setToolTipText("Next version");
958
- redoButton.addActionListener(this);
959
- redoButton.setEnabled(false);
1143
+ versionManagerPanel.add(nextVersionButton = GetButton("icons/redo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1144
+ nextVersionButton.setToolTipText("Next version");
1145
+ nextVersionButton.addActionListener(this);
1146
+ nextVersionButton.setEnabled(false);
1147
+
1148
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1149
+ oneStepButton.setToolTipText("Animate one step forward");
1150
+ oneStepButton.addActionListener(this);
9601151
9611152 oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
9621153 liveCB.setToolTipText("Enable animation");
9631154 liveCB.addItemListener(this);
9641155
965
- oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
966
- oneStepButton.setToolTipText("Animate one step forward");
967
- oneStepButton.addActionListener(this);
968
-
9691156 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9701157 fastCB.setToolTipText("Fast mode");
9711158 fastCB.addItemListener(this);
....@@ -981,38 +1168,23 @@
9811168
9821169 if (Globals.ADVANCED)
9831170 {
984
- oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1171
+ oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Globals.NIMBUSLAF)); //, oe.aConstraints);
9851172 snapobjectButton.addActionListener(this);
9861173 snapobjectButton.setToolTipText("Snap Object");
9871174
988
- 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);
9891176 fourButton.addActionListener(this);
9901177 fourButton.setToolTipText("Show control panel only");
9911178 }
9921179
9931180 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
9941181
995
- oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
996
- twoButton.setToolTipText("Show 3D view only");
997
- twoButton.addActionListener(this);
998
- this.fullscreenLayout = twoButton;
999
-
1000
- oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1001
- threeButton.setToolTipText("Show controls and 3D view");
1002
- threeButton.addActionListener(this);
1003
- oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1004
- sixButton.setToolTipText("Show 3D view and controls");
1005
- sixButton.addActionListener(this);
1006
-// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1007
-// sevenButton.setToolTipText("3-column layout");
1008
-// sevenButton.addActionListener(this);
1009
- //
10101182
1011
- 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);
10121184 rootButton.setToolTipText("Open selection in new tab");
10131185 rootButton.addActionListener(this);
10141186
1015
- 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);
10161188 closeButton.setToolTipText("Close tab");
10171189 closeButton.addActionListener(this);
10181190 //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
....@@ -1021,38 +1193,38 @@
10211193 cGridBag row1 = new cGridBag();
10221194
10231195 // INSERT
1024
- row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1025
- gridButton.setToolTipText("Create grid");
1196
+ row1.add(gridButton = GetButton("icons/grid.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1197
+ gridButton.setToolTipText("Create ground");
10261198 gridButton.addActionListener(this);
10271199
1028
- row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1200
+ row1.add(boxButton = GetButton("icons/box.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10291201 boxButton.setToolTipText("Create box");
10301202 boxButton.addActionListener(this);
10311203
1032
- row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1033
- sphereButton.setToolTipText("Create sphere");
1034
- sphereButton.addActionListener(this);
1035
-
1036
- row1.add(coneButton = GetButton("icons/cone.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1037
- coneButton.setToolTipText("Create cone");
1038
- coneButton.addActionListener(this);
1039
-
1040
- row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1041
- torusButton.setToolTipText("Create torus");
1042
- torusButton.addActionListener(this);
1043
-
1044
- row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1204
+ row1.add(superButton = GetButton("icons/super.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10451205 superButton.setToolTipText("Create superellipsoid");
10461206 superButton.addActionListener(this);
10471207
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
+
10481220 if (Globals.ADVANCED)
10491221 {
1050
- 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);
10511223 kleinButton.setToolTipText("Create Klein bottle");
10521224 kleinButton.addActionListener(this);
10531225 }
10541226
1055
- row1.add(particlesButton = GetButton("icons/particles.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1227
+ row1.add(particlesButton = GetButton("icons/particles.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10561228 particlesButton.setToolTipText("Create particle system");
10571229 particlesButton.addActionListener(this);
10581230
....@@ -1060,72 +1232,73 @@
10601232
10611233 cGridBag row2 = new cGridBag();
10621234
1063
- row2.add(groupButton = GetButton("icons/group.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1235
+ row2.add(groupButton = GetButton("icons/group.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10641236 groupButton.setToolTipText("Create group");
10651237 groupButton.addActionListener(this);
10661238
1067
- row2.add(compositeButton = GetButton("icons/composite.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1239
+ row2.add(compositeButton = GetButton("icons/composite.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10681240 compositeButton.setToolTipText("Create composite");
10691241 compositeButton.addActionListener(this);
10701242
1071
- row2.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1243
+ row2.add(switchButton = GetButton("icons/switch.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10721244 switchButton.setToolTipText("Create item switcher");
10731245 switchButton.addActionListener(this);
10741246
1075
- row2.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1247
+ row2.add(loopButton = GetButton("icons/loop.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10761248 loopButton.setToolTipText("Create loop");
10771249 loopButton.addActionListener(this);
10781250
1079
- row2.add(textureButton = GetButton("icons/texture.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1251
+ row2.add(textureButton = GetButton("icons/texture.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10801252 textureButton.setToolTipText("Create texture");
10811253 textureButton.addActionListener(this);
10821254
1083
- row2.add(overlayButton = GetButton("icons/overlay.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1255
+ row2.add(overlayButton = GetButton("icons/overlay.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10841256 overlayButton.setToolTipText("Create overlay");
10851257 overlayButton.addActionListener(this);
10861258
1087
- 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);
10881260 lightButton.setToolTipText("Create light");
10891261 lightButton.addActionListener(this);
10901262
10911263 oe.toolboxPanel.add(row2);
10921264
1093
- // ENVYMAPS
1094
- cGridBag skyboxpane = new cGridBag();
1095
- skyboxpane.preferredHeight = 100;
1265
+ cGridBag textures = new cGridBag();
10961266
1097
- oe.toolboxPanel.add(skyboxpane);
1267
+ CreateTexturePanel(textures);
10981268
1099
- JTabbedPane skyboxpanel = new JTabbedPane();
1100
- skyboxpane.add(skyboxpanel);
1269
+ int tabCount = resourcecontainer.getTabCount();
11011270
1102
- AddSkyboxTab0(skyboxpanel);
1103
- AddSkyboxTab1(skyboxpanel);
1104
- AddSkyboxTab2(skyboxpanel);
1105
- AddSkyboxTab3(skyboxpanel);
1271
+ if (tabCount > 0)
1272
+ resourcecontainer.setSelectedIndex((int)(Math.random() * tabCount));
1273
+
1274
+ oe.toolboxPanel.add(textures);
1275
+
1276
+ textures.preferredHeight = 100;
1277
+
1278
+ CreateSkyboxPanel(oe.skyboxPanel);
11061279
11071280 // EDIT panel
1108
- editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1281
+ editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11091282 editButton.setToolTipText("Pin selection controls");
11101283 editButton.addActionListener(this);
11111284
1112
- editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1113
- uneditButton.setToolTipText("Remove selection controls");
1285
+ editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1286
+ uneditButton.setToolTipText("Unpin and remove selection controls");
11141287 uneditButton.addActionListener(this);
11151288
11161289 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1117
- allParamsButton.setToolTipText("Show all controle");
1290
+ allParamsButton.setToolTipText("Show all controls");
11181291 allParamsButton.addActionListener(this);
11191292
1120
- editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1121
- clearPanelButton.setToolTipText("Clear edit panel");
1293
+ editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1294
+ clearPanelButton.setToolTipText("Clear all controls");
11221295 clearPanelButton.addActionListener(this);
11231296
1124
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- unselectButton.setToolTipText("Unselect");
1126
- unselectButton.addActionListener(this);
1297
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1298
+ //unselectButton.setToolTipText("Unselect");
1299
+ //unselectButton.addActionListener(this);
11271300
1128
- 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);
11291302 flashSelectionButton.setToolTipText("Highlight selection");
11301303 flashSelectionButton.addActionListener(this);
11311304
....@@ -1148,6 +1321,8 @@
11481321
11491322 cGridBag jSPPanel = new cGridBag();
11501323
1324
+ jSPPanel.preferredHeight = 20;
1325
+
11511326 JScrollPane jSP;
11521327 //ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints);
11531328 jSPPanel.add(jSP = new JScrollPane(oe.jTree)); //, oe.aConstraints);
....@@ -1156,11 +1331,11 @@
11561331 oe.treePanel.add(jSPPanel);
11571332 oe.treePanel.Return();
11581333
1159
- oe.treePanel.add(copyOptionsPanel);
1334
+ oe.treePanel.add(versionManagerPanel);
11601335 oe.treePanel.Return();
1161
- cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
1162
- versionSlider = (cNumberSlider)sliderPane.getComponent(1);
1163
- sliderPane.preferredHeight = 1;
1336
+ versionSliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
1337
+ versionSlider = (cNumberSlider)versionSliderPane.getComponent(1);
1338
+ versionSliderPane.preferredHeight = 3;
11641339
11651340 // mainPanel.setDividerLocation(0.1); //1.0);
11661341 mainPanel.setResizeWeight(0.4);
....@@ -1183,7 +1358,7 @@
11831358 dgr.addDragGestureListener(this);
11841359 }catch(Exception e) {}
11851360 */
1186
- radio.layout = sixButton; // sevenButton;
1361
+ radio.layout = threeButton; // sixButton;
11871362 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
11881363 }
11891364
....@@ -1234,9 +1409,12 @@
12341409 smoothCB.setToolTipText("Snapping delay");
12351410 smoothCB.addItemListener(this);
12361411
1237
- panel.add(slowCB = new cCheckBox("Slow", CameraPane.SLOWPOSE)); //, constraints);
1238
- slowCB.setToolTipText("Smooth interpolation");
1239
- slowCB.addItemListener(this);
1412
+// panel.add(slowCB = new cCheckBox("Slow", CameraPane.SLOWPOSE)); //, constraints);
1413
+// slowCB.setToolTipText("Smooth interpolation");
1414
+// slowCB.addItemListener(this);
1415
+ panel.add(minshaderCB = new cCheckBox("Min shader", Globals.MINSHADER)); //, constraints);
1416
+ minshaderCB.setToolTipText("Minimal fast shader");
1417
+ minshaderCB.addItemListener(this);
12401418
12411419 // constraints.gridy += 1;
12421420 // panel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), constraints);
....@@ -1315,6 +1493,14 @@
13151493
13161494 void EditObject(Object3D obj)
13171495 {
1496
+ assert(obj instanceof Composite);
1497
+
1498
+// if (obj.versionlist == null)
1499
+// {
1500
+// obj.versionlist = new Object3D[100];
1501
+// obj.versionindex = -1;
1502
+// }
1503
+
13181504 cRadio radioButton = new cRadio(obj.name);
13191505
13201506 // June 2019. Patch to avoid bug with transparency.
....@@ -1325,7 +1511,7 @@
13251511 }
13261512
13271513 radioButton.SetObject(obj);
1328
- radioButton.layout = sixButton; // sevenButton;
1514
+ radioButton.layout = threeButton; // sixButton;
13291515 radioButton.SetCamera(cameraView.renderCamera, false);
13301516 radioButton.addActionListener(this);
13311517 radioPanel.add(radioButton);
....@@ -1339,6 +1525,7 @@
13391525
13401526 oe.SetupViews();
13411527
1528
+ if (Globals.DEBUG)
13421529 System.out.println("SetupViews");
13431530 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
13441531 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -1350,6 +1537,8 @@
13501537 cCheckBox localCB;
13511538 cCheckBox crowdCB;
13521539 cCheckBox smoothCB;
1540
+ cCheckBox minshaderCB;
1541
+
13531542 cToggleButton fastCB;
13541543 cCheckBox slowCB;
13551544 cCheckBox boxCB;
....@@ -1420,6 +1609,12 @@
14201609 {
14211610 cameraView.ToggleInertia();
14221611 cameraView.repaint();
1612
+ }
1613
+ else if(e.getSource() == minshaderCB)
1614
+ {
1615
+ Globals.MINSHADER ^= true;
1616
+ cameraView.programInitialized = false;
1617
+ cameraView.repaint();
14231618 }
14241619 else if(e.getSource() == localCB)
14251620 {
....@@ -1697,7 +1892,12 @@
16971892 TreePath path;
16981893
16991894 public TransferableTreePath(TreePath tp) {
1700
- path = tp;
1895
+ Object[] objs = new Object[tp.getPathCount()];
1896
+ for (int i=0; i<objs.length; i++)
1897
+ {
1898
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1899
+ }
1900
+ path = new TreePath(objs);
17011901 }
17021902
17031903 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -1929,24 +2129,24 @@
19292129 switch(axis)
19302130 {
19312131 case 0 :
1932
- vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z;
1933
- vert2.x = minima.x; vert2.y = maxima.y; vert2.z = minima.z;
1934
- vert3.x = minima.x; vert3.y = minima.y; vert3.z = maxima.z;
1935
- 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;
19362136 norm = cVector.X;
19372137 break;
19382138 case 1 :
1939
- vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z;
1940
- vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z;
1941
- vert3.x = minima.x; vert3.y = minima.y; vert3.z = maxima.z;
1942
- 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;
19432143 norm = cVector.Y;
19442144 break;
19452145 case 2 :
1946
- vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z;
1947
- vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z;
1948
- vert3.x = minima.x; vert3.y = maxima.y; vert3.z = minima.z;
1949
- 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;
19502150 norm = cVector.Z;
19512151 break;
19522152 }
....@@ -1987,7 +2187,11 @@
19872187 shadow.material = new cMaterial(obj.material);
19882188 shadow.material.diffuse = 0.0001f;
19892189 shadow.material.specular = 0.0001f;
1990
- //shadow.projectedVertices[1].x = 300;
2190
+ shadow.material.opacity = 0.75f;
2191
+
2192
+ AllocProjectedVertices(shadow);
2193
+
2194
+ shadow.projectedVertices[1].x = 300;
19912195
19922196 makeSomething(shadow);
19932197 }
....@@ -2508,27 +2712,35 @@
25082712 } else
25092713 if (source == loopItem || source == loopButton)
25102714 {
2715
+ if (!group.selection.isEmpty())
2716
+ {
25112717 Composite csg = new GroupLeaf();
25122718 csg.count = 5;
2513
- group(csg);
25142719 Composite child = new cGroup("Branch");
25152720 csg.addChild(child);
25162721 child.addChild(csg);
2722
+ group(csg);
2723
+ }
25172724 } else
25182725 if (source == doubleItem)
25192726 {
2727
+ if (!group.selection.isEmpty())
2728
+ {
25202729 Composite csg = new GroupLeaf("Fork");
25212730 csg.count = 5;
2522
- group(csg);
25232731 Composite child = new cGroup("Branch A");
25242732 csg.addChild(child);
25252733 child.addChild(csg);
25262734 child = new cGroup("Branch B");
25272735 csg.addChild(child);
25282736 child.addChild(csg);
2737
+ group(csg);
2738
+ }
25292739 } else
25302740 if (source == tripleItem)
25312741 {
2742
+ if (!group.selection.isEmpty())
2743
+ {
25322744 Composite csg = new GroupLeaf("Trident");
25332745 csg.count = 4;
25342746 group(csg);
....@@ -2541,6 +2753,7 @@
25412753 child = new cGroup();
25422754 csg.addChild(child);
25432755 child.addChild(csg);
2756
+ }
25442757 } else
25452758 if (source == computeAOItem)
25462759 {
....@@ -2560,7 +2773,7 @@
25602773 if (source == invariantsItem)
25612774 {
25622775 System.out.println("Invariants:");
2563
- Grafreed.grafreeD.universe.invariants();
2776
+ Grafreed.grafreed.universe.invariants();
25642777 } else
25652778 if (source == memoryItem)
25662779 {
....@@ -2591,33 +2804,52 @@
25912804 {
25922805 ToggleFullScreen();
25932806 } else
2594
- if (source == undoButton)
2807
+ if (source == collapseButton)
2808
+ {
2809
+ this.expandedLayout = radio.layout;
2810
+ CollapseToolbar();
2811
+ } else
2812
+ if (source == maximize3DButton)
2813
+ {
2814
+ this.expandedLayout = radio.layout;
2815
+ radio.layout = twoButton;
2816
+ Show3DView();
2817
+ CollapseToolbar();
2818
+ } else
2819
+ if (source == previousVersionButton)
25952820 {
25962821 // Go to previous version
25972822 //if (!Undo())
25982823 //java.awt.Toolkit.getDefaultToolkit().beep();
2599
- Undo();
2824
+ PreviousVersion();
26002825 } else
26012826 if (source == restoreButton)
26022827 {
26032828 // Restore current version
26042829 Restore();
2830
+ //restoreButton.setEnabled(false);
26052831 } else
26062832 if (source == replaceButton)
26072833 {
26082834 // Overwrite current version
26092835 Replace();
2836
+ //replaceButton.setEnabled(false);
26102837 } else
2611
- if (source == redoButton)
2838
+ if (source == nextVersionButton)
26122839 {
26132840 // Go to next version
2614
- Redo();
2841
+ NextVersion();
26152842 } else
2616
- if (source == saveButton)
2843
+ if (source == saveVersionButton)
26172844 {
26182845 // Save a new version
26192846 if (!Save(true))
26202847 java.awt.Toolkit.getDefaultToolkit().beep();
2848
+ } else
2849
+ if (source == deleteVersionButton)
2850
+ {
2851
+ // Delete a new version
2852
+ DeleteVersion();
26212853 } else
26222854 if (source == oneStepButton)
26232855 {
....@@ -2672,11 +2904,11 @@
26722904 } else
26732905 if (source == undoItem)
26742906 {
2675
- Undo();
2907
+ PreviousVersion();
26762908 } else
26772909 if (source == redoItem)
26782910 {
2679
- Redo();
2911
+ NextVersion();
26802912 } else
26812913 if (source == duplicateItem)
26822914 {
....@@ -3157,22 +3389,34 @@
31573389 } else
31583390 if (source == ungroupItem || source == ungroupButton)
31593391 {
3160
- boolean hasRoot = false;
3392
+ boolean canUngroup = true;
31613393
31623394 for (int i=0; i<group.selection.size(); i++)
31633395 {
3164
- if (group.selection.get(i) == group)
3396
+ Object3D selectedItem = group.selection.get(i);
3397
+
3398
+ if (selectedItem.Size() == 0)
31653399 {
3166
- 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;
31673409 break;
31683410 }
31693411 }
31703412
3171
- if (!hasRoot)
3413
+ if (canUngroup)
31723414 {
31733415 for (int i=0; i<group.selection.size(); i++)
31743416 {
3175
- Ungroup(group.selection.get(i));
3417
+ Object3D selectedItem = group.selection.get(i);
3418
+
3419
+ Ungroup(selectedItem);
31763420 }
31773421
31783422 ClearSelection(false);
....@@ -3223,6 +3467,10 @@
32233467 if (source == clearMaterialsItem)
32243468 {
32253469 ClearMaterials();
3470
+ } else
3471
+ if (source == clearVersionsItem)
3472
+ {
3473
+ ClearVersions();
32263474 } else
32273475 if (source == liveleavesItem)
32283476 {
....@@ -3535,38 +3783,7 @@
35353783 if (CameraPane.FULLSCREEN)
35363784 fullscreenLayout = radio.layout;
35373785
3538
- // bug
3539
- //gridPanel.setDividerLocation(1.0);
3540
- //bigPanel.setDividerLocation(0.0);
3541
-// bigThree.remove(scenePanel);
3542
-// bigThree.remove(centralPanel);
3543
-// bigThree.remove(XYZPanel);
3544
-// aWindowConstraints.gridx = 0;
3545
-// aWindowConstraints.gridy = 0;
3546
-// aWindowConstraints.gridwidth = 1;
3547
-// // aConstraints.gridheight = 3;
3548
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3549
-// aWindowConstraints.weightx = 0;
3550
-// aWindowConstraints.weighty = 1;
3551
-// //bigThree.add(jtp, aWindowConstraints);
3552
-// aWindowConstraints.weightx = 1;
3553
-// aWindowConstraints.gridwidth = 3;
3554
-// // aConstraints.gridheight = 3;
3555
-// aWindowConstraints.gridx = 1;
3556
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3557
-// bigThree.add(centralPanel, aWindowConstraints);
3558
-// aWindowConstraints.weightx = 0;
3559
-// aWindowConstraints.gridx = 4;
3560
-// aWindowConstraints.gridwidth = 1;
3561
-// // aConstraints.gridheight = 3;
3562
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3563
-// //bigThree.add(XYZPanel, aWindowConstraints);
3564
-// scenePanel.setVisible(false);
3565
-// centralPanel.setVisible(true);
3566
-// XYZPanel.setVisible(false);
3567
- bigThree.ClearUI();
3568
- bigThree.add(centralPanel);
3569
- bigThree.FlushUI();
3786
+ Show3DView();
35703787
35713788 cameraView.requestFocusInWindow();
35723789
....@@ -3752,6 +3969,7 @@
37523969 } else
37533970 if (source == rootButton)
37543971 {
3972
+ Replace();
37553973 Object3D obj;
37563974 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37573975 {
....@@ -3766,6 +3984,8 @@
37663984 if (source == closeButton)
37673985 {
37683986 //System.out.println("CLOSE: " + buttonGroup.getSelection());
3987
+ Replace();
3988
+
37693989 cRadio ab;
37703990 for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
37713991 {
....@@ -3809,10 +4029,10 @@
38094029 {
38104030 Object3D child = (Object3D)e.nextElement();
38114031 if(child.editWindow != null)
3812
- objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38134032 child.pinned = false;
38144033 child.CloseUI();
38154034 listUI.remove(child);
4035
+// objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38164036
38174037 //child.editWindow = null; // ???????????
38184038 }
....@@ -3831,6 +4051,7 @@
38314051 obj.CloseUI();
38324052 }
38334053 listUI.clear();
4054
+ SetPinStates(group.selection.size() > 0);
38344055 refreshContents(true);
38354056 } else
38364057 if (source == allParamsButton)
....@@ -3863,6 +4084,8 @@
38634084 } else
38644085 if(source instanceof cRadio)
38654086 {
4087
+ Replace();
4088
+
38664089 group.parent = keepparent;
38674090 group.attributes = 0;
38684091 //group.editWindow = null;
....@@ -3887,8 +4110,6 @@
38874110
38884111 copy = group;
38894112
3890
- SetUndoStates();
3891
-
38924113 //Globals.theRenderer.object = group;
38934114 if(!useclient)
38944115 {
....@@ -3916,7 +4137,33 @@
39164137 */
39174138 radio.layout.doClick();
39184139
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
+
39194165 ClearUnpinned();
4166
+
39204167 //Grafreed.Assert(group != null);
39214168 //Grafreed.Assert(group.selection != null);
39224169 SetPinStates(group.selection == null || group.selection.size() > 0);
....@@ -3933,11 +4180,13 @@
39334180 } else if (event.getSource() == editCameraItem)
39344181 {
39354182 cameraView.ProtectCamera();
4183
+ cameraView.requestFocusInWindow();
39364184 cameraView.repaint();
39374185 return;
39384186 } else if (event.getSource() == restoreCameraItem || event.getSource() == restoreCameraButton)
39394187 {
39404188 cameraView.RevertCamera();
4189
+ cameraView.requestFocusInWindow();
39414190 cameraView.repaint();
39424191 return;
39434192 // } else if (event.getSource() == textureButton)
....@@ -4056,7 +4305,7 @@
40564305 TouchTransform(obj);
40574306 continue;
40584307 }
4059
- if ((mask&2) != 0) // Scale
4308
+ if ((mask&2) != 0) // Scale/rotation
40604309 {
40614310 obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
40624311 obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
....@@ -4064,10 +4313,6 @@
40644313 obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
40654314 obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
40664315 obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
4067
- }
4068
- if ((mask&4) != 0) // Rotation
4069
- {
4070
- // ?
40714316 }
40724317 if ((mask&1) != 0) // Translation
40734318 {
....@@ -4876,6 +5121,12 @@
48765121 refreshContents();
48775122 }
48785123
5124
+ void ClearVersions()
5125
+ {
5126
+ group.selection.ClearVersions();
5127
+ refreshContents();
5128
+ }
5129
+
48795130 void FlipV(boolean flip)
48805131 {
48815132 group.selection.FlipV(flip);
....@@ -5070,9 +5321,7 @@
50705321
50715322 freezemodel = false;
50725323 }
5073
-
5074
- boolean flashIt = true;
5075
-
5324
+
50765325 public void valueChanged(TreeSelectionEvent e)
50775326 //public boolean handleEvent(Event event)
50785327 {
....@@ -5145,13 +5394,31 @@
51455394 {
51465395 editButton.setEnabled(enabled);
51475396 uneditButton.setEnabled(enabled);
5148
- unselectButton.setEnabled(enabled);
5397
+ //unselectButton.setEnabled(enabled);
51495398 flashSelectionButton.setEnabled(enabled);
5399
+
5400
+ 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);
51505416 }
51515417
51525418 void refreshContents(boolean cp)
51535419 {
5154
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5420
+ if (Globals.ADVANCED)
5421
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51555422 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51565423 {
51575424 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5161,7 +5428,7 @@
51615428 Object3D child = (Object3D) group.selection.get(i);
51625429
51635430 objEditor.AddInfo(child, this, true);
5164
- System.err.println("info : " + child.GetPath());
5431
+// System.err.println("info : " + child.GetPath());
51655432 }
51665433
51675434 objEditor.SetText(); // jan 2014
....@@ -5987,7 +6254,6 @@
59876254
59886255 cButton restoreCameraButton;
59896256
5990
- cButton saveButton;
59916257 cButton oneStepButton;
59926258
59936259 cButton groupButton;
....@@ -6045,11 +6311,11 @@
60456311 private MenuItem lookAtItem;
60466312 private MenuItem lookFromItem;
60476313 private MenuItem switchViewItem;
6048
- private MenuItem cutItem;
6314
+ private JMenuItem cutItem;
60496315 private MenuItem undoItem;
60506316 private MenuItem redoItem;
60516317 private JMenuItem duplicateItem;
6052
- private MenuItem cloneItem;
6318
+ private JMenuItem cloneItem;
60536319 private MenuItem cloneSupportItem;
60546320 private MenuItem overwriteGeoItem;
60556321 private MenuItem overwriteMatItem;
....@@ -6070,13 +6336,13 @@
60706336 private MenuItem cloneGeometriesItem;
60716337 private MenuItem shareGeometriesItem;
60726338 private MenuItem mergeGeometriesItem;
6073
- private MenuItem copyItem;
6339
+ private JMenuItem copyItem;
60746340 private MenuItem pasteItem;
6075
- private MenuItem pasteIntoItem;
6076
- private MenuItem pasteLinkItem;
6077
- private MenuItem pasteCloneItem;
6078
- private MenuItem pasteExpandItem;
6079
- private MenuItem deleteItem;
6341
+ private JMenuItem pasteIntoItem;
6342
+ private JMenuItem pasteLinkItem;
6343
+ private JMenuItem pasteCloneItem;
6344
+ private JMenuItem pasteExpandItem;
6345
+ private JMenuItem deleteItem;
60806346 private MenuItem clearAllItem;
60816347 private MenuItem genUVItem;
60826348 private MenuItem genNormalsMESHItem;
....@@ -6102,6 +6368,7 @@
61026368 private MenuItem clipMeshItem;
61036369 private MenuItem smoothMeshItem;
61046370 private MenuItem clearMaterialsItem;
6371
+ private MenuItem clearVersionsItem;
61056372
61066373 private MenuItem liveleavesItem;
61076374 private MenuItem unliveleavesItem;
....@@ -6131,7 +6398,7 @@
61316398 private MenuItem transformGeometryItem;
61326399 private MenuItem transformChildrenItem;
61336400 private MenuItem hideItem;
6134
- private MenuItem grabItem;
6401
+ private JMenuItem grabItem;
61356402 private MenuItem backItem;
61366403 private MenuItem frontItem;
61376404 private MenuItem cameraItem;
....@@ -6144,7 +6411,7 @@
61446411 private MenuItem switchTransfoItem;
61456412 private MenuItem morphItem;
61466413 private MenuItem linkerItem;
6147
- private MenuItem ungroupItem;
6414
+ private JMenuItem ungroupItem;
61486415 private MenuItem editItem;
61496416 private MenuItem openWindowItem;
61506417 private MenuItem editLeafItem;