Normand Briere
2019-08-17 d5d6485126da83b06645e90e3e4ce66659a56009
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,131 @@
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
+ if (icon != null)
87
+ return new cButton(icon, border);
88
+ else
89
+ return new cButton(name, border);
90
+ }
91
+
92
+ cLabel GetLabel(String name, boolean border)
93
+ {
94
+ //ImageIcon icon = GetIcon(name);
95
+ return new cLabel(GetImage(name), border);
96
+ }
97
+
98
+ cToggleButton GetToggleButton(String name, boolean border)
99
+ {
100
+ ImageIcon icon = GetIcon(name);
101
+ return new cToggleButton(icon, border);
102
+ }
103
+
104
+ cCheckBox GetCheckBox(String name, boolean border)
105
+ {
106
+ ImageIcon icon = GetIcon(name);
107
+ return new cCheckBox(icon, border);
108
+ }
109
+
110
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
111
+
112
+ static ImageIcon GetIcon(String name)
113
+ {
114
+ javax.swing.ImageIcon iconCache = icons.get(name);
115
+ if (iconCache != null)
116
+ {
117
+ return iconCache;
118
+ }
119
+
120
+ try
121
+ {
122
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
123
+
124
+// if (image.getWidth() > 48 && image.getHeight() > 48)
125
+// {
126
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
127
+// Graphics2D g = resized.createGraphics();
128
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
129
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
130
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
131
+// g.dispose();
132
+//
133
+// image = resized;
134
+// }
135
+
136
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
137
+
138
+ icons.put(name, icon);
139
+
140
+ return icon;
141
+ }
142
+ catch (Exception e)
143
+ {
144
+ //icons.put(name, null);
145
+ return null;
146
+ }
147
+ }
148
+
149
+ BufferedImage GetImage(String name)
150
+ {
151
+ try
152
+ {
153
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
154
+
155
+ return image;
156
+ }
157
+ catch (Exception e)
158
+ {
159
+ return null;
160
+ }
161
+ }
38162
39163 // SCRIPT
40164
....@@ -145,7 +269,7 @@
145269
146270 objEditor.ctrlPanel.remove(namePanel);
147271
148
- if (!GroupEditor.allparams)
272
+ if (!allparams)
149273 return;
150274
151275 // objEditor.ctrlPanel.remove(liveCB);
....@@ -168,7 +292,8 @@
168292 // objEditor.ctrlPanel.remove(remarkButton);
169293
170294 objEditor.ctrlPanel.remove(setupPanel);
171
- objEditor.ctrlPanel.remove(commandsPanel);
295
+ objEditor.ctrlPanel.remove(setupPanel2);
296
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
172297 objEditor.ctrlPanel.remove(pushPanel);
173298 //objEditor.ctrlPanel.remove(fillPanel);
174299
....@@ -216,6 +341,14 @@
216341 client = inClient;
217342 copy = client;
218343
344
+// if (copy.versionlist == null)
345
+// {
346
+// copy.versionlist = new Object3D[100];
347
+// copy.versionindex = -1;
348
+//
349
+// callee.Save(true);
350
+// }
351
+
219352 // "this" is not called: SetupUI2(objEditor);
220353 }
221354
....@@ -229,6 +362,14 @@
229362 client = inClient;
230363 copy = client;
231364
365
+ if (copy.versionlist == null)
366
+ {
367
+ copy.versionlist = new Object3D[100];
368
+ copy.versionindex = -1;
369
+
370
+// Save(true);
371
+ }
372
+
232373 SetupUI2(callee.GetEditor());
233374 }
234375
....@@ -243,13 +384,15 @@
243384 //localCopy.parent = null;
244385
245386 frame = new JFrame();
387
+ frame.setUndecorated(false);
246388 objEditor = this;
247389 this.callee = callee;
248390
249391 //parent = p;
250392
251393 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
252
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
394
+ if (Globals.DEBUG)
395
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
253396 //gd.setFullScreenWindow(this);
254397 //setResizable(false);
255398 //if (!isDisplayable())
....@@ -260,6 +403,14 @@
260403 copy = localCopy;
261404 copy.editWindow = this;
262405
406
+// if (copy.versionlist == null)
407
+// {
408
+// copy.versionlist = new Object3D[100];
409
+// copy.versionindex = -1;
410
+//
411
+// Save(true);
412
+// }
413
+
263414 SetupMenu();
264415
265416 //SetupName(objEditor); // new
....@@ -273,12 +424,20 @@
273424 return frame.action(event, obj);
274425 }
275426
427
+ // Cannot work without static
428
+ static boolean allparams = true;
429
+
430
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
431
+
432
+ // This is to refresh the UI of the material panel.
433
+ boolean patchMaterial;
434
+
276435 void SetupMenu()
277436 {
278437 frame.setMenuBar(menuBar = new MenuBar());
279438 menuBar.add(fileMenu = new Menu("File"));
280439 fileMenu.add(newItem = new MenuItem("New"));
281
- fileMenu.add(loadItem = new MenuItem("Load..."));
440
+ fileMenu.add(openItem = new MenuItem("Open..."));
282441
283442 //oe.menuBar.add(menu = new Menu("Include"));
284443 Menu menu = new Menu("Import");
....@@ -310,7 +469,7 @@
310469 }
311470
312471 newItem.addActionListener(this);
313
- loadItem.addActionListener(this);
472
+ openItem.addActionListener(this);
314473 saveItem.addActionListener(this);
315474 saveAsItem.addActionListener(this);
316475 exportAsItem.addActionListener(this);
....@@ -319,28 +478,102 @@
319478 closeItem.addActionListener(this);
320479
321480 objectPanel = new JTabbedPane();
481
+
482
+ ChangeListener changeListener = new ChangeListener()
483
+ {
484
+ //String name;
485
+
486
+ public void stateChanged(ChangeEvent changeEvent)
487
+ {
488
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
489
+// {
490
+// if (latestObject != null)
491
+// {
492
+// refreshContents(true);
493
+// SetMaterial(latestObject);
494
+// }
495
+//
496
+// materialFlushed = true;
497
+// }
498
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
499
+// {
500
+// if (listUI.size() == 0)
501
+// EditSelection(false);
502
+// }
503
+
504
+// if (objectPanel.getSelectedIndex() == 4)
505
+// {
506
+// name = copy.skyboxname;
507
+//
508
+// if (name == null)
509
+// {
510
+// name = "";
511
+// }
512
+//
513
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
514
+// copy.skyboxext = "jpg";
515
+// }
516
+// else
517
+// {
518
+// if (name != null)
519
+// {
520
+// if (name.equals(""))
521
+// {
522
+// copy.skyboxname = null;
523
+// copy.skyboxext = null;
524
+// }
525
+// else
526
+// {
527
+// copy.skyboxname = name;
528
+// }
529
+// }
530
+// }
531
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
532
+
533
+// refreshContents(false); // To refresh Info tab
534
+ cameraView.repaint();
535
+ }
536
+ };
537
+ objectPanel.addChangeListener(changeListener);
538
+
322539 toolbarPanel = new JPanel();
323540 toolbarPanel.setName("Toolbar");
541
+
324542 treePanel = new cGridBag();
325543 treePanel.setName("Tree");
544
+
545
+ editPanel = new cGridBag().setVertical(true);
546
+ //editPanel.setName("Edit");
547
+
326548 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
327
- ctrlPanel.setName("Edit");
328
- materialPanel = new cGridBag().setVertical(true);
329
- materialPanel.setName("Material");
549
+
550
+ editCommandsPanel = new cGridBag();
551
+ editPanel.add(editCommandsPanel);
552
+ editPanel.add(ctrlPanel);
553
+
554
+ toolboxPanel = new cGridBag().setVertical(true);
555
+ //toolboxPanel.setName("Toolbox");
556
+
557
+ skyboxPanel = new cGridBag().setVertical(true);
558
+
559
+ materialPanel = new cGridBag().setVertical(false);
560
+ //materialPanel.setName("Material");
561
+
330562 /*JTextPane*/
331563 infoarea = createTextPane();
332564 doc = infoarea.getStyledDocument();
333565
334566 infoarea.setEditable(true);
335567 SetText();
568
+
336569 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
337570 // infoarea.setOpaque(false);
338571 // //infoarea.setForeground(textcolor);
339572 // TEXTAREA infoarea.setLineWrap(true);
340573 // TEXTAREA infoarea.setWrapStyleWord(true);
341574 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");
575
+ infoPanel.setPreferredSize(new Dimension(1, 1));
576
+ //infoPanel.setName("Info");
344577 //infoPanel.setLayout(new BorderLayout());
345578 //infoPanel.add(createTextPane());
346579
....@@ -351,7 +584,14 @@
351584 mainPanel.setDividerSize(9);
352585 mainPanel.setDividerLocation(0.5); //1.0);
353586 mainPanel.setResizeWeight(0.5);
354
-
587
+
588
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
589
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
590
+ divider.setDividerSize(15);
591
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
592
+
593
+ mainPanel.setUI(new BasicSplitPaneUI());
594
+
355595 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
356596 //mainPanel.setLayout(new GridBagLayout());
357597 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -419,10 +659,10 @@
419659 e.printStackTrace();
420660 }
421661
422
- String selection = infoarea.getText();
423
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
424
- java.awt.datatransfer.Clipboard clipboard =
425
- Toolkit.getDefaultToolkit().getSystemClipboard();
662
+// String selection = infoarea.getText();
663
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
664
+// java.awt.datatransfer.Clipboard clipboard =
665
+// Toolkit.getDefaultToolkit().getSystemClipboard();
426666 //clipboard.setContents(data, data);
427667 }
428668
....@@ -582,21 +822,169 @@
582822 }
583823 }
584824
825
+//static GraphicsDevice device = GraphicsEnvironment
826
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
827
+
828
+ Rectangle keeprect;
829
+ cRadio radio;
830
+
831
+cButton keepButton;
832
+ cButton twoButton; // Full 3D
833
+ cButton sixButton;
834
+ cButton threeButton;
835
+ cButton sevenButton;
836
+ cButton fourButton; // full panel
837
+ cButton oneButton; // full XYZ
838
+ //cButton currentLayout;
839
+
840
+ boolean maximized;
841
+
842
+ cButton fullscreenLayout;
843
+ cButton expandedLayout;
844
+
845
+ void Minimize()
846
+ {
847
+ frame.setState(Frame.ICONIFIED);
848
+ frame.validate();
849
+ }
850
+
851
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
852
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
853
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
854
+ void Maximize()
855
+ {
856
+ if (CameraPane.FULLSCREEN)
857
+ {
858
+ ToggleFullScreen();
859
+ }
860
+
861
+ if (maximized)
862
+ {
863
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
864
+ }
865
+ else
866
+ {
867
+ keeprect = frame.getBounds();
868
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
869
+// Dimension rect2 = frame.getToolkit().getScreenSize();
870
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
871
+// frame.setState(Frame.MAXIMIZED_BOTH);
872
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
873
+ }
874
+
875
+ maximized ^= true;
876
+
877
+ frame.validate();
878
+ }
879
+
880
+ cButton minButton;
881
+ cButton maxButton;
882
+ cButton fullButton;
883
+ cButton collapseButton;
884
+ cButton maximize3DButton;
885
+
585886 void ToggleFullScreen()
586887 {
587
- if (CameraPane.FULLSCREEN)
888
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
889
+
890
+ cameraView.ToggleFullScreen();
891
+
892
+ if (!CameraPane.FULLSCREEN)
588893 {
589
- frame.getContentPane().remove(/*"Center",*/bigThree);
590
- framePanel.add(bigThree);
591
- frame.getContentPane().add(/*"Center",*/framePanel);
894
+ device.setFullScreenWindow(null);
895
+ frame.dispose();
896
+ frame.setUndecorated(false);
897
+ frame.validate();
898
+ frame.setVisible(true);
899
+
900
+ //frame.setVisible(false);
901
+// frame.removeNotify();
902
+// frame.setUndecorated(false);
903
+// frame.addNotify();
904
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
905
+
906
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
907
+// X framePanel.add(bigThree);
908
+// X frame.getContentPane().add(/*"Center",*/framePanel);
909
+// framePanel.setDividerLocation(46); // icons are 24x24
910
+
911
+ //frame.setVisible(true);
912
+// radio.layout = keepButton;
913
+ //theFrame = null;
914
+ keepButton = null;
915
+// radio.layout.doClick();
916
+
592917 } else
593918 {
594
- frame.getContentPane().remove(/*"Center",*/framePanel);
595
- framePanel.remove(bigThree);
596
- frame.getContentPane().add(/*"Center",*/bigThree);
919
+ keepButton = radio.layout;
920
+ //keeprect = frame.getBounds();
921
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
922
+// frame.getToolkit().getScreenSize().height);
923
+ //frame.setVisible(false);
924
+
925
+ frame.dispose();
926
+ frame.setUndecorated(true);
927
+ device.setFullScreenWindow(frame);
928
+ frame.validate();
929
+ frame.setVisible(true);
930
+// frame.removeNotify();
931
+// frame.setUndecorated(true);
932
+// frame.addNotify();
933
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
934
+// X framePanel.remove(bigThree);
935
+// X frame.getContentPane().add(/*"Center",*/bigThree);
936
+// framePanel.setDividerLocation(0);
937
+
938
+// radio.layout = fullscreenLayout;
939
+// radio.layout.doClick();
940
+ //frame.setVisible(true);
597941 }
598
- cameraView.ToggleFullScreen();
942
+ frame.validate();
943
+
944
+ cameraView.requestFocusInWindow();
599945 }
946
+
947
+ void CollapseToolbar()
948
+ {
949
+ framePanel.setDividerLocation(0);
950
+ //frame.validate();
951
+
952
+ cameraView.requestFocusInWindow();
953
+ }
954
+
955
+ private Object3D Duplicate(Object3D object)
956
+ {
957
+ boolean temp = CameraPane.SWITCH;
958
+ CameraPane.SWITCH = false;
959
+
960
+ if (Grafreed.grafreed.universe.versiontable == null)
961
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
962
+
963
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
964
+ // if (copy == client)
965
+
966
+ Object3D versions[] = object.versionlist;
967
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
968
+ object.versionlist = null;
969
+ object.versiontable = null;
970
+
971
+ Object3D parent = object.parent;
972
+ object.parent = null;
973
+
974
+ //byte[] compress = Compress(copy);
975
+ Object3D compress = (Object3D)Grafreed.clone(object);
976
+
977
+ object.parent = parent;
978
+
979
+ object.versionlist = versions;
980
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
981
+
982
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
983
+
984
+ CameraPane.SWITCH = temp;
985
+
986
+ return compress;
987
+ }
600988
601989 private JTextPane createTextPane()
602990 {
....@@ -719,6 +1107,7 @@
7191107 {
7201108 SetupMaterial(materialPanel);
7211109 }
1110
+
7221111 //SetupName();
7231112 //SetupViews();
7241113 }
....@@ -728,7 +1117,7 @@
7281117 // NumberSlider vDivsField;
7291118 // JCheckBox endcaps;
7301119 JCheckBox liveCB;
731
- JCheckBox selectCB;
1120
+ JCheckBox selectableCB;
7321121 JCheckBox hideCB;
7331122 JCheckBox link2masterCB;
7341123 JCheckBox markCB;
....@@ -736,7 +1125,12 @@
7361125 JCheckBox speedupCB;
7371126 JCheckBox rewindCB;
7381127 JCheckBox flipVCB;
1128
+
1129
+ cCheckBox toggleTextureCB;
1130
+ cCheckBox toggleSwitchCB;
1131
+
7391132 JComboBox texresMenu;
1133
+
7401134 JButton resetButton;
7411135 JButton stepButton;
7421136 JButton stepAllButton;
....@@ -745,9 +1139,13 @@
7451139 JButton fasterButton;
7461140 JButton remarkButton;
7471141
1142
+ cGridBag editPanel;
1143
+ cGridBag editCommandsPanel;
1144
+
7481145 cGridBag namePanel;
7491146 cGridBag setupPanel;
750
- cGridBag commandsPanel;
1147
+ cGridBag setupPanel2;
1148
+ cGridBag objectCommandsPanel;
7511149 cGridBag pushPanel;
7521150 cGridBag fillPanel;
7531151
....@@ -918,61 +1316,81 @@
9181316
9191317 namePanel = new cGridBag();
9201318
1319
+ //if (copy.pinned)
1320
+ {
1321
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1322
+ pinButton.setSelected(copy.pinned);
1323
+ cGridBag t = new cGridBag();
1324
+ t.preferredWidth = 2;
1325
+ t.add(pinButton);
1326
+ namePanel.add(t);
1327
+
1328
+ pinButton.addItemListener(this);
1329
+ }
1330
+
9211331 nameField = AddText(namePanel, copy.GetName());
922
- namePanel.add(nameField);
1332
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9231333 oe.ctrlPanel.add(namePanel);
9241334
9251335 oe.ctrlPanel.Return();
9261336
927
- if (!GroupEditor.allparams)
1337
+ if (!allparams)
9281338 return;
9291339
9301340 setupPanel = new cGridBag().setVertical(false);
9311341
9321342 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
9331343 liveCB.setToolTipText("Animate object");
934
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
935
- selectCB.setToolTipText("Make object selectable");
1344
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1345
+ markCB.setToolTipText("Set target transform");
1346
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1347
+ selectableCB.setToolTipText("Make object selectable");
9361348 // Return();
1349
+
9371350 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9381351 hideCB.setToolTipText("Hide object");
939
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
940
- markCB.setToolTipText("Set the animation target transform");
9411352
942
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1353
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1354
+
1355
+ setupPanel2 = new cGridBag().setVertical(false);
1356
+
1357
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9431358 rewindCB.setToolTipText("Rewind animation");
9441359
945
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
946
- randomCB.setToolTipText("Option for switch node");
1360
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1361
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9471362
1363
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1364
+ link2masterCB.setToolTipText("Attach to support");
1365
+
9481366 if (Globals.ADVANCED)
9491367 {
950
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
951
- link2masterCB.setToolTipText("Attach to support");
952
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1368
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9531369 speedupCB.setToolTipText("Option motion capture");
9541370 }
9551371
9561372 oe.ctrlPanel.add(setupPanel);
9571373 oe.ctrlPanel.Return();
1374
+ oe.ctrlPanel.add(setupPanel2);
1375
+ oe.ctrlPanel.Return();
9581376
959
- commandsPanel = new cGridBag().setVertical(false);
1377
+ objectCommandsPanel = new cGridBag().setVertical(false);
9601378
961
- resetButton = AddButton(commandsPanel, "Reset");
1379
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9621380 resetButton.setToolTipText("Jump to frame zero");
963
- stepButton = AddButton(commandsPanel, "Step");
1381
+ stepButton = AddButton(objectCommandsPanel, "Step");
9641382 stepButton.setToolTipText("Step one frame");
9651383 // resetAllButton = AddButton(oe, "Reset All");
9661384 // stepAllButton = AddButton(oe, "Step All");
9671385 // Return();
968
- slowerButton = AddButton(commandsPanel, "Slow");
1386
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9691387 slowerButton.setToolTipText("Decrease animation speed");
970
- fasterButton = AddButton(commandsPanel, "Fast");
1388
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9711389 fasterButton.setToolTipText("Increase animation speed");
972
- remarkButton = AddButton(commandsPanel, "Remark");
1390
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9731391 remarkButton.setToolTipText("Set the current transform as the target");
9741392
975
- oe.ctrlPanel.add(commandsPanel);
1393
+ oe.ctrlPanel.add(objectCommandsPanel);
9761394 oe.ctrlPanel.Return();
9771395
9781396 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1132,6 +1550,7 @@
11321550
11331551 if (cam == null || !(copy.get(0) instanceof cGroup))
11341552 {
1553
+ if (Globals.DEBUG)
11351554 System.out.println("CREATE CAMERAS");
11361555 cams = new cTemplate();
11371556 cams.name = "Cameras";
....@@ -1178,8 +1597,11 @@
11781597 //worldPanel.setName("World");
11791598 centralPanel = new cGridBag();
11801599 centralPanel.preferredWidth = 20;
1181
- timelinePanel = new JPanel(new BorderLayout());
1182
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1600
+
1601
+ if (Globals.ADVANCED)
1602
+ {
1603
+ timelinePanel = new JPanel(new BorderLayout());
1604
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11831605
11841606 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11851607 cameraPanel.setContinuousLayout(true);
....@@ -1188,7 +1610,10 @@
11881610 // cameraPanel.setDividerSize(9);
11891611 cameraPanel.setResizeWeight(1.0);
11901612
1613
+ }
1614
+
11911615 centralPanel.add(cameraView);
1616
+ centralPanel.setFocusable(true);
11921617 //frame.setJMenuBar(timelineMenubar);
11931618 //centralPanel.add(timelinePanel);
11941619
....@@ -1207,6 +1632,42 @@
12071632 //frontView.object = copy;
12081633 //sideView.object = copy;
12091634
1635
+ transformPanel = new cGridBag().setVertical(true);
1636
+
1637
+ cGridBag resetTransformPanel = new cGridBag();
1638
+
1639
+ resetTransformPanel.preferredHeight = 2;
1640
+
1641
+ cButton resetTransform = GetButton("Reset all", !Grafreed.NIMBUSLAF);
1642
+ resetTransform.addMouseListener(new MouseAdapter()
1643
+ {
1644
+ public void mouseClicked(MouseEvent e)
1645
+ {
1646
+ ResetTransform();
1647
+ }
1648
+ });
1649
+ resetTransformPanel.add(resetTransform);
1650
+
1651
+ resetTransform = GetButton("T only", !Grafreed.NIMBUSLAF);
1652
+ resetTransform.addMouseListener(new MouseAdapter()
1653
+ {
1654
+ public void mouseClicked(MouseEvent e)
1655
+ {
1656
+ ResetTransform(1);
1657
+ }
1658
+ });
1659
+ resetTransformPanel.add(resetTransform);
1660
+
1661
+ resetTransform = GetButton("RS only", !Grafreed.NIMBUSLAF);
1662
+ resetTransform.addMouseListener(new MouseAdapter()
1663
+ {
1664
+ public void mouseClicked(MouseEvent e)
1665
+ {
1666
+ ResetTransform(2);
1667
+ }
1668
+ });
1669
+ resetTransformPanel.add(resetTransform);
1670
+
12101671 XYZPanel = new cGridBag().setVertical(true);
12111672 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
12121673
....@@ -1214,7 +1675,11 @@
12141675 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12151676 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12161677 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1678
+ //XYZPanel.setName("XYZ");
12171679
1680
+ transformPanel.add(resetTransformPanel);
1681
+ transformPanel.add(XYZPanel);
1682
+
12181683 /*
12191684 gridPanel = new JPanel(); //new BorderLayout());
12201685 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1222,12 +1687,12 @@
12221687 gridPanel.add(cameraView);
12231688 gridPanel.add(XYZPanel);
12241689 */
1225
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1226
- gridPanel.setContinuousLayout(true);
1227
- gridPanel.setOneTouchExpandable(true);
1228
- gridPanel.setDividerLocation(1.0);
1229
- gridPanel.setDividerSize(9);
1230
- gridPanel.setResizeWeight(0.85);
1690
+// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1691
+// gridPanel.setContinuousLayout(true);
1692
+// gridPanel.setOneTouchExpandable(true);
1693
+// gridPanel.setDividerLocation(1.0);
1694
+// gridPanel.setDividerSize(9);
1695
+// gridPanel.setResizeWeight(0.85);
12311696
12321697 // aConstraints.weighty = 0;
12331698 //System.out.println("THIS = " + this);
....@@ -1250,14 +1715,34 @@
12501715
12511716 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12521717 //tmp.setName("Edit");
1718
+ objectPanel.add(toolboxPanel);
1719
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1720
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
1721
+
12531722 objectPanel.add(materialPanel);
1723
+ objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1724
+ objectPanel.setToolTipTextAt(1, "Material");
1725
+
1726
+ objectPanel.add(skyboxPanel);
1727
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1728
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1729
+
12541730 // JPanel north = new JPanel(new BorderLayout());
12551731 // north.setName("Edit");
12561732 // north.add(ctrlPanel, BorderLayout.NORTH);
12571733 // objectPanel.add(north);
1258
- objectPanel.add(ctrlPanel);
1259
- objectPanel.add(infoPanel);
1260
-
1734
+ objectPanel.add(editPanel);
1735
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1736
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1737
+
1738
+ objectPanel.add(transformPanel);
1739
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1740
+ objectPanel.setToolTipTextAt(4, "TRS transform");
1741
+
1742
+ patchMaterial = true;
1743
+ cameraView.patchMaterial = this;
1744
+ objectPanel.setSelectedIndex(1);
1745
+
12611746 /*
12621747 aConstraints.gridx = 0;
12631748 aConstraints.gridwidth = 1;
....@@ -1265,7 +1750,7 @@
12651750 aConstraints.gridy += 1;
12661751 aConstraints.gridwidth = 1;
12671752 mainPanel.add(objectPanel, aConstraints);
1268
- */
1753
+ */
12691754
12701755 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12711756 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1282,9 +1767,7 @@
12821767 JTabbedPane tabbedPane = new JTabbedPane();
12831768 tabbedPane.add(scrollpane);
12841769
1285
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1286
-
1287
- optionsPanel = new cGridBag().setVertical(true);
1770
+ optionsPanel = new cGridBag().setVertical(false);
12881771
12891772 optionsPanel.setName("Options");
12901773
....@@ -1292,8 +1775,15 @@
12921775
12931776 tabbedPane.add(optionsPanel);
12941777
1778
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1779
+
12951780 scenePanel.add(tabbedPane);
12961781
1782
+ //if (Globals.ADVANCED)
1783
+// tabbedPane.add(infoPanel);
1784
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1785
+// tabbedPane.setToolTipTextAt(3, "Information");
1786
+
12971787 /*
12981788 cTree jTree = new cTree(null);
12991789 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1314,13 +1804,13 @@
13141804 jtp.add(tree);
13151805 */
13161806
1317
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1318
- bigPanel.setContinuousLayout(true);
1319
- bigPanel.setOneTouchExpandable(true);
1320
- bigPanel.setDividerLocation(0.8);
1321
- bigPanel.setDividerSize(15);
1322
- bigPanel.setResizeWeight(0.15);
1323
- bigPanel.setName("Scene");
1807
+// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1808
+// bigPanel.setContinuousLayout(true);
1809
+// bigPanel.setOneTouchExpandable(true);
1810
+// bigPanel.setDividerLocation(0.8);
1811
+// bigPanel.setDividerSize(15);
1812
+// bigPanel.setResizeWeight(0.15);
1813
+// bigPanel.setName("Scene");
13241814
13251815 //bigPanel.setLayout(new BorderLayout());
13261816 //bigPanel.setSize(new Dimension(10,10));
....@@ -1355,7 +1845,7 @@
13551845 bigThree = new cGridBag();
13561846 bigThree.addComponent(scenePanel);
13571847 bigThree.addComponent(centralPanel);
1358
- bigThree.addComponent(XYZPanel);
1848
+ //bigThree.addComponent(XYZPanel);
13591849
13601850 // // SIDE EFFECT!!!
13611851 // aConstraints.gridx = 0;
....@@ -1364,16 +1854,33 @@
13641854 // aConstraints.gridheight = 1;
13651855
13661856 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1367
- framePanel.setContinuousLayout(true);
1368
- framePanel.setOneTouchExpandable(true);
1369
- framePanel.setDividerLocation(0.8);
1857
+
1858
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1859
+ new java.beans.PropertyChangeListener()
1860
+ {
1861
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1862
+ {
1863
+ if ((Integer)pce.getOldValue() == 1)
1864
+ {
1865
+ if (radio.layout != expandedLayout)
1866
+ {
1867
+ radio.layout = expandedLayout;
1868
+ radio.layout.doClick();
1869
+ }
1870
+ }
1871
+ }
1872
+ });
1873
+
1874
+ framePanel.setContinuousLayout(false);
1875
+ framePanel.setOneTouchExpandable(false);
1876
+ //.setDividerLocation(0.8);
13701877 //framePanel.setDividerSize(15);
13711878 //framePanel.setResizeWeight(0.15);
13721879 framePanel.setName("Frame");
13731880
13741881 frame.getContentPane().setLayout(new BorderLayout());
13751882 /**/
1376
- JTabbedPane worldPane = new JTabbedPane();
1883
+ //JTabbedPane worldPane = new JTabbedPane();
13771884 //worldPane.add(bigPanel);
13781885 //worldPane.add(worldPanel);
13791886 /**/
....@@ -1384,14 +1891,18 @@
13841891 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13851892
13861893 frame.setSize(1280, 860);
1387
- frame.setVisible(true);
1894
+
1895
+ cameraView.requestFocusInWindow();
1896
+
1897
+// gridPanel.setDividerLocation(1.0);
1898
+
1899
+ frame.validate();
13881900
1389
- gridPanel.setDividerLocation(1.0);
1901
+ frame.setVisible(true);
13901902
13911903 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13921904 frame.addWindowListener(new WindowAdapter()
13931905 {
1394
-
13951906 public void windowClosing(WindowEvent e)
13961907 {
13971908 Close();
....@@ -1414,12 +1925,426 @@
14141925 ctrlPanel.removeAll();
14151926 }
14161927
1417
- void SetupMaterial(cGridBag panel)
1928
+ void SetupMaterial(cGridBag materialpanel)
14181929 {
1419
- /*
1930
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1931
+
1932
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1933
+ skin.setToolTipText("Skin");
1934
+ skin.addMouseListener(new MouseAdapter()
1935
+ {
1936
+ public void mouseClicked(MouseEvent e)
1937
+ {
1938
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1939
+ cMaterial material = object.material;
1940
+
1941
+ // Skin
1942
+ colorField.setFloat(material.color);
1943
+ float saturation = material.modulation;
1944
+
1945
+ if (!cameraView.Skinshader)
1946
+ {
1947
+ saturation /= 1.5;
1948
+ }
1949
+
1950
+ saturationField.setFloat(saturation);
1951
+
1952
+ subsurfaceField.setFloat(material.subsurface);
1953
+ selfshadowField.setFloat(material.diffuseness);
1954
+ diffusenessField.setFloat(material.factor);
1955
+ shininessField.setFloat(material.shininess);
1956
+ shadowbiasField.setFloat(material.shadowbias);
1957
+ diffuseField.setFloat(material.diffuse);
1958
+ specularField.setFloat(material.specular);
1959
+
1960
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1961
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1962
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1963
+
1964
+ materialtouched = true;
1965
+ applySelf();
1966
+ }
1967
+ });
1968
+ presetpanel.add(skin);
1969
+
1970
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1971
+ lambert.setToolTipText("Diffuse");
1972
+ lambert.addMouseListener(new MouseAdapter()
1973
+ {
1974
+ public void mouseClicked(MouseEvent e)
1975
+ {
1976
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1977
+ cMaterial material = object.material;
1978
+
1979
+ diffusenessField.setFloat(material.factor);
1980
+ selfshadowField.setFloat(material.diffuseness);
1981
+
1982
+ materialtouched = true;
1983
+ applySelf();
1984
+ }
1985
+ });
1986
+ presetpanel.add(lambert);
1987
+
1988
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1989
+ diffuse2.setToolTipText("Diffuse2");
1990
+ diffuse2.addMouseListener(new MouseAdapter()
1991
+ {
1992
+ public void mouseClicked(MouseEvent e)
1993
+ {
1994
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1995
+ cMaterial material = object.material;
1996
+
1997
+ diffusenessField.setFloat(material.factor);
1998
+ selfshadowField.setFloat(material.diffuseness);
1999
+
2000
+ materialtouched = true;
2001
+ applySelf();
2002
+ }
2003
+ });
2004
+ presetpanel.add(diffuse2);
2005
+
2006
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
2007
+ diffusemoon.setToolTipText("Moon");
2008
+ diffusemoon.addMouseListener(new MouseAdapter()
2009
+ {
2010
+ public void mouseClicked(MouseEvent e)
2011
+ {
2012
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
2013
+ cMaterial material = object.material;
2014
+
2015
+ diffusenessField.setFloat(material.factor);
2016
+ selfshadowField.setFloat(material.diffuseness);
2017
+
2018
+ materialtouched = true;
2019
+ applySelf();
2020
+ }
2021
+ });
2022
+ presetpanel.add(diffusemoon);
2023
+
2024
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
2025
+ diffusemoon2.setToolTipText("Moon2");
2026
+ diffusemoon2.addMouseListener(new MouseAdapter()
2027
+ {
2028
+ public void mouseClicked(MouseEvent e)
2029
+ {
2030
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
2031
+ cMaterial material = object.material;
2032
+
2033
+ diffusenessField.setFloat(material.factor);
2034
+ selfshadowField.setFloat(material.diffuseness);
2035
+
2036
+ materialtouched = true;
2037
+ applySelf();
2038
+ }
2039
+ });
2040
+ presetpanel.add(diffusemoon2);
2041
+
2042
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
2043
+ diffusemoon3.setToolTipText("Moon3");
2044
+ diffusemoon3.addMouseListener(new MouseAdapter()
2045
+ {
2046
+ public void mouseClicked(MouseEvent e)
2047
+ {
2048
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2049
+ cMaterial material = object.material;
2050
+
2051
+ diffusenessField.setFloat(material.factor);
2052
+ selfshadowField.setFloat(material.diffuseness);
2053
+
2054
+ materialtouched = true;
2055
+ applySelf();
2056
+ }
2057
+ });
2058
+ presetpanel.add(diffusemoon3);
2059
+
2060
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
2061
+ diffusesheen.setToolTipText("Sheen");
2062
+ diffusesheen.addMouseListener(new MouseAdapter()
2063
+ {
2064
+ public void mouseClicked(MouseEvent e)
2065
+ {
2066
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2067
+ cMaterial material = object.material;
2068
+
2069
+ sheenField.setFloat(material.sheen);
2070
+
2071
+ materialtouched = true;
2072
+ applySelf();
2073
+ }
2074
+ });
2075
+ presetpanel.add(diffusesheen);
2076
+
2077
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2078
+ rough.setToolTipText("Rough metal");
2079
+ rough.addMouseListener(new MouseAdapter()
2080
+ {
2081
+ public void mouseClicked(MouseEvent e)
2082
+ {
2083
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2084
+ cMaterial material = object.material;
2085
+
2086
+ shininessField.setFloat(material.shininess);
2087
+ velvetField.setFloat(material.velvet);
2088
+
2089
+ materialtouched = true;
2090
+ applySelf();
2091
+ }
2092
+ });
2093
+ presetpanel.add(rough);
2094
+
2095
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2096
+ rough2.setToolTipText("Medium metal");
2097
+ rough2.addMouseListener(new MouseAdapter()
2098
+ {
2099
+ public void mouseClicked(MouseEvent e)
2100
+ {
2101
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2102
+ cMaterial material = object.material;
2103
+
2104
+ shininessField.setFloat(material.shininess);
2105
+ lightareaField.setFloat(material.lightarea);
2106
+
2107
+ materialtouched = true;
2108
+ applySelf();
2109
+ }
2110
+ });
2111
+ presetpanel.add(rough2);
2112
+
2113
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2114
+ shini0.setToolTipText("Shiny");
2115
+ shini0.addMouseListener(new MouseAdapter()
2116
+ {
2117
+ public void mouseClicked(MouseEvent e)
2118
+ {
2119
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2120
+ cMaterial material = object.material;
2121
+
2122
+ shininessField.setFloat(material.shininess);
2123
+ lightareaField.setFloat(material.lightarea);
2124
+
2125
+ materialtouched = true;
2126
+ applySelf();
2127
+ }
2128
+ });
2129
+ presetpanel.add(shini0);
2130
+
2131
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2132
+ shini1.setToolTipText("Shiny2");
2133
+ shini1.addMouseListener(new MouseAdapter()
2134
+ {
2135
+ public void mouseClicked(MouseEvent e)
2136
+ {
2137
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2138
+ cMaterial material = object.material;
2139
+
2140
+ shininessField.setFloat(material.shininess);
2141
+ lightareaField.setFloat(material.lightarea);
2142
+
2143
+ materialtouched = true;
2144
+ applySelf();
2145
+ }
2146
+ });
2147
+ presetpanel.add(shini1);
2148
+
2149
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2150
+ shini2.setToolTipText("Shiny3");
2151
+ shini2.addMouseListener(new MouseAdapter()
2152
+ {
2153
+ public void mouseClicked(MouseEvent e)
2154
+ {
2155
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2156
+ cMaterial material = object.material;
2157
+
2158
+ shininessField.setFloat(material.shininess);
2159
+ lightareaField.setFloat(material.lightarea);
2160
+
2161
+ materialtouched = true;
2162
+ applySelf();
2163
+ }
2164
+ });
2165
+ presetpanel.add(shini2);
2166
+
2167
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2168
+ aniso.setToolTipText("AnisoU");
2169
+ aniso.addMouseListener(new MouseAdapter()
2170
+ {
2171
+ public void mouseClicked(MouseEvent e)
2172
+ {
2173
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2174
+ cMaterial material = object.material;
2175
+
2176
+ anisoField.setFloat(material.aniso);
2177
+ anisoVField.setFloat(material.anisoV);
2178
+
2179
+ materialtouched = true;
2180
+ applySelf();
2181
+ }
2182
+ });
2183
+ presetpanel.add(aniso);
2184
+
2185
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2186
+ aniso2.setToolTipText("AnisoV");
2187
+ aniso2.addMouseListener(new MouseAdapter()
2188
+ {
2189
+ public void mouseClicked(MouseEvent e)
2190
+ {
2191
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2192
+ cMaterial material = object.material;
2193
+
2194
+ anisoField.setFloat(material.aniso);
2195
+ anisoVField.setFloat(material.anisoV);
2196
+
2197
+ materialtouched = true;
2198
+ applySelf();
2199
+ }
2200
+ });
2201
+ presetpanel.add(aniso2);
2202
+
2203
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2204
+ aniso3.setToolTipText("AnisoUV");
2205
+ aniso3.addMouseListener(new MouseAdapter()
2206
+ {
2207
+ public void mouseClicked(MouseEvent e)
2208
+ {
2209
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2210
+ cMaterial material = object.material;
2211
+
2212
+ anisoField.setFloat(material.aniso);
2213
+ anisoVField.setFloat(material.anisoV);
2214
+
2215
+ materialtouched = true;
2216
+ applySelf();
2217
+ }
2218
+ });
2219
+ presetpanel.add(aniso3);
2220
+
2221
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2222
+ velvet0.setToolTipText("Velvet");
2223
+ velvet0.addMouseListener(new MouseAdapter()
2224
+ {
2225
+ public void mouseClicked(MouseEvent e)
2226
+ {
2227
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2228
+ cMaterial material = object.material;
2229
+
2230
+ diffusenessField.setFloat(material.factor);
2231
+ selfshadowField.setFloat(material.diffuseness);
2232
+ sheenField.setFloat(material.sheen);
2233
+ shininessField.setFloat(material.shininess);
2234
+ velvetField.setFloat(material.velvet);
2235
+ shiftField.setFloat(material.shift);
2236
+
2237
+ materialtouched = true;
2238
+ applySelf();
2239
+ }
2240
+ });
2241
+ presetpanel.add(velvet0);
2242
+
2243
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2244
+ bump0.setToolTipText("Bump texture");
2245
+ bump0.addMouseListener(new MouseAdapter()
2246
+ {
2247
+ public void mouseClicked(MouseEvent e)
2248
+ {
2249
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2250
+ cMaterial material = object.material;
2251
+
2252
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2253
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2254
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2255
+
2256
+ materialtouched = true;
2257
+ applySelf();
2258
+ }
2259
+ });
2260
+ presetpanel.add(bump0);
2261
+
2262
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2263
+ borderShader.setToolTipText("Border fade");
2264
+ borderShader.addMouseListener(new MouseAdapter()
2265
+ {
2266
+ public void mouseClicked(MouseEvent e)
2267
+ {
2268
+ borderfadeField.setFloat(0.5);
2269
+ opacityField.setFloat(0.75);
2270
+
2271
+ materialtouched = true;
2272
+ applySelf();
2273
+ }
2274
+ });
2275
+ presetpanel.add(borderShader);
2276
+
2277
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2278
+ halo.setToolTipText("Halo");
2279
+ halo.addMouseListener(new MouseAdapter()
2280
+ {
2281
+ public void mouseClicked(MouseEvent e)
2282
+ {
2283
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2284
+ cMaterial material = object.material;
2285
+
2286
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2287
+
2288
+ materialtouched = true;
2289
+ applySelf();
2290
+ }
2291
+ });
2292
+ presetpanel.add(halo);
2293
+
2294
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2295
+ candle.setToolTipText("Candle");
2296
+ candle.addMouseListener(new MouseAdapter()
2297
+ {
2298
+ public void mouseClicked(MouseEvent e)
2299
+ {
2300
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2301
+ cMaterial material = object.material;
2302
+
2303
+ subsurfaceField.setFloat(material.subsurface);
2304
+ shadowbiasField.setFloat(material.shadowbias);
2305
+ ambientField.setFloat(material.ambient);
2306
+ specularField.setFloat(material.specular);
2307
+ lightareaField.setFloat(material.lightarea);
2308
+ shininessField.setFloat(material.shininess);
2309
+
2310
+ materialtouched = true;
2311
+ applySelf();
2312
+ }
2313
+ });
2314
+ presetpanel.add(candle);
2315
+
2316
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2317
+ shadowShader.setToolTipText("Shadow");
2318
+ shadowShader.addMouseListener(new MouseAdapter()
2319
+ {
2320
+ public void mouseClicked(MouseEvent e)
2321
+ {
2322
+ diffuseField.setFloat(0.001);
2323
+ ambientField.setFloat(0.001);
2324
+ cameraField.setFloat(0.001);
2325
+ specularField.setFloat(0.001);
2326
+ fakedepthField.setFloat(0.001);
2327
+ opacityField.setFloat(0.6);
2328
+
2329
+ materialtouched = true;
2330
+ applySelf();
2331
+ }
2332
+ });
2333
+ presetpanel.add(shadowShader);
2334
+
2335
+ cGridBag panel = new cGridBag().setVertical(true);
2336
+
2337
+ presetpanel.preferredWidth = 1;
2338
+
2339
+ materialpanel.add(presetpanel);
2340
+ materialpanel.add(panel);
2341
+
2342
+ panel.preferredWidth = 8;
2343
+
2344
+ /*
14202345 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14212346 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1422
- */
2347
+ */
14232348
14242349 cGridBag editBar = new cGridBag().setVertical(false);
14252350
....@@ -1453,45 +2378,61 @@
14532378 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14542379
14552380 cGridBag colorSection = new cGridBag().setVertical(true);
2381
+
2382
+ cGridBag huepanel = new cGridBag();
2383
+ cGridBag huelabel = new cGridBag();
2384
+ cLabel hue = GetLabel("icons/hue.png", false);
2385
+ hue.fit = true;
2386
+
2387
+ hue.addMouseListener(new MouseAdapter()
2388
+ {
2389
+ public void mousePressed(MouseEvent e)
2390
+ {
2391
+ int x = e.getX();
2392
+
2393
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2394
+ }
2395
+ });
2396
+
2397
+ huelabel.add(hue);
2398
+ huelabel.preferredWidth = 20;
2399
+ huepanel.add(new cGridBag()); // Label
2400
+ huepanel.add(huelabel); // Field/slider
2401
+
2402
+ huepanel.preferredHeight = 7;
2403
+
2404
+ colorSection.add(huepanel);
14562405
14572406 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);
2407
+
2408
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2409
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2410
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2411
+
14612412 //colorField.preferredWidth = 200;
14622413 colorSection.add(color);
14632414
14642415 cGridBag modulation = new cGridBag();
14652416 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14662417 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1467
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2418
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14682419 colorSection.add(modulation);
14692420
2421
+ cGridBag opacity = new cGridBag();
2422
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2423
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2424
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2425
+ colorSection.add(opacity);
2426
+
2427
+ colorSection.add(GetSeparator());
2428
+
14702429 cGridBag texture = new cGridBag();
14712430 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14722431 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14732432 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14742433 colorSection.add(texture);
14752434
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());
2435
+ panel.add(GetSeparator());
14952436
14962437 panel.add(colorSection);
14972438
....@@ -1541,7 +2482,13 @@
15412482 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15422483 diffuseSection.add(fakedepth);
15432484
1544
- panel.add(new JSeparator());
2485
+ cGridBag shadowbias = new cGridBag();
2486
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2487
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2488
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2489
+ diffuseSection.add(shadowbias);
2490
+
2491
+ panel.add(GetSeparator());
15452492
15462493 panel.add(diffuseSection);
15472494
....@@ -1591,42 +2538,48 @@
15912538 // aConstraints.gridy += 1;
15922539 // aConstraints.gridwidth = 1;
15932540
2541
+ cGridBag anisoU = new cGridBag();
2542
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2543
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2544
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2545
+ specularSection.add(anisoU);
15942546
1595
- panel.add(new JSeparator());
2547
+ cGridBag anisoV = new cGridBag();
2548
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2549
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2550
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2551
+ specularSection.add(anisoV);
2552
+
2553
+
2554
+ panel.add(GetSeparator());
15962555
15972556 panel.add(specularSection);
15982557
15992558 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16002559
1601
- cGridBag globalSection = new cGridBag().setVertical(true);
2560
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16022561
16032562 cGridBag camera = new cGridBag();
16042563 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16052564 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16062565 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1607
- globalSection.add(camera);
2566
+ colorSection.add(camera);
16082567
16092568 cGridBag ambient = new cGridBag();
16102569 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16112570 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16122571 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(ambient);
2572
+ colorSection.add(ambient);
16142573
16152574 cGridBag backlit = new cGridBag();
16162575 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16172576 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16182577 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(backlit);
2578
+ colorSection.add(backlit);
16202579
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());
2580
+ //panel.add(new JSeparator());
16282581
1629
- panel.add(globalSection);
2582
+ //panel.add(globalSection);
16302583
16312584 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16322585
....@@ -1668,7 +2621,7 @@
16682621 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16692622 textureSection.add(opacityPower);
16702623
1671
- panel.add(new JSeparator());
2624
+ panel.add(GetSeparator());
16722625
16732626 panel.add(textureSection);
16742627
....@@ -1733,8 +2686,9 @@
17332686 // 3D models
17342687 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17352688 {
1736
- lastConverter = new com.jmex.model.converters.MaxToJme();
1737
- LoadFile(filename, lastConverter);
2689
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2690
+ //LoadFile(filename, lastConverter);
2691
+ LoadObjFile(filename); // New 3ds loader
17382692 continue;
17392693 }
17402694 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2072,19 +3026,19 @@
20723026
20733027 void LoadObjFile(String fullname)
20743028 {
2075
- /*
3029
+ System.out.println("Loading " + fullname);
3030
+ /**/
20763031 //lastFilename = fullname;
20773032 if(loadObjThread == null)
20783033 {
2079
- loadObjThread = new LoadOBJThread();
2080
- loadObjThread.start();
3034
+ loadObjThread = new LoadOBJThread();
3035
+ loadObjThread.start();
20813036 }
20823037
20833038 loadObjThread.add(fullname);
2084
- */
3039
+ /**/
20853040
2086
- System.out.println("Loading " + fullname);
2087
- makeSomething(new FileObject(fullname, true), true);
3041
+ //makeSomething(new FileObject(fullname, true), true);
20883042 }
20893043
20903044 void LoadGFDFile(String fullname)
....@@ -2460,6 +3414,7 @@
24603414 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24613415 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24623416 }
3417
+
24633418 //cJME.count++;
24643419 //cJME.count %= 12;
24653420 if (gc)
....@@ -2643,6 +3598,7 @@
26433598 }
26443599 }
26453600 }
3601
+
26463602 cFileSystemPane FSPane;
26473603
26483604 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2652,7 +3608,7 @@
26523608
26533609 freezematerial = true;
26543610 colorField.setFloat(mat.color);
2655
- modulationField.setFloat(mat.modulation);
3611
+ saturationField.setFloat(mat.modulation);
26563612 metalnessField.setFloat(mat.metalness);
26573613 diffuseField.setFloat(mat.diffuse);
26583614 specularField.setFloat(mat.specular);
....@@ -2696,11 +3652,14 @@
26963652 }
26973653 }
26983654 }
3655
+
26993656 freezematerial = false;
27003657 }
27013658
27023659 void SetMaterial(Object3D object)
27033660 {
3661
+ latestObject = object;
3662
+
27043663 cMaterial mat = object.material;
27053664
27063665 if (mat == null)
....@@ -2711,32 +3670,8 @@
27113670
27123671 if (multiplyToggle != null)
27133672 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
- }
3673
+
3674
+ AllocProjectedVertices(object);
27403675
27413676 SetMaterial(mat, object.projectedVertices);
27423677 }
....@@ -2812,12 +3747,17 @@
28123747 // }
28133748
28143749 /**/
2815
- if (deselect)
3750
+ if (deselect || child == null)
28163751 {
28173752 //group.deselectAll();
28183753 //freeze = true;
28193754 GetTree().clearSelection();
28203755 //freeze = false;
3756
+
3757
+ if (child == null)
3758
+ {
3759
+ return;
3760
+ }
28213761 }
28223762
28233763 //group.addSelectee(child);
....@@ -2851,6 +3791,17 @@
28513791 public void itemStateChanged(ItemEvent event)
28523792 {
28533793 // System.out.println("Propagate = " + propagate);
3794
+ if (event.getSource() == pinButton)
3795
+ {
3796
+ copy.pinned ^= true;
3797
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3798
+ {
3799
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3800
+ copy.CloseUI();
3801
+ //copy.editWindow.refreshContents();
3802
+ }
3803
+ }
3804
+ else
28543805 if (event.getSource() == propagateToggle)
28553806 {
28563807 propagate ^= true;
....@@ -2886,7 +3837,7 @@
28863837 cameraView.ToggleDL();
28873838 cameraView.repaint();
28883839 return;
2889
- } else if (event.getSource() == toggleTextureItem)
3840
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28903841 {
28913842 cameraView.ToggleTexture();
28923843 // june 2013 copy.HardTouch();
....@@ -2925,9 +3876,9 @@
29253876 frame.validate();
29263877
29273878 return;
2928
- } else if (event.getSource() == toggleSwitchItem)
3879
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29293880 {
2930
- cameraView.ToggleRandom();
3881
+ cameraView.ToggleSwitch();
29313882 cameraView.repaint();
29323883 return;
29333884 } else if (event.getSource() == toggleHandleItem)
....@@ -2955,8 +3906,9 @@
29553906 } else if (event.getSource() == liveCB)
29563907 {
29573908 copy.live ^= true;
3909
+ objEditor.refreshContents(true); // To show item colors
29583910 return;
2959
- } else if (event.getSource() == selectCB)
3911
+ } else if (event.getSource() == selectableCB)
29603912 {
29613913 copy.dontselect ^= true;
29623914 return;
....@@ -2964,7 +3916,7 @@
29643916 {
29653917 copy.hide ^= true;
29663918 copy.Touch(); // display list issue
2967
- objEditor.refreshContents();
3919
+ objEditor.refreshContents(true); // To show item colors
29683920 return;
29693921 } else if (event.getSource() == link2masterCB)
29703922 {
....@@ -3029,7 +3981,7 @@
30293981 //System.out.println("ObjEditor " + event);
30303982 applySelf0(true);
30313983 //parent.applySelf();
3032
- objEditor.refreshContents();
3984
+ // conflicts with requestFocus objEditor.refreshContents();
30333985 } else if (source == resetButton)
30343986 {
30353987 CameraPane.fullreset = true;
....@@ -3141,9 +4093,9 @@
31414093 {
31424094 Close();
31434095 //return true;
3144
- } else if (source == loadItem)
4096
+ } else if (source == openItem)
31454097 {
3146
- load();
4098
+ Open();
31474099 //return true;
31484100 } else if (source == newItem)
31494101 {
....@@ -3168,6 +4120,10 @@
31684120 {
31694121 generatePOV();
31704122 //return true;
4123
+ } else if (event.getSource() == archiveItem)
4124
+ {
4125
+ cTools.Archive(frame);
4126
+ return;
31714127 } else if (source == zBufferItem)
31724128 {
31734129 try
....@@ -3214,22 +4170,32 @@
32144170 objEditor.refreshContents();
32154171 }
32164172
3217
- static public byte[] Compress(Object o)
4173
+ static public byte[] Compress(Object3D o)
32184174 {
4175
+ // Slower to actually compress.
32194176 try
32204177 {
32214178 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3222
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3223
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4179
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4180
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
32244181
4182
+ Object3D parent = o.parent;
4183
+ o.parent = null;
4184
+
32254185 out.writeObject(o);
32264186
4187
+ o.parent = parent;
4188
+
32274189 out.flush();
32284190
3229
- zstream.close();
4191
+ baos //zstream
4192
+ .close();
32304193 out.close();
32314194
3232
- return baos.toByteArray();
4195
+ byte[] bytes = baos.toByteArray();
4196
+
4197
+ System.out.println("save #bytes = " + bytes.length);
4198
+ return bytes;
32334199 } catch (Exception e)
32344200 {
32354201 System.err.println(e);
....@@ -3239,12 +4205,16 @@
32394205
32404206 static public Object Uncompress(byte[] bytes)
32414207 {
4208
+ System.out.println("restore #bytes = " + bytes.length);
32424209 try
32434210 {
32444211 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3245
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3246
- ObjectInputStream in = new ObjectInputStream(istream);
4212
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4213
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
32474214 Object obj = in.readObject();
4215
+
4216
+ bais //istream
4217
+ .close();
32484218 in.close();
32494219
32504220 return obj;
....@@ -3299,32 +4269,97 @@
32994269 return null;
33004270 }
33014271
3302
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
33034272
33044273 public void Save()
33054274 {
3306
- cRadio tab = GetCurrentTab();
4275
+ //Save(true);
4276
+ Replace();
4277
+ SetVersionStates();
4278
+ }
4279
+
4280
+ private boolean Equal(byte[] compress, byte[] name)
4281
+ {
4282
+ if (compress.length != name.length)
4283
+ {
4284
+ return false;
4285
+ }
33074286
3308
- copy.ExtractBigData(hashtable);
4287
+ for (int i=compress.length; --i>=0;)
4288
+ {
4289
+ if (compress[i] != name[i])
4290
+ return false;
4291
+ }
4292
+
4293
+ return true;
4294
+ }
4295
+
4296
+ void DeleteVersion()
4297
+ {
4298
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4299
+ {
4300
+ copy.versionlist[i] = copy.versionlist[i+1];
4301
+ }
4302
+
4303
+ if (copy.versionlist[copy.versionindex] == null)
4304
+ copy.versionindex -= 1;
4305
+
4306
+ if (copy.versionindex != -1)
4307
+ CopyChanged();
4308
+
4309
+ SetVersionStates();
4310
+ }
4311
+
4312
+ public boolean Save(boolean user)
4313
+ {
4314
+ System.err.println("Save");
4315
+ Replace();
4316
+
4317
+ //cRadio tab = GetCurrentTab();
4318
+
4319
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
4320
+
4321
+ boolean thesame = false;
4322
+
4323
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4324
+// {
4325
+// thesame = true;
4326
+// }
33094327
33104328 //EditorFrame.m_MainFrame.requestFocusInWindow();
3311
- tab.graphs[tab.undoindex++] = (Object3D)clone(copy);
3312
-
3313
- copy.RestoreBigData(hashtable);
3314
-
3315
- //assert(hashtable.isEmpty());
3316
-
3317
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
4329
+ if (!thesame)
33184330 {
3319
- tab.graphs[i] = null;
4331
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4332
+ {
4333
+ copy.versionlist[i] = copy.versionlist[i-1];
4334
+ }
4335
+
4336
+ //tab.user[tab.versionindex] = user;
4337
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4338
+
4339
+ copy.versionlist[++copy.versionindex] = compress;
4340
+
4341
+ // if (increment)
4342
+ // tab.versionindex++;
33204343 }
33214344
4345
+ //copy.RestoreBigData(versiontable);
4346
+
4347
+ //assert(hashtable.isEmpty());
4348
+
4349
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4350
+// {
4351
+// //tab.user[i] = false;
4352
+// copy.versionlist[i] = null;
4353
+// }
4354
+
4355
+ SetVersionStates();
4356
+
33224357 // test save
33234358 if (false)
33244359 {
33254360 try
33264361 {
3327
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4362
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
33284363 ObjectOutputStream p = new ObjectOutputStream(ostream);
33294364
33304365 p.writeObject(copy);
....@@ -3337,21 +4372,68 @@
33374372 e.printStackTrace();
33384373 }
33394374 }
4375
+
4376
+ return !thesame;
4377
+ }
4378
+
4379
+ boolean flashIt = true;
4380
+
4381
+ void RefreshSelection()
4382
+ {
4383
+ Object3D selection = new Object3D();
4384
+
4385
+ for (int i = 0; i < copy.selection.size(); i++)
4386
+ {
4387
+ Object3D elem = copy.selection.elementAt(i);
4388
+
4389
+ Object3D obj = copy.GetObject(elem.GetUUID());
4390
+
4391
+ if (obj == null)
4392
+ {
4393
+ copy.selection.remove(i--);
4394
+ }
4395
+ else
4396
+ {
4397
+ selection.add(obj);
4398
+ copy.selection.setElementAt(obj, i);
4399
+ }
4400
+ }
4401
+
4402
+ flashIt = false;
4403
+ GetTree().clearSelection();
4404
+ for (int i = 0; i < selection.size(); i++)
4405
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4406
+ flashIt = true;
4407
+
4408
+ //refreshContents(false);
33404409 }
33414410
3342
- void CopyChanged(Object3D obj)
4411
+ void CopyChanged()
33434412 {
3344
- copy.ExtractBigData(hashtable);
4413
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4414
+
4415
+ SetVersionStates();
4416
+
4417
+ boolean temp = CameraPane.SWITCH;
4418
+ CameraPane.SWITCH = false;
4419
+
4420
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
33454421
33464422 copy.clear();
33474423
4424
+ copy.skyboxname = obj.skyboxname;
4425
+ copy.skyboxext = obj.skyboxext;
4426
+
33484427 for (int i=0; i<obj.Size(); i++)
33494428 {
33504429 copy.add(obj.get(i));
33514430 }
33524431
3353
- copy.RestoreBigData(hashtable);
4432
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
33544433
4434
+ CameraPane.SWITCH = temp;
4435
+
4436
+ RefreshSelection();
33554437 //assert(hashtable.isEmpty());
33564438
33574439 copy.Touch();
....@@ -3372,43 +4454,161 @@
33724454 }
33734455 }
33744456
3375
- refreshContents();
4457
+ refreshContents(true);
33764458 }
33774459
3378
- public void Undo()
3379
- {
3380
- cRadio tab = GetCurrentTab();
4460
+ cButton previousVersionButton;
4461
+ cButton restoreButton;
4462
+ cButton replaceButton;
4463
+ cButton nextVersionButton;
4464
+ cButton saveVersionButton;
4465
+ cButton deleteVersionButton;
33814466
3382
- if (tab.undoindex == 0)
4467
+ boolean muteSlider;
4468
+
4469
+ int VersionCount()
4470
+ {
4471
+ int count = 0;
4472
+
4473
+ for (int i = copy.versionlist.length; --i >= 0;)
4474
+ {
4475
+ if (copy.versionlist[i] != null)
4476
+ count++;
4477
+ }
4478
+
4479
+ return count;
4480
+ }
4481
+
4482
+ public cGridBag versionSliderPane;
4483
+
4484
+ void SetVersionStates()
4485
+ {
4486
+ //if (true)
4487
+ // return;
4488
+
4489
+ //cRadio tab = GetCurrentTab();
4490
+
4491
+ if (copy.versionlist == null)
4492
+ {
4493
+ saveVersionButton.setEnabled(false);
4494
+ restoreButton.setEnabled(false);
4495
+ replaceButton.setEnabled(false);
4496
+ previousVersionButton.setEnabled(false);
4497
+ nextVersionButton.setEnabled(false);
4498
+ deleteVersionButton.setEnabled(false);
4499
+ versionSliderPane.setVisible(false);
4500
+ }
4501
+ else
4502
+ {
4503
+ restoreButton.setEnabled(copy.versionindex != -1);
4504
+ replaceButton.setEnabled(copy.versionindex != -1);
4505
+
4506
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4507
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4508
+
4509
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4510
+ //copy.versionlist[copy.versionindex + 1] != null);
4511
+
4512
+ muteSlider = true;
4513
+ versionSlider.setMinimum(0);
4514
+ versionSlider.setMaximum(VersionCount() - 1);
4515
+ versionSlider.setInteger(copy.versionindex);
4516
+ versionSlider.setEnabled(copy.versionindex != -1);
4517
+ muteSlider = false;
4518
+
4519
+ versionSliderPane.setVisible(true);
4520
+ }
4521
+ }
4522
+
4523
+ public boolean PreviousVersion()
4524
+ {
4525
+ // Option?
4526
+ Replace();
4527
+
4528
+ System.err.println("Undo");
4529
+
4530
+ //cRadio tab = GetCurrentTab();
4531
+
4532
+ if (copy.versionindex == 0)
33834533 {
33844534 java.awt.Toolkit.getDefaultToolkit().beep();
3385
- return;
4535
+ return false;
33864536 }
33874537
3388
- if (tab.graphs[tab.undoindex] == null)
3389
- {
3390
- Save();
3391
- tab.undoindex -= 1;
3392
- }
4538
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4539
+// {
4540
+// if (Save(false))
4541
+// tab.versionindex -= 1;
4542
+// else
4543
+// {
4544
+// if (tab.versionindex <= 0)
4545
+// return false;
4546
+// else
4547
+// tab.versionindex -= 1;
4548
+// }
4549
+// }
33934550
3394
- tab.undoindex -= 1;
4551
+ copy.versionindex -= 1;
33954552
3396
- CopyChanged(tab.graphs[tab.undoindex]);
4553
+ CopyChanged();
4554
+
4555
+ return true;
33974556 }
33984557
3399
- public void Redo()
4558
+ public boolean Restore()
34004559 {
3401
- cRadio tab = GetCurrentTab();
4560
+ System.err.println("Restore");
34024561
3403
- if (tab.graphs[tab.undoindex + 1] == null)
4562
+ //cRadio tab = GetCurrentTab();
4563
+
4564
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4565
+ {
4566
+ java.awt.Toolkit.getDefaultToolkit().beep();
4567
+ return false;
4568
+ }
4569
+
4570
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4571
+ CopyChanged();
4572
+
4573
+ return true;
4574
+ }
4575
+
4576
+ public boolean Replace()
4577
+ {
4578
+ //System.err.println("Replace");
4579
+
4580
+ //cRadio tab = GetCurrentTab();
4581
+
4582
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4583
+ {
4584
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4585
+ return false;
4586
+ }
4587
+
4588
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4589
+
4590
+ return true;
4591
+ }
4592
+
4593
+ public void NextVersion()
4594
+ {
4595
+ // Option?
4596
+ Replace();
4597
+
4598
+ //cRadio tab = GetCurrentTab();
4599
+
4600
+ if (copy.versionlist[copy.versionindex + 1] == null)
34044601 {
34054602 java.awt.Toolkit.getDefaultToolkit().beep();
34064603 return;
34074604 }
34084605
3409
- tab.undoindex += 1;
4606
+ copy.versionindex += 1;
34104607
3411
- CopyChanged(tab.graphs[tab.undoindex]);
4608
+ CopyChanged();
4609
+
4610
+ //if (!tab.user[tab.versionindex])
4611
+ // tab.graphs[tab.versionindex] = null;
34124612 }
34134613
34144614 void ImportGFD()
....@@ -3560,7 +4760,7 @@
35604760 assert false;
35614761 }
35624762
3563
- void EditSelection()
4763
+ void EditSelection(boolean newWindow)
35644764 {
35654765 }
35664766
....@@ -3602,6 +4802,12 @@
36024802 // else
36034803 // applySelf(true);
36044804 // }
4805
+
4806
+ boolean Equal(double a, double b)
4807
+ {
4808
+ return Math.abs(a - b) < 0.001;
4809
+ }
4810
+
36054811 void applySelf0(boolean name)
36064812 {
36074813 if (name)
....@@ -3619,7 +4825,7 @@
36194825 //copy.material = new cMaterial(copy.GetMaterial());
36204826
36214827 current.color = (float) colorField.getFloat();
3622
- current.modulation = (float) modulationField.getFloat();
4828
+ current.modulation = (float) saturationField.getFloat();
36234829 current.metalness = (float) metalnessField.getFloat();
36244830 current.diffuse = (float) diffuseField.getFloat();
36254831 current.specular = (float) specularField.getFloat();
....@@ -3651,29 +4857,52 @@
36514857 {
36524858 cMaterial mat = copy.material;
36534859
3654
- colorField.SetToolTipValue((mat.color));
3655
- modulationField.SetToolTipValue((mat.modulation));
3656
- metalnessField.SetToolTipValue((mat.metalness));
3657
- diffuseField.SetToolTipValue((mat.diffuse));
3658
- specularField.SetToolTipValue((mat.specular));
3659
- shininessField.SetToolTipValue((mat.shininess));
3660
- shiftField.SetToolTipValue((mat.shift));
3661
- ambientField.SetToolTipValue((mat.ambient));
3662
- lightareaField.SetToolTipValue((mat.lightarea));
3663
- diffusenessField.SetToolTipValue((mat.factor));
3664
- velvetField.SetToolTipValue((mat.velvet));
3665
- sheenField.SetToolTipValue((mat.sheen));
3666
- subsurfaceField.SetToolTipValue((mat.subsurface));
3667
- backlitField.SetToolTipValue((mat.bump));
3668
- anisoField.SetToolTipValue((mat.aniso));
3669
- anisoVField.SetToolTipValue((mat.anisoV));
3670
- cameraField.SetToolTipValue((mat.cameralight));
3671
- selfshadowField.SetToolTipValue((mat.diffuseness));
3672
- shadowField.SetToolTipValue((mat.shadow));
3673
- textureField.SetToolTipValue((mat.texture));
3674
- opacityField.SetToolTipValue((mat.opacity));
3675
- fakedepthField.SetToolTipValue((mat.fakedepth));
3676
- shadowbiasField.SetToolTipValue((mat.shadowbias));
4860
+ if (!Equal(colorField.getFloat(), mat.color))
4861
+ colorField.SetToolTipValue((mat.color));
4862
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4863
+ saturationField.SetToolTipValue((mat.modulation));
4864
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4865
+ metalnessField.SetToolTipValue((mat.metalness));
4866
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4867
+ diffuseField.SetToolTipValue((mat.diffuse));
4868
+ if (!Equal(specularField.getFloat(), mat.specular))
4869
+ specularField.SetToolTipValue((mat.specular));
4870
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4871
+ shininessField.SetToolTipValue((mat.shininess));
4872
+ if (!Equal(shiftField.getFloat(), mat.shift))
4873
+ shiftField.SetToolTipValue((mat.shift));
4874
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4875
+ ambientField.SetToolTipValue((mat.ambient));
4876
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4877
+ lightareaField.SetToolTipValue((mat.lightarea));
4878
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4879
+ diffusenessField.SetToolTipValue((mat.factor));
4880
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4881
+ velvetField.SetToolTipValue((mat.velvet));
4882
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4883
+ sheenField.SetToolTipValue((mat.sheen));
4884
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4885
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4886
+ if (!Equal(backlitField.getFloat(), mat.bump))
4887
+ backlitField.SetToolTipValue((mat.bump));
4888
+ if (!Equal(anisoField.getFloat(), mat.aniso))
4889
+ anisoField.SetToolTipValue((mat.aniso));
4890
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
4891
+ anisoVField.SetToolTipValue((mat.anisoV));
4892
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
4893
+ cameraField.SetToolTipValue((mat.cameralight));
4894
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
4895
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4896
+ if (!Equal(shadowField.getFloat(), mat.shadow))
4897
+ shadowField.SetToolTipValue((mat.shadow));
4898
+ if (!Equal(textureField.getFloat(), mat.texture))
4899
+ textureField.SetToolTipValue((mat.texture));
4900
+ if (!Equal(opacityField.getFloat(), mat.opacity))
4901
+ opacityField.SetToolTipValue((mat.opacity));
4902
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
4903
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4904
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
4905
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
36774906 }
36784907
36794908 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -3704,9 +4933,28 @@
37044933 //copy.Touch();
37054934 }
37064935
4936
+ cNumberSlider versionSlider;
4937
+
37074938 public void stateChanged(ChangeEvent e)
37084939 {
3709
- // assert(false);
4940
+ // assert(false);
4941
+ if (e.getSource() == versionSlider)
4942
+ {
4943
+ if (muteSlider)
4944
+ return;
4945
+
4946
+ Replace();
4947
+
4948
+ int version = versionSlider.getInteger();
4949
+
4950
+ if (version != -1 && copy.versionlist[version] != null)
4951
+ {
4952
+ copy.versionindex = version;
4953
+ CopyChanged();
4954
+ }
4955
+
4956
+ return;
4957
+ }
37104958
37114959 if (freezematerial)
37124960 {
....@@ -3742,6 +4990,12 @@
37424990 {
37434991 //System.out.println("stateChanged = " + this);
37444992 materialtouched = true;
4993
+
4994
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4995
+ {
4996
+ saturationField.setFloat(1);
4997
+ }
4998
+
37454999 applySelf();
37465000 //System.out.println("this = " + this);
37475001 //System.out.println("PARENT = " + parent);
....@@ -4041,6 +5295,7 @@
40415295 {
40425296 if (GetTree() != null)
40435297 {
5298
+ GetTree().revalidate();
40445299 GetTree().repaint();
40455300 }
40465301
....@@ -4049,13 +5304,19 @@
40495304 ctrlPanel.validate(); // ? new
40505305 ctrlPanel.repaint();
40515306 }
5307
+
5308
+ if (previousVersionButton != null && copy.versionlist != null)
5309
+ SetVersionStates();
5310
+
5311
+ cameraView.requestFocusInWindow();
40525312 }
40535313
40545314 static TweenManager tweenManager = new TweenManager();
40555315
40565316 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
40575317 {
4058
- Save();
5318
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5319
+ Save();
40595320 //Tween.set(thing, 0).target(1).start(tweenManager);
40605321 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
40615322 // if (thing instanceof GenericJointDemo)
....@@ -4079,7 +5340,7 @@
40795340 // group = (Composite) group.get(0);
40805341 // }
40815342
4082
- System.out.println("makeSomething of " + thing);
5343
+ //System.out.println("makeSomething of " + thing);
40835344
40845345 /*
40855346 if (deselect && jList != null)
....@@ -4142,6 +5403,12 @@
41425403 {
41435404 ResetModel();
41445405 Select(thing.GetTreePath(), true, false); // unselect... false);
5406
+
5407
+ if (thing.Size() == 0)
5408
+ {
5409
+ //EditSelection(false);
5410
+ }
5411
+
41455412 refreshContents();
41465413 }
41475414
....@@ -4279,6 +5546,7 @@
42795546
42805547 try
42815548 {
5549
+ // Try compressed version first.
42825550 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
42835551 java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
42845552 java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
....@@ -4289,7 +5557,9 @@
42895557 readobj.ResetDisplayList();
42905558 } catch (Exception e)
42915559 {
4292
- //e.printStackTrace();
5560
+ if (!e.toString().contains("GZIP"))
5561
+ e.printStackTrace();
5562
+
42935563 try
42945564 {
42955565 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4348,6 +5618,12 @@
43485618
43495619 void LoadIt(Object obj)
43505620 {
5621
+ if (obj == null)
5622
+ {
5623
+ // Invalid file
5624
+ return;
5625
+ }
5626
+
43515627 System.out.println("Loaded " + obj);
43525628 //new Exception().printStackTrace();
43535629 Object3D readobj = (Object3D) obj;
....@@ -4357,11 +5633,14 @@
43575633
43585634 if (readobj != null)
43595635 {
4360
- Save();
5636
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5637
+ // Save();
43615638 try
43625639 {
43635640 //readobj.deepCopySelf(copy);
43645641 copy.clear(); // june 2014
5642
+ copy.skyboxname = readobj.skyboxname;
5643
+ copy.skyboxext = readobj.skyboxext;
43655644 for (int i = 0; i < readobj.size(); i++)
43665645 {
43675646 Object3D child = readobj.get(i); // reserve(i);
....@@ -4402,6 +5681,7 @@
44025681 }
44035682 } catch (ClassCastException e)
44045683 {
5684
+ e.printStackTrace();
44055685 assert (false);
44065686 Composite c = (Composite) copy;
44075687 c.children.clear();
....@@ -4412,17 +5692,32 @@
44125692 c.addChild(csg);
44135693 }
44145694
5695
+ copy.versionlist = readobj.versionlist;
5696
+ copy.versionindex = readobj.versionindex;
5697
+ copy.versiontable = readobj.versiontable;
5698
+
5699
+ if (copy.versionlist == null)
5700
+ {
5701
+ // Backward compatibility
5702
+ copy.versionlist = new Object3D[100];
5703
+ copy.versionindex = -1;
5704
+
5705
+ //Save(true);
5706
+ }
5707
+
5708
+ //? SetUndoStates();
5709
+
44155710 ResetModel();
44165711 copy.HardTouch(); // recompile?
44175712 refreshContents();
44185713 }
44195714 }
44205715
4421
- void load() // throws ClassNotFoundException
5716
+ void Open() // throws ClassNotFoundException
44225717 {
44235718 if (Grafreed.standAlone)
44245719 {
4425
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5720
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
44265721 browser.show();
44275722 String filename = browser.getFile();
44285723 if (filename != null && filename.length() > 0)
....@@ -4499,6 +5794,8 @@
44995794
45005795 void save()
45015796 {
5797
+ Replace();
5798
+
45025799 if (lastname == null)
45035800 {
45045801 return;
....@@ -4521,6 +5818,7 @@
45215818 //ps.print(buffer.toString());
45225819 } catch (IOException e)
45235820 {
5821
+ e.printStackTrace();
45245822 }
45255823 }
45265824
....@@ -4535,6 +5833,8 @@
45355833 String filename = browser.getFile();
45365834 if (filename != null && filename.length() > 0)
45375835 {
5836
+ if (!filename.endsWith(".gfd"))
5837
+ filename += ".gfd";
45385838 lastname = browser.getDirectory() + filename;
45395839 save();
45405840 }
....@@ -4701,7 +6001,7 @@
47016001 MenuBar menuBar;
47026002 Menu fileMenu;
47036003 MenuItem newItem;
4704
- MenuItem loadItem;
6004
+ MenuItem openItem;
47056005 MenuItem saveItem;
47066006 MenuItem saveAsItem;
47076007 MenuItem exportAsItem;
....@@ -4724,22 +6024,38 @@
47246024 CheckboxMenuItem toggleSwitchItem;
47256025 CheckboxMenuItem toggleRootItem;
47266026 CheckboxMenuItem animationItem;
6027
+ MenuItem archiveItem;
47276028 CheckboxMenuItem toggleHandleItem;
47286029 CheckboxMenuItem togglePaintItem;
47296030 JSplitPane mainPanel;
47306031 JScrollPane scrollpane;
6032
+
47316033 JPanel toolbarPanel;
6034
+
47326035 cGridBag treePanel;
6036
+
47336037 JPanel radioPanel;
47346038 ButtonGroup buttonGroup;
4735
- cGridBag ctrlPanel;
6039
+
6040
+ cGridBag toolboxPanel;
6041
+ cGridBag skyboxPanel;
47366042 cGridBag materialPanel;
6043
+ cGridBag ctrlPanel;
6044
+
47376045 JScrollPane infoPanel;
6046
+
47386047 cGridBag optionsPanel;
6048
+
47396049 JTabbedPane objectPanel;
6050
+ boolean materialFlushed;
6051
+ Object3D latestObject;
6052
+
6053
+ cGridBag transformPanel;
47406054 cGridBag XYZPanel;
6055
+
47416056 JSplitPane gridPanel;
47426057 JSplitPane bigPanel;
6058
+
47436059 cGridBag bigThree;
47446060 cGridBag scenePanel;
47456061 cGridBag centralPanel;
....@@ -4797,7 +6113,7 @@
47976113 JLabel colorLabel;
47986114 cNumberSlider colorField;
47996115 JLabel modulationLabel;
4800
- cNumberSlider modulationField;
6116
+ cNumberSlider saturationField;
48016117 JLabel metalnessLabel;
48026118 cNumberSlider metalnessField;
48036119 JLabel diffuseLabel;
....@@ -4828,6 +6144,7 @@
48286144 cNumberSlider anisoField;
48296145 JLabel anisoVLabel;
48306146 cNumberSlider anisoVField;
6147
+
48316148 JLabel cameraLabel;
48326149 cNumberSlider cameraField;
48336150 JLabel selfshadowLabel;
....@@ -4842,6 +6159,7 @@
48426159 cNumberSlider fakedepthField;
48436160 JLabel shadowbiasLabel;
48446161 cNumberSlider shadowbiasField;
6162
+
48456163 JLabel bumpLabel;
48466164 cNumberSlider bumpField;
48476165 JLabel noiseLabel;
....@@ -4854,7 +6172,7 @@
48546172 cNumberSlider fogField;
48556173 JLabel opacityPowerLabel;
48566174 cNumberSlider opacityPowerField;
4857
- JTree jTree;
6175
+ cTree jTree;
48586176 //ObjectUI parent;
48596177
48606178 cNumberSlider normalpushField;