Normand Briere
2019-09-02 21ac57b36a9e3b909853c7d64ac29b7ad72490a3
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,46 @@
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
+
322371 //ObjEditor objEditor;
323372 public void closeUI2()
324373 {
....@@ -356,11 +405,15 @@
356405 this.copy = this.group = group;
357406 //selectees = this.group.selectees;
358407
359
- if (copy.versions == null)
360
- {
361
- copy.versions = new Object3D[100];
362
- copy.versionindex = -1;
363
- }
408
+ assert(false);
409
+
410
+// if (copy.versionlist == null)
411
+// {
412
+// copy.versionlist = new Object3D[100];
413
+// copy.versionindex = -1;
414
+//
415
+// //Save(true);
416
+// }
364417
365418 if(ui)
366419 SetupUI(objEditor);
....@@ -383,13 +436,13 @@
383436
384437 ((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true);
385438
386
- if (copy.versions == null)
387
- {
388
- copy.versions = new Object3D[100];
389
- copy.versionindex = -1;
390
-
391
- Save(true);
392
- }
439
+// if (copy.versionlist == null)
440
+// {
441
+// copy.versionlist = new Object3D[100];
442
+// copy.versionindex = -1;
443
+//
444
+// //Save(true);
445
+// }
393446 }
394447
395448 void CloneSelection(boolean supports)
....@@ -479,33 +532,35 @@
479532 // menu.add("-");
480533 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
481534 duplicateItem.addActionListener(this);
482
- cloneItem = menu.add(new MenuItem("Clone"));
535
+
536
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
483537 cloneItem.addActionListener(this);
484
- if (Globals.ADVANCED)
538
+ //if (Globals.ADVANCED)
485539 {
486540 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
487541 cloneSupportItem.addActionListener(this);
488542 }
543
+ oe.jTree.popup.addSeparator();
489544 menu.add("-");
490
- cutItem = menu.add(new MenuItem("Cut"));
545
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
491546 cutItem.addActionListener(this);
492
- copyItem = menu.add(new MenuItem("Copy"));
547
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
493548 copyItem.addActionListener(this);
494549 pasteItem = menu.add(new MenuItem("Paste"));
495550 pasteItem.addActionListener(this);
496551
497
- menu.add("-");
498
- pasteIntoItem = menu.add(new MenuItem("Paste into"));
552
+ oe.jTree.popup.addSeparator();
553
+ //menu.add("-");
554
+ pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into"));
499555 pasteIntoItem.addActionListener(this);
500
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
556
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
501557 pasteLinkItem.addActionListener(this);
502
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
558
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
503559 pasteCloneItem.addActionListener(this);
504
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
560
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
505561 // pasteExpandItem.addActionListener(this);
506
- menu.add("-");
507
- deleteItem = menu.add(new MenuItem("Delete"));
508
- deleteItem.addActionListener(this);
562
+ //menu.add("-");
563
+ oe.jTree.popup.addSeparator();
509564
510565 if (Globals.ADVANCED)
511566 {
....@@ -591,11 +646,9 @@
591646 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
592647 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
593648 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
594
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
595649 oe.cameraMenu.add("-");
596650 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
597651 openWindowItem.addActionListener(this);
598
- editLeafItem.addActionListener(this);
599652 lookAtItem.addActionListener(this);
600653 //lookFromItem.addActinoListener(this);
601654 //switchViewItem.addActionListener(this);
....@@ -642,9 +695,8 @@
642695 setMasterItem.addActionListener(this);
643696 }
644697
645
- oe.menuBar.add(menu = new Menu("Group"));
646
-// grabItem = menu.add(new MenuItem("Grab"));
647
-// grabItem.addActionListener(this);
698
+ oe.menuBar.add(menu = new Menu("Order"));
699
+
648700 backItem = menu.add(new MenuItem("Back"));
649701 backItem.addActionListener(this);
650702 frontItem = menu.add(new MenuItem("Front"));
....@@ -652,13 +704,21 @@
652704 // compositeItem = menu.add(new MenuItem("Composite"));
653705 // compositeItem.addActionListener(this);
654706
707
+ grabItem = oe.jTree.popup.add(new JMenuItem("Group"));
708
+ grabItem.addActionListener(this);
709
+
655710 if (Globals.ADVANCED)
656711 {
657712 hideItem = menu.add(new MenuItem("Hidden Group"));
658713 hideItem.addActionListener(this);
659714 }
660
- ungroupItem = menu.add(new MenuItem("Ungroup"));
715
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
661716 ungroupItem.addActionListener(this);
717
+
718
+ oe.jTree.popup.addSeparator();
719
+
720
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
721
+ deleteItem.addActionListener(this);
662722
663723 // menu.add("-");
664724 //
....@@ -695,9 +755,9 @@
695755 shadowYItem.addActionListener(this);
696756 shadowZItem = menu.add(new MenuItem("Shadow Blue"));
697757 shadowZItem.addActionListener(this);
758
+
698759 attributeItem = menu.add(new MenuItem("Attribute"));
699760 attributeItem.addActionListener(this);
700
-
701761 if (Globals.ADVANCED)
702762 {
703763 menu.add("-");
....@@ -709,11 +769,18 @@
709769 pointflowItem.addActionListener(this);
710770 }
711771 menu.add("-");
772
+ textureRatioRItem = menu.add(new MenuItem("Texture Ratio Red"));
773
+ textureRatioRItem.addActionListener(this);
774
+ textureRatioGItem = menu.add(new MenuItem("Texture Ratio Green"));
775
+ textureRatioGItem.addActionListener(this);
776
+ textureRatioBItem = menu.add(new MenuItem("Texture Ratio Blue"));
777
+ textureRatioBItem.addActionListener(this);
778
+ menu.add("-");
712779 resetTransformItem = menu.add(new MenuItem("Reset Transform"));
713780 resetTransformItem.addActionListener(this);
714781 resetCentroidItem = menu.add(new MenuItem("Reset Centroid"));
715782 resetCentroidItem.addActionListener(this);
716
- resetCentroidXZItem = menu.add(new MenuItem("Reset Centroid XY"));
783
+ resetCentroidXZItem = menu.add(new MenuItem("Reset Centroid XZ"));
717784 resetCentroidXZItem.addActionListener(this);
718785 transformGeometryItem = menu.add(new MenuItem("Transform Geometry"));
719786 transformGeometryItem.addActionListener(this);
....@@ -765,6 +832,8 @@
765832 }
766833
767834 oe.menuBar.add(menu = new Menu("Attributes"));
835
+ clearVersionsItem = menu.add(new MenuItem("Clear Versions"));
836
+ clearVersionsItem.addActionListener(this);
768837 clearMaterialsItem = menu.add(new MenuItem("Clear Materials"));
769838 clearMaterialsItem.addActionListener(this);
770839 resetAllItem = menu.add(new MenuItem("Reset All"));
....@@ -787,9 +856,9 @@
787856 hideleavesItem.addActionListener(this);
788857 showleavesItem = menu.add(new MenuItem("Show Leaves"));
789858 showleavesItem.addActionListener(this);
790
- markleavesItem = menu.add(new MenuItem("Mark Leaves"));
859
+ markleavesItem = menu.add(new MenuItem("Anim Leaves"));
791860 markleavesItem.addActionListener(this);
792
- unmarkleavesItem = menu.add(new MenuItem("Unmark Leaves"));
861
+ unmarkleavesItem = menu.add(new MenuItem("Unanim Leaves"));
793862 unmarkleavesItem.addActionListener(this);
794863 rewindleavesItem = menu.add(new MenuItem("Rewind Leaves"));
795864 rewindleavesItem.addActionListener(this);
....@@ -843,6 +912,9 @@
843912 shareGeometriesItem.addActionListener(this);
844913 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
845914 mergeGeometriesItem.addActionListener(this);
915
+ menu.add("-");
916
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
917
+ editLeafItem.addActionListener(this);
846918 if (Globals.ADVANCED)
847919 {
848920 // Pretty much the same as duplicate and clone.
....@@ -859,6 +931,79 @@
859931 buildToolsMenu(menu);
860932 }
861933
934
+ JTabbedPane resourcecontainer;
935
+ cGridBag currenttab;
936
+ //boolean added; // patch for jar
937
+
938
+ int totalcount = 0;
939
+
940
+ int tabcount = 0;
941
+ int colcount = 0;
942
+ int rowcount = 0;
943
+ int texturecount = 0;
944
+
945
+ int columns = 5;
946
+ int rows = 7;
947
+
948
+ public void ResourceCallBack(String[] path)
949
+ {
950
+// for (int i = 0; i < path.length; i++)
951
+// System.out.print(path[i] + "/");
952
+// System.out.println();
953
+
954
+ if (//rowcount == 0 ||
955
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
956
+ {
957
+ currenttab = new cGridBag();
958
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
959
+ currenttab.setName(tabname);
960
+ //added = false;
961
+ resourcecontainer.add(currenttab);
962
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
963
+ rowcount = 1;
964
+ colcount = 0;
965
+ texturecount = 0;
966
+ }
967
+
968
+ if (path.length > 2 && (path[2].toLowerCase().endsWith(".jpg") || path[2].toLowerCase().endsWith(".png")))
969
+ {
970
+ //if (!added)
971
+ {
972
+ //added = true;
973
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
974
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
975
+ }
976
+
977
+ AddTextureButton(path[0], path[1], path[2], ++texturecount, currenttab);
978
+ totalcount++;
979
+
980
+ if (++colcount >= columns)
981
+ {
982
+ colcount = 0;
983
+ currenttab.Return();
984
+
985
+ if (rowcount++ >= rows)
986
+ {
987
+ rowcount = 0;
988
+ }
989
+ }
990
+ }
991
+ else
992
+ {
993
+// if (!path[path.length-1].equals("icons"))
994
+// resourcecontainer.Return();
995
+ }
996
+ }
997
+
998
+ void CreateTexturePanel(cGridBag container)
999
+ {
1000
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
1001
+ container.add(resourcecontainer);
1002
+
1003
+ Grafreed.ParseResources("textures", this);
1004
+
1005
+ // 935. System.out.println("Total = " + totalcount);
1006
+ }
8621007
8631008 void SetupUI2(ObjEditor oe)
8641009 {
....@@ -877,11 +1022,6 @@
8771022 //new Exception().printStackTrace();
8781023
8791024 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;
8851025 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8861026
8871027 oe.buttonGroup = new ButtonGroup();
....@@ -902,9 +1042,9 @@
9021042 oe.radioPanel.add(dummyButton);
9031043 oe.buttonGroup.add(dummyButton);
9041044 */
905
- cGridBag copyOptionsPanel = new cGridBag();
1045
+ cGridBag versionManagerPanel = new cGridBag();
9061046
907
- copyOptionsPanel.preferredHeight = 2;
1047
+ versionManagerPanel.preferredHeight = 4;
9081048
9091049 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
9101050
....@@ -914,58 +1054,102 @@
9141054
9151055 if (Globals.ADVANCED)
9161056 {
917
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
918
- maxButton.setToolTipText("Maximize window");
919
- maxButton.addActionListener(this);
1057
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1058
+// maxButton.setToolTipText("Maximize window");
1059
+// maxButton.addActionListener(this);
9201060 }
9211061
922
- oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
923
- fullButton.setToolTipText("Full-screen window");
924
- fullButton.addActionListener(this);
1062
+ cButton gcButton;
9251063
926
- oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1064
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1065
+// gcButton.setToolTipText("Garbage collect");
1066
+// gcButton.addActionListener(new ActionListener()
1067
+// {
1068
+// public void actionPerformed(ActionEvent e)
1069
+// {
1070
+// System.gc();
1071
+// }
1072
+// });
1073
+
1074
+ oe.toolbarPanel.add(fullScreenButton = GetButton("icons/fullscreen.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1075
+ fullScreenButton.setToolTipText("Full-screen window");
1076
+ fullScreenButton.addActionListener(this);
1077
+
1078
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1079
+ collapseButton.setToolTipText("Collapse toolbar");
1080
+ collapseButton.addActionListener(this);
1081
+
1082
+// oe.toolbarPanel.add(maximize3DButton = GetButton("icons/square.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1083
+// maximize3DButton.setToolTipText("Maximize 3D view");
1084
+// maximize3DButton.addActionListener(this);
1085
+
1086
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1087
+ twoButton.setToolTipText("Show 3D view only");
1088
+ twoButton.addActionListener(this);
1089
+ this.fullscreenLayout = twoButton;
1090
+
1091
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1092
+ threeButton.setToolTipText("Show controls and 3D view");
1093
+ threeButton.addActionListener(this);
1094
+ if (Globals.ADVANCED)
1095
+ {
1096
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1097
+ sixButton.setToolTipText("Show 3D view and controls");
1098
+ sixButton.addActionListener(this);
1099
+ }
1100
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1101
+// sevenButton.setToolTipText("3-column layout");
1102
+// sevenButton.addActionListener(this);
1103
+ //
1104
+
1105
+ oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
9271106 screenfitButton.setToolTipText("Screen fit");
9281107 screenfitButton.addActionListener(this);
9291108
930
- oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1109
+ oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
9311110 restoreCameraButton.setToolTipText("Restore viewpoint");
9321111 restoreCameraButton.addActionListener(this);
9331112
934
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
935
- saveButton.setToolTipText("Duplicate current version");
936
- saveButton.addActionListener(this);
1113
+ versionManagerPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1114
+ saveVersionButton.setToolTipText("Duplicate current version");
1115
+ saveVersionButton.addActionListener(this);
9371116
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);
1117
+ versionManagerPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1118
+ deleteVersionButton.setToolTipText("Delete current version");
1119
+ deleteVersionButton.addActionListener(this);
1120
+ deleteVersionButton.setEnabled(false);
1121
+
1122
+ versionManagerPanel.add(previousVersionButton = GetButton("icons/undo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1123
+ previousVersionButton.setToolTipText("Previous version");
1124
+ previousVersionButton.addActionListener(this);
1125
+ previousVersionButton.setEnabled(false);
9421126
9431127 cGridBag updown = new cGridBag().setVertical(true);
944
- updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
945
- restoreButton.setToolTipText("Restore current version (undo latest change)");
1128
+ updown.add(restoreButton = GetButton("icons/restore.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1129
+ restoreButton.setToolTipText("Undo (restore current version)");
9461130 restoreButton.addActionListener(this);
9471131 restoreButton.setEnabled(false);
9481132
949
- updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
950
- replaceButton.setToolTipText("Replace current version (save latest change)");
1133
+ updown.add(replaceButton = GetButton("icons/replace.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1134
+ replaceButton.setToolTipText("Save (replace current version)");
9511135 replaceButton.addActionListener(this);
9521136 replaceButton.setEnabled(false);
9531137
954
- copyOptionsPanel.add(updown);
1138
+ versionManagerPanel.add(updown);
9551139
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);
1140
+ versionManagerPanel.add(nextVersionButton = GetButton("icons/redo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1141
+ nextVersionButton.setToolTipText("Next version");
1142
+ nextVersionButton.addActionListener(this);
1143
+ nextVersionButton.setEnabled(false);
1144
+
1145
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1146
+ oneStepButton.setToolTipText("Animate one step forward");
1147
+ oneStepButton.addActionListener(this);
9601148
9611149 oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
9621150 liveCB.setToolTipText("Enable animation");
9631151 liveCB.addItemListener(this);
9641152
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
-
9691153 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9701154 fastCB.setToolTipText("Fast mode");
9711155 fastCB.addItemListener(this);
....@@ -981,38 +1165,23 @@
9811165
9821166 if (Globals.ADVANCED)
9831167 {
984
- oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1168
+ oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Globals.NIMBUSLAF)); //, oe.aConstraints);
9851169 snapobjectButton.addActionListener(this);
9861170 snapobjectButton.setToolTipText("Snap Object");
9871171
988
- oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1172
+ oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
9891173 fourButton.addActionListener(this);
9901174 fourButton.setToolTipText("Show control panel only");
9911175 }
9921176
9931177 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
9941178
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
- //
10101179
1011
- oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1180
+ oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10121181 rootButton.setToolTipText("Open selection in new tab");
10131182 rootButton.addActionListener(this);
10141183
1015
- oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1184
+ oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10161185 closeButton.setToolTipText("Close tab");
10171186 closeButton.addActionListener(this);
10181187 //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
....@@ -1021,38 +1190,38 @@
10211190 cGridBag row1 = new cGridBag();
10221191
10231192 // INSERT
1024
- row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1025
- gridButton.setToolTipText("Create grid");
1193
+ row1.add(gridButton = GetButton("icons/grid.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1194
+ gridButton.setToolTipText("Create ground");
10261195 gridButton.addActionListener(this);
10271196
1028
- row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1197
+ row1.add(boxButton = GetButton("icons/box.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10291198 boxButton.setToolTipText("Create box");
10301199 boxButton.addActionListener(this);
10311200
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);
1201
+ row1.add(superButton = GetButton("icons/super.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10451202 superButton.setToolTipText("Create superellipsoid");
10461203 superButton.addActionListener(this);
10471204
1048
- if (Globals.ADVANCED)
1205
+ row1.add(sphereButton = GetButton("icons/sphere.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1206
+ sphereButton.setToolTipText("Create sphere");
1207
+ sphereButton.addActionListener(this);
1208
+
1209
+ row1.add(coneButton = GetButton("icons/cone.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1210
+ coneButton.setToolTipText("Create cone");
1211
+ coneButton.addActionListener(this);
1212
+
1213
+ row1.add(torusButton = GetButton("icons/torus.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1214
+ torusButton.setToolTipText("Create torus");
1215
+ torusButton.addActionListener(this);
1216
+
1217
+ if (false) //Globals.ADVANCED)
10491218 {
1050
- oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1219
+ oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10511220 kleinButton.setToolTipText("Create Klein bottle");
10521221 kleinButton.addActionListener(this);
10531222 }
10541223
1055
- row1.add(particlesButton = GetButton("icons/particles.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1224
+ row1.add(particlesButton = GetButton("icons/particles.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10561225 particlesButton.setToolTipText("Create particle system");
10571226 particlesButton.addActionListener(this);
10581227
....@@ -1060,72 +1229,73 @@
10601229
10611230 cGridBag row2 = new cGridBag();
10621231
1063
- row2.add(groupButton = GetButton("icons/group.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1232
+ row2.add(groupButton = GetButton("icons/group.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10641233 groupButton.setToolTipText("Create group");
10651234 groupButton.addActionListener(this);
10661235
1067
- row2.add(compositeButton = GetButton("icons/composite.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1236
+ row2.add(compositeButton = GetButton("icons/composite.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10681237 compositeButton.setToolTipText("Create composite");
10691238 compositeButton.addActionListener(this);
10701239
1071
- row2.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1240
+ row2.add(switchButton = GetButton("icons/switch.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10721241 switchButton.setToolTipText("Create item switcher");
10731242 switchButton.addActionListener(this);
10741243
1075
- row2.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1244
+ row2.add(loopButton = GetButton("icons/loop.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10761245 loopButton.setToolTipText("Create loop");
10771246 loopButton.addActionListener(this);
10781247
1079
- row2.add(textureButton = GetButton("icons/texture.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1248
+ row2.add(textureButton = GetButton("icons/texture.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10801249 textureButton.setToolTipText("Create texture");
10811250 textureButton.addActionListener(this);
10821251
1083
- row2.add(overlayButton = GetButton("icons/overlay.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1252
+ row2.add(overlayButton = GetButton("icons/overlay.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10841253 overlayButton.setToolTipText("Create overlay");
10851254 overlayButton.addActionListener(this);
10861255
1087
- row2.add(lightButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1256
+ row2.add(lightButton = GetButton("icons/light-bulb.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10881257 lightButton.setToolTipText("Create light");
10891258 lightButton.addActionListener(this);
10901259
10911260 oe.toolboxPanel.add(row2);
10921261
1093
- // ENVYMAPS
1094
- cGridBag skyboxpane = new cGridBag();
1095
- skyboxpane.preferredHeight = 100;
1262
+ cGridBag textures = new cGridBag();
10961263
1097
- oe.toolboxPanel.add(skyboxpane);
1264
+ CreateTexturePanel(textures);
10981265
1099
- JTabbedPane skyboxpanel = new JTabbedPane();
1100
- skyboxpane.add(skyboxpanel);
1266
+ int tabCount = resourcecontainer.getTabCount();
11011267
1102
- AddSkyboxTab0(skyboxpanel);
1103
- AddSkyboxTab1(skyboxpanel);
1104
- AddSkyboxTab2(skyboxpanel);
1105
- AddSkyboxTab3(skyboxpanel);
1268
+ if (tabCount > 0)
1269
+ resourcecontainer.setSelectedIndex((int)(Math.random() * tabCount));
1270
+
1271
+ oe.toolboxPanel.add(textures);
1272
+
1273
+ textures.preferredHeight = 100;
1274
+
1275
+ CreateSkyboxPanel(oe.skyboxPanel);
11061276
11071277 // EDIT panel
1108
- editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1278
+ editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11091279 editButton.setToolTipText("Pin selection controls");
11101280 editButton.addActionListener(this);
11111281
1112
- editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1113
- uneditButton.setToolTipText("Remove selection controls");
1282
+ editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1283
+ uneditButton.setToolTipText("Unpin and remove selection controls");
11141284 uneditButton.addActionListener(this);
11151285
11161286 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1117
- allParamsButton.setToolTipText("Show all controle");
1287
+ allParamsButton.setToolTipText("Show all controls");
11181288 allParamsButton.addActionListener(this);
11191289
1120
- editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1121
- clearPanelButton.setToolTipText("Clear edit panel");
1290
+ editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1291
+ clearPanelButton.setToolTipText("Clear all controls");
11221292 clearPanelButton.addActionListener(this);
11231293
1124
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- unselectButton.setToolTipText("Unselect");
1126
- unselectButton.addActionListener(this);
1294
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1295
+ //unselectButton.setToolTipText("Unselect");
1296
+ //unselectButton.addActionListener(this);
11271297
1128
- editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1298
+ editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11291299 flashSelectionButton.setToolTipText("Highlight selection");
11301300 flashSelectionButton.addActionListener(this);
11311301
....@@ -1148,6 +1318,8 @@
11481318
11491319 cGridBag jSPPanel = new cGridBag();
11501320
1321
+ jSPPanel.preferredHeight = 20;
1322
+
11511323 JScrollPane jSP;
11521324 //ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints);
11531325 jSPPanel.add(jSP = new JScrollPane(oe.jTree)); //, oe.aConstraints);
....@@ -1156,11 +1328,11 @@
11561328 oe.treePanel.add(jSPPanel);
11571329 oe.treePanel.Return();
11581330
1159
- oe.treePanel.add(copyOptionsPanel);
1331
+ oe.treePanel.add(versionManagerPanel);
11601332 oe.treePanel.Return();
1161
- cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
1162
- versionSlider = (cNumberSlider)sliderPane.getComponent(1);
1163
- sliderPane.preferredHeight = 1;
1333
+ versionSliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
1334
+ versionSlider = (cNumberSlider)versionSliderPane.getComponent(1);
1335
+ versionSliderPane.preferredHeight = 3;
11641336
11651337 // mainPanel.setDividerLocation(0.1); //1.0);
11661338 mainPanel.setResizeWeight(0.4);
....@@ -1318,6 +1490,14 @@
13181490
13191491 void EditObject(Object3D obj)
13201492 {
1493
+ //assert(obj instanceof Composite);
1494
+
1495
+// if (obj.versionlist == null)
1496
+// {
1497
+// obj.versionlist = new Object3D[100];
1498
+// obj.versionindex = -1;
1499
+// }
1500
+
13211501 cRadio radioButton = new cRadio(obj.name);
13221502
13231503 // June 2019. Patch to avoid bug with transparency.
....@@ -1342,6 +1522,7 @@
13421522
13431523 oe.SetupViews();
13441524
1525
+ if (Globals.DEBUG)
13451526 System.out.println("SetupViews");
13461527 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
13471528 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -1708,7 +1889,12 @@
17081889 TreePath path;
17091890
17101891 public TransferableTreePath(TreePath tp) {
1711
- path = tp;
1892
+ Object[] objs = new Object[tp.getPathCount()];
1893
+ for (int i=0; i<objs.length; i++)
1894
+ {
1895
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1896
+ }
1897
+ path = new TreePath(objs);
17121898 }
17131899
17141900 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -1940,24 +2126,24 @@
19402126 switch(axis)
19412127 {
19422128 case 0 :
1943
- vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z;
1944
- vert2.x = minima.x; vert2.y = maxima.y; vert2.z = minima.z;
1945
- vert3.x = minima.x; vert3.y = minima.y; vert3.z = maxima.z;
1946
- vert4.x = minima.x; vert4.y = maxima.y; vert4.z = maxima.z;
2129
+ vert1.x = minima.x + 0.001f; vert1.y = minima.y; vert1.z = minima.z;
2130
+ vert2.x = minima.x + 0.001f; vert2.y = maxima.y; vert2.z = minima.z;
2131
+ vert3.x = minima.x + 0.001f; vert3.y = minima.y; vert3.z = maxima.z;
2132
+ vert4.x = minima.x + 0.001f; vert4.y = maxima.y; vert4.z = maxima.z;
19472133 norm = cVector.X;
19482134 break;
19492135 case 1 :
1950
- vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z;
1951
- vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z;
1952
- vert3.x = minima.x; vert3.y = minima.y; vert3.z = maxima.z;
1953
- vert4.x = maxima.x; vert4.y = minima.y; vert4.z = maxima.z;
2136
+ vert1.x = minima.x; vert1.y = minima.y + 0.001f; vert1.z = minima.z;
2137
+ vert2.x = maxima.x; vert2.y = minima.y + 0.001f; vert2.z = minima.z;
2138
+ vert3.x = minima.x; vert3.y = minima.y + 0.001f; vert3.z = maxima.z;
2139
+ vert4.x = maxima.x; vert4.y = minima.y + 0.001f; vert4.z = maxima.z;
19542140 norm = cVector.Y;
19552141 break;
19562142 case 2 :
1957
- vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z;
1958
- vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z;
1959
- vert3.x = minima.x; vert3.y = maxima.y; vert3.z = minima.z;
1960
- vert4.x = maxima.x; vert4.y = maxima.y; vert4.z = minima.z;
2143
+ vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z + 0.001f;
2144
+ vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z + 0.001f;
2145
+ vert3.x = minima.x; vert3.y = maxima.y; vert3.z = minima.z + 0.001f;
2146
+ vert4.x = maxima.x; vert4.y = maxima.y; vert4.z = minima.z + 0.001f;
19612147 norm = cVector.Z;
19622148 break;
19632149 }
....@@ -1998,7 +2184,11 @@
19982184 shadow.material = new cMaterial(obj.material);
19992185 shadow.material.diffuse = 0.0001f;
20002186 shadow.material.specular = 0.0001f;
2001
- //shadow.projectedVertices[1].x = 300;
2187
+ shadow.material.opacity = 0.75f;
2188
+
2189
+ AllocProjectedVertices(shadow);
2190
+
2191
+ shadow.projectedVertices[1].x = 300;
20022192
20032193 makeSomething(shadow);
20042194 }
....@@ -2519,27 +2709,35 @@
25192709 } else
25202710 if (source == loopItem || source == loopButton)
25212711 {
2712
+ if (!group.selection.isEmpty())
2713
+ {
25222714 Composite csg = new GroupLeaf();
2523
- csg.count = 5;
25242715 group(csg);
2716
+ csg.count = 5;
25252717 Composite child = new cGroup("Branch");
25262718 csg.addChild(child);
25272719 child.addChild(csg);
2720
+ }
25282721 } else
25292722 if (source == doubleItem)
25302723 {
2724
+ if (!group.selection.isEmpty())
2725
+ {
25312726 Composite csg = new GroupLeaf("Fork");
2532
- csg.count = 5;
25332727 group(csg);
2728
+ csg.count = 5;
25342729 Composite child = new cGroup("Branch A");
25352730 csg.addChild(child);
25362731 child.addChild(csg);
25372732 child = new cGroup("Branch B");
25382733 csg.addChild(child);
25392734 child.addChild(csg);
2735
+ }
25402736 } else
25412737 if (source == tripleItem)
25422738 {
2739
+ if (!group.selection.isEmpty())
2740
+ {
25432741 Composite csg = new GroupLeaf("Trident");
25442742 csg.count = 4;
25452743 group(csg);
....@@ -2552,6 +2750,7 @@
25522750 child = new cGroup();
25532751 csg.addChild(child);
25542752 child.addChild(csg);
2753
+ }
25552754 } else
25562755 if (source == computeAOItem)
25572756 {
....@@ -2571,7 +2770,7 @@
25712770 if (source == invariantsItem)
25722771 {
25732772 System.out.println("Invariants:");
2574
- Grafreed.grafreeD.universe.invariants();
2773
+ Grafreed.grafreed.universe.invariants();
25752774 } else
25762775 if (source == memoryItem)
25772776 {
....@@ -2598,37 +2797,56 @@
25982797 {
25992798 Maximize();
26002799 } else
2601
- if (source == fullButton)
2800
+ if (source == fullScreenButton)
26022801 {
26032802 ToggleFullScreen();
26042803 } else
2605
- if (source == undoButton)
2804
+ if (source == collapseButton)
2805
+ {
2806
+ this.expandedLayout = radio.layout;
2807
+ CollapseToolbar();
2808
+ } else
2809
+// if (source == maximize3DButton)
2810
+// {
2811
+// this.expandedLayout = radio.layout;
2812
+// radio.layout = twoButton;
2813
+// CollapseToolbar();
2814
+// Show3DView();
2815
+// } else
2816
+ if (source == previousVersionButton)
26062817 {
26072818 // Go to previous version
26082819 //if (!Undo())
26092820 //java.awt.Toolkit.getDefaultToolkit().beep();
2610
- Undo();
2821
+ PreviousVersion();
26112822 } else
26122823 if (source == restoreButton)
26132824 {
26142825 // Restore current version
26152826 Restore();
2827
+ //restoreButton.setEnabled(false);
26162828 } else
26172829 if (source == replaceButton)
26182830 {
26192831 // Overwrite current version
26202832 Replace();
2833
+ //replaceButton.setEnabled(false);
26212834 } else
2622
- if (source == redoButton)
2835
+ if (source == nextVersionButton)
26232836 {
26242837 // Go to next version
2625
- Redo();
2838
+ NextVersion();
26262839 } else
2627
- if (source == saveButton)
2840
+ if (source == saveVersionButton)
26282841 {
26292842 // Save a new version
26302843 if (!Save(true))
26312844 java.awt.Toolkit.getDefaultToolkit().beep();
2845
+ } else
2846
+ if (source == deleteVersionButton)
2847
+ {
2848
+ // Delete a new version
2849
+ DeleteVersion();
26322850 } else
26332851 if (source == oneStepButton)
26342852 {
....@@ -2683,11 +2901,11 @@
26832901 } else
26842902 if (source == undoItem)
26852903 {
2686
- Undo();
2904
+ PreviousVersion();
26872905 } else
26882906 if (source == redoItem)
26892907 {
2690
- Redo();
2908
+ NextVersion();
26912909 } else
26922910 if (source == duplicateItem)
26932911 {
....@@ -3168,22 +3386,34 @@
31683386 } else
31693387 if (source == ungroupItem || source == ungroupButton)
31703388 {
3171
- boolean hasRoot = false;
3389
+ boolean canUngroup = true;
31723390
31733391 for (int i=0; i<group.selection.size(); i++)
31743392 {
3175
- if (group.selection.get(i) == group)
3393
+ Object3D selectedItem = group.selection.get(i);
3394
+
3395
+ if (selectedItem.Size() == 0)
31763396 {
3177
- hasRoot = true;
3397
+ // Cannot ungroup leaves
3398
+ canUngroup = false;
3399
+ break;
3400
+ }
3401
+
3402
+ if (selectedItem == group)
3403
+ {
3404
+ // Cannot ungroup root
3405
+ canUngroup = false;
31783406 break;
31793407 }
31803408 }
31813409
3182
- if (!hasRoot)
3410
+ if (canUngroup)
31833411 {
31843412 for (int i=0; i<group.selection.size(); i++)
31853413 {
3186
- Ungroup(group.selection.get(i));
3414
+ Object3D selectedItem = group.selection.get(i);
3415
+
3416
+ Ungroup(selectedItem);
31873417 }
31883418
31893419 ClearSelection(false);
....@@ -3234,6 +3464,10 @@
32343464 if (source == clearMaterialsItem)
32353465 {
32363466 ClearMaterials();
3467
+ } else
3468
+ if (source == clearVersionsItem)
3469
+ {
3470
+ ClearVersions();
32373471 } else
32383472 if (source == liveleavesItem)
32393473 {
....@@ -3374,6 +3608,18 @@
33743608 if (source == transformChildrenItem)
33753609 {
33763610 TransformChildren();
3611
+ } else
3612
+ if (source == textureRatioRItem)
3613
+ {
3614
+ TextureRatio(0);
3615
+ } else
3616
+ if (source == textureRatioGItem)
3617
+ {
3618
+ TextureRatio(1);
3619
+ } else
3620
+ if (source == textureRatioBItem)
3621
+ {
3622
+ TextureRatio(2);
33773623 } else
33783624 if (source == resetTransformItem)
33793625 {
....@@ -3546,38 +3792,7 @@
35463792 if (CameraPane.FULLSCREEN)
35473793 fullscreenLayout = radio.layout;
35483794
3549
- // bug
3550
- //gridPanel.setDividerLocation(1.0);
3551
- //bigPanel.setDividerLocation(0.0);
3552
-// bigThree.remove(scenePanel);
3553
-// bigThree.remove(centralPanel);
3554
-// bigThree.remove(XYZPanel);
3555
-// aWindowConstraints.gridx = 0;
3556
-// aWindowConstraints.gridy = 0;
3557
-// aWindowConstraints.gridwidth = 1;
3558
-// // aConstraints.gridheight = 3;
3559
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3560
-// aWindowConstraints.weightx = 0;
3561
-// aWindowConstraints.weighty = 1;
3562
-// //bigThree.add(jtp, aWindowConstraints);
3563
-// aWindowConstraints.weightx = 1;
3564
-// aWindowConstraints.gridwidth = 3;
3565
-// // aConstraints.gridheight = 3;
3566
-// aWindowConstraints.gridx = 1;
3567
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3568
-// bigThree.add(centralPanel, aWindowConstraints);
3569
-// aWindowConstraints.weightx = 0;
3570
-// aWindowConstraints.gridx = 4;
3571
-// aWindowConstraints.gridwidth = 1;
3572
-// // aConstraints.gridheight = 3;
3573
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3574
-// //bigThree.add(XYZPanel, aWindowConstraints);
3575
-// scenePanel.setVisible(false);
3576
-// centralPanel.setVisible(true);
3577
-// XYZPanel.setVisible(false);
3578
- bigThree.ClearUI();
3579
- bigThree.add(centralPanel);
3580
- bigThree.FlushUI();
3795
+ Show3DView();
35813796
35823797 cameraView.requestFocusInWindow();
35833798
....@@ -3763,6 +3978,7 @@
37633978 } else
37643979 if (source == rootButton)
37653980 {
3981
+ Replace();
37663982 Object3D obj;
37673983 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37683984 {
....@@ -3777,6 +3993,9 @@
37773993 if (source == closeButton)
37783994 {
37793995 //System.out.println("CLOSE: " + buttonGroup.getSelection());
3996
+ if (copy.versionlist != null)
3997
+ Replace();
3998
+
37803999 cRadio ab;
37814000 for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
37824001 {
....@@ -3820,10 +4039,10 @@
38204039 {
38214040 Object3D child = (Object3D)e.nextElement();
38224041 if(child.editWindow != null)
3823
- objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38244042 child.pinned = false;
38254043 child.CloseUI();
38264044 listUI.remove(child);
4045
+// objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38274046
38284047 //child.editWindow = null; // ???????????
38294048 }
....@@ -3842,6 +4061,7 @@
38424061 obj.CloseUI();
38434062 }
38444063 listUI.clear();
4064
+ SetPinStates(group.selection.size() > 0);
38454065 refreshContents(true);
38464066 } else
38474067 if (source == allParamsButton)
....@@ -3874,6 +4094,9 @@
38744094 } else
38754095 if(source instanceof cRadio)
38764096 {
4097
+ if (copy.versionlist != null)
4098
+ Replace();
4099
+
38774100 group.parent = keepparent;
38784101 group.attributes = 0;
38794102 //group.editWindow = null;
....@@ -3898,8 +4121,6 @@
38984121
38994122 copy = group;
39004123
3901
- SetUndoStates();
3902
-
39034124 //Globals.theRenderer.object = group;
39044125 if(!useclient)
39054126 {
....@@ -3927,7 +4148,34 @@
39274148 */
39284149 radio.layout.doClick();
39294150
4151
+ //assert(copy instanceof Composite);
4152
+
4153
+ if (copy.versionlist == null)
4154
+ {
4155
+ copy.versionindex = -1;
4156
+
4157
+ // Cannot work with loops
4158
+ // To fix this issue, we first mark all nodes above the root,
4159
+ // and check if any of these nodes are reachable below the root.
4160
+ Grafreed.grafreed.universe.TagObjects(copy, true);
4161
+
4162
+ if (copy instanceof Composite && !copy.HasTags())
4163
+ {
4164
+ if (copy.versionlist == null)
4165
+ copy.versionlist = new Object3D[100];
4166
+
4167
+ //Save(true);
4168
+ }
4169
+ else
4170
+ copy.versionindex = -2;
4171
+
4172
+ Grafreed.grafreed.universe.TagObjects(copy, false);
4173
+ }
4174
+
4175
+ SetVersionStates();
4176
+
39304177 ClearUnpinned();
4178
+
39314179 //Grafreed.Assert(group != null);
39324180 //Grafreed.Assert(group.selection != null);
39334181 SetPinStates(group.selection == null || group.selection.size() > 0);
....@@ -4039,6 +4287,18 @@
40394287 refreshContents();
40404288 }
40414289
4290
+ void TextureRatio(int axis)
4291
+ {
4292
+ Object3D obj;
4293
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
4294
+ {
4295
+ obj = (Object3D)e.nextElement();
4296
+ obj.TextureRatio(axis);
4297
+ }
4298
+
4299
+ refreshContents();
4300
+ }
4301
+
40424302 void ResetTransform()
40434303 {
40444304 ResetTransform(-1);
....@@ -4054,42 +4314,8 @@
40544314 if (obj.toParent == null)
40554315 continue;
40564316
4057
- if (mask == -1)
4058
- {
4059
- if (obj instanceof Camera) // jan 2014
4060
- {
4061
- LA.matIdentity(obj.toParent);
4062
- LA.matIdentity(obj.fromParent);
4063
- }
4064
- else
4065
- {
4066
- obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent);
4067
- obj.fromParent = null; // LA.matIdentity(obj.fromParent);
4068
- }
4069
- TouchTransform(obj);
4070
- continue;
4071
- }
4072
- if ((mask&2) != 0) // Scale
4073
- {
4074
- obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
4075
- obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
4076
- obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
4077
- obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
4078
- obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
4079
- obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
4080
- }
4081
- if ((mask&4) != 0) // Rotation
4082
- {
4083
- // ?
4084
- }
4085
- if ((mask&1) != 0) // Translation
4086
- {
4087
- if (obj.toParent != null)
4088
- {
4089
- obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0;
4090
- obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0;
4091
- }
4092
- }
4317
+ obj.ResetTransform(mask);
4318
+
40934319 if (obj.parent == null)
40944320 {
40954321 System.out.println("NULL PARENT!");
....@@ -4598,6 +4824,12 @@
45984824 {
45994825 Object3D obj = group.selection.get(i);
46004826
4827
+ if (obj.toParent == null)
4828
+ {
4829
+ obj.toParent = LA.newMatrix();
4830
+ obj.fromParent = LA.newMatrix();
4831
+ }
4832
+
46014833 LA.matTranslate(obj.toParent, i * scale, 0, 0);
46024834 LA.matTranslateInv(obj.fromParent, -i * scale, 0, 0);
46034835 }
....@@ -4889,6 +5121,12 @@
48895121 refreshContents();
48905122 }
48915123
5124
+ void ClearVersions()
5125
+ {
5126
+ group.selection.ClearVersions();
5127
+ refreshContents();
5128
+ }
5129
+
48925130 void FlipV(boolean flip)
48935131 {
48945132 group.selection.FlipV(flip);
....@@ -5083,9 +5321,7 @@
50835321
50845322 freezemodel = false;
50855323 }
5086
-
5087
- boolean flashIt = true;
5088
-
5324
+
50895325 public void valueChanged(TreeSelectionEvent e)
50905326 //public boolean handleEvent(Event event)
50915327 {
....@@ -5129,7 +5365,7 @@
51295365 if (tps != null && tps.length > 0 && tps[0].getLastPathComponent() instanceof Camera)
51305366 // a camera
51315367 {
5132
- if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crash the camera because of invalid lightspace
5368
+ if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crashes the camera because of invalid lightspace
51335369 {
51345370 CameraPane.camerachangeframe = 0; // don't refuse it
51355371 Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());
....@@ -5158,13 +5394,31 @@
51585394 {
51595395 editButton.setEnabled(enabled);
51605396 uneditButton.setEnabled(enabled);
5161
- unselectButton.setEnabled(enabled);
5397
+ //unselectButton.setEnabled(enabled);
51625398 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(true); // allComposites);
51635416 }
51645417
51655418 void refreshContents(boolean cp)
51665419 {
5167
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5420
+ if (Globals.SHOWINFO)
5421
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51685422 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51695423 {
51705424 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5174,7 +5428,7 @@
51745428 Object3D child = (Object3D) group.selection.get(i);
51755429
51765430 objEditor.AddInfo(child, this, true);
5177
- System.err.println("info : " + child.GetPath());
5431
+// System.err.println("info : " + child.GetPath());
51785432 }
51795433
51805434 objEditor.SetText(); // jan 2014
....@@ -6000,7 +6254,6 @@
60006254
60016255 cButton restoreCameraButton;
60026256
6003
- cButton saveButton;
60046257 cButton oneStepButton;
60056258
60066259 cButton groupButton;
....@@ -6058,11 +6311,11 @@
60586311 private MenuItem lookAtItem;
60596312 private MenuItem lookFromItem;
60606313 private MenuItem switchViewItem;
6061
- private MenuItem cutItem;
6314
+ private JMenuItem cutItem;
60626315 private MenuItem undoItem;
60636316 private MenuItem redoItem;
60646317 private JMenuItem duplicateItem;
6065
- private MenuItem cloneItem;
6318
+ private JMenuItem cloneItem;
60666319 private MenuItem cloneSupportItem;
60676320 private MenuItem overwriteGeoItem;
60686321 private MenuItem overwriteMatItem;
....@@ -6083,13 +6336,13 @@
60836336 private MenuItem cloneGeometriesItem;
60846337 private MenuItem shareGeometriesItem;
60856338 private MenuItem mergeGeometriesItem;
6086
- private MenuItem copyItem;
6339
+ private JMenuItem copyItem;
60876340 private MenuItem pasteItem;
6088
- private MenuItem pasteIntoItem;
6089
- private MenuItem pasteLinkItem;
6090
- private MenuItem pasteCloneItem;
6091
- private MenuItem pasteExpandItem;
6092
- private MenuItem deleteItem;
6341
+ private JMenuItem pasteIntoItem;
6342
+ private JMenuItem pasteLinkItem;
6343
+ private JMenuItem pasteCloneItem;
6344
+ private JMenuItem pasteExpandItem;
6345
+ private JMenuItem deleteItem;
60936346 private MenuItem clearAllItem;
60946347 private MenuItem genUVItem;
60956348 private MenuItem genNormalsMESHItem;
....@@ -6115,6 +6368,7 @@
61156368 private MenuItem clipMeshItem;
61166369 private MenuItem smoothMeshItem;
61176370 private MenuItem clearMaterialsItem;
6371
+ private MenuItem clearVersionsItem;
61186372
61196373 private MenuItem liveleavesItem;
61206374 private MenuItem unliveleavesItem;
....@@ -6138,13 +6392,16 @@
61386392 private MenuItem maxTexturesItem;
61396393 private MenuItem panoTexturesItem;
61406394
6395
+ private MenuItem textureRatioRItem;
6396
+ private MenuItem textureRatioGItem;
6397
+ private MenuItem textureRatioBItem;
61416398 private MenuItem resetCentroidItem;
61426399 private MenuItem resetCentroidXZItem;
61436400 private MenuItem resetTransformItem;
61446401 private MenuItem transformGeometryItem;
61456402 private MenuItem transformChildrenItem;
61466403 private MenuItem hideItem;
6147
- private MenuItem grabItem;
6404
+ private JMenuItem grabItem;
61486405 private MenuItem backItem;
61496406 private MenuItem frontItem;
61506407 private MenuItem cameraItem;
....@@ -6157,7 +6414,7 @@
61576414 private MenuItem switchTransfoItem;
61586415 private MenuItem morphItem;
61596416 private MenuItem linkerItem;
6160
- private MenuItem ungroupItem;
6417
+ private JMenuItem ungroupItem;
61616418 private MenuItem editItem;
61626419 private MenuItem openWindowItem;
61636420 private MenuItem editLeafItem;