Normand Briere
2019-08-16 64e20f390e4b8e58bd0006dde8fa10fba1dac1d5
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -30,11 +34,128 @@
3034 iSendInfo
3135 //KeyListener
3236 {
37
+ public cToggleButton pinButton;
3338 boolean timeline;
3439 boolean wasFullScreen;
3540
3641 GroupEditor callee;
3742 JFrame frame;
43
+
44
+ static ObjEditor theFrame;
45
+
46
+ public void AllocProjectedVertices(Object3D object)
47
+ {
48
+ assert (object.projectedVertices != null);
49
+
50
+ if (object.projectedVertices.length <= 2)
51
+ {
52
+ // Side effect...
53
+ Object3D.cVector2[] keep = object.projectedVertices;
54
+ object.projectedVertices = new Object3D.cVector2[3];
55
+ for (int i = 0; i < 3; i++)
56
+ {
57
+ if (i < keep.length)
58
+ {
59
+ object.projectedVertices[i] = keep[i];
60
+ } else
61
+ {
62
+ object.projectedVertices[i] = new Object3D.cVector2();
63
+ }
64
+ /*
65
+ if(keep.length == 0)
66
+ object.projectedVertices[0] = new Object3D.cVector2();
67
+ else
68
+ object.projectedVertices[0] = keep[0];
69
+ object.projectedVertices[1] = new Object3D.cVector2();
70
+ */
71
+ }
72
+ }
73
+ }
74
+
75
+ public cGridBag GetSeparator()
76
+ {
77
+ cGridBag separator = new cGridBag();
78
+ separator.add(new JSeparator());
79
+ separator.preferredHeight = 5;
80
+ return separator;
81
+ }
82
+
83
+ cButton GetButton(String name, boolean border)
84
+ {
85
+ ImageIcon icon = GetIcon(name);
86
+ return new cButton(icon, border);
87
+ }
88
+
89
+ cLabel GetLabel(String name, boolean border)
90
+ {
91
+ //ImageIcon icon = GetIcon(name);
92
+ return new cLabel(GetImage(name), border);
93
+ }
94
+
95
+ cToggleButton GetToggleButton(String name, boolean border)
96
+ {
97
+ ImageIcon icon = GetIcon(name);
98
+ return new cToggleButton(icon, border);
99
+ }
100
+
101
+ cCheckBox GetCheckBox(String name, boolean border)
102
+ {
103
+ ImageIcon icon = GetIcon(name);
104
+ return new cCheckBox(icon, border);
105
+ }
106
+
107
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
108
+
109
+ ImageIcon GetIcon(String name)
110
+ {
111
+ javax.swing.ImageIcon iconCache = icons.get(name);
112
+ if (iconCache != null)
113
+ {
114
+ return iconCache;
115
+ }
116
+
117
+ try
118
+ {
119
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
120
+
121
+// if (image.getWidth() > 48 && image.getHeight() > 48)
122
+// {
123
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
124
+// Graphics2D g = resized.createGraphics();
125
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
126
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
127
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
128
+// g.dispose();
129
+//
130
+// image = resized;
131
+// }
132
+
133
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
134
+
135
+ icons.put(name, icon);
136
+
137
+ return icon;
138
+ }
139
+ catch (Exception e)
140
+ {
141
+ //icons.put(name, null);
142
+ return null;
143
+ }
144
+ }
145
+
146
+ BufferedImage GetImage(String name)
147
+ {
148
+ try
149
+ {
150
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
151
+
152
+ return image;
153
+ }
154
+ catch (Exception e)
155
+ {
156
+ return null;
157
+ }
158
+ }
38159
39160 // SCRIPT
40161
....@@ -145,7 +266,7 @@
145266
146267 objEditor.ctrlPanel.remove(namePanel);
147268
148
- if (!GroupEditor.allparams)
269
+ if (!allparams)
149270 return;
150271
151272 // objEditor.ctrlPanel.remove(liveCB);
....@@ -168,7 +289,8 @@
168289 // objEditor.ctrlPanel.remove(remarkButton);
169290
170291 objEditor.ctrlPanel.remove(setupPanel);
171
- objEditor.ctrlPanel.remove(commandsPanel);
292
+ objEditor.ctrlPanel.remove(setupPanel2);
293
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
172294 objEditor.ctrlPanel.remove(pushPanel);
173295 //objEditor.ctrlPanel.remove(fillPanel);
174296
....@@ -216,6 +338,14 @@
216338 client = inClient;
217339 copy = client;
218340
341
+// if (copy.versionlist == null)
342
+// {
343
+// copy.versionlist = new Object3D[100];
344
+// copy.versionindex = -1;
345
+//
346
+// callee.Save(true);
347
+// }
348
+
219349 // "this" is not called: SetupUI2(objEditor);
220350 }
221351
....@@ -229,6 +359,14 @@
229359 client = inClient;
230360 copy = client;
231361
362
+ if (copy.versionlist == null)
363
+ {
364
+ copy.versionlist = new Object3D[100];
365
+ copy.versionindex = -1;
366
+
367
+// Save(true);
368
+ }
369
+
232370 SetupUI2(callee.GetEditor());
233371 }
234372
....@@ -243,13 +381,15 @@
243381 //localCopy.parent = null;
244382
245383 frame = new JFrame();
384
+ frame.setUndecorated(false);
246385 objEditor = this;
247386 this.callee = callee;
248387
249388 //parent = p;
250389
251390 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
252
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
391
+ if (Globals.DEBUG)
392
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
253393 //gd.setFullScreenWindow(this);
254394 //setResizable(false);
255395 //if (!isDisplayable())
....@@ -260,6 +400,14 @@
260400 copy = localCopy;
261401 copy.editWindow = this;
262402
403
+// if (copy.versionlist == null)
404
+// {
405
+// copy.versionlist = new Object3D[100];
406
+// copy.versionindex = -1;
407
+//
408
+// Save(true);
409
+// }
410
+
263411 SetupMenu();
264412
265413 //SetupName(objEditor); // new
....@@ -273,12 +421,17 @@
273421 return frame.action(event, obj);
274422 }
275423
424
+ // Cannot work without static
425
+ static boolean allparams = true;
426
+
427
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
428
+
276429 void SetupMenu()
277430 {
278431 frame.setMenuBar(menuBar = new MenuBar());
279432 menuBar.add(fileMenu = new Menu("File"));
280433 fileMenu.add(newItem = new MenuItem("New"));
281
- fileMenu.add(loadItem = new MenuItem("Open..."));
434
+ fileMenu.add(openItem = new MenuItem("Open..."));
282435
283436 //oe.menuBar.add(menu = new Menu("Include"));
284437 Menu menu = new Menu("Import");
....@@ -310,7 +463,7 @@
310463 }
311464
312465 newItem.addActionListener(this);
313
- loadItem.addActionListener(this);
466
+ openItem.addActionListener(this);
314467 saveItem.addActionListener(this);
315468 saveAsItem.addActionListener(this);
316469 exportAsItem.addActionListener(this);
....@@ -319,28 +472,102 @@
319472 closeItem.addActionListener(this);
320473
321474 objectPanel = new JTabbedPane();
475
+
476
+ ChangeListener changeListener = new ChangeListener()
477
+ {
478
+ //String name;
479
+
480
+ public void stateChanged(ChangeEvent changeEvent)
481
+ {
482
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
483
+// {
484
+// if (latestObject != null)
485
+// {
486
+// refreshContents(true);
487
+// SetMaterial(latestObject);
488
+// }
489
+//
490
+// materialFlushed = true;
491
+// }
492
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
493
+// {
494
+// if (listUI.size() == 0)
495
+// EditSelection(false);
496
+// }
497
+
498
+// if (objectPanel.getSelectedIndex() == 4)
499
+// {
500
+// name = copy.skyboxname;
501
+//
502
+// if (name == null)
503
+// {
504
+// name = "";
505
+// }
506
+//
507
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
508
+// copy.skyboxext = "jpg";
509
+// }
510
+// else
511
+// {
512
+// if (name != null)
513
+// {
514
+// if (name.equals(""))
515
+// {
516
+// copy.skyboxname = null;
517
+// copy.skyboxext = null;
518
+// }
519
+// else
520
+// {
521
+// copy.skyboxname = name;
522
+// }
523
+// }
524
+// }
525
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
526
+
527
+// refreshContents(false); // To refresh Info tab
528
+ cameraView.repaint();
529
+ }
530
+ };
531
+ objectPanel.addChangeListener(changeListener);
532
+
322533 toolbarPanel = new JPanel();
323534 toolbarPanel.setName("Toolbar");
535
+
324536 treePanel = new cGridBag();
325537 treePanel.setName("Tree");
538
+
539
+ editPanel = new cGridBag().setVertical(true);
540
+ //editPanel.setName("Edit");
541
+
326542 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
327
- ctrlPanel.setName("Edit");
328
- materialPanel = new cGridBag().setVertical(true);
329
- materialPanel.setName("Material");
543
+
544
+ editCommandsPanel = new cGridBag();
545
+ editPanel.add(editCommandsPanel);
546
+ editPanel.add(ctrlPanel);
547
+
548
+ toolboxPanel = new cGridBag().setVertical(true);
549
+ //toolboxPanel.setName("Toolbox");
550
+
551
+ skyboxPanel = new cGridBag().setVertical(true);
552
+
553
+ materialPanel = new cGridBag().setVertical(false);
554
+ //materialPanel.setName("Material");
555
+
330556 /*JTextPane*/
331557 infoarea = createTextPane();
332558 doc = infoarea.getStyledDocument();
333559
334560 infoarea.setEditable(true);
335561 SetText();
562
+
336563 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
337564 // infoarea.setOpaque(false);
338565 // //infoarea.setForeground(textcolor);
339566 // TEXTAREA infoarea.setLineWrap(true);
340567 // TEXTAREA infoarea.setWrapStyleWord(true);
341568 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
342
- infoPanel.setPreferredSize(new Dimension(50, 200));
343
- infoPanel.setName("Info");
569
+ infoPanel.setPreferredSize(new Dimension(1, 1));
570
+ //infoPanel.setName("Info");
344571 //infoPanel.setLayout(new BorderLayout());
345572 //infoPanel.add(createTextPane());
346573
....@@ -351,7 +578,14 @@
351578 mainPanel.setDividerSize(9);
352579 mainPanel.setDividerLocation(0.5); //1.0);
353580 mainPanel.setResizeWeight(0.5);
354
-
581
+
582
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
583
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
584
+ divider.setDividerSize(15);
585
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
586
+
587
+ mainPanel.setUI(new BasicSplitPaneUI());
588
+
355589 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
356590 //mainPanel.setLayout(new GridBagLayout());
357591 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -582,21 +816,158 @@
582816 }
583817 }
584818
819
+//static GraphicsDevice device = GraphicsEnvironment
820
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
821
+
822
+ Rectangle keeprect;
823
+ cRadio radio;
824
+
825
+cButton keepButton;
826
+ cButton twoButton; // Full 3D
827
+ cButton sixButton;
828
+ cButton threeButton;
829
+ cButton sevenButton;
830
+ cButton fourButton; // full panel
831
+ cButton oneButton; // full XYZ
832
+ //cButton currentLayout;
833
+
834
+ boolean maximized;
835
+
836
+ cButton fullscreenLayout;
837
+ cButton expandedLayout;
838
+
839
+ void Minimize()
840
+ {
841
+ frame.setState(Frame.ICONIFIED);
842
+ frame.validate();
843
+ }
844
+
845
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
846
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
847
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
848
+ void Maximize()
849
+ {
850
+ if (CameraPane.FULLSCREEN)
851
+ {
852
+ ToggleFullScreen();
853
+ }
854
+
855
+ if (maximized)
856
+ {
857
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
858
+ }
859
+ else
860
+ {
861
+ keeprect = frame.getBounds();
862
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
863
+// Dimension rect2 = frame.getToolkit().getScreenSize();
864
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
865
+// frame.setState(Frame.MAXIMIZED_BOTH);
866
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
867
+ }
868
+
869
+ maximized ^= true;
870
+
871
+ frame.validate();
872
+ }
873
+
874
+ cButton minButton;
875
+ cButton maxButton;
876
+ cButton fullButton;
877
+ cButton collapseButton;
878
+ cButton maximize3DButton;
879
+
585880 void ToggleFullScreen()
586881 {
587
- if (CameraPane.FULLSCREEN)
882
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
883
+
884
+ cameraView.ToggleFullScreen();
885
+
886
+ if (!CameraPane.FULLSCREEN)
588887 {
589
- frame.getContentPane().remove(/*"Center",*/bigThree);
590
- framePanel.add(bigThree);
591
- frame.getContentPane().add(/*"Center",*/framePanel);
888
+ device.setFullScreenWindow(null);
889
+ frame.dispose();
890
+ frame.setUndecorated(false);
891
+ frame.validate();
892
+ frame.setVisible(true);
893
+
894
+ //frame.setVisible(false);
895
+// frame.removeNotify();
896
+// frame.setUndecorated(false);
897
+// frame.addNotify();
898
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
899
+
900
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
901
+// X framePanel.add(bigThree);
902
+// X frame.getContentPane().add(/*"Center",*/framePanel);
903
+// framePanel.setDividerLocation(46); // icons are 24x24
904
+
905
+ //frame.setVisible(true);
906
+// radio.layout = keepButton;
907
+ //theFrame = null;
908
+ keepButton = null;
909
+// radio.layout.doClick();
910
+
592911 } else
593912 {
594
- frame.getContentPane().remove(/*"Center",*/framePanel);
595
- framePanel.remove(bigThree);
596
- frame.getContentPane().add(/*"Center",*/bigThree);
913
+ keepButton = radio.layout;
914
+ //keeprect = frame.getBounds();
915
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
916
+// frame.getToolkit().getScreenSize().height);
917
+ //frame.setVisible(false);
918
+
919
+ frame.dispose();
920
+ frame.setUndecorated(true);
921
+ device.setFullScreenWindow(frame);
922
+ frame.validate();
923
+ frame.setVisible(true);
924
+// frame.removeNotify();
925
+// frame.setUndecorated(true);
926
+// frame.addNotify();
927
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
928
+// X framePanel.remove(bigThree);
929
+// X frame.getContentPane().add(/*"Center",*/bigThree);
930
+// framePanel.setDividerLocation(0);
931
+
932
+// radio.layout = fullscreenLayout;
933
+// radio.layout.doClick();
934
+ //frame.setVisible(true);
597935 }
598
- cameraView.ToggleFullScreen();
936
+ frame.validate();
937
+
938
+ cameraView.requestFocusInWindow();
599939 }
940
+
941
+ void CollapseToolbar()
942
+ {
943
+ framePanel.setDividerLocation(0);
944
+ //frame.validate();
945
+
946
+ cameraView.requestFocusInWindow();
947
+ }
948
+
949
+ private Object3D Duplicate(Object3D object)
950
+ {
951
+ boolean temp = CameraPane.SWITCH;
952
+ CameraPane.SWITCH = false;
953
+
954
+ object.ExtractBigData(versiontable);
955
+ // if (copy == client)
956
+
957
+ Object3D versions[] = object.versionlist;
958
+ object.versionlist = null;
959
+
960
+ //byte[] compress = Compress(copy);
961
+ Object3D compress = (Object3D)Grafreed.clone(object);
962
+
963
+ object.versionlist = versions;
964
+
965
+ object.RestoreBigData(versiontable);
966
+
967
+ CameraPane.SWITCH = temp;
968
+
969
+ return compress;
970
+ }
600971
601972 private JTextPane createTextPane()
602973 {
....@@ -719,6 +1090,7 @@
7191090 {
7201091 SetupMaterial(materialPanel);
7211092 }
1093
+
7221094 //SetupName();
7231095 //SetupViews();
7241096 }
....@@ -728,7 +1100,7 @@
7281100 // NumberSlider vDivsField;
7291101 // JCheckBox endcaps;
7301102 JCheckBox liveCB;
731
- JCheckBox selectCB;
1103
+ JCheckBox selectableCB;
7321104 JCheckBox hideCB;
7331105 JCheckBox link2masterCB;
7341106 JCheckBox markCB;
....@@ -736,7 +1108,12 @@
7361108 JCheckBox speedupCB;
7371109 JCheckBox rewindCB;
7381110 JCheckBox flipVCB;
1111
+
1112
+ cCheckBox toggleTextureCB;
1113
+ cCheckBox toggleSwitchCB;
1114
+
7391115 JComboBox texresMenu;
1116
+
7401117 JButton resetButton;
7411118 JButton stepButton;
7421119 JButton stepAllButton;
....@@ -745,9 +1122,13 @@
7451122 JButton fasterButton;
7461123 JButton remarkButton;
7471124
1125
+ cGridBag editPanel;
1126
+ cGridBag editCommandsPanel;
1127
+
7481128 cGridBag namePanel;
7491129 cGridBag setupPanel;
750
- cGridBag commandsPanel;
1130
+ cGridBag setupPanel2;
1131
+ cGridBag objectCommandsPanel;
7511132 cGridBag pushPanel;
7521133 cGridBag fillPanel;
7531134
....@@ -918,61 +1299,81 @@
9181299
9191300 namePanel = new cGridBag();
9201301
1302
+ //if (copy.pinned)
1303
+ {
1304
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1305
+ pinButton.setSelected(copy.pinned);
1306
+ cGridBag t = new cGridBag();
1307
+ t.preferredWidth = 2;
1308
+ t.add(pinButton);
1309
+ namePanel.add(t);
1310
+
1311
+ pinButton.addItemListener(this);
1312
+ }
1313
+
9211314 nameField = AddText(namePanel, copy.GetName());
922
- namePanel.add(nameField);
1315
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9231316 oe.ctrlPanel.add(namePanel);
9241317
9251318 oe.ctrlPanel.Return();
9261319
927
- if (!GroupEditor.allparams)
1320
+ if (!allparams)
9281321 return;
9291322
9301323 setupPanel = new cGridBag().setVertical(false);
9311324
9321325 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
9331326 liveCB.setToolTipText("Animate object");
934
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
935
- selectCB.setToolTipText("Make object selectable");
1327
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1328
+ markCB.setToolTipText("Set target transform");
1329
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1330
+ selectableCB.setToolTipText("Make object selectable");
9361331 // Return();
1332
+
9371333 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9381334 hideCB.setToolTipText("Hide object");
939
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
940
- markCB.setToolTipText("Set the animation target transform");
9411335
942
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1336
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1337
+
1338
+ setupPanel2 = new cGridBag().setVertical(false);
1339
+
1340
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9431341 rewindCB.setToolTipText("Rewind animation");
9441342
945
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
946
- randomCB.setToolTipText("Option for switch node");
1343
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1344
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9471345
1346
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1347
+ link2masterCB.setToolTipText("Attach to support");
1348
+
9481349 if (Globals.ADVANCED)
9491350 {
950
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
951
- link2masterCB.setToolTipText("Attach to support");
952
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1351
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9531352 speedupCB.setToolTipText("Option motion capture");
9541353 }
9551354
9561355 oe.ctrlPanel.add(setupPanel);
9571356 oe.ctrlPanel.Return();
1357
+ oe.ctrlPanel.add(setupPanel2);
1358
+ oe.ctrlPanel.Return();
9581359
959
- commandsPanel = new cGridBag().setVertical(false);
1360
+ objectCommandsPanel = new cGridBag().setVertical(false);
9601361
961
- resetButton = AddButton(commandsPanel, "Reset");
1362
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9621363 resetButton.setToolTipText("Jump to frame zero");
963
- stepButton = AddButton(commandsPanel, "Step");
1364
+ stepButton = AddButton(objectCommandsPanel, "Step");
9641365 stepButton.setToolTipText("Step one frame");
9651366 // resetAllButton = AddButton(oe, "Reset All");
9661367 // stepAllButton = AddButton(oe, "Step All");
9671368 // Return();
968
- slowerButton = AddButton(commandsPanel, "Slow");
1369
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9691370 slowerButton.setToolTipText("Decrease animation speed");
970
- fasterButton = AddButton(commandsPanel, "Fast");
1371
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9711372 fasterButton.setToolTipText("Increase animation speed");
972
- remarkButton = AddButton(commandsPanel, "Remark");
1373
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9731374 remarkButton.setToolTipText("Set the current transform as the target");
9741375
975
- oe.ctrlPanel.add(commandsPanel);
1376
+ oe.ctrlPanel.add(objectCommandsPanel);
9761377 oe.ctrlPanel.Return();
9771378
9781379 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1132,6 +1533,7 @@
11321533
11331534 if (cam == null || !(copy.get(0) instanceof cGroup))
11341535 {
1536
+ if (Globals.DEBUG)
11351537 System.out.println("CREATE CAMERAS");
11361538 cams = new cTemplate();
11371539 cams.name = "Cameras";
....@@ -1178,8 +1580,11 @@
11781580 //worldPanel.setName("World");
11791581 centralPanel = new cGridBag();
11801582 centralPanel.preferredWidth = 20;
1181
- timelinePanel = new JPanel(new BorderLayout());
1182
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1583
+
1584
+ if (Globals.ADVANCED)
1585
+ {
1586
+ timelinePanel = new JPanel(new BorderLayout());
1587
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11831588
11841589 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11851590 cameraPanel.setContinuousLayout(true);
....@@ -1188,7 +1593,10 @@
11881593 // cameraPanel.setDividerSize(9);
11891594 cameraPanel.setResizeWeight(1.0);
11901595
1596
+ }
1597
+
11911598 centralPanel.add(cameraView);
1599
+ centralPanel.setFocusable(true);
11921600 //frame.setJMenuBar(timelineMenubar);
11931601 //centralPanel.add(timelinePanel);
11941602
....@@ -1214,6 +1622,7 @@
12141622 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12151623 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12161624 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1625
+ //XYZPanel.setName("XYZ");
12171626
12181627 /*
12191628 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1251,13 +1660,29 @@
12511660 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12521661 //tmp.setName("Edit");
12531662 objectPanel.add(materialPanel);
1663
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1664
+ objectPanel.setToolTipTextAt(0, "Material");
1665
+
1666
+ objectPanel.add(toolboxPanel);
1667
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1668
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1669
+
1670
+ objectPanel.add(skyboxPanel);
1671
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1672
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1673
+
12541674 // JPanel north = new JPanel(new BorderLayout());
12551675 // north.setName("Edit");
12561676 // north.add(ctrlPanel, BorderLayout.NORTH);
12571677 // objectPanel.add(north);
1258
- objectPanel.add(ctrlPanel);
1259
- objectPanel.add(infoPanel);
1260
-
1678
+ objectPanel.add(editPanel);
1679
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1680
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1681
+
1682
+ objectPanel.add(XYZPanel);
1683
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1684
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1685
+
12611686 /*
12621687 aConstraints.gridx = 0;
12631688 aConstraints.gridwidth = 1;
....@@ -1265,7 +1690,7 @@
12651690 aConstraints.gridy += 1;
12661691 aConstraints.gridwidth = 1;
12671692 mainPanel.add(objectPanel, aConstraints);
1268
- */
1693
+ */
12691694
12701695 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12711696 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1277,14 +1702,12 @@
12771702 scrollpane.addMouseWheelListener(this); // Default not fast enough
12781703
12791704 /*JTabbedPane*/ scenePanel = new cGridBag();
1280
- scenePanel.preferredWidth = 6;
1705
+ scenePanel.preferredWidth = 5;
12811706
12821707 JTabbedPane tabbedPane = new JTabbedPane();
12831708 tabbedPane.add(scrollpane);
12841709
1285
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1286
-
1287
- optionsPanel = new cGridBag().setVertical(true);
1710
+ optionsPanel = new cGridBag().setVertical(false);
12881711
12891712 optionsPanel.setName("Options");
12901713
....@@ -1292,8 +1715,15 @@
12921715
12931716 tabbedPane.add(optionsPanel);
12941717
1718
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1719
+
12951720 scenePanel.add(tabbedPane);
12961721
1722
+ //if (Globals.ADVANCED)
1723
+// tabbedPane.add(infoPanel);
1724
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1725
+// tabbedPane.setToolTipTextAt(3, "Information");
1726
+
12971727 /*
12981728 cTree jTree = new cTree(null);
12991729 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1355,7 +1785,7 @@
13551785 bigThree = new cGridBag();
13561786 bigThree.addComponent(scenePanel);
13571787 bigThree.addComponent(centralPanel);
1358
- bigThree.addComponent(XYZPanel);
1788
+ //bigThree.addComponent(XYZPanel);
13591789
13601790 // // SIDE EFFECT!!!
13611791 // aConstraints.gridx = 0;
....@@ -1364,16 +1794,33 @@
13641794 // aConstraints.gridheight = 1;
13651795
13661796 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1367
- framePanel.setContinuousLayout(true);
1368
- framePanel.setOneTouchExpandable(true);
1369
- framePanel.setDividerLocation(0.8);
1797
+
1798
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1799
+ new java.beans.PropertyChangeListener()
1800
+ {
1801
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1802
+ {
1803
+ if ((Integer)pce.getOldValue() == 1)
1804
+ {
1805
+ if (radio.layout != expandedLayout)
1806
+ {
1807
+ radio.layout = expandedLayout;
1808
+ radio.layout.doClick();
1809
+ }
1810
+ }
1811
+ }
1812
+ });
1813
+
1814
+ framePanel.setContinuousLayout(false);
1815
+ framePanel.setOneTouchExpandable(false);
1816
+ //.setDividerLocation(0.8);
13701817 //framePanel.setDividerSize(15);
13711818 //framePanel.setResizeWeight(0.15);
13721819 framePanel.setName("Frame");
13731820
13741821 frame.getContentPane().setLayout(new BorderLayout());
13751822 /**/
1376
- JTabbedPane worldPane = new JTabbedPane();
1823
+ //JTabbedPane worldPane = new JTabbedPane();
13771824 //worldPane.add(bigPanel);
13781825 //worldPane.add(worldPanel);
13791826 /**/
....@@ -1384,14 +1831,18 @@
13841831 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13851832
13861833 frame.setSize(1280, 860);
1387
- frame.setVisible(true);
1388
-
1834
+
1835
+ cameraView.requestFocusInWindow();
1836
+
13891837 gridPanel.setDividerLocation(1.0);
1838
+
1839
+ frame.validate();
1840
+
1841
+ frame.setVisible(true);
13901842
13911843 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13921844 frame.addWindowListener(new WindowAdapter()
13931845 {
1394
-
13951846 public void windowClosing(WindowEvent e)
13961847 {
13971848 Close();
....@@ -1414,12 +1865,418 @@
14141865 ctrlPanel.removeAll();
14151866 }
14161867
1417
- void SetupMaterial(cGridBag panel)
1868
+ void SetupMaterial(cGridBag materialpanel)
14181869 {
1419
- /*
1870
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1871
+
1872
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1873
+ skin.setToolTipText("Skin");
1874
+ skin.addMouseListener(new MouseAdapter()
1875
+ {
1876
+ public void mouseClicked(MouseEvent e)
1877
+ {
1878
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1879
+ cMaterial material = object.material;
1880
+
1881
+ // Skin
1882
+ colorField.setFloat(material.color);
1883
+ saturationField.setFloat(material.modulation);
1884
+ subsurfaceField.setFloat(material.subsurface);
1885
+ selfshadowField.setFloat(material.diffuseness);
1886
+ diffusenessField.setFloat(material.factor);
1887
+ shininessField.setFloat(material.shininess);
1888
+ shadowbiasField.setFloat(material.shadowbias);
1889
+ diffuseField.setFloat(material.diffuse);
1890
+ specularField.setFloat(material.specular);
1891
+
1892
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1893
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1894
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1895
+
1896
+ materialtouched = true;
1897
+ applySelf();
1898
+ }
1899
+ });
1900
+ presetpanel.add(skin);
1901
+
1902
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1903
+ lambert.setToolTipText("Diffuse");
1904
+ lambert.addMouseListener(new MouseAdapter()
1905
+ {
1906
+ public void mouseClicked(MouseEvent e)
1907
+ {
1908
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1909
+ cMaterial material = object.material;
1910
+
1911
+ diffusenessField.setFloat(material.factor);
1912
+ selfshadowField.setFloat(material.diffuseness);
1913
+
1914
+ materialtouched = true;
1915
+ applySelf();
1916
+ }
1917
+ });
1918
+ presetpanel.add(lambert);
1919
+
1920
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1921
+ diffuse2.setToolTipText("Diffuse2");
1922
+ diffuse2.addMouseListener(new MouseAdapter()
1923
+ {
1924
+ public void mouseClicked(MouseEvent e)
1925
+ {
1926
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1927
+ cMaterial material = object.material;
1928
+
1929
+ diffusenessField.setFloat(material.factor);
1930
+ selfshadowField.setFloat(material.diffuseness);
1931
+
1932
+ materialtouched = true;
1933
+ applySelf();
1934
+ }
1935
+ });
1936
+ presetpanel.add(diffuse2);
1937
+
1938
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1939
+ diffusemoon.setToolTipText("Moon");
1940
+ diffusemoon.addMouseListener(new MouseAdapter()
1941
+ {
1942
+ public void mouseClicked(MouseEvent e)
1943
+ {
1944
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1945
+ cMaterial material = object.material;
1946
+
1947
+ diffusenessField.setFloat(material.factor);
1948
+ selfshadowField.setFloat(material.diffuseness);
1949
+
1950
+ materialtouched = true;
1951
+ applySelf();
1952
+ }
1953
+ });
1954
+ presetpanel.add(diffusemoon);
1955
+
1956
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1957
+ diffusemoon2.setToolTipText("Moon2");
1958
+ diffusemoon2.addMouseListener(new MouseAdapter()
1959
+ {
1960
+ public void mouseClicked(MouseEvent e)
1961
+ {
1962
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1963
+ cMaterial material = object.material;
1964
+
1965
+ diffusenessField.setFloat(material.factor);
1966
+ selfshadowField.setFloat(material.diffuseness);
1967
+
1968
+ materialtouched = true;
1969
+ applySelf();
1970
+ }
1971
+ });
1972
+ presetpanel.add(diffusemoon2);
1973
+
1974
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1975
+ diffusemoon3.setToolTipText("Moon3");
1976
+ diffusemoon3.addMouseListener(new MouseAdapter()
1977
+ {
1978
+ public void mouseClicked(MouseEvent e)
1979
+ {
1980
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1981
+ cMaterial material = object.material;
1982
+
1983
+ diffusenessField.setFloat(material.factor);
1984
+ selfshadowField.setFloat(material.diffuseness);
1985
+
1986
+ materialtouched = true;
1987
+ applySelf();
1988
+ }
1989
+ });
1990
+ presetpanel.add(diffusemoon3);
1991
+
1992
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1993
+ diffusesheen.setToolTipText("Sheen");
1994
+ diffusesheen.addMouseListener(new MouseAdapter()
1995
+ {
1996
+ public void mouseClicked(MouseEvent e)
1997
+ {
1998
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1999
+ cMaterial material = object.material;
2000
+
2001
+ sheenField.setFloat(material.sheen);
2002
+
2003
+ materialtouched = true;
2004
+ applySelf();
2005
+ }
2006
+ });
2007
+ presetpanel.add(diffusesheen);
2008
+
2009
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2010
+ rough.setToolTipText("Rough metal");
2011
+ rough.addMouseListener(new MouseAdapter()
2012
+ {
2013
+ public void mouseClicked(MouseEvent e)
2014
+ {
2015
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2016
+ cMaterial material = object.material;
2017
+
2018
+ shininessField.setFloat(material.shininess);
2019
+ velvetField.setFloat(material.velvet);
2020
+
2021
+ materialtouched = true;
2022
+ applySelf();
2023
+ }
2024
+ });
2025
+ presetpanel.add(rough);
2026
+
2027
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2028
+ rough2.setToolTipText("Medium metal");
2029
+ rough2.addMouseListener(new MouseAdapter()
2030
+ {
2031
+ public void mouseClicked(MouseEvent e)
2032
+ {
2033
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2034
+ cMaterial material = object.material;
2035
+
2036
+ shininessField.setFloat(material.shininess);
2037
+ lightareaField.setFloat(material.lightarea);
2038
+
2039
+ materialtouched = true;
2040
+ applySelf();
2041
+ }
2042
+ });
2043
+ presetpanel.add(rough2);
2044
+
2045
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2046
+ shini0.setToolTipText("Shiny");
2047
+ shini0.addMouseListener(new MouseAdapter()
2048
+ {
2049
+ public void mouseClicked(MouseEvent e)
2050
+ {
2051
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2052
+ cMaterial material = object.material;
2053
+
2054
+ shininessField.setFloat(material.shininess);
2055
+ lightareaField.setFloat(material.lightarea);
2056
+
2057
+ materialtouched = true;
2058
+ applySelf();
2059
+ }
2060
+ });
2061
+ presetpanel.add(shini0);
2062
+
2063
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2064
+ shini1.setToolTipText("Shiny2");
2065
+ shini1.addMouseListener(new MouseAdapter()
2066
+ {
2067
+ public void mouseClicked(MouseEvent e)
2068
+ {
2069
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2070
+ cMaterial material = object.material;
2071
+
2072
+ shininessField.setFloat(material.shininess);
2073
+ lightareaField.setFloat(material.lightarea);
2074
+
2075
+ materialtouched = true;
2076
+ applySelf();
2077
+ }
2078
+ });
2079
+ presetpanel.add(shini1);
2080
+
2081
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2082
+ shini2.setToolTipText("Shiny3");
2083
+ shini2.addMouseListener(new MouseAdapter()
2084
+ {
2085
+ public void mouseClicked(MouseEvent e)
2086
+ {
2087
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2088
+ cMaterial material = object.material;
2089
+
2090
+ shininessField.setFloat(material.shininess);
2091
+ lightareaField.setFloat(material.lightarea);
2092
+
2093
+ materialtouched = true;
2094
+ applySelf();
2095
+ }
2096
+ });
2097
+ presetpanel.add(shini2);
2098
+
2099
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2100
+ aniso.setToolTipText("AnisoU");
2101
+ aniso.addMouseListener(new MouseAdapter()
2102
+ {
2103
+ public void mouseClicked(MouseEvent e)
2104
+ {
2105
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2106
+ cMaterial material = object.material;
2107
+
2108
+ anisoField.setFloat(material.aniso);
2109
+ anisoVField.setFloat(material.anisoV);
2110
+
2111
+ materialtouched = true;
2112
+ applySelf();
2113
+ }
2114
+ });
2115
+ presetpanel.add(aniso);
2116
+
2117
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2118
+ aniso2.setToolTipText("AnisoV");
2119
+ aniso2.addMouseListener(new MouseAdapter()
2120
+ {
2121
+ public void mouseClicked(MouseEvent e)
2122
+ {
2123
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2124
+ cMaterial material = object.material;
2125
+
2126
+ anisoField.setFloat(material.aniso);
2127
+ anisoVField.setFloat(material.anisoV);
2128
+
2129
+ materialtouched = true;
2130
+ applySelf();
2131
+ }
2132
+ });
2133
+ presetpanel.add(aniso2);
2134
+
2135
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2136
+ aniso3.setToolTipText("AnisoUV");
2137
+ aniso3.addMouseListener(new MouseAdapter()
2138
+ {
2139
+ public void mouseClicked(MouseEvent e)
2140
+ {
2141
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2142
+ cMaterial material = object.material;
2143
+
2144
+ anisoField.setFloat(material.aniso);
2145
+ anisoVField.setFloat(material.anisoV);
2146
+
2147
+ materialtouched = true;
2148
+ applySelf();
2149
+ }
2150
+ });
2151
+ presetpanel.add(aniso3);
2152
+
2153
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2154
+ velvet0.setToolTipText("Velvet");
2155
+ velvet0.addMouseListener(new MouseAdapter()
2156
+ {
2157
+ public void mouseClicked(MouseEvent e)
2158
+ {
2159
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2160
+ cMaterial material = object.material;
2161
+
2162
+ diffusenessField.setFloat(material.factor);
2163
+ selfshadowField.setFloat(material.diffuseness);
2164
+ sheenField.setFloat(material.sheen);
2165
+ shininessField.setFloat(material.shininess);
2166
+ velvetField.setFloat(material.velvet);
2167
+ shiftField.setFloat(material.shift);
2168
+
2169
+ materialtouched = true;
2170
+ applySelf();
2171
+ }
2172
+ });
2173
+ presetpanel.add(velvet0);
2174
+
2175
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2176
+ bump0.setToolTipText("Bump texture");
2177
+ bump0.addMouseListener(new MouseAdapter()
2178
+ {
2179
+ public void mouseClicked(MouseEvent e)
2180
+ {
2181
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2182
+ cMaterial material = object.material;
2183
+
2184
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2185
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2186
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2187
+
2188
+ materialtouched = true;
2189
+ applySelf();
2190
+ }
2191
+ });
2192
+ presetpanel.add(bump0);
2193
+
2194
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2195
+ borderShader.setToolTipText("Border fade");
2196
+ borderShader.addMouseListener(new MouseAdapter()
2197
+ {
2198
+ public void mouseClicked(MouseEvent e)
2199
+ {
2200
+ borderfadeField.setFloat(0.5);
2201
+ opacityField.setFloat(0.75);
2202
+
2203
+ materialtouched = true;
2204
+ applySelf();
2205
+ }
2206
+ });
2207
+ presetpanel.add(borderShader);
2208
+
2209
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2210
+ halo.setToolTipText("Halo");
2211
+ halo.addMouseListener(new MouseAdapter()
2212
+ {
2213
+ public void mouseClicked(MouseEvent e)
2214
+ {
2215
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2216
+ cMaterial material = object.material;
2217
+
2218
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2219
+
2220
+ materialtouched = true;
2221
+ applySelf();
2222
+ }
2223
+ });
2224
+ presetpanel.add(halo);
2225
+
2226
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2227
+ candle.setToolTipText("Candle");
2228
+ candle.addMouseListener(new MouseAdapter()
2229
+ {
2230
+ public void mouseClicked(MouseEvent e)
2231
+ {
2232
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2233
+ cMaterial material = object.material;
2234
+
2235
+ subsurfaceField.setFloat(material.subsurface);
2236
+ shadowbiasField.setFloat(material.shadowbias);
2237
+ ambientField.setFloat(material.ambient);
2238
+ specularField.setFloat(material.specular);
2239
+ lightareaField.setFloat(material.lightarea);
2240
+ shininessField.setFloat(material.shininess);
2241
+
2242
+ materialtouched = true;
2243
+ applySelf();
2244
+ }
2245
+ });
2246
+ presetpanel.add(candle);
2247
+
2248
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2249
+ shadowShader.setToolTipText("Shadow");
2250
+ shadowShader.addMouseListener(new MouseAdapter()
2251
+ {
2252
+ public void mouseClicked(MouseEvent e)
2253
+ {
2254
+ diffuseField.setFloat(0.001);
2255
+ ambientField.setFloat(0.001);
2256
+ cameraField.setFloat(0.001);
2257
+ specularField.setFloat(0.001);
2258
+ fakedepthField.setFloat(0.001);
2259
+ opacityField.setFloat(0.6);
2260
+
2261
+ materialtouched = true;
2262
+ applySelf();
2263
+ }
2264
+ });
2265
+ presetpanel.add(shadowShader);
2266
+
2267
+ cGridBag panel = new cGridBag().setVertical(true);
2268
+
2269
+ presetpanel.preferredWidth = 1;
2270
+
2271
+ materialpanel.add(presetpanel);
2272
+ materialpanel.add(panel);
2273
+
2274
+ panel.preferredWidth = 8;
2275
+
2276
+ /*
14202277 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14212278 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1422
- */
2279
+ */
14232280
14242281 cGridBag editBar = new cGridBag().setVertical(false);
14252282
....@@ -1453,45 +2310,61 @@
14532310 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14542311
14552312 cGridBag colorSection = new cGridBag().setVertical(true);
2313
+
2314
+ cGridBag huepanel = new cGridBag();
2315
+ cGridBag huelabel = new cGridBag();
2316
+ cLabel hue = GetLabel("icons/hue.png", false);
2317
+ hue.fit = true;
2318
+
2319
+ hue.addMouseListener(new MouseAdapter()
2320
+ {
2321
+ public void mousePressed(MouseEvent e)
2322
+ {
2323
+ int x = e.getX();
2324
+
2325
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2326
+ }
2327
+ });
2328
+
2329
+ huelabel.add(hue);
2330
+ huelabel.preferredWidth = 20;
2331
+ huepanel.add(new cGridBag()); // Label
2332
+ huepanel.add(huelabel); // Field/slider
2333
+
2334
+ huepanel.preferredHeight = 7;
2335
+
2336
+ colorSection.add(huepanel);
14562337
14572338 cGridBag color = new cGridBag();
1458
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1459
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1460
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2339
+
2340
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2341
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2342
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2343
+
14612344 //colorField.preferredWidth = 200;
14622345 colorSection.add(color);
14632346
14642347 cGridBag modulation = new cGridBag();
14652348 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14662349 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1467
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2350
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14682351 colorSection.add(modulation);
14692352
2353
+ cGridBag opacity = new cGridBag();
2354
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2355
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2356
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2357
+ colorSection.add(opacity);
2358
+
2359
+ colorSection.add(GetSeparator());
2360
+
14702361 cGridBag texture = new cGridBag();
14712362 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14722363 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14732364 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14742365 colorSection.add(texture);
14752366
1476
- cGridBag anisoU = new cGridBag();
1477
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1478
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1479
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1480
- colorSection.add(anisoU);
1481
-
1482
- cGridBag anisoV = new cGridBag();
1483
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1484
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1485
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1486
- colorSection.add(anisoV);
1487
-
1488
- cGridBag shadowbias = new cGridBag();
1489
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1490
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1491
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1492
- colorSection.add(shadowbias);
1493
-
1494
- panel.add(new JSeparator());
2367
+ panel.add(GetSeparator());
14952368
14962369 panel.add(colorSection);
14972370
....@@ -1541,7 +2414,13 @@
15412414 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15422415 diffuseSection.add(fakedepth);
15432416
1544
- panel.add(new JSeparator());
2417
+ cGridBag shadowbias = new cGridBag();
2418
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2419
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2420
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2421
+ diffuseSection.add(shadowbias);
2422
+
2423
+ panel.add(GetSeparator());
15452424
15462425 panel.add(diffuseSection);
15472426
....@@ -1591,42 +2470,48 @@
15912470 // aConstraints.gridy += 1;
15922471 // aConstraints.gridwidth = 1;
15932472
2473
+ cGridBag anisoU = new cGridBag();
2474
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2475
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2476
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2477
+ specularSection.add(anisoU);
15942478
1595
- panel.add(new JSeparator());
2479
+ cGridBag anisoV = new cGridBag();
2480
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2481
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2482
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2483
+ specularSection.add(anisoV);
2484
+
2485
+
2486
+ panel.add(GetSeparator());
15962487
15972488 panel.add(specularSection);
15982489
15992490 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16002491
1601
- cGridBag globalSection = new cGridBag().setVertical(true);
2492
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16022493
16032494 cGridBag camera = new cGridBag();
16042495 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16052496 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16062497 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1607
- globalSection.add(camera);
2498
+ colorSection.add(camera);
16082499
16092500 cGridBag ambient = new cGridBag();
16102501 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16112502 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16122503 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(ambient);
2504
+ colorSection.add(ambient);
16142505
16152506 cGridBag backlit = new cGridBag();
16162507 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16172508 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16182509 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(backlit);
2510
+ colorSection.add(backlit);
16202511
1621
- cGridBag opacity = new cGridBag();
1622
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1623
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1624
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1625
- globalSection.add(opacity);
1626
-
1627
- panel.add(new JSeparator());
2512
+ //panel.add(new JSeparator());
16282513
1629
- panel.add(globalSection);
2514
+ //panel.add(globalSection);
16302515
16312516 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16322517
....@@ -1668,7 +2553,7 @@
16682553 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16692554 textureSection.add(opacityPower);
16702555
1671
- panel.add(new JSeparator());
2556
+ panel.add(GetSeparator());
16722557
16732558 panel.add(textureSection);
16742559
....@@ -1733,8 +2618,9 @@
17332618 // 3D models
17342619 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17352620 {
1736
- lastConverter = new com.jmex.model.converters.MaxToJme();
1737
- LoadFile(filename, lastConverter);
2621
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2622
+ //LoadFile(filename, lastConverter);
2623
+ LoadObjFile(filename); // New 3ds loader
17382624 continue;
17392625 }
17402626 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2460,6 +3346,7 @@
24603346 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24613347 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24623348 }
3349
+
24633350 //cJME.count++;
24643351 //cJME.count %= 12;
24653352 if (gc)
....@@ -2643,6 +3530,7 @@
26433530 }
26443531 }
26453532 }
3533
+
26463534 cFileSystemPane FSPane;
26473535
26483536 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2652,7 +3540,7 @@
26523540
26533541 freezematerial = true;
26543542 colorField.setFloat(mat.color);
2655
- modulationField.setFloat(mat.modulation);
3543
+ saturationField.setFloat(mat.modulation);
26563544 metalnessField.setFloat(mat.metalness);
26573545 diffuseField.setFloat(mat.diffuse);
26583546 specularField.setFloat(mat.specular);
....@@ -2696,11 +3584,14 @@
26963584 }
26973585 }
26983586 }
3587
+
26993588 freezematerial = false;
27003589 }
27013590
27023591 void SetMaterial(Object3D object)
27033592 {
3593
+ latestObject = object;
3594
+
27043595 cMaterial mat = object.material;
27053596
27063597 if (mat == null)
....@@ -2711,32 +3602,8 @@
27113602
27123603 if (multiplyToggle != null)
27133604 multiplyToggle.setSelected(mat.multiply);
2714
-
2715
- assert (object.projectedVertices != null);
2716
-
2717
- if (object.projectedVertices.length <= 2)
2718
- {
2719
- // Side effect...
2720
- Object3D.cVector2[] keep = object.projectedVertices;
2721
- object.projectedVertices = new Object3D.cVector2[3];
2722
- for (int i = 0; i < 3; i++)
2723
- {
2724
- if (i < keep.length)
2725
- {
2726
- object.projectedVertices[i] = keep[i];
2727
- } else
2728
- {
2729
- object.projectedVertices[i] = new Object3D.cVector2();
2730
- }
2731
- /*
2732
- if(keep.length == 0)
2733
- object.projectedVertices[0] = new Object3D.cVector2();
2734
- else
2735
- object.projectedVertices[0] = keep[0];
2736
- object.projectedVertices[1] = new Object3D.cVector2();
2737
- */
2738
- }
2739
- }
3605
+
3606
+ AllocProjectedVertices(object);
27403607
27413608 SetMaterial(mat, object.projectedVertices);
27423609 }
....@@ -2812,12 +3679,17 @@
28123679 // }
28133680
28143681 /**/
2815
- if (deselect)
3682
+ if (deselect || child == null)
28163683 {
28173684 //group.deselectAll();
28183685 //freeze = true;
28193686 GetTree().clearSelection();
28203687 //freeze = false;
3688
+
3689
+ if (child == null)
3690
+ {
3691
+ return;
3692
+ }
28213693 }
28223694
28233695 //group.addSelectee(child);
....@@ -2851,6 +3723,17 @@
28513723 public void itemStateChanged(ItemEvent event)
28523724 {
28533725 // System.out.println("Propagate = " + propagate);
3726
+ if (event.getSource() == pinButton)
3727
+ {
3728
+ copy.pinned ^= true;
3729
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3730
+ {
3731
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3732
+ copy.CloseUI();
3733
+ //copy.editWindow.refreshContents();
3734
+ }
3735
+ }
3736
+ else
28543737 if (event.getSource() == propagateToggle)
28553738 {
28563739 propagate ^= true;
....@@ -2886,7 +3769,7 @@
28863769 cameraView.ToggleDL();
28873770 cameraView.repaint();
28883771 return;
2889
- } else if (event.getSource() == toggleTextureItem)
3772
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28903773 {
28913774 cameraView.ToggleTexture();
28923775 // june 2013 copy.HardTouch();
....@@ -2925,7 +3808,7 @@
29253808 frame.validate();
29263809
29273810 return;
2928
- } else if (event.getSource() == toggleSwitchItem)
3811
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29293812 {
29303813 cameraView.ToggleSwitch();
29313814 cameraView.repaint();
....@@ -2955,8 +3838,9 @@
29553838 } else if (event.getSource() == liveCB)
29563839 {
29573840 copy.live ^= true;
3841
+ objEditor.refreshContents(true); // To show item colors
29583842 return;
2959
- } else if (event.getSource() == selectCB)
3843
+ } else if (event.getSource() == selectableCB)
29603844 {
29613845 copy.dontselect ^= true;
29623846 return;
....@@ -2964,7 +3848,7 @@
29643848 {
29653849 copy.hide ^= true;
29663850 copy.Touch(); // display list issue
2967
- objEditor.refreshContents();
3851
+ objEditor.refreshContents(true); // To show item colors
29683852 return;
29693853 } else if (event.getSource() == link2masterCB)
29703854 {
....@@ -3141,9 +4025,9 @@
31414025 {
31424026 Close();
31434027 //return true;
3144
- } else if (source == loadItem)
4028
+ } else if (source == openItem)
31454029 {
3146
- load();
4030
+ Open();
31474031 //return true;
31484032 } else if (source == newItem)
31494033 {
....@@ -3168,6 +4052,10 @@
31684052 {
31694053 generatePOV();
31704054 //return true;
4055
+ } else if (event.getSource() == archiveItem)
4056
+ {
4057
+ cTools.Archive(frame);
4058
+ return;
31714059 } else if (source == zBufferItem)
31724060 {
31734061 try
....@@ -3216,11 +4104,12 @@
32164104
32174105 static public byte[] Compress(Object3D o)
32184106 {
4107
+ // Slower to actually compress.
32194108 try
32204109 {
32214110 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3222
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3223
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4111
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4112
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
32244113
32254114 Object3D parent = o.parent;
32264115 o.parent = null;
....@@ -3231,10 +4120,14 @@
32314120
32324121 out.flush();
32334122
3234
- zstream.close();
4123
+ baos //zstream
4124
+ .close();
32354125 out.close();
32364126
3237
- return baos.toByteArray();
4127
+ byte[] bytes = baos.toByteArray();
4128
+
4129
+ System.out.println("save #bytes = " + bytes.length);
4130
+ return bytes;
32384131 } catch (Exception e)
32394132 {
32404133 System.err.println(e);
....@@ -3244,13 +4137,16 @@
32444137
32454138 static public Object Uncompress(byte[] bytes)
32464139 {
3247
- System.out.println("#bytes = " + bytes.length);
4140
+ System.out.println("restore #bytes = " + bytes.length);
32484141 try
32494142 {
32504143 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3251
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3252
- ObjectInputStream in = new ObjectInputStream(istream);
4144
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4145
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
32534146 Object obj = in.readObject();
4147
+
4148
+ bais //istream
4149
+ .close();
32544150 in.close();
32554151
32564152 return obj;
....@@ -3305,37 +4201,95 @@
33054201 return null;
33064202 }
33074203
3308
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
33094204
33104205 public void Save()
33114206 {
3312
- cRadio tab = GetCurrentTab();
4207
+ //Save(true);
4208
+ Replace();
4209
+ SetVersionStates();
4210
+ }
4211
+
4212
+ private boolean Equal(byte[] compress, byte[] name)
4213
+ {
4214
+ if (compress.length != name.length)
4215
+ {
4216
+ return false;
4217
+ }
33134218
3314
- boolean temp = CameraPane.SWITCH;
3315
- CameraPane.SWITCH = false;
4219
+ for (int i=compress.length; --i>=0;)
4220
+ {
4221
+ if (compress[i] != name[i])
4222
+ return false;
4223
+ }
33164224
3317
- copy.ExtractBigData(hashtable);
4225
+ return true;
4226
+ }
4227
+
4228
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4229
+
4230
+ void DeleteVersion()
4231
+ {
4232
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4233
+ {
4234
+ copy.versionlist[i] = copy.versionlist[i+1];
4235
+ }
4236
+
4237
+ CopyChanged();
4238
+
4239
+ SetVersionStates();
4240
+ }
4241
+
4242
+ public boolean Save(boolean user)
4243
+ {
4244
+ System.err.println("Save");
4245
+ Replace();
4246
+
4247
+ //cRadio tab = GetCurrentTab();
4248
+
4249
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
4250
+
4251
+ boolean thesame = false;
4252
+
4253
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4254
+// {
4255
+// thesame = true;
4256
+// }
33184257
33194258 //EditorFrame.m_MainFrame.requestFocusInWindow();
3320
- tab.graphs[tab.undoindex++] = Compress(copy);
3321
-
3322
- copy.RestoreBigData(hashtable);
3323
-
3324
- CameraPane.SWITCH = temp;
3325
-
3326
- //assert(hashtable.isEmpty());
3327
-
3328
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
4259
+ if (!thesame)
33294260 {
3330
- tab.graphs[i] = null;
4261
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4262
+ {
4263
+ copy.versionlist[i] = copy.versionlist[i-1];
4264
+ }
4265
+
4266
+ //tab.user[tab.versionindex] = user;
4267
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4268
+
4269
+ copy.versionlist[++copy.versionindex] = compress;
4270
+
4271
+ // if (increment)
4272
+ // tab.versionindex++;
33314273 }
33324274
4275
+ //copy.RestoreBigData(versiontable);
4276
+
4277
+ //assert(hashtable.isEmpty());
4278
+
4279
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4280
+// {
4281
+// //tab.user[i] = false;
4282
+// copy.versionlist[i] = null;
4283
+// }
4284
+
4285
+ SetVersionStates();
4286
+
33334287 // test save
33344288 if (false)
33354289 {
33364290 try
33374291 {
3338
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4292
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
33394293 ObjectOutputStream p = new ObjectOutputStream(ostream);
33404294
33414295 p.writeObject(copy);
....@@ -3348,26 +4302,68 @@
33484302 e.printStackTrace();
33494303 }
33504304 }
4305
+
4306
+ return !thesame;
4307
+ }
4308
+
4309
+ boolean flashIt = true;
4310
+
4311
+ void RefreshSelection()
4312
+ {
4313
+ Object3D selection = new Object3D();
4314
+
4315
+ for (int i = 0; i < copy.selection.size(); i++)
4316
+ {
4317
+ Object3D elem = copy.selection.elementAt(i);
4318
+
4319
+ Object3D obj = copy.GetObject(elem.GetUUID());
4320
+
4321
+ if (obj == null)
4322
+ {
4323
+ copy.selection.remove(i--);
4324
+ }
4325
+ else
4326
+ {
4327
+ selection.add(obj);
4328
+ copy.selection.setElementAt(obj, i);
4329
+ }
4330
+ }
4331
+
4332
+ flashIt = false;
4333
+ GetTree().clearSelection();
4334
+ for (int i = 0; i < selection.size(); i++)
4335
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4336
+ flashIt = true;
4337
+
4338
+ //refreshContents(false);
33514339 }
33524340
3353
- void CopyChanged(Object3D obj)
4341
+ void CopyChanged()
33544342 {
4343
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4344
+
4345
+ SetVersionStates();
4346
+
33554347 boolean temp = CameraPane.SWITCH;
33564348 CameraPane.SWITCH = false;
33574349
3358
- copy.ExtractBigData(hashtable);
4350
+ copy.ExtractBigData(versiontable);
33594351
33604352 copy.clear();
33614353
4354
+ copy.skyboxname = obj.skyboxname;
4355
+ copy.skyboxext = obj.skyboxext;
4356
+
33624357 for (int i=0; i<obj.Size(); i++)
33634358 {
33644359 copy.add(obj.get(i));
33654360 }
33664361
3367
- copy.RestoreBigData(hashtable);
4362
+ copy.RestoreBigData(versiontable);
33684363
33694364 CameraPane.SWITCH = temp;
33704365
4366
+ RefreshSelection();
33714367 //assert(hashtable.isEmpty());
33724368
33734369 copy.Touch();
....@@ -3388,43 +4384,144 @@
33884384 }
33894385 }
33904386
3391
- refreshContents();
4387
+ refreshContents(true);
33924388 }
33934389
3394
- public void Undo()
3395
- {
3396
- cRadio tab = GetCurrentTab();
4390
+ cButton previousVersionButton;
4391
+ cButton restoreButton;
4392
+ cButton replaceButton;
4393
+ cButton nextVersionButton;
4394
+ cButton saveVersionButton;
4395
+ cButton deleteVersionButton;
33974396
3398
- if (tab.undoindex == 0)
4397
+ boolean muteSlider;
4398
+
4399
+ int VersionCount()
4400
+ {
4401
+ int count = 0;
4402
+
4403
+ for (int i = copy.versionlist.length; --i >= 0;)
4404
+ {
4405
+ if (copy.versionlist[i] != null)
4406
+ count++;
4407
+ }
4408
+
4409
+ return count;
4410
+ }
4411
+
4412
+ void SetVersionStates()
4413
+ {
4414
+ //if (true)
4415
+ // return;
4416
+
4417
+ //cRadio tab = GetCurrentTab();
4418
+
4419
+ restoreButton.setEnabled(copy.versionindex != -1);
4420
+ replaceButton.setEnabled(copy.versionindex != -1);
4421
+
4422
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4423
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4424
+
4425
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4426
+ copy.versionlist[copy.versionindex + 1] != null);
4427
+
4428
+ muteSlider = true;
4429
+ versionSlider.setMinimum(0);
4430
+ versionSlider.setMaximum(VersionCount() - 1);
4431
+ versionSlider.setInteger(copy.versionindex);
4432
+ versionSlider.setEnabled(copy.versionindex != -1);
4433
+ muteSlider = false;
4434
+ }
4435
+
4436
+ public boolean PreviousVersion()
4437
+ {
4438
+ // Option?
4439
+ Replace();
4440
+
4441
+ System.err.println("Undo");
4442
+
4443
+ //cRadio tab = GetCurrentTab();
4444
+
4445
+ if (copy.versionindex == 0)
33994446 {
34004447 java.awt.Toolkit.getDefaultToolkit().beep();
3401
- return;
4448
+ return false;
34024449 }
34034450
3404
- if (tab.graphs[tab.undoindex] == null)
3405
- {
3406
- Save();
3407
- tab.undoindex -= 1;
3408
- }
4451
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4452
+// {
4453
+// if (Save(false))
4454
+// tab.versionindex -= 1;
4455
+// else
4456
+// {
4457
+// if (tab.versionindex <= 0)
4458
+// return false;
4459
+// else
4460
+// tab.versionindex -= 1;
4461
+// }
4462
+// }
34094463
3410
- tab.undoindex -= 1;
4464
+ copy.versionindex -= 1;
34114465
3412
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4466
+ CopyChanged();
4467
+
4468
+ return true;
34134469 }
34144470
3415
- public void Redo()
4471
+ public boolean Restore()
34164472 {
3417
- cRadio tab = GetCurrentTab();
4473
+ System.err.println("Restore");
34184474
3419
- if (tab.graphs[tab.undoindex + 1] == null)
4475
+ //cRadio tab = GetCurrentTab();
4476
+
4477
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4478
+ {
4479
+ java.awt.Toolkit.getDefaultToolkit().beep();
4480
+ return false;
4481
+ }
4482
+
4483
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4484
+ CopyChanged();
4485
+
4486
+ return true;
4487
+ }
4488
+
4489
+ public boolean Replace()
4490
+ {
4491
+ System.err.println("Replace");
4492
+
4493
+ //cRadio tab = GetCurrentTab();
4494
+
4495
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4496
+ {
4497
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4498
+ return false;
4499
+ }
4500
+
4501
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4502
+
4503
+ return true;
4504
+ }
4505
+
4506
+ public void NextVersion()
4507
+ {
4508
+ // Option?
4509
+ Replace();
4510
+
4511
+ //cRadio tab = GetCurrentTab();
4512
+
4513
+ if (copy.versionlist[copy.versionindex + 1] == null)
34204514 {
34214515 java.awt.Toolkit.getDefaultToolkit().beep();
34224516 return;
34234517 }
34244518
3425
- tab.undoindex += 1;
4519
+ copy.versionindex += 1;
34264520
3427
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4521
+ CopyChanged();
4522
+
4523
+ //if (!tab.user[tab.versionindex])
4524
+ // tab.graphs[tab.versionindex] = null;
34284525 }
34294526
34304527 void ImportGFD()
....@@ -3576,7 +4673,7 @@
35764673 assert false;
35774674 }
35784675
3579
- void EditSelection()
4676
+ void EditSelection(boolean newWindow)
35804677 {
35814678 }
35824679
....@@ -3635,7 +4732,7 @@
36354732 //copy.material = new cMaterial(copy.GetMaterial());
36364733
36374734 current.color = (float) colorField.getFloat();
3638
- current.modulation = (float) modulationField.getFloat();
4735
+ current.modulation = (float) saturationField.getFloat();
36394736 current.metalness = (float) metalnessField.getFloat();
36404737 current.diffuse = (float) diffuseField.getFloat();
36414738 current.specular = (float) specularField.getFloat();
....@@ -3668,7 +4765,7 @@
36684765 cMaterial mat = copy.material;
36694766
36704767 colorField.SetToolTipValue((mat.color));
3671
- modulationField.SetToolTipValue((mat.modulation));
4768
+ saturationField.SetToolTipValue((mat.modulation));
36724769 metalnessField.SetToolTipValue((mat.metalness));
36734770 diffuseField.SetToolTipValue((mat.diffuse));
36744771 specularField.SetToolTipValue((mat.specular));
....@@ -3720,9 +4817,28 @@
37204817 //copy.Touch();
37214818 }
37224819
4820
+ cNumberSlider versionSlider;
4821
+
37234822 public void stateChanged(ChangeEvent e)
37244823 {
37254824 // assert(false);
4825
+ if (e.getSource() == versionSlider)
4826
+ {
4827
+ if (muteSlider)
4828
+ return;
4829
+
4830
+ Replace();
4831
+
4832
+ int version = versionSlider.getInteger();
4833
+
4834
+ if (version != -1 && copy.versionlist[version] != null)
4835
+ {
4836
+ copy.versionindex = version;
4837
+ CopyChanged();
4838
+ }
4839
+
4840
+ return;
4841
+ }
37264842
37274843 if (freezematerial)
37284844 {
....@@ -3758,6 +4874,12 @@
37584874 {
37594875 //System.out.println("stateChanged = " + this);
37604876 materialtouched = true;
4877
+
4878
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4879
+ {
4880
+ saturationField.setFloat(1);
4881
+ }
4882
+
37614883 applySelf();
37624884 //System.out.println("this = " + this);
37634885 //System.out.println("PARENT = " + parent);
....@@ -4057,6 +5179,7 @@
40575179 {
40585180 if (GetTree() != null)
40595181 {
5182
+ GetTree().revalidate();
40605183 GetTree().repaint();
40615184 }
40625185
....@@ -4065,13 +5188,19 @@
40655188 ctrlPanel.validate(); // ? new
40665189 ctrlPanel.repaint();
40675190 }
5191
+
5192
+ if (previousVersionButton != null && copy.versionlist != null)
5193
+ SetVersionStates();
5194
+
5195
+ cameraView.requestFocusInWindow();
40685196 }
40695197
40705198 static TweenManager tweenManager = new TweenManager();
40715199
40725200 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
40735201 {
4074
- Save();
5202
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5203
+ Save();
40755204 //Tween.set(thing, 0).target(1).start(tweenManager);
40765205 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
40775206 // if (thing instanceof GenericJointDemo)
....@@ -4095,7 +5224,7 @@
40955224 // group = (Composite) group.get(0);
40965225 // }
40975226
4098
- System.out.println("makeSomething of " + thing);
5227
+ //System.out.println("makeSomething of " + thing);
40995228
41005229 /*
41015230 if (deselect && jList != null)
....@@ -4158,6 +5287,12 @@
41585287 {
41595288 ResetModel();
41605289 Select(thing.GetTreePath(), true, false); // unselect... false);
5290
+
5291
+ if (thing.Size() == 0)
5292
+ {
5293
+ //EditSelection(false);
5294
+ }
5295
+
41615296 refreshContents();
41625297 }
41635298
....@@ -4306,7 +5441,9 @@
43065441 readobj.ResetDisplayList();
43075442 } catch (Exception e)
43085443 {
4309
- //e.printStackTrace();
5444
+ if (!e.toString().contains("GZIP"))
5445
+ e.printStackTrace();
5446
+
43105447 try
43115448 {
43125449 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4380,11 +5517,14 @@
43805517
43815518 if (readobj != null)
43825519 {
4383
- Save();
5520
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5521
+ // Save();
43845522 try
43855523 {
43865524 //readobj.deepCopySelf(copy);
43875525 copy.clear(); // june 2014
5526
+ copy.skyboxname = readobj.skyboxname;
5527
+ copy.skyboxext = readobj.skyboxext;
43885528 for (int i = 0; i < readobj.size(); i++)
43895529 {
43905530 Object3D child = readobj.get(i); // reserve(i);
....@@ -4425,6 +5565,7 @@
44255565 }
44265566 } catch (ClassCastException e)
44275567 {
5568
+ e.printStackTrace();
44285569 assert (false);
44295570 Composite c = (Composite) copy;
44305571 c.children.clear();
....@@ -4435,17 +5576,31 @@
44355576 c.addChild(csg);
44365577 }
44375578
5579
+ copy.versionlist = readobj.versionlist;
5580
+ copy.versionindex = readobj.versionindex;
5581
+
5582
+ if (copy.versionlist == null)
5583
+ {
5584
+ // Backward compatibility
5585
+ copy.versionlist = new Object3D[100];
5586
+ copy.versionindex = -1;
5587
+
5588
+ //Save(true);
5589
+ }
5590
+
5591
+ //? SetUndoStates();
5592
+
44385593 ResetModel();
44395594 copy.HardTouch(); // recompile?
44405595 refreshContents();
44415596 }
44425597 }
44435598
4444
- void load() // throws ClassNotFoundException
5599
+ void Open() // throws ClassNotFoundException
44455600 {
44465601 if (Grafreed.standAlone)
44475602 {
4448
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5603
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
44495604 browser.show();
44505605 String filename = browser.getFile();
44515606 if (filename != null && filename.length() > 0)
....@@ -4522,6 +5677,8 @@
45225677
45235678 void save()
45245679 {
5680
+ Replace();
5681
+
45255682 if (lastname == null)
45265683 {
45275684 return;
....@@ -4544,6 +5701,7 @@
45445701 //ps.print(buffer.toString());
45455702 } catch (IOException e)
45465703 {
5704
+ e.printStackTrace();
45475705 }
45485706 }
45495707
....@@ -4558,6 +5716,8 @@
45585716 String filename = browser.getFile();
45595717 if (filename != null && filename.length() > 0)
45605718 {
5719
+ if (!filename.endsWith(".gfd"))
5720
+ filename += ".gfd";
45615721 lastname = browser.getDirectory() + filename;
45625722 save();
45635723 }
....@@ -4724,7 +5884,7 @@
47245884 MenuBar menuBar;
47255885 Menu fileMenu;
47265886 MenuItem newItem;
4727
- MenuItem loadItem;
5887
+ MenuItem openItem;
47285888 MenuItem saveItem;
47295889 MenuItem saveAsItem;
47305890 MenuItem exportAsItem;
....@@ -4747,22 +5907,37 @@
47475907 CheckboxMenuItem toggleSwitchItem;
47485908 CheckboxMenuItem toggleRootItem;
47495909 CheckboxMenuItem animationItem;
5910
+ MenuItem archiveItem;
47505911 CheckboxMenuItem toggleHandleItem;
47515912 CheckboxMenuItem togglePaintItem;
47525913 JSplitPane mainPanel;
47535914 JScrollPane scrollpane;
5915
+
47545916 JPanel toolbarPanel;
5917
+
47555918 cGridBag treePanel;
5919
+
47565920 JPanel radioPanel;
47575921 ButtonGroup buttonGroup;
4758
- cGridBag ctrlPanel;
5922
+
5923
+ cGridBag toolboxPanel;
5924
+ cGridBag skyboxPanel;
47595925 cGridBag materialPanel;
5926
+ cGridBag ctrlPanel;
5927
+
47605928 JScrollPane infoPanel;
5929
+
47615930 cGridBag optionsPanel;
5931
+
47625932 JTabbedPane objectPanel;
5933
+ boolean materialFlushed;
5934
+ Object3D latestObject;
5935
+
47635936 cGridBag XYZPanel;
5937
+
47645938 JSplitPane gridPanel;
47655939 JSplitPane bigPanel;
5940
+
47665941 cGridBag bigThree;
47675942 cGridBag scenePanel;
47685943 cGridBag centralPanel;
....@@ -4820,7 +5995,7 @@
48205995 JLabel colorLabel;
48215996 cNumberSlider colorField;
48225997 JLabel modulationLabel;
4823
- cNumberSlider modulationField;
5998
+ cNumberSlider saturationField;
48245999 JLabel metalnessLabel;
48256000 cNumberSlider metalnessField;
48266001 JLabel diffuseLabel;
....@@ -4851,6 +6026,7 @@
48516026 cNumberSlider anisoField;
48526027 JLabel anisoVLabel;
48536028 cNumberSlider anisoVField;
6029
+
48546030 JLabel cameraLabel;
48556031 cNumberSlider cameraField;
48566032 JLabel selfshadowLabel;
....@@ -4865,6 +6041,7 @@
48656041 cNumberSlider fakedepthField;
48666042 JLabel shadowbiasLabel;
48676043 cNumberSlider shadowbiasField;
6044
+
48686045 JLabel bumpLabel;
48696046 cNumberSlider bumpField;
48706047 JLabel noiseLabel;
....@@ -4877,7 +6054,7 @@
48776054 cNumberSlider fogField;
48786055 JLabel opacityPowerLabel;
48796056 cNumberSlider opacityPowerField;
4880
- JTree jTree;
6057
+ cTree jTree;
48816058 //ObjectUI parent;
48826059
48836060 cNumberSlider normalpushField;