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)
....@@ -410,6 +419,8 @@
410419 {
411420 copy.versionlist = new Object3D[100];
412421 copy.versionindex = -1;
422
+
423
+ Save(true);
413424 }
414425
415426 if(ui)
....@@ -529,32 +540,37 @@
529540 // menu.add("-");
530541 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
531542 duplicateItem.addActionListener(this);
532
- cloneItem = menu.add(new MenuItem("Clone"));
543
+
544
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
533545 cloneItem.addActionListener(this);
534
- if (Globals.ADVANCED)
546
+ //if (Globals.ADVANCED)
535547 {
536548 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
537549 cloneSupportItem.addActionListener(this);
538550 }
551
+ oe.jTree.popup.addSeparator();
539552 menu.add("-");
540
- cutItem = menu.add(new MenuItem("Cut"));
553
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
541554 cutItem.addActionListener(this);
542
- copyItem = menu.add(new MenuItem("Copy"));
555
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
543556 copyItem.addActionListener(this);
544557 pasteItem = menu.add(new MenuItem("Paste"));
545558 pasteItem.addActionListener(this);
546559
547
- menu.add("-");
548
- 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"));
549563 pasteIntoItem.addActionListener(this);
550
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
564
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
551565 pasteLinkItem.addActionListener(this);
552
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
566
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
553567 pasteCloneItem.addActionListener(this);
554
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
568
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
555569 // pasteExpandItem.addActionListener(this);
556
- menu.add("-");
557
- deleteItem = menu.add(new MenuItem("Delete"));
570
+ //menu.add("-");
571
+ oe.jTree.popup.addSeparator();
572
+
573
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
558574 deleteItem.addActionListener(this);
559575
560576 if (Globals.ADVANCED)
....@@ -641,11 +657,9 @@
641657 oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
642658 //cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
643659 //cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
644
- editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
645660 oe.cameraMenu.add("-");
646661 openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
647662 openWindowItem.addActionListener(this);
648
- editLeafItem.addActionListener(this);
649663 lookAtItem.addActionListener(this);
650664 //lookFromItem.addActinoListener(this);
651665 //switchViewItem.addActionListener(this);
....@@ -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("-");
....@@ -893,6 +907,9 @@
893907 shareGeometriesItem.addActionListener(this);
894908 mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
895909 mergeGeometriesItem.addActionListener(this);
910
+ menu.add("-");
911
+ editLeafItem = menu.add(new MenuItem("Edit leaf..."));
912
+ editLeafItem.addActionListener(this);
896913 if (Globals.ADVANCED)
897914 {
898915 // Pretty much the same as duplicate and clone.
....@@ -911,7 +928,7 @@
911928
912929 JTabbedPane resourcecontainer;
913930 cGridBag currenttab;
914
- boolean added; // patch for jar
931
+ //boolean added; // patch for jar
915932
916933 int tabcount = 0;
917934 int colcount = 0;
....@@ -928,12 +945,14 @@
928945 // System.out.println();
929946
930947 if (//rowcount == 0 ||
931
- path.length == 1)
948
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
932949 {
933950 currenttab = new cGridBag();
934
- added = false;
935951 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
936952 currenttab.setName(tabname);
953
+ //added = false;
954
+ resourcecontainer.add(currenttab);
955
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
937956 rowcount = 1;
938957 colcount = 0;
939958 texturecount = 0;
....@@ -941,12 +960,11 @@
941960
942961 if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
943962 {
944
- if (!added)
963
+ //if (!added)
945964 {
946
- added = true;
947
- resourcecontainer.add(currenttab);
965
+ //added = true;
948966 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
949
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
967
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
950968 }
951969
952970 AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
....@@ -1026,22 +1044,22 @@
10261044
10271045 if (Globals.ADVANCED)
10281046 {
1029
- oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1030
- maxButton.setToolTipText("Maximize window");
1031
- maxButton.addActionListener(this);
1047
+// oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1048
+// maxButton.setToolTipText("Maximize window");
1049
+// maxButton.addActionListener(this);
10321050 }
10331051
10341052 cButton gcButton;
10351053
1036
- oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1037
- gcButton.setToolTipText("Garbage collect");
1038
- gcButton.addActionListener(new ActionListener()
1039
- {
1040
- public void actionPerformed(ActionEvent e)
1041
- {
1042
- System.gc();
1043
- }
1044
- });
1054
+// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1055
+// gcButton.setToolTipText("Garbage collect");
1056
+// gcButton.addActionListener(new ActionListener()
1057
+// {
1058
+// public void actionPerformed(ActionEvent e)
1059
+// {
1060
+// System.gc();
1061
+// }
1062
+// });
10451063
10461064 oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10471065 collapseButton.setToolTipText("Collapse toolbar");
....@@ -1162,12 +1180,16 @@
11621180
11631181 // INSERT
11641182 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1165
- gridButton.setToolTipText("Create grid");
1183
+ gridButton.setToolTipText("Create ground");
11661184 gridButton.addActionListener(this);
11671185
11681186 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11691187 boxButton.setToolTipText("Create box");
11701188 boxButton.addActionListener(this);
1189
+
1190
+ row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1191
+ superButton.setToolTipText("Create superellipsoid");
1192
+ superButton.addActionListener(this);
11711193
11721194 row1.add(sphereButton = GetButton("icons/sphere.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11731195 sphereButton.setToolTipText("Create sphere");
....@@ -1180,10 +1202,6 @@
11801202 row1.add(torusButton = GetButton("icons/torus.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11811203 torusButton.setToolTipText("Create torus");
11821204 torusButton.addActionListener(this);
1183
-
1184
- row1.add(superButton = GetButton("icons/super.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1185
- superButton.setToolTipText("Create superellipsoid");
1186
- superButton.addActionListener(this);
11871205
11881206 if (Globals.ADVANCED)
11891207 {
....@@ -1454,6 +1472,14 @@
14541472
14551473 void EditObject(Object3D obj)
14561474 {
1475
+ assert(obj instanceof Composite);
1476
+
1477
+// if (obj.versionlist == null)
1478
+// {
1479
+// obj.versionlist = new Object3D[100];
1480
+// obj.versionindex = -1;
1481
+// }
1482
+
14571483 cRadio radioButton = new cRadio(obj.name);
14581484
14591485 // June 2019. Patch to avoid bug with transparency.
....@@ -2139,7 +2165,11 @@
21392165 shadow.material = new cMaterial(obj.material);
21402166 shadow.material.diffuse = 0.0001f;
21412167 shadow.material.specular = 0.0001f;
2142
- //shadow.projectedVertices[1].x = 300;
2168
+ shadow.material.opacity = 0.75f;
2169
+
2170
+ AllocProjectedVertices(shadow);
2171
+
2172
+ shadow.projectedVertices[1].x = 300;
21432173
21442174 makeSomething(shadow);
21452175 }
....@@ -2660,27 +2690,35 @@
26602690 } else
26612691 if (source == loopItem || source == loopButton)
26622692 {
2693
+ if (!group.selection.isEmpty())
2694
+ {
26632695 Composite csg = new GroupLeaf();
26642696 csg.count = 5;
2665
- group(csg);
26662697 Composite child = new cGroup("Branch");
26672698 csg.addChild(child);
26682699 child.addChild(csg);
2700
+ group(csg);
2701
+ }
26692702 } else
26702703 if (source == doubleItem)
26712704 {
2705
+ if (!group.selection.isEmpty())
2706
+ {
26722707 Composite csg = new GroupLeaf("Fork");
26732708 csg.count = 5;
2674
- group(csg);
26752709 Composite child = new cGroup("Branch A");
26762710 csg.addChild(child);
26772711 child.addChild(csg);
26782712 child = new cGroup("Branch B");
26792713 csg.addChild(child);
26802714 child.addChild(csg);
2715
+ group(csg);
2716
+ }
26812717 } else
26822718 if (source == tripleItem)
26832719 {
2720
+ if (!group.selection.isEmpty())
2721
+ {
26842722 Composite csg = new GroupLeaf("Trident");
26852723 csg.count = 4;
26862724 group(csg);
....@@ -2693,6 +2731,7 @@
26932731 child = new cGroup();
26942732 csg.addChild(child);
26952733 child.addChild(csg);
2734
+ }
26962735 } else
26972736 if (source == computeAOItem)
26982737 {
....@@ -3328,22 +3367,34 @@
33283367 } else
33293368 if (source == ungroupItem || source == ungroupButton)
33303369 {
3331
- boolean hasRoot = false;
3370
+ boolean canUngroup = true;
33323371
33333372 for (int i=0; i<group.selection.size(); i++)
33343373 {
3335
- if (group.selection.get(i) == group)
3374
+ Object3D selectedItem = group.selection.get(i);
3375
+
3376
+ if (selectedItem.Size() == 0)
33363377 {
3337
- 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;
33383387 break;
33393388 }
33403389 }
33413390
3342
- if (!hasRoot)
3391
+ if (canUngroup)
33433392 {
33443393 for (int i=0; i<group.selection.size(); i++)
33453394 {
3346
- Ungroup(group.selection.get(i));
3395
+ Object3D selectedItem = group.selection.get(i);
3396
+
3397
+ Ungroup(selectedItem);
33473398 }
33483399
33493400 ClearSelection(false);
....@@ -3892,6 +3943,7 @@
38923943 } else
38933944 if (source == rootButton)
38943945 {
3946
+ Replace();
38953947 Object3D obj;
38963948 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
38973949 {
....@@ -4028,8 +4080,6 @@
40284080
40294081 copy = group;
40304082
4031
- SetUndoStates();
4032
-
40334083 //Globals.theRenderer.object = group;
40344084 if(!useclient)
40354085 {
....@@ -4057,6 +4107,18 @@
40574107 */
40584108 radio.layout.doClick();
40594109
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();
4121
+
40604122 ClearUnpinned();
40614123
40624124 //Grafreed.Assert(group != null);
....@@ -5291,6 +5353,20 @@
52915353 flashSelectionButton.setEnabled(enabled);
52925354
52935355 clearPanelButton.setEnabled(!listUI.isEmpty());
5356
+
5357
+ boolean allComposites = true;
5358
+
5359
+ if (group.selection != null)
5360
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
5361
+ {
5362
+ if (!(e.nextElement() instanceof Composite))
5363
+ {
5364
+ allComposites = false;
5365
+ break;
5366
+ }
5367
+ }
5368
+
5369
+ rootButton.setEnabled(allComposites);
52945370 }
52955371
52965372 void refreshContents(boolean cp)
....@@ -6188,11 +6264,11 @@
61886264 private MenuItem lookAtItem;
61896265 private MenuItem lookFromItem;
61906266 private MenuItem switchViewItem;
6191
- private MenuItem cutItem;
6267
+ private JMenuItem cutItem;
61926268 private MenuItem undoItem;
61936269 private MenuItem redoItem;
61946270 private JMenuItem duplicateItem;
6195
- private MenuItem cloneItem;
6271
+ private JMenuItem cloneItem;
61966272 private MenuItem cloneSupportItem;
61976273 private MenuItem overwriteGeoItem;
61986274 private MenuItem overwriteMatItem;
....@@ -6213,13 +6289,13 @@
62136289 private MenuItem cloneGeometriesItem;
62146290 private MenuItem shareGeometriesItem;
62156291 private MenuItem mergeGeometriesItem;
6216
- private MenuItem copyItem;
6292
+ private JMenuItem copyItem;
62176293 private MenuItem pasteItem;
6218
- private MenuItem pasteIntoItem;
6219
- private MenuItem pasteLinkItem;
6220
- private MenuItem pasteCloneItem;
6221
- private MenuItem pasteExpandItem;
6222
- private MenuItem deleteItem;
6294
+ private JMenuItem pasteIntoItem;
6295
+ private JMenuItem pasteLinkItem;
6296
+ private JMenuItem pasteCloneItem;
6297
+ private JMenuItem pasteExpandItem;
6298
+ private JMenuItem deleteItem;
62236299 private MenuItem clearAllItem;
62246300 private MenuItem genUVItem;
62256301 private MenuItem genNormalsMESHItem;
....@@ -6287,7 +6363,7 @@
62876363 private MenuItem switchTransfoItem;
62886364 private MenuItem morphItem;
62896365 private MenuItem linkerItem;
6290
- private MenuItem ungroupItem;
6366
+ private JMenuItem ungroupItem;
62916367 private MenuItem editItem;
62926368 private MenuItem openWindowItem;
62936369 private MenuItem editLeafItem;