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 {
....@@ -470,6 +469,14 @@
470469 markleavesItem.addActionListener(this);
471470 unmarkleavesItem = menu.add(new MenuItem("Unmark Leaves"));
472471 unmarkleavesItem.addActionListener(this);
472
+ rewindleavesItem = menu.add(new MenuItem("Rewind Leaves"));
473
+ rewindleavesItem.addActionListener(this);
474
+ unrewindleavesItem = menu.add(new MenuItem("Unrewind Leaves"));
475
+ unrewindleavesItem.addActionListener(this);
476
+ randomleavesItem = menu.add(new MenuItem("Random Leaves"));
477
+ randomleavesItem.addActionListener(this);
478
+ unrandomleavesItem = menu.add(new MenuItem("Unrandom Leaves"));
479
+ unrandomleavesItem.addActionListener(this);
473480 menu.add("-");
474481 flipVItem = menu.add(new MenuItem("Flip V"));
475482 flipVItem.addActionListener(this);
....@@ -527,6 +534,18 @@
527534
528535 void SetupUI2(ObjEditor oe)
529536 {
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
+
530549 //new Exception().printStackTrace();
531550
532551 oe.radioPanel = new JPanel(new GridBagLayout());
....@@ -557,15 +576,27 @@
557576 */
558577 //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
559578
560
- 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);
561592 undoButton.setToolTipText("Undo changes");
562593 undoButton.addActionListener(this);
563594
564
- oe.toolbarPanel.add(redoButton = new cButton("Redo", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
595
+ oe.toolbarPanel.add(redoButton = new cButton("\u21aa", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
565596 redoButton.setToolTipText("Redo changes");
566597 redoButton.addActionListener(this);
567598
568
- oe.toolbarPanel.add(saveButton = new cButton("Save", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
599
+ oe.toolbarPanel.add(saveButton = new cButton("\u21e3", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
569600 saveButton.setToolTipText("Save changes");
570601 saveButton.addActionListener(this);
571602
....@@ -573,7 +604,7 @@
573604 liveCB.setToolTipText("Enable animation");
574605 liveCB.addItemListener(this);
575606
576
- oe.toolbarPanel.add(oneStepButton = new cButton("Step", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
607
+ oe.toolbarPanel.add(oneStepButton = new cButton("\u29f4", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
577608 oneStepButton.setToolTipText("Animate one step forward");
578609 oneStepButton.addActionListener(this);
579610
....@@ -581,7 +612,7 @@
581612 fastCB.setToolTipText("Fast mode");
582613 fastCB.addItemListener(this);
583614
584
- oe.toolbarPanel.add(trackCB = new cCheckBox("Track", CameraPane.TRACK)); //, oe.aConstraints);
615
+ oe.toolbarPanel.add(trackCB = new cCheckBox(":", CameraPane.TRACK)); //, oe.aConstraints);
585616 trackCB.setToolTipText("Enable tracking");
586617 trackCB.addItemListener(this);
587618
....@@ -605,19 +636,19 @@
605636
606637 oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
607638
608
- oe.toolbarPanel.add(twoButton = new cButton("|+|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
639
+ oe.toolbarPanel.add(twoButton = new cButton("|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
609640 twoButton.setToolTipText("Show center view only");
610641 twoButton.addActionListener(this);
611
- oe.toolbarPanel.add(fourButton = new cButton("+||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
642
+ oe.toolbarPanel.add(fourButton = new cButton("-||", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
612643 fourButton.addActionListener(this);
613644 fourButton.setToolTipText("Show left panel only");
614
- oe.toolbarPanel.add(sixButton = new cButton("+|+|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
645
+ oe.toolbarPanel.add(sixButton = new cButton("-|-|", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
615646 sixButton.setToolTipText("2-column layout left");
616647 sixButton.addActionListener(this);
617
- oe.toolbarPanel.add(threeButton = new cButton("|+|+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
648
+ oe.toolbarPanel.add(threeButton = new cButton("|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
618649 threeButton.setToolTipText("2-column layout right");
619650 threeButton.addActionListener(this);
620
- oe.toolbarPanel.add(sevenButton = new cButton("+|+|+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
651
+ oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
621652 sevenButton.setToolTipText("3-column layout");
622653 sevenButton.addActionListener(this);
623654 //
....@@ -632,32 +663,30 @@
632663 //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
633664 //clearButton.addActionListener(this);
634665
635
- cGridBag commandsPanel = new cGridBag();
636
-
637
- commandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
666
+ editCommandsPanel.add(editButton = new cButton("+", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
638667 editButton.setToolTipText("Edit selection");
639668 editButton.addActionListener(this);
640669
641
- commandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
670
+ editCommandsPanel.add(uneditButton = new cButton("-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
642671 uneditButton.setToolTipText("Unedit selection");
643672 uneditButton.addActionListener(this);
644673
645
- commandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
674
+ editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
646675 allParamsButton.setToolTipText("Edit all params");
647676 allParamsButton.addActionListener(this);
648677
649
- commandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
678
+ editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
650679 clearPanelButton.setToolTipText("Clear edit panel");
651680 clearPanelButton.addActionListener(this);
652681
653
- commandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
682
+ editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
654683 unselectButton.setToolTipText("Unselect");
655684 unselectButton.addActionListener(this);
656685
657
- commandsPanel.preferredHeight = 1;
686
+ editCommandsPanel.preferredHeight = 1;
658687
659
- oe.treePanel.add(commandsPanel);
660
- oe.treePanel.Return();
688
+// oe.treePanel.add(commandsPanel);
689
+// oe.treePanel.Return();
661690
662691 // oe.aConstraints.gridx += 1;
663692 // oe.aConstraints.weighty = 0;
....@@ -779,11 +808,19 @@
779808 // debugCB.addItemListener(this);
780809
781810 panel.add(oeilCB = new cCheckBox("Eye", CameraPane.OEIL)); //, constraints);
811
+ oeilCB.setToolTipText("Move camera when tracking target");
782812 oeilCB.addItemListener(this);
783813
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
+ {
784820 panel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT)); //, constraints);
785821 lookAtCB.setToolTipText("Look-at target");
786822 lookAtCB.addItemListener(this);
823
+ }
787824
788825 }
789826
....@@ -798,6 +835,14 @@
798835 void EditObject(Object3D obj)
799836 {
800837 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
+
801846 radioButton.SetObject(obj);
802847 radioButton.layout = sevenButton;
803848 radioButton.SetCamera(cameraView.renderCamera, false);
....@@ -809,6 +854,8 @@
809854
810855 void SetupViews(ObjEditor oe)
811856 {
857
+ theFrame = this;
858
+
812859 oe.SetupViews();
813860
814861 System.out.println("SetupViews");
....@@ -832,7 +879,9 @@
832879 JCheckBox speakerCameraCB;
833880 JCheckBox speakerFocusCB;
834881 JCheckBox debugCB;
882
+
835883 JCheckBox oeilCB;
884
+ JCheckBox shadowCB;
836885 JCheckBox lookAtCB;
837886
838887 // static int COLOR = 1;
....@@ -871,6 +920,7 @@
871920 } else if(e.getSource() == liveCB)
872921 {
873922 cameraView.ToggleLive();
923
+ refreshContents(false);
874924 }
875925 else if(e.getSource() == supportCB)
876926 {
....@@ -934,6 +984,10 @@
934984 else if(e.getSource() == oeilCB)
935985 {
936986 cameraView.ToggleOeil();
987
+ }
988
+ else if(e.getSource() == shadowCB)
989
+ {
990
+ Globals.COMPUTESHADOWWHENLIVE ^= true;
937991 }
938992 else if(e.getSource() == lookAtCB)
939993 {
....@@ -1278,7 +1332,7 @@
12781332 memoryItem.addActionListener(this);
12791333 menu.add(analyzeItem = new MenuItem("Analyze"));
12801334 analyzeItem.addActionListener(this);
1281
- menu.add(dumpItem = new MenuItem("Dump"));
1335
+ menu.add(dumpItem = new MenuItem("Print"));
12821336 dumpItem.addActionListener(this);
12831337 // menu.add(pathItem = new MenuItem("From-to path"));
12841338 // pathItem.addActionListener(this);
....@@ -1419,6 +1473,7 @@
14191473 shadow.material = new cMaterial(obj.material);
14201474 shadow.material.diffuse = 0.0001f;
14211475 shadow.material.specular = 0.0001f;
1476
+ //shadow.projectedVertices[1].x = 300;
14221477
14231478 makeSomething(shadow);
14241479 }
....@@ -1968,6 +2023,18 @@
19682023 if (source == dumpItem)
19692024 {
19702025 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();
19712038 } else
19722039 if (source == undoButton)
19732040 {
....@@ -2608,6 +2675,22 @@
26082675 {
26092676 MarkLeaves(false);
26102677 } else
2678
+ if (source == rewindleavesItem)
2679
+ {
2680
+ RewindLeaves(true);
2681
+ } else
2682
+ if (source == unrewindleavesItem)
2683
+ {
2684
+ RewindLeaves(false);
2685
+ } else
2686
+ if (source == randomleavesItem)
2687
+ {
2688
+ RandomLeaves(true);
2689
+ } else
2690
+ if (source == unrandomleavesItem)
2691
+ {
2692
+ RandomLeaves(false);
2693
+ } else
26112694 if (source == flipVItem)
26122695 {
26132696 FlipV(true);
....@@ -2874,6 +2957,24 @@
28742957 bigThree.ClearUI();
28752958 bigThree.add(centralPanel);
28762959 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
+
28772978 } else
28782979 if (source == threeButton)
28792980 {
....@@ -2910,6 +3011,8 @@
29103011 bigThree.add(centralPanel);
29113012 bigThree.add(XYZPanel);
29123013 bigThree.FlushUI();
3014
+
3015
+ cameraView.requestFocusInWindow();
29133016 } else
29143017 if (source == fourButton)
29153018 {
....@@ -2945,6 +3048,8 @@
29453048 bigThree.ClearUI();
29463049 bigThree.add(scenePanel);
29473050 bigThree.FlushUI();
3051
+
3052
+ cameraView.requestFocusInWindow();
29483053 } else
29493054 if (source == sixButton)
29503055 {
....@@ -2981,6 +3086,8 @@
29813086 bigThree.add(scenePanel);
29823087 bigThree.add(centralPanel);
29833088 bigThree.FlushUI();
3089
+
3090
+ cameraView.requestFocusInWindow();
29843091 } else
29853092 if (source == sevenButton)
29863093 {
....@@ -3018,6 +3125,8 @@
30183125 bigThree.add(centralPanel);
30193126 bigThree.add(XYZPanel);
30203127 bigThree.FlushUI();
3128
+
3129
+ cameraView.requestFocusInWindow();
30213130 } else
30223131 if (source == rootButton)
30233132 {
....@@ -3029,6 +3138,7 @@
30293138 EditObject(obj);
30303139 }
30313140
3141
+ cameraView.requestFocusInWindow();
30323142 refreshContents(true);
30333143 } else
30343144 if (source == closeButton)
....@@ -3038,8 +3148,14 @@
30383148 for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
30393149 {
30403150 ab = (cRadio)e.nextElement();
3041
- if(ab.getModel().isSelected() && ab.GetObject() != client)
3151
+ if (ab.getModel().isSelected() && ab.GetObject() != client)
30423152 {
3153
+ // Patch to avoid bug with transparency.
3154
+ if (!ab.hadMaterial)
3155
+ {
3156
+ ab.object.material = null;
3157
+ }
3158
+
30433159 buttonGroup.remove(ab);
30443160 radioPanel.remove(ab);
30453161
....@@ -3050,6 +3166,8 @@
30503166 break;
30513167 }
30523168 }
3169
+
3170
+ cameraView.requestFocusInWindow();
30533171 refreshContents(true);
30543172 } else
30553173 if (source == editItem || source == editButton)
....@@ -3154,7 +3272,7 @@
31543272 }
31553273
31563274 // fix "+" issue
3157
- group.editWindow = this;
3275
+ //group.editWindow = this;
31583276
31593277 /*
31603278 currentLayout = radio.layout;
....@@ -3167,6 +3285,8 @@
31673285 //group.parent = null; // ROOT
31683286 //group.attributes = -1;
31693287 ResetModel();
3288
+
3289
+ cameraView.requestFocusInWindow();
31703290 refreshContents(true);
31713291 } else if (event.getSource() == editCameraItem)
31723292 {
....@@ -3190,7 +3310,6 @@
31903310 }
31913311
31923312 boolean useclient = false;
3193
- cRadio radio;
31943313
31953314 void ToggleRoot()
31963315 {
....@@ -4145,6 +4264,18 @@
41454264 refreshContents();
41464265 }
41474266
4267
+ void RewindLeaves(boolean hide)
4268
+ {
4269
+ group.selection.RewindLeaves(hide);
4270
+ refreshContents();
4271
+ }
4272
+
4273
+ void RandomLeaves(boolean hide)
4274
+ {
4275
+ group.selection.RandomLeaves(hide);
4276
+ refreshContents();
4277
+ }
4278
+
41484279 void SetTexRes(int tr)
41494280 {
41504281 group.selection.SetTexRes(tr);
....@@ -4320,7 +4451,6 @@
43204451 //case 702: // Event.LIST_DESELECT
43214452 group.deselectAll();
43224453 TreePath tps[] = objEditor.jTree.getSelectionPaths();
4323
- objEditor.ClearInfo(); // .GetMaterial());
43244454 if (tps != null)
43254455 {
43264456 for (int i=0; i < tps.length; i++)
....@@ -4329,10 +4459,8 @@
43294459
43304460 //if (child.parent != null)
43314461 //child.parent.addSelectee(child);
4462
+ objEditor.SetMaterial(child);
43324463 group.addSelectee(child);
4333
- objEditor.SetMaterial(child); // .GetMaterial());
4334
- objEditor.AddInfo(child, this, true); // .GetMaterial());
4335
- System.err.println("info : " + child.GetPath());
43364464 }
43374465 }
43384466 // else
....@@ -4342,8 +4470,6 @@
43424470 // System.err.println("info : " + group.GetPath());
43434471 // }
43444472
4345
- objEditor.SetText(); // jan 2014
4346
-
43474473 if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(tps[0].getLastPathComponent() instanceof Camera))
43484474 CameraPane.flash = true;
43494475
....@@ -4367,6 +4493,26 @@
43674493
43684494 freezemodel = false;
43694495 }
4496
+
4497
+ void refreshContents(boolean cp)
4498
+ {
4499
+ if (!Globals.MOUSEDRAGGED)
4500
+ {
4501
+ objEditor.ClearInfo(); // .GetMaterial());
4502
+
4503
+ for (int i=0; i < group.selection.Size(); i++)
4504
+ {
4505
+ Object3D child = (Object3D) group.selection.get(i);
4506
+
4507
+ objEditor.AddInfo(child, this, true);
4508
+ System.err.println("info : " + child.GetPath());
4509
+ }
4510
+
4511
+ objEditor.SetText(); // jan 2014
4512
+ }
4513
+
4514
+ super.refreshContents(cp);
4515
+ }
43704516
43714517 void linkSomething(Object3D thing)
43724518 {
....@@ -5167,9 +5313,12 @@
51675313 cButton clearpanelButton;
51685314 cButton unselectButton;
51695315
5170
- cButton saveButton;
5316
+ cButton minButton;
5317
+ cButton maxButton;
5318
+ cButton fullButton;
51715319 cButton undoButton;
51725320 cButton redoButton;
5321
+ cButton saveButton;
51735322 cButton oneStepButton;
51745323
51755324 cButton screenfitButton;
....@@ -5182,14 +5331,6 @@
51825331 cButton closeButton;
51835332
51845333 cButton setsupportButton;
5185
-
5186
- cButton twoButton;
5187
- cButton sixButton;
5188
- cButton threeButton;
5189
- cButton sevenButton;
5190
- cButton fourButton; // full panel
5191
- cButton oneButton; // full XYZ
5192
- //cButton currentLayout;
51935334
51945335 //
51955336 //Composite
....@@ -5267,6 +5408,10 @@
52675408 private MenuItem showleavesItem;
52685409 private MenuItem markleavesItem;
52695410 private MenuItem unmarkleavesItem;
5411
+ private MenuItem rewindleavesItem;
5412
+ private MenuItem unrewindleavesItem;
5413
+ private MenuItem randomleavesItem;
5414
+ private MenuItem unrandomleavesItem;
52705415
52715416 private MenuItem flipVItem;
52725417 private MenuItem unflipVItem;