Normand Briere
2019-08-15 33504fc9a180903aace77613264550754fba5706
GroupEditor.java
....@@ -31,7 +31,7 @@
3131 final String path = "cubemaps/" + f + "-skyboxes/" + s;
3232 row.add(skyboxButton = GetButton(path + "/preview.jpg", !Grafreed.NIMBUSLAF));
3333 //row.add(skyboxButton = GetButton(path + "/negx.jpg", !Grafreed.NIMBUSLAF));
34
- skyboxButton.setToolTipText(s);
34
+ skyboxButton.setToolTipText(s.equals("") ? "No background" : s);
3535 skyboxButton.addActionListener(new ActionListener()
3636 {
3737 @Override
....@@ -73,7 +73,7 @@
7373 cGridBag row5 = new cGridBag();
7474 cGridBag row6 = new cGridBag();
7575
76
- AddSkyboxButton("default", "rgb", row0);
76
+ AddSkyboxButton("default", "", row0);
7777 //AddSkyboxButton("default", "cornell", row0);
7878 AddSkyboxButton("penguins", "dust", row0);
7979 AddSkyboxButton("penguins", "tropic", row0);
....@@ -330,10 +330,19 @@
330330
331331 public void ChangeSkybox(String skybox)
332332 {
333
- //cameraView.envyoff = false;
334
- group.skyboxname = skybox;
335
- group.skyboxext = "jpg";
336
- 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
+ }
337346 }
338347
339348 public void CreateSkyboxPanel(cGridBag skyboxPanel)
....@@ -531,32 +540,37 @@
531540 // menu.add("-");
532541 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
533542 duplicateItem.addActionListener(this);
534
- cloneItem = menu.add(new MenuItem("Clone"));
543
+
544
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
535545 cloneItem.addActionListener(this);
536
- if (Globals.ADVANCED)
546
+ //if (Globals.ADVANCED)
537547 {
538548 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
539549 cloneSupportItem.addActionListener(this);
540550 }
551
+ oe.jTree.popup.addSeparator();
541552 menu.add("-");
542
- cutItem = menu.add(new MenuItem("Cut"));
553
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
543554 cutItem.addActionListener(this);
544
- copyItem = menu.add(new MenuItem("Copy"));
555
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
545556 copyItem.addActionListener(this);
546557 pasteItem = menu.add(new MenuItem("Paste"));
547558 pasteItem.addActionListener(this);
548559
549
- menu.add("-");
550
- pasteIntoItem = menu.add(new MenuItem("Paste into"));
560
+ oe.jTree.popup.addSeparator();
561
+ //menu.add("-");
562
+ pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into"));
551563 pasteIntoItem.addActionListener(this);
552
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
564
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
553565 pasteLinkItem.addActionListener(this);
554
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
566
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
555567 pasteCloneItem.addActionListener(this);
556
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
568
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
557569 // pasteExpandItem.addActionListener(this);
558
- menu.add("-");
559
- deleteItem = menu.add(new MenuItem("Delete"));
570
+ //menu.add("-");
571
+ oe.jTree.popup.addSeparator();
572
+
573
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
560574 deleteItem.addActionListener(this);
561575
562576 if (Globals.ADVANCED)
....@@ -707,7 +721,7 @@
707721 hideItem = menu.add(new MenuItem("Hidden Group"));
708722 hideItem.addActionListener(this);
709723 }
710
- ungroupItem = menu.add(new MenuItem("Ungroup"));
724
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
711725 ungroupItem.addActionListener(this);
712726
713727 // menu.add("-");
....@@ -914,7 +928,7 @@
914928
915929 JTabbedPane resourcecontainer;
916930 cGridBag currenttab;
917
- boolean added; // patch for jar
931
+ //boolean added; // patch for jar
918932
919933 int tabcount = 0;
920934 int colcount = 0;
....@@ -931,12 +945,14 @@
931945 // System.out.println();
932946
933947 if (//rowcount == 0 ||
934
- path.length == 1)
948
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
935949 {
936950 currenttab = new cGridBag();
937
- added = false;
938951 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
939952 currenttab.setName(tabname);
953
+ //added = false;
954
+ resourcecontainer.add(currenttab);
955
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
940956 rowcount = 1;
941957 colcount = 0;
942958 texturecount = 0;
....@@ -944,12 +960,11 @@
944960
945961 if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
946962 {
947
- if (!added)
963
+ //if (!added)
948964 {
949
- added = true;
950
- resourcecontainer.add(currenttab);
965
+ //added = true;
951966 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
952
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
967
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
953968 }
954969
955970 AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
....@@ -1034,8 +1049,8 @@
10341049 // maxButton.addActionListener(this);
10351050 }
10361051
1037
-// cButton gcButton;
1038
-//
1052
+ cButton gcButton;
1053
+
10391054 // oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10401055 // gcButton.setToolTipText("Garbage collect");
10411056 // gcButton.addActionListener(new ActionListener()
....@@ -1172,6 +1187,10 @@
11721187 boxButton.setToolTipText("Create box");
11731188 boxButton.addActionListener(this);
11741189
1190
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1191
+ superButton.setToolTipText("Create superellipsoid");
1192
+ superButton.addActionListener(this);
1193
+
11751194 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11761195 sphereButton.setToolTipText("Create sphere");
11771196 sphereButton.addActionListener(this);
....@@ -1183,10 +1202,6 @@
11831202 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11841203 torusButton.setToolTipText("Create torus");
11851204 torusButton.addActionListener(this);
1186
-
1187
- row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1188
- superButton.setToolTipText("Create superellipsoid");
1189
- superButton.addActionListener(this);
11901205
11911206 if (Globals.ADVANCED)
11921207 {
....@@ -1459,11 +1474,11 @@
14591474 {
14601475 assert(obj instanceof Composite);
14611476
1462
- if (obj.versionlist == null)
1463
- {
1464
- obj.versionlist = new Object3D[100];
1465
- obj.versionindex = -1;
1466
- }
1477
+// if (obj.versionlist == null)
1478
+// {
1479
+// obj.versionlist = new Object3D[100];
1480
+// obj.versionindex = -1;
1481
+// }
14671482
14681483 cRadio radioButton = new cRadio(obj.name);
14691484
....@@ -2150,7 +2165,11 @@
21502165 shadow.material = new cMaterial(obj.material);
21512166 shadow.material.diffuse = 0.0001f;
21522167 shadow.material.specular = 0.0001f;
2153
- //shadow.projectedVertices[1].x = 300;
2168
+ shadow.material.opacity = 0.75f;
2169
+
2170
+ AllocProjectedVertices(shadow);
2171
+
2172
+ shadow.projectedVertices[1].x = 300;
21542173
21552174 makeSomething(shadow);
21562175 }
....@@ -2671,27 +2690,35 @@
26712690 } else
26722691 if (source == loopItem || source == loopButton)
26732692 {
2693
+ if (!group.selection.isEmpty())
2694
+ {
26742695 Composite csg = new GroupLeaf();
26752696 csg.count = 5;
2676
- group(csg);
26772697 Composite child = new cGroup("Branch");
26782698 csg.addChild(child);
26792699 child.addChild(csg);
2700
+ group(csg);
2701
+ }
26802702 } else
26812703 if (source == doubleItem)
26822704 {
2705
+ if (!group.selection.isEmpty())
2706
+ {
26832707 Composite csg = new GroupLeaf("Fork");
26842708 csg.count = 5;
2685
- group(csg);
26862709 Composite child = new cGroup("Branch A");
26872710 csg.addChild(child);
26882711 child.addChild(csg);
26892712 child = new cGroup("Branch B");
26902713 csg.addChild(child);
26912714 child.addChild(csg);
2715
+ group(csg);
2716
+ }
26922717 } else
26932718 if (source == tripleItem)
26942719 {
2720
+ if (!group.selection.isEmpty())
2721
+ {
26952722 Composite csg = new GroupLeaf("Trident");
26962723 csg.count = 4;
26972724 group(csg);
....@@ -2704,6 +2731,7 @@
27042731 child = new cGroup();
27052732 csg.addChild(child);
27062733 child.addChild(csg);
2734
+ }
27072735 } else
27082736 if (source == computeAOItem)
27092737 {
....@@ -3339,22 +3367,34 @@
33393367 } else
33403368 if (source == ungroupItem || source == ungroupButton)
33413369 {
3342
- boolean hasRoot = false;
3370
+ boolean canUngroup = true;
33433371
33443372 for (int i=0; i<group.selection.size(); i++)
33453373 {
3346
- if (group.selection.get(i) == group)
3374
+ Object3D selectedItem = group.selection.get(i);
3375
+
3376
+ if (selectedItem.Size() == 0)
33473377 {
3348
- hasRoot = true;
3378
+ // Cannot ungroup leaves
3379
+ canUngroup = false;
3380
+ break;
3381
+ }
3382
+
3383
+ if (selectedItem == group)
3384
+ {
3385
+ // Cannot ungroup root
3386
+ canUngroup = false;
33493387 break;
33503388 }
33513389 }
33523390
3353
- if (!hasRoot)
3391
+ if (canUngroup)
33543392 {
33553393 for (int i=0; i<group.selection.size(); i++)
33563394 {
3357
- Ungroup(group.selection.get(i));
3395
+ Object3D selectedItem = group.selection.get(i);
3396
+
3397
+ Ungroup(selectedItem);
33583398 }
33593399
33603400 ClearSelection(false);
....@@ -4067,7 +4107,17 @@
40674107 */
40684108 radio.layout.doClick();
40694109
4070
- SetUndoStates();
4110
+ assert(copy instanceof Composite);
4111
+
4112
+ if (copy.versionlist == null)
4113
+ {
4114
+ copy.versionlist = new Object3D[100];
4115
+ copy.versionindex = -1;
4116
+
4117
+ Save(true);
4118
+ }
4119
+
4120
+ SetVersionStates();
40714121
40724122 ClearUnpinned();
40734123
....@@ -5306,6 +5356,7 @@
53065356
53075357 boolean allComposites = true;
53085358
5359
+ if (group.selection != null)
53095360 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
53105361 {
53115362 if (!(e.nextElement() instanceof Composite))
....@@ -6213,11 +6264,11 @@
62136264 private MenuItem lookAtItem;
62146265 private MenuItem lookFromItem;
62156266 private MenuItem switchViewItem;
6216
- private MenuItem cutItem;
6267
+ private JMenuItem cutItem;
62176268 private MenuItem undoItem;
62186269 private MenuItem redoItem;
62196270 private JMenuItem duplicateItem;
6220
- private MenuItem cloneItem;
6271
+ private JMenuItem cloneItem;
62216272 private MenuItem cloneSupportItem;
62226273 private MenuItem overwriteGeoItem;
62236274 private MenuItem overwriteMatItem;
....@@ -6238,13 +6289,13 @@
62386289 private MenuItem cloneGeometriesItem;
62396290 private MenuItem shareGeometriesItem;
62406291 private MenuItem mergeGeometriesItem;
6241
- private MenuItem copyItem;
6292
+ private JMenuItem copyItem;
62426293 private MenuItem pasteItem;
6243
- private MenuItem pasteIntoItem;
6244
- private MenuItem pasteLinkItem;
6245
- private MenuItem pasteCloneItem;
6246
- private MenuItem pasteExpandItem;
6247
- private MenuItem deleteItem;
6294
+ private JMenuItem pasteIntoItem;
6295
+ private JMenuItem pasteLinkItem;
6296
+ private JMenuItem pasteCloneItem;
6297
+ private JMenuItem pasteExpandItem;
6298
+ private JMenuItem deleteItem;
62486299 private MenuItem clearAllItem;
62496300 private MenuItem genUVItem;
62506301 private MenuItem genNormalsMESHItem;
....@@ -6312,7 +6363,7 @@
63126363 private MenuItem switchTransfoItem;
63136364 private MenuItem morphItem;
63146365 private MenuItem linkerItem;
6315
- private MenuItem ungroupItem;
6366
+ private JMenuItem ungroupItem;
63166367 private MenuItem editItem;
63176368 private MenuItem openWindowItem;
63186369 private MenuItem editLeafItem;