Normand Briere
2019-06-24 c67da2e5d8655704601d6d06e8bc60aabe212253
GroupEditor.java
....@@ -176,7 +176,6 @@
176176 copyItem.addActionListener(this);
177177 pasteItem = menu.add(new MenuItem("Paste"));
178178 pasteItem.addActionListener(this);
179
- menu.add("-");
180179
181180 menu.add("-");
182181 pasteIntoItem = menu.add(new MenuItem("Paste into"));
....@@ -246,7 +245,7 @@
246245
247246 cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
248247 toggleDebugItem.addItemListener(this);
249
- toggleDebugItem.setState(CameraPane.DEBUG);
248
+ toggleDebugItem.setState(Globals.DEBUG);
250249
251250 cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
252251 toggleFrustumItem.addItemListener(this);
....@@ -369,11 +368,11 @@
369368 billboardItem.addActionListener(this);
370369 csgItem = menu.add(new MenuItem("CSG"));
371370 csgItem.addActionListener(this);
372
- shadowXItem = menu.add(new MenuItem("Shadow X"));
371
+ shadowXItem = menu.add(new MenuItem("Shadow Red"));
373372 shadowXItem.addActionListener(this);
374
- shadowYItem = menu.add(new MenuItem("Shadow Y"));
373
+ shadowYItem = menu.add(new MenuItem("Shadow Green"));
375374 shadowYItem.addActionListener(this);
376
- shadowZItem = menu.add(new MenuItem("Shadow Z"));
375
+ shadowZItem = menu.add(new MenuItem("Shadow Blue"));
377376 shadowZItem.addActionListener(this);
378377 if (Globals.ADVANCED)
379378 {
....@@ -535,6 +534,18 @@
535534
536535 void SetupUI2(ObjEditor oe)
537536 {
537
+ // June 2019
538
+ if (oe == null)
539
+ {
540
+ //super.SetupUI2(this);
541
+ //return;
542
+ }
543
+
544
+ if (copy != group)
545
+ {
546
+ //super.SetupUI2(this);
547
+ }
548
+
538549 //new Exception().printStackTrace();
539550
540551 oe.radioPanel = new JPanel(new GridBagLayout());
....@@ -565,15 +576,27 @@
565576 */
566577 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
567578
568
- oe.toolbarPanel.add(undoButton = new cButton("Undo", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
579
+ //oe.toolbarPanel.add(minButton = new cButton("Min", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
580
+ //minButton.setToolTipText("Minimize window");
581
+ //minButton.addActionListener(this);
582
+
583
+ oe.toolbarPanel.add(maxButton = new cButton("\u271A", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
584
+ maxButton.setToolTipText("Maximize window");
585
+ maxButton.addActionListener(this);
586
+
587
+ oe.toolbarPanel.add(fullButton = new cButton("\u2b1c", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
588
+ fullButton.setToolTipText("Full-screen window");
589
+ fullButton.addActionListener(this);
590
+
591
+ oe.toolbarPanel.add(undoButton = new cButton("\u21a9", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
569592 undoButton.setToolTipText("Undo changes");
570593 undoButton.addActionListener(this);
571594
572
- oe.toolbarPanel.add(redoButton = new cButton("Redo", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
595
+ oe.toolbarPanel.add(redoButton = new cButton("\u21aa", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
573596 redoButton.setToolTipText("Redo changes");
574597 redoButton.addActionListener(this);
575598
576
- oe.toolbarPanel.add(saveButton = new cButton("Save", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
599
+ oe.toolbarPanel.add(saveButton = new cButton("\u21e3", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
577600 saveButton.setToolTipText("Save changes");
578601 saveButton.addActionListener(this);
579602
....@@ -581,7 +604,7 @@
581604 liveCB.setToolTipText("Enable animation");
582605 liveCB.addItemListener(this);
583606
584
- oe.toolbarPanel.add(oneStepButton = new cButton("Step", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
607
+ oe.toolbarPanel.add(oneStepButton = new cButton("\u29f4", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
585608 oneStepButton.setToolTipText("Animate one step forward");
586609 oneStepButton.addActionListener(this);
587610
....@@ -589,7 +612,7 @@
589612 fastCB.setToolTipText("Fast mode");
590613 fastCB.addItemListener(this);
591614
592
- oe.toolbarPanel.add(trackCB = new cCheckBox("Track", CameraPane.TRACK)); //, oe.aConstraints);
615
+ oe.toolbarPanel.add(trackCB = new cCheckBox(":", CameraPane.TRACK)); //, oe.aConstraints);
593616 trackCB.setToolTipText("Enable tracking");
594617 trackCB.addItemListener(this);
595618
....@@ -613,19 +636,19 @@
613636
614637 oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
615638
616
- oe.toolbarPanel.add(twoButton = new cButton("|+|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
639
+ oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
617640 twoButton.setToolTipText("Show center view only");
618641 twoButton.addActionListener(this);
619
- oe.toolbarPanel.add(fourButton = new cButton("+||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
642
+ oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
620643 fourButton.addActionListener(this);
621644 fourButton.setToolTipText("Show left panel only");
622
- oe.toolbarPanel.add(sixButton = new cButton("+|+|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
645
+ oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
623646 sixButton.setToolTipText("2-column layout left");
624647 sixButton.addActionListener(this);
625
- oe.toolbarPanel.add(threeButton = new cButton("|+|+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
648
+ oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
626649 threeButton.setToolTipText("2-column layout right");
627650 threeButton.addActionListener(this);
628
- oe.toolbarPanel.add(sevenButton = new cButton("+|+|+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
651
+ oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
629652 sevenButton.setToolTipText("3-column layout");
630653 sevenButton.addActionListener(this);
631654 //
....@@ -640,32 +663,30 @@
640663 //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
641664 //clearButton.addActionListener(this);
642665
643
- cGridBag commandsPanel = new cGridBag();
644
-
645
- commandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
666
+ editCommandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
646667 editButton.setToolTipText("Edit selection");
647668 editButton.addActionListener(this);
648669
649
- commandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
670
+ editCommandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
650671 uneditButton.setToolTipText("Unedit selection");
651672 uneditButton.addActionListener(this);
652673
653
- commandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
674
+ editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
654675 allParamsButton.setToolTipText("Edit all params");
655676 allParamsButton.addActionListener(this);
656677
657
- commandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
678
+ editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
658679 clearPanelButton.setToolTipText("Clear edit panel");
659680 clearPanelButton.addActionListener(this);
660681
661
- commandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
682
+ editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
662683 unselectButton.setToolTipText("Unselect");
663684 unselectButton.addActionListener(this);
664685
665
- commandsPanel.preferredHeight = 1;
686
+ editCommandsPanel.preferredHeight = 1;
666687
667
- oe.treePanel.add(commandsPanel);
668
- oe.treePanel.Return();
688
+// oe.treePanel.add(commandsPanel);
689
+// oe.treePanel.Return();
669690
670691 // oe.aConstraints.gridx += 1;
671692 // oe.aConstraints.weighty = 0;
....@@ -787,11 +808,19 @@
787808 // debugCB.addItemListener(this);
788809
789810 panel.add(oeilCB = new cCheckBox("Eye", CameraPane.OEIL)); //, constraints);
811
+ oeilCB.setToolTipText("Move camera when tracking target");
790812 oeilCB.addItemListener(this);
791813
814
+ panel.add(shadowCB = new cCheckBox("Shadow", Globals.COMPUTESHADOWWHENLIVE)); //, constraints);
815
+ shadowCB.setToolTipText("Compute shadows when live");
816
+ shadowCB.addItemListener(this);
817
+
818
+ if (Globals.ADVANCED)
819
+ {
792820 panel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT)); //, constraints);
793821 lookAtCB.setToolTipText("Look-at target");
794822 lookAtCB.addItemListener(this);
823
+ }
795824
796825 }
797826
....@@ -806,6 +835,14 @@
806835 void EditObject(Object3D obj)
807836 {
808837 cRadio radioButton = new cRadio(obj.name);
838
+
839
+ // Patch to avoid bug with transparency.
840
+ radioButton.hadMaterial = obj.material != null;
841
+ if (!radioButton.hadMaterial)
842
+ {
843
+ obj.material = new cMaterial();
844
+ }
845
+
809846 radioButton.SetObject(obj);
810847 radioButton.layout = sevenButton;
811848 radioButton.SetCamera(cameraView.renderCamera, false);
....@@ -817,6 +854,8 @@
817854
818855 void SetupViews(ObjEditor oe)
819856 {
857
+ theFrame = this;
858
+
820859 oe.SetupViews();
821860
822861 System.out.println("SetupViews");
....@@ -840,7 +879,9 @@
840879 JCheckBox speakerCameraCB;
841880 JCheckBox speakerFocusCB;
842881 JCheckBox debugCB;
882
+
843883 JCheckBox oeilCB;
884
+ JCheckBox shadowCB;
844885 JCheckBox lookAtCB;
845886
846887 // static int COLOR = 1;
....@@ -943,6 +984,10 @@
943984 else if(e.getSource() == oeilCB)
944985 {
945986 cameraView.ToggleOeil();
987
+ }
988
+ else if(e.getSource() == shadowCB)
989
+ {
990
+ Globals.COMPUTESHADOWWHENLIVE ^= true;
946991 }
947992 else if(e.getSource() == lookAtCB)
948993 {
....@@ -1428,6 +1473,7 @@
14281473 shadow.material = new cMaterial(obj.material);
14291474 shadow.material.diffuse = 0.0001f;
14301475 shadow.material.specular = 0.0001f;
1476
+ //shadow.projectedVertices[1].x = 300;
14311477
14321478 makeSomething(shadow);
14331479 }
....@@ -1977,6 +2023,18 @@
19772023 if (source == dumpItem)
19782024 {
19792025 DumpObject();
2026
+ } else
2027
+ if (source == minButton)
2028
+ {
2029
+ Minimize();
2030
+ } else
2031
+ if (source == maxButton)
2032
+ {
2033
+ Maximize();
2034
+ } else
2035
+ if (source == fullButton)
2036
+ {
2037
+ ToggleFullScreen();
19802038 } else
19812039 if (source == undoButton)
19822040 {
....@@ -2899,6 +2957,24 @@
28992957 bigThree.ClearUI();
29002958 bigThree.add(centralPanel);
29012959 bigThree.FlushUI();
2960
+
2961
+ cameraView.requestFocusInWindow();
2962
+
2963
+// refreshContents(true);
2964
+//
2965
+// try
2966
+// {
2967
+// java.awt.Robot bot = new java.awt.Robot();
2968
+// int mask = InputEvent.BUTTON1_MASK;
2969
+// bot.mouseMove(100, 100);
2970
+// bot.mousePress(mask);
2971
+// bot.mouseRelease(mask);
2972
+// }
2973
+// catch (Exception e)
2974
+// {
2975
+//
2976
+// }
2977
+
29022978 } else
29032979 if (source == threeButton)
29042980 {
....@@ -2935,6 +3011,8 @@
29353011 bigThree.add(centralPanel);
29363012 bigThree.add(XYZPanel);
29373013 bigThree.FlushUI();
3014
+
3015
+ cameraView.requestFocusInWindow();
29383016 } else
29393017 if (source == fourButton)
29403018 {
....@@ -2970,6 +3048,8 @@
29703048 bigThree.ClearUI();
29713049 bigThree.add(scenePanel);
29723050 bigThree.FlushUI();
3051
+
3052
+ cameraView.requestFocusInWindow();
29733053 } else
29743054 if (source == sixButton)
29753055 {
....@@ -3006,6 +3086,8 @@
30063086 bigThree.add(scenePanel);
30073087 bigThree.add(centralPanel);
30083088 bigThree.FlushUI();
3089
+
3090
+ cameraView.requestFocusInWindow();
30093091 } else
30103092 if (source == sevenButton)
30113093 {
....@@ -3043,6 +3125,8 @@
30433125 bigThree.add(centralPanel);
30443126 bigThree.add(XYZPanel);
30453127 bigThree.FlushUI();
3128
+
3129
+ cameraView.requestFocusInWindow();
30463130 } else
30473131 if (source == rootButton)
30483132 {
....@@ -3054,6 +3138,7 @@
30543138 EditObject(obj);
30553139 }
30563140
3141
+ cameraView.requestFocusInWindow();
30573142 refreshContents(true);
30583143 } else
30593144 if (source == closeButton)
....@@ -3063,8 +3148,14 @@
30633148 for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
30643149 {
30653150 ab = (cRadio)e.nextElement();
3066
- if(ab.getModel().isSelected() && ab.GetObject() != client)
3151
+ if (ab.getModel().isSelected() && ab.GetObject() != client)
30673152 {
3153
+ // Patch to avoid bug with transparency.
3154
+ if (!ab.hadMaterial)
3155
+ {
3156
+ ab.object.material = null;
3157
+ }
3158
+
30683159 buttonGroup.remove(ab);
30693160 radioPanel.remove(ab);
30703161
....@@ -3075,6 +3166,8 @@
30753166 break;
30763167 }
30773168 }
3169
+
3170
+ cameraView.requestFocusInWindow();
30783171 refreshContents(true);
30793172 } else
30803173 if (source == editItem || source == editButton)
....@@ -3179,7 +3272,7 @@
31793272 }
31803273
31813274 // fix "+" issue
3182
- group.editWindow = this;
3275
+ //group.editWindow = this;
31833276
31843277 /*
31853278 currentLayout = radio.layout;
....@@ -3192,6 +3285,8 @@
31923285 //group.parent = null; // ROOT
31933286 //group.attributes = -1;
31943287 ResetModel();
3288
+
3289
+ cameraView.requestFocusInWindow();
31953290 refreshContents(true);
31963291 } else if (event.getSource() == editCameraItem)
31973292 {
....@@ -3215,7 +3310,6 @@
32153310 }
32163311
32173312 boolean useclient = false;
3218
- cRadio radio;
32193313
32203314 void ToggleRoot()
32213315 {
....@@ -5219,9 +5313,12 @@
52195313 cButton clearpanelButton;
52205314 cButton unselectButton;
52215315
5222
- cButton saveButton;
5316
+ cButton minButton;
5317
+ cButton maxButton;
5318
+ cButton fullButton;
52235319 cButton undoButton;
52245320 cButton redoButton;
5321
+ cButton saveButton;
52255322 cButton oneStepButton;
52265323
52275324 cButton screenfitButton;
....@@ -5234,14 +5331,6 @@
52345331 cButton closeButton;
52355332
52365333 cButton setsupportButton;
5237
-
5238
- cButton twoButton;
5239
- cButton sixButton;
5240
- cButton threeButton;
5241
- cButton sevenButton;
5242
- cButton fourButton; // full panel
5243
- cButton oneButton; // full XYZ
5244
- //cButton currentLayout;
52455334
52465335 //
52475336 //Composite