Normand Briere
2019-09-04 c8bb659043bfa0ccf9436d7cbbc49255b4c82402
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,37 @@
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"));
505
-// pasteExpandItem.addActionListener(this);
506
- menu.add("-");
507
- deleteItem = menu.add(new MenuItem("Delete"));
508
- deleteItem.addActionListener(this);
560
+// CRASH
561
+ pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
562
+//
563
+ pasteExpandItem.addActionListener(this);
564
+ //menu.add("-");
565
+ oe.jTree.popup.addSeparator();
509566
510567 if (Globals.ADVANCED)
511568 {
....@@ -591,11 +648,9 @@
591648 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
592649 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
593650 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
594
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
595651 oe.cameraMenu.add("-");
596652 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
597653 openWindowItem.addActionListener(this);
598
- editLeafItem.addActionListener(this);
599654 lookAtItem.addActionListener(this);
600655 //lookFromItem.addActinoListener(this);
601656 //switchViewItem.addActionListener(this);
....@@ -642,9 +697,8 @@
642697 setMasterItem.addActionListener(this);
643698 }
644699
645
- oe.menuBar.add(menu = new Menu("Group"));
646
-// grabItem = menu.add(new MenuItem("Grab"));
647
-// grabItem.addActionListener(this);
700
+ oe.menuBar.add(menu = new Menu("Order"));
701
+
648702 backItem = menu.add(new MenuItem("Back"));
649703 backItem.addActionListener(this);
650704 frontItem = menu.add(new MenuItem("Front"));
....@@ -652,13 +706,21 @@
652706 // compositeItem = menu.add(new MenuItem("Composite"));
653707 // compositeItem.addActionListener(this);
654708
709
+ grabItem = oe.jTree.popup.add(new JMenuItem("Group"));
710
+ grabItem.addActionListener(this);
711
+
655712 if (Globals.ADVANCED)
656713 {
657714 hideItem = menu.add(new MenuItem("Hidden Group"));
658715 hideItem.addActionListener(this);
659716 }
660
- ungroupItem = menu.add(new MenuItem("Ungroup"));
717
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
661718 ungroupItem.addActionListener(this);
719
+
720
+ oe.jTree.popup.addSeparator();
721
+
722
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
723
+ deleteItem.addActionListener(this);
662724
663725 // menu.add("-");
664726 //
....@@ -695,9 +757,9 @@
695757 shadowYItem.addActionListener(this);
696758 shadowZItem = menu.add(new MenuItem("Shadow Blue"));
697759 shadowZItem.addActionListener(this);
760
+
698761 attributeItem = menu.add(new MenuItem("Attribute"));
699762 attributeItem.addActionListener(this);
700
-
701763 if (Globals.ADVANCED)
702764 {
703765 menu.add("-");
....@@ -709,11 +771,18 @@
709771 pointflowItem.addActionListener(this);
710772 }
711773 menu.add("-");
774
+ textureRatioRItem = menu.add(new MenuItem("Texture Ratio Red"));
775
+ textureRatioRItem.addActionListener(this);
776
+ textureRatioGItem = menu.add(new MenuItem("Texture Ratio Green"));
777
+ textureRatioGItem.addActionListener(this);
778
+ textureRatioBItem = menu.add(new MenuItem("Texture Ratio Blue"));
779
+ textureRatioBItem.addActionListener(this);
780
+ menu.add("-");
712781 resetTransformItem = menu.add(new MenuItem("Reset Transform"));
713782 resetTransformItem.addActionListener(this);
714783 resetCentroidItem = menu.add(new MenuItem("Reset Centroid"));
715784 resetCentroidItem.addActionListener(this);
716
- resetCentroidXZItem = menu.add(new MenuItem("Reset Centroid XY"));
785
+ resetCentroidXZItem = menu.add(new MenuItem("Reset Centroid XZ"));
717786 resetCentroidXZItem.addActionListener(this);
718787 transformGeometryItem = menu.add(new MenuItem("Transform Geometry"));
719788 transformGeometryItem.addActionListener(this);
....@@ -765,6 +834,8 @@
765834 }
766835
767836 oe.menuBar.add(menu = new Menu("Attributes"));
837
+ clearVersionsItem = menu.add(new MenuItem("Clear Versions"));
838
+ clearVersionsItem.addActionListener(this);
768839 clearMaterialsItem = menu.add(new MenuItem("Clear Materials"));
769840 clearMaterialsItem.addActionListener(this);
770841 resetAllItem = menu.add(new MenuItem("Reset All"));
....@@ -787,9 +858,9 @@
787858 hideleavesItem.addActionListener(this);
788859 showleavesItem = menu.add(new MenuItem("Show Leaves"));
789860 showleavesItem.addActionListener(this);
790
- markleavesItem = menu.add(new MenuItem("Mark Leaves"));
861
+ markleavesItem = menu.add(new MenuItem("Anim Leaves"));
791862 markleavesItem.addActionListener(this);
792
- unmarkleavesItem = menu.add(new MenuItem("Unmark Leaves"));
863
+ unmarkleavesItem = menu.add(new MenuItem("Unanim Leaves"));
793864 unmarkleavesItem.addActionListener(this);
794865 rewindleavesItem = menu.add(new MenuItem("Rewind Leaves"));
795866 rewindleavesItem.addActionListener(this);
....@@ -843,6 +914,9 @@
843914 shareGeometriesItem.addActionListener(this);
844915 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
845916 mergeGeometriesItem.addActionListener(this);
917
+ menu.add("-");
918
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
919
+ editLeafItem.addActionListener(this);
846920 if (Globals.ADVANCED)
847921 {
848922 // Pretty much the same as duplicate and clone.
....@@ -859,6 +933,79 @@
859933 buildToolsMenu(menu);
860934 }
861935
936
+ JTabbedPane resourcecontainer;
937
+ cGridBag currenttab;
938
+ //boolean added; // patch for jar
939
+
940
+ int totalcount = 0;
941
+
942
+ int tabcount = 0;
943
+ int colcount = 0;
944
+ int rowcount = 0;
945
+ int texturecount = 0;
946
+
947
+ int columns = 5;
948
+ int rows = 7;
949
+
950
+ public void ResourceCallBack(String[] path)
951
+ {
952
+// for (int i = 0; i < path.length; i++)
953
+// System.out.print(path[i] + "/");
954
+// System.out.println();
955
+
956
+ if (//rowcount == 0 ||
957
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
958
+ {
959
+ currenttab = new cGridBag();
960
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
961
+ currenttab.setName(tabname);
962
+ //added = false;
963
+ resourcecontainer.add(currenttab);
964
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
965
+ rowcount = 1;
966
+ colcount = 0;
967
+ texturecount = 0;
968
+ }
969
+
970
+ if (path.length > 2 && (path[2].toLowerCase().endsWith(".jpg") || path[2].toLowerCase().endsWith(".png")))
971
+ {
972
+ //if (!added)
973
+ {
974
+ //added = true;
975
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
976
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
977
+ }
978
+
979
+ AddTextureButton(path[0], path[1], path[2], ++texturecount, currenttab);
980
+ totalcount++;
981
+
982
+ if (++colcount >= columns)
983
+ {
984
+ colcount = 0;
985
+ currenttab.Return();
986
+
987
+ if (rowcount++ >= rows)
988
+ {
989
+ rowcount = 0;
990
+ }
991
+ }
992
+ }
993
+ else
994
+ {
995
+// if (!path[path.length-1].equals("icons"))
996
+// resourcecontainer.Return();
997
+ }
998
+ }
999
+
1000
+ void CreateTexturePanel(cGridBag container)
1001
+ {
1002
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
1003
+ container.add(resourcecontainer);
1004
+
1005
+ Grafreed.ParseResources("textures", this);
1006
+
1007
+ // 935. System.out.println("Total = " + totalcount);
1008
+ }
8621009
8631010 void SetupUI2(ObjEditor oe)
8641011 {
....@@ -877,11 +1024,6 @@
8771024 //new Exception().printStackTrace();
8781025
8791026 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;
8851027 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
8861028
8871029 oe.buttonGroup = new ButtonGroup();
....@@ -902,9 +1044,9 @@
9021044 oe.radioPanel.add(dummyButton);
9031045 oe.buttonGroup.add(dummyButton);
9041046 */
905
- cGridBag copyOptionsPanel = new cGridBag();
1047
+ cGridBag versionManagerPanel = new cGridBag();
9061048
907
- copyOptionsPanel.preferredHeight = 2;
1049
+ versionManagerPanel.preferredHeight = 4;
9081050
9091051 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
9101052
....@@ -914,58 +1056,102 @@
9141056
9151057 if (Globals.ADVANCED)
9161058 {
917
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
918
- maxButton.setToolTipText("Maximize window");
919
- maxButton.addActionListener(this);
1059
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1060
+// maxButton.setToolTipText("Maximize window");
1061
+// maxButton.addActionListener(this);
9201062 }
9211063
922
- oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
923
- fullButton.setToolTipText("Full-screen window");
924
- fullButton.addActionListener(this);
1064
+ cButton gcButton;
9251065
926
- oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1066
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1067
+// gcButton.setToolTipText("Garbage collect");
1068
+// gcButton.addActionListener(new ActionListener()
1069
+// {
1070
+// public void actionPerformed(ActionEvent e)
1071
+// {
1072
+// System.gc();
1073
+// }
1074
+// });
1075
+
1076
+ oe.toolbarPanel.add(fullScreenButton = GetButton("icons/fullscreen.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1077
+ fullScreenButton.setToolTipText("Full-screen window");
1078
+ fullScreenButton.addActionListener(this);
1079
+
1080
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1081
+ collapseButton.setToolTipText("Collapse toolbar");
1082
+ collapseButton.addActionListener(this);
1083
+
1084
+// oe.toolbarPanel.add(maximize3DButton = GetButton("icons/square.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1085
+// maximize3DButton.setToolTipText("Maximize 3D view");
1086
+// maximize3DButton.addActionListener(this);
1087
+
1088
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1089
+ twoButton.setToolTipText("Show 3D view only");
1090
+ twoButton.addActionListener(this);
1091
+ this.fullscreenLayout = twoButton;
1092
+
1093
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1094
+ threeButton.setToolTipText("Show controls and 3D view");
1095
+ threeButton.addActionListener(this);
1096
+ if (Globals.ADVANCED)
1097
+ {
1098
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1099
+ sixButton.setToolTipText("Show 3D view and controls");
1100
+ sixButton.addActionListener(this);
1101
+ }
1102
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1103
+// sevenButton.setToolTipText("3-column layout");
1104
+// sevenButton.addActionListener(this);
1105
+ //
1106
+
1107
+ oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
9271108 screenfitButton.setToolTipText("Screen fit");
9281109 screenfitButton.addActionListener(this);
9291110
930
- oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1111
+ oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
9311112 restoreCameraButton.setToolTipText("Restore viewpoint");
9321113 restoreCameraButton.addActionListener(this);
9331114
934
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
935
- saveButton.setToolTipText("Duplicate current version");
936
- saveButton.addActionListener(this);
1115
+ versionManagerPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1116
+ saveVersionButton.setToolTipText("Duplicate current version");
1117
+ saveVersionButton.addActionListener(this);
9371118
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);
1119
+ versionManagerPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1120
+ deleteVersionButton.setToolTipText("Delete current version");
1121
+ deleteVersionButton.addActionListener(this);
1122
+ deleteVersionButton.setEnabled(false);
1123
+
1124
+ versionManagerPanel.add(previousVersionButton = GetButton("icons/undo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1125
+ previousVersionButton.setToolTipText("Previous version");
1126
+ previousVersionButton.addActionListener(this);
1127
+ previousVersionButton.setEnabled(false);
9421128
9431129 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)");
1130
+ updown.add(restoreButton = GetButton("icons/restore.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1131
+ restoreButton.setToolTipText("Undo (restore current version)");
9461132 restoreButton.addActionListener(this);
9471133 restoreButton.setEnabled(false);
9481134
949
- updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
950
- replaceButton.setToolTipText("Replace current version (save latest change)");
1135
+ updown.add(replaceButton = GetButton("icons/replace.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1136
+ replaceButton.setToolTipText("Save (replace current version)");
9511137 replaceButton.addActionListener(this);
9521138 replaceButton.setEnabled(false);
9531139
954
- copyOptionsPanel.add(updown);
1140
+ versionManagerPanel.add(updown);
9551141
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);
1142
+ versionManagerPanel.add(nextVersionButton = GetButton("icons/redo.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1143
+ nextVersionButton.setToolTipText("Next version");
1144
+ nextVersionButton.addActionListener(this);
1145
+ nextVersionButton.setEnabled(false);
1146
+
1147
+ oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1148
+ oneStepButton.setToolTipText("Animate one step forward");
1149
+ oneStepButton.addActionListener(this);
9601150
9611151 oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
9621152 liveCB.setToolTipText("Enable animation");
9631153 liveCB.addItemListener(this);
9641154
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
-
9691155 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9701156 fastCB.setToolTipText("Fast mode");
9711157 fastCB.addItemListener(this);
....@@ -981,38 +1167,23 @@
9811167
9821168 if (Globals.ADVANCED)
9831169 {
984
- oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1170
+ oe.toolbarPanel.add(snapobjectButton = new cButton("O+", !Globals.NIMBUSLAF)); //, oe.aConstraints);
9851171 snapobjectButton.addActionListener(this);
9861172 snapobjectButton.setToolTipText("Snap Object");
9871173
988
- oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1174
+ oe.toolbarPanel.add(fourButton = GetButton("icons/controls-horizontal.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
9891175 fourButton.addActionListener(this);
9901176 fourButton.setToolTipText("Show control panel only");
9911177 }
9921178
9931179 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
9941180
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
- //
10101181
1011
- oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1182
+ oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10121183 rootButton.setToolTipText("Open selection in new tab");
10131184 rootButton.addActionListener(this);
10141185
1015
- oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1186
+ oe.toolbarPanel.add(closeButton = GetButton("icons/close-icon.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10161187 closeButton.setToolTipText("Close tab");
10171188 closeButton.addActionListener(this);
10181189 //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
....@@ -1021,38 +1192,38 @@
10211192 cGridBag row1 = new cGridBag();
10221193
10231194 // INSERT
1024
- row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1025
- gridButton.setToolTipText("Create grid");
1195
+ row1.add(gridButton = GetButton("icons/grid.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1196
+ gridButton.setToolTipText("Create ground");
10261197 gridButton.addActionListener(this);
10271198
1028
- row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1199
+ row1.add(boxButton = GetButton("icons/box.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10291200 boxButton.setToolTipText("Create box");
10301201 boxButton.addActionListener(this);
10311202
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);
1203
+ row1.add(superButton = GetButton("icons/super.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10451204 superButton.setToolTipText("Create superellipsoid");
10461205 superButton.addActionListener(this);
10471206
1048
- if (Globals.ADVANCED)
1207
+ row1.add(sphereButton = GetButton("icons/sphere.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1208
+ sphereButton.setToolTipText("Create sphere");
1209
+ sphereButton.addActionListener(this);
1210
+
1211
+ row1.add(coneButton = GetButton("icons/cone.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1212
+ coneButton.setToolTipText("Create cone");
1213
+ coneButton.addActionListener(this);
1214
+
1215
+ row1.add(torusButton = GetButton("icons/torus.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1216
+ torusButton.setToolTipText("Create torus");
1217
+ torusButton.addActionListener(this);
1218
+
1219
+ if (false) //Globals.ADVANCED)
10491220 {
1050
- oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1221
+ oe.toolboxPanel.add(kleinButton = GetButton("icons/klein.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10511222 kleinButton.setToolTipText("Create Klein bottle");
10521223 kleinButton.addActionListener(this);
10531224 }
10541225
1055
- row1.add(particlesButton = GetButton("icons/particles.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1226
+ row1.add(particlesButton = GetButton("icons/particles.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10561227 particlesButton.setToolTipText("Create particle system");
10571228 particlesButton.addActionListener(this);
10581229
....@@ -1060,72 +1231,73 @@
10601231
10611232 cGridBag row2 = new cGridBag();
10621233
1063
- row2.add(groupButton = GetButton("icons/group.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1234
+ row2.add(groupButton = GetButton("icons/group.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10641235 groupButton.setToolTipText("Create group");
10651236 groupButton.addActionListener(this);
10661237
1067
- row2.add(compositeButton = GetButton("icons/composite.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1238
+ row2.add(compositeButton = GetButton("icons/composite.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10681239 compositeButton.setToolTipText("Create composite");
10691240 compositeButton.addActionListener(this);
10701241
1071
- row2.add(switchButton = GetButton("icons/switch.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1242
+ row2.add(switchButton = GetButton("icons/switch.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10721243 switchButton.setToolTipText("Create item switcher");
10731244 switchButton.addActionListener(this);
10741245
1075
- row2.add(loopButton = GetButton("icons/loop.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1246
+ row2.add(loopButton = GetButton("icons/loop.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10761247 loopButton.setToolTipText("Create loop");
10771248 loopButton.addActionListener(this);
10781249
1079
- row2.add(textureButton = GetButton("icons/texture.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1250
+ row2.add(textureButton = GetButton("icons/texture.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10801251 textureButton.setToolTipText("Create texture");
10811252 textureButton.addActionListener(this);
10821253
1083
- row2.add(overlayButton = GetButton("icons/overlay.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1254
+ row2.add(overlayButton = GetButton("icons/overlay.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10841255 overlayButton.setToolTipText("Create overlay");
10851256 overlayButton.addActionListener(this);
10861257
1087
- row2.add(lightButton = GetButton("icons/light-bulb.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1258
+ row2.add(lightButton = GetButton("icons/light-bulb.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
10881259 lightButton.setToolTipText("Create light");
10891260 lightButton.addActionListener(this);
10901261
10911262 oe.toolboxPanel.add(row2);
10921263
1093
- // ENVYMAPS
1094
- cGridBag skyboxpane = new cGridBag();
1095
- skyboxpane.preferredHeight = 100;
1264
+ cGridBag textures = new cGridBag();
10961265
1097
- oe.toolboxPanel.add(skyboxpane);
1266
+ CreateTexturePanel(textures);
10981267
1099
- JTabbedPane skyboxpanel = new JTabbedPane();
1100
- skyboxpane.add(skyboxpanel);
1268
+ int tabCount = resourcecontainer.getTabCount();
11011269
1102
- AddSkyboxTab0(skyboxpanel);
1103
- AddSkyboxTab1(skyboxpanel);
1104
- AddSkyboxTab2(skyboxpanel);
1105
- AddSkyboxTab3(skyboxpanel);
1270
+ if (tabCount > 0)
1271
+ resourcecontainer.setSelectedIndex((int)(Math.random() * tabCount));
1272
+
1273
+ oe.toolboxPanel.add(textures);
1274
+
1275
+ textures.preferredHeight = 100;
1276
+
1277
+ CreateSkyboxPanel(oe.skyboxPanel);
11061278
11071279 // EDIT panel
1108
- editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1280
+ editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11091281 editButton.setToolTipText("Pin selection controls");
11101282 editButton.addActionListener(this);
11111283
1112
- editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1113
- uneditButton.setToolTipText("Remove selection controls");
1284
+ editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1285
+ uneditButton.setToolTipText("Unpin and remove selection controls");
11141286 uneditButton.addActionListener(this);
11151287
11161288 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1117
- allParamsButton.setToolTipText("Show all controle");
1289
+ allParamsButton.setToolTipText("Show all controls");
11181290 allParamsButton.addActionListener(this);
11191291
1120
- editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1121
- clearPanelButton.setToolTipText("Clear edit panel");
1292
+ editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
1293
+ clearPanelButton.setToolTipText("Clear all controls");
11221294 clearPanelButton.addActionListener(this);
11231295
1124
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- unselectButton.setToolTipText("Unselect");
1126
- unselectButton.addActionListener(this);
1296
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1297
+ //unselectButton.setToolTipText("Unselect");
1298
+ //unselectButton.addActionListener(this);
11271299
1128
- editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1300
+ editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
11291301 flashSelectionButton.setToolTipText("Highlight selection");
11301302 flashSelectionButton.addActionListener(this);
11311303
....@@ -1148,6 +1320,8 @@
11481320
11491321 cGridBag jSPPanel = new cGridBag();
11501322
1323
+ jSPPanel.preferredHeight = 20;
1324
+
11511325 JScrollPane jSP;
11521326 //ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints);
11531327 jSPPanel.add(jSP = new JScrollPane(oe.jTree)); //, oe.aConstraints);
....@@ -1156,11 +1330,12 @@
11561330 oe.treePanel.add(jSPPanel);
11571331 oe.treePanel.Return();
11581332
1159
- oe.treePanel.add(copyOptionsPanel);
1333
+ oe.treePanel.add(versionManagerPanel);
11601334 oe.treePanel.Return();
1161
- cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
1162
- versionSlider = (cNumberSlider)sliderPane.getComponent(1);
1163
- sliderPane.preferredHeight = 1;
1335
+
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);
....@@ -1318,6 +1493,14 @@
13181493
13191494 void EditObject(Object3D obj)
13201495 {
1496
+ //assert(obj instanceof Composite);
1497
+
1498
+// if (obj.versionlist == null)
1499
+// {
1500
+// obj.versionlist = new Object3D[100];
1501
+// obj.versionindex = -1;
1502
+// }
1503
+
13211504 cRadio radioButton = new cRadio(obj.name);
13221505
13231506 // June 2019. Patch to avoid bug with transparency.
....@@ -1342,6 +1525,7 @@
13421525
13431526 oe.SetupViews();
13441527
1528
+ if (Globals.DEBUG)
13451529 System.out.println("SetupViews");
13461530 DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
13471531 oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
....@@ -1708,7 +1892,12 @@
17081892 TreePath path;
17091893
17101894 public TransferableTreePath(TreePath tp) {
1711
- 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);
17121901 }
17131902
17141903 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -1940,24 +2129,24 @@
19402129 switch(axis)
19412130 {
19422131 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;
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;
19472136 norm = cVector.X;
19482137 break;
19492138 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;
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;
19542143 norm = cVector.Y;
19552144 break;
19562145 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;
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;
19612150 norm = cVector.Z;
19622151 break;
19632152 }
....@@ -1998,7 +2187,11 @@
19982187 shadow.material = new cMaterial(obj.material);
19992188 shadow.material.diffuse = 0.0001f;
20002189 shadow.material.specular = 0.0001f;
2001
- //shadow.projectedVertices[1].x = 300;
2190
+ shadow.material.opacity = 0.75f;
2191
+
2192
+ AllocProjectedVertices(shadow);
2193
+
2194
+ shadow.projectedVertices[1].x = 300;
20022195
20032196 makeSomething(shadow);
20042197 }
....@@ -2519,27 +2712,35 @@
25192712 } else
25202713 if (source == loopItem || source == loopButton)
25212714 {
2715
+ if (!group.selection.isEmpty())
2716
+ {
25222717 Composite csg = new GroupLeaf();
2523
- csg.count = 5;
25242718 group(csg);
2719
+ csg.count = 5;
25252720 Composite child = new cGroup("Branch");
25262721 csg.addChild(child);
25272722 child.addChild(csg);
2723
+ }
25282724 } else
25292725 if (source == doubleItem)
25302726 {
2727
+ if (!group.selection.isEmpty())
2728
+ {
25312729 Composite csg = new GroupLeaf("Fork");
2532
- csg.count = 5;
25332730 group(csg);
2731
+ csg.count = 5;
25342732 Composite child = new cGroup("Branch A");
25352733 csg.addChild(child);
25362734 child.addChild(csg);
25372735 child = new cGroup("Branch B");
25382736 csg.addChild(child);
25392737 child.addChild(csg);
2738
+ }
25402739 } else
25412740 if (source == tripleItem)
25422741 {
2742
+ if (!group.selection.isEmpty())
2743
+ {
25432744 Composite csg = new GroupLeaf("Trident");
25442745 csg.count = 4;
25452746 group(csg);
....@@ -2552,6 +2753,7 @@
25522753 child = new cGroup();
25532754 csg.addChild(child);
25542755 child.addChild(csg);
2756
+ }
25552757 } else
25562758 if (source == computeAOItem)
25572759 {
....@@ -2571,7 +2773,7 @@
25712773 if (source == invariantsItem)
25722774 {
25732775 System.out.println("Invariants:");
2574
- Grafreed.grafreeD.universe.invariants();
2776
+ Grafreed.grafreed.universe.invariants();
25752777 } else
25762778 if (source == memoryItem)
25772779 {
....@@ -2598,37 +2800,56 @@
25982800 {
25992801 Maximize();
26002802 } else
2601
- if (source == fullButton)
2803
+ if (source == fullScreenButton)
26022804 {
26032805 ToggleFullScreen();
26042806 } else
2605
- 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
+// CollapseToolbar();
2817
+// Show3DView();
2818
+// } else
2819
+ if (source == previousVersionButton)
26062820 {
26072821 // Go to previous version
26082822 //if (!Undo())
26092823 //java.awt.Toolkit.getDefaultToolkit().beep();
2610
- Undo();
2824
+ PreviousVersion();
26112825 } else
26122826 if (source == restoreButton)
26132827 {
26142828 // Restore current version
26152829 Restore();
2830
+ //restoreButton.setEnabled(false);
26162831 } else
26172832 if (source == replaceButton)
26182833 {
26192834 // Overwrite current version
26202835 Replace();
2836
+ //replaceButton.setEnabled(false);
26212837 } else
2622
- if (source == redoButton)
2838
+ if (source == nextVersionButton)
26232839 {
26242840 // Go to next version
2625
- Redo();
2841
+ NextVersion();
26262842 } else
2627
- if (source == saveButton)
2843
+ if (source == saveVersionButton)
26282844 {
26292845 // Save a new version
26302846 if (!Save(true))
26312847 java.awt.Toolkit.getDefaultToolkit().beep();
2848
+ } else
2849
+ if (source == deleteVersionButton)
2850
+ {
2851
+ // Delete a new version
2852
+ DeleteVersion();
26322853 } else
26332854 if (source == oneStepButton)
26342855 {
....@@ -2683,11 +2904,11 @@
26832904 } else
26842905 if (source == undoItem)
26852906 {
2686
- Undo();
2907
+ PreviousVersion();
26872908 } else
26882909 if (source == redoItem)
26892910 {
2690
- Redo();
2911
+ NextVersion();
26912912 } else
26922913 if (source == duplicateItem)
26932914 {
....@@ -3168,22 +3389,34 @@
31683389 } else
31693390 if (source == ungroupItem || source == ungroupButton)
31703391 {
3171
- boolean hasRoot = false;
3392
+ boolean canUngroup = true;
31723393
31733394 for (int i=0; i<group.selection.size(); i++)
31743395 {
3175
- if (group.selection.get(i) == group)
3396
+ Object3D selectedItem = group.selection.get(i);
3397
+
3398
+ if (selectedItem.Size() == 0)
31763399 {
3177
- 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;
31783409 break;
31793410 }
31803411 }
31813412
3182
- if (!hasRoot)
3413
+ if (canUngroup)
31833414 {
31843415 for (int i=0; i<group.selection.size(); i++)
31853416 {
3186
- Ungroup(group.selection.get(i));
3417
+ Object3D selectedItem = group.selection.get(i);
3418
+
3419
+ Ungroup(selectedItem);
31873420 }
31883421
31893422 ClearSelection(false);
....@@ -3234,6 +3467,10 @@
32343467 if (source == clearMaterialsItem)
32353468 {
32363469 ClearMaterials();
3470
+ } else
3471
+ if (source == clearVersionsItem)
3472
+ {
3473
+ ClearVersions();
32373474 } else
32383475 if (source == liveleavesItem)
32393476 {
....@@ -3374,6 +3611,18 @@
33743611 if (source == transformChildrenItem)
33753612 {
33763613 TransformChildren();
3614
+ } else
3615
+ if (source == textureRatioRItem)
3616
+ {
3617
+ TextureRatio(0);
3618
+ } else
3619
+ if (source == textureRatioGItem)
3620
+ {
3621
+ TextureRatio(1);
3622
+ } else
3623
+ if (source == textureRatioBItem)
3624
+ {
3625
+ TextureRatio(2);
33773626 } else
33783627 if (source == resetTransformItem)
33793628 {
....@@ -3546,38 +3795,7 @@
35463795 if (CameraPane.FULLSCREEN)
35473796 fullscreenLayout = radio.layout;
35483797
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();
3798
+ Show3DView();
35813799
35823800 cameraView.requestFocusInWindow();
35833801
....@@ -3763,6 +3981,7 @@
37633981 } else
37643982 if (source == rootButton)
37653983 {
3984
+ Replace();
37663985 Object3D obj;
37673986 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
37683987 {
....@@ -3777,6 +3996,9 @@
37773996 if (source == closeButton)
37783997 {
37793998 //System.out.println("CLOSE: " + buttonGroup.getSelection());
3999
+ if (copy.versionlist != null)
4000
+ Replace();
4001
+
37804002 cRadio ab;
37814003 for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
37824004 {
....@@ -3820,10 +4042,10 @@
38204042 {
38214043 Object3D child = (Object3D)e.nextElement();
38224044 if(child.editWindow != null)
3823
- objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38244045 child.pinned = false;
38254046 child.CloseUI();
38264047 listUI.remove(child);
4048
+// objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38274049
38284050 //child.editWindow = null; // ???????????
38294051 }
....@@ -3842,6 +4064,7 @@
38424064 obj.CloseUI();
38434065 }
38444066 listUI.clear();
4067
+ SetPinStates(group.selection.size() > 0);
38454068 refreshContents(true);
38464069 } else
38474070 if (source == allParamsButton)
....@@ -3874,6 +4097,9 @@
38744097 } else
38754098 if(source instanceof cRadio)
38764099 {
4100
+ if (copy.versionlist != null)
4101
+ Replace();
4102
+
38774103 group.parent = keepparent;
38784104 group.attributes = 0;
38794105 //group.editWindow = null;
....@@ -3898,8 +4124,6 @@
38984124
38994125 copy = group;
39004126
3901
- SetUndoStates();
3902
-
39034127 //Globals.theRenderer.object = group;
39044128 if(!useclient)
39054129 {
....@@ -3927,7 +4151,34 @@
39274151 */
39284152 radio.layout.doClick();
39294153
4154
+ //assert(copy instanceof Composite);
4155
+
4156
+ if (copy.versionlist == null)
4157
+ {
4158
+ copy.versionindex = -1;
4159
+
4160
+ // Cannot work with loops
4161
+ // To fix this issue, we first mark all nodes above the root,
4162
+ // and check if any of these nodes are reachable below the root.
4163
+ Grafreed.grafreed.universe.TagObjects(copy, true);
4164
+
4165
+ if (copy instanceof Composite && !copy.HasTags())
4166
+ {
4167
+ if (copy.versionlist == null)
4168
+ copy.versionlist = new Object3D[100];
4169
+
4170
+ //Save(true);
4171
+ }
4172
+ else
4173
+ copy.versionindex = -2;
4174
+
4175
+ Grafreed.grafreed.universe.TagObjects(copy, false);
4176
+ }
4177
+
4178
+ SetVersionStates();
4179
+
39304180 ClearUnpinned();
4181
+
39314182 //Grafreed.Assert(group != null);
39324183 //Grafreed.Assert(group.selection != null);
39334184 SetPinStates(group.selection == null || group.selection.size() > 0);
....@@ -4039,9 +4290,46 @@
40394290 refreshContents();
40404291 }
40414292
4293
+ void TextureRatio(int axis)
4294
+ {
4295
+ Object3D obj;
4296
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
4297
+ {
4298
+ obj = (Object3D)e.nextElement();
4299
+ obj.TextureRatio(axis);
4300
+ }
4301
+
4302
+ refreshContents();
4303
+ }
4304
+
40424305 void ResetTransform()
40434306 {
40444307 ResetTransform(-1);
4308
+ }
4309
+
4310
+ void ScaleSelection(int scale)
4311
+ {
4312
+ Object3D obj;
4313
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
4314
+ {
4315
+ obj = (Object3D)e.nextElement();
4316
+
4317
+ if (obj.toParent == null)
4318
+ continue;
4319
+
4320
+ obj.Scale(scale);
4321
+
4322
+ if (obj.parent == null)
4323
+ {
4324
+ System.out.println("NULL PARENT!");
4325
+ // new Exception().printStackTrace();
4326
+ }
4327
+ else
4328
+ TouchTransform(obj);
4329
+ //obj.parent.Touch();
4330
+ }
4331
+
4332
+ refreshContents();
40454333 }
40464334
40474335 void ResetTransform(int mask)
....@@ -4054,42 +4342,8 @@
40544342 if (obj.toParent == null)
40554343 continue;
40564344
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
- }
4345
+ obj.ResetTransform(mask);
4346
+
40934347 if (obj.parent == null)
40944348 {
40954349 System.out.println("NULL PARENT!");
....@@ -4598,6 +4852,12 @@
45984852 {
45994853 Object3D obj = group.selection.get(i);
46004854
4855
+ if (obj.toParent == null)
4856
+ {
4857
+ obj.toParent = LA.newMatrix();
4858
+ obj.fromParent = LA.newMatrix();
4859
+ }
4860
+
46014861 LA.matTranslate(obj.toParent, i * scale, 0, 0);
46024862 LA.matTranslateInv(obj.fromParent, -i * scale, 0, 0);
46034863 }
....@@ -4889,6 +5149,12 @@
48895149 refreshContents();
48905150 }
48915151
5152
+ void ClearVersions()
5153
+ {
5154
+ group.selection.ClearVersions();
5155
+ refreshContents();
5156
+ }
5157
+
48925158 void FlipV(boolean flip)
48935159 {
48945160 group.selection.FlipV(flip);
....@@ -5083,9 +5349,7 @@
50835349
50845350 freezemodel = false;
50855351 }
5086
-
5087
- boolean flashIt = true;
5088
-
5352
+
50895353 public void valueChanged(TreeSelectionEvent e)
50905354 //public boolean handleEvent(Event event)
50915355 {
....@@ -5129,7 +5393,7 @@
51295393 if (tps != null && tps.length > 0 && tps[0].getLastPathComponent() instanceof Camera)
51305394 // a camera
51315395 {
5132
- if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crash the camera because of invalid lightspace
5396
+ if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crashes the camera because of invalid lightspace
51335397 {
51345398 CameraPane.camerachangeframe = 0; // don't refuse it
51355399 Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());
....@@ -5158,13 +5422,31 @@
51585422 {
51595423 editButton.setEnabled(enabled);
51605424 uneditButton.setEnabled(enabled);
5161
- unselectButton.setEnabled(enabled);
5425
+ //unselectButton.setEnabled(enabled);
51625426 flashSelectionButton.setEnabled(enabled);
5427
+
5428
+ clearPanelButton.setEnabled(!listUI.isEmpty());
5429
+
5430
+ boolean allComposites = true;
5431
+
5432
+ if (group.selection != null)
5433
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5434
+ {
5435
+ Object next = e.nextElement();
5436
+ if (!(next instanceof Composite)) // || (next instanceof GroupLeaf))
5437
+ {
5438
+ allComposites = false;
5439
+ break;
5440
+ }
5441
+ }
5442
+
5443
+ rootButton.setEnabled(true); // allComposites);
51635444 }
51645445
51655446 void refreshContents(boolean cp)
51665447 {
5167
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5448
+ if (Globals.SHOWINFO)
5449
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51685450 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51695451 {
51705452 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5174,7 +5456,7 @@
51745456 Object3D child = (Object3D) group.selection.get(i);
51755457
51765458 objEditor.AddInfo(child, this, true);
5177
- System.err.println("info : " + child.GetPath());
5459
+// System.err.println("info : " + child.GetPath());
51785460 }
51795461
51805462 objEditor.SetText(); // jan 2014
....@@ -6000,7 +6282,6 @@
60006282
60016283 cButton restoreCameraButton;
60026284
6003
- cButton saveButton;
60046285 cButton oneStepButton;
60056286
60066287 cButton groupButton;
....@@ -6058,11 +6339,11 @@
60586339 private MenuItem lookAtItem;
60596340 private MenuItem lookFromItem;
60606341 private MenuItem switchViewItem;
6061
- private MenuItem cutItem;
6342
+ private JMenuItem cutItem;
60626343 private MenuItem undoItem;
60636344 private MenuItem redoItem;
60646345 private JMenuItem duplicateItem;
6065
- private MenuItem cloneItem;
6346
+ private JMenuItem cloneItem;
60666347 private MenuItem cloneSupportItem;
60676348 private MenuItem overwriteGeoItem;
60686349 private MenuItem overwriteMatItem;
....@@ -6083,13 +6364,13 @@
60836364 private MenuItem cloneGeometriesItem;
60846365 private MenuItem shareGeometriesItem;
60856366 private MenuItem mergeGeometriesItem;
6086
- private MenuItem copyItem;
6367
+ private JMenuItem copyItem;
60876368 private MenuItem pasteItem;
6088
- private MenuItem pasteIntoItem;
6089
- private MenuItem pasteLinkItem;
6090
- private MenuItem pasteCloneItem;
6091
- private MenuItem pasteExpandItem;
6092
- private MenuItem deleteItem;
6369
+ private JMenuItem pasteIntoItem;
6370
+ private JMenuItem pasteLinkItem;
6371
+ private JMenuItem pasteCloneItem;
6372
+ private JMenuItem pasteExpandItem;
6373
+ private JMenuItem deleteItem;
60936374 private MenuItem clearAllItem;
60946375 private MenuItem genUVItem;
60956376 private MenuItem genNormalsMESHItem;
....@@ -6115,6 +6396,7 @@
61156396 private MenuItem clipMeshItem;
61166397 private MenuItem smoothMeshItem;
61176398 private MenuItem clearMaterialsItem;
6399
+ private MenuItem clearVersionsItem;
61186400
61196401 private MenuItem liveleavesItem;
61206402 private MenuItem unliveleavesItem;
....@@ -6138,13 +6420,16 @@
61386420 private MenuItem maxTexturesItem;
61396421 private MenuItem panoTexturesItem;
61406422
6423
+ private MenuItem textureRatioRItem;
6424
+ private MenuItem textureRatioGItem;
6425
+ private MenuItem textureRatioBItem;
61416426 private MenuItem resetCentroidItem;
61426427 private MenuItem resetCentroidXZItem;
61436428 private MenuItem resetTransformItem;
61446429 private MenuItem transformGeometryItem;
61456430 private MenuItem transformChildrenItem;
61466431 private MenuItem hideItem;
6147
- private MenuItem grabItem;
6432
+ private JMenuItem grabItem;
61486433 private MenuItem backItem;
61496434 private MenuItem frontItem;
61506435 private MenuItem cameraItem;
....@@ -6157,7 +6442,7 @@
61576442 private MenuItem switchTransfoItem;
61586443 private MenuItem morphItem;
61596444 private MenuItem linkerItem;
6160
- private MenuItem ungroupItem;
6445
+ private JMenuItem ungroupItem;
61616446 private MenuItem editItem;
61626447 private MenuItem openWindowItem;
61636448 private MenuItem editLeafItem;