Normand Briere
2019-08-19 22e8ab6479334206f97b0093f6c5ffd14610cce3
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,146 @@
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 Composite CreateCameras()
76
+ {
77
+ Composite cams = new cTemplate();
78
+ cams.name = "Cameras";
79
+ copy.insertElementAt(cams, 0);
80
+
81
+ cams.addChild(new Camera());
82
+ cams.addChild(new Camera(1));
83
+ cams.addChild(new Camera(2));
84
+ cams.addChild(new Camera(3));
85
+ cams.addChild(new Camera(4));
86
+
87
+ return cams;
88
+ }
89
+
90
+ public cGridBag GetSeparator()
91
+ {
92
+ cGridBag separator = new cGridBag();
93
+ separator.add(new JSeparator());
94
+ separator.preferredHeight = 5;
95
+ return separator;
96
+ }
97
+
98
+ cButton GetButton(String name, boolean border)
99
+ {
100
+ ImageIcon icon = GetIcon(name);
101
+ if (icon != null || name.contains("/"))
102
+ return new cButton(icon, border);
103
+ else
104
+ return new cButton(name, border);
105
+ }
106
+
107
+ cLabel GetLabel(String name, boolean border)
108
+ {
109
+ //ImageIcon icon = GetIcon(name);
110
+ return new cLabel(GetImage(name), border);
111
+ }
112
+
113
+ cToggleButton GetToggleButton(String name, boolean border)
114
+ {
115
+ ImageIcon icon = GetIcon(name);
116
+ return new cToggleButton(icon, border);
117
+ }
118
+
119
+ cCheckBox GetCheckBox(String name, boolean border)
120
+ {
121
+ ImageIcon icon = GetIcon(name);
122
+ return new cCheckBox(icon, border);
123
+ }
124
+
125
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
126
+
127
+ static ImageIcon GetIcon(String name)
128
+ {
129
+ javax.swing.ImageIcon iconCache = icons.get(name);
130
+ if (iconCache != null)
131
+ {
132
+ return iconCache;
133
+ }
134
+
135
+ try
136
+ {
137
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
138
+
139
+// if (image.getWidth() > 48 && image.getHeight() > 48)
140
+// {
141
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
142
+// Graphics2D g = resized.createGraphics();
143
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
144
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
145
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
146
+// g.dispose();
147
+//
148
+// image = resized;
149
+// }
150
+
151
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
152
+
153
+ icons.put(name, icon);
154
+
155
+ return icon;
156
+ }
157
+ catch (Exception e)
158
+ {
159
+ //icons.put(name, null);
160
+ return null;
161
+ }
162
+ }
163
+
164
+ BufferedImage GetImage(String name)
165
+ {
166
+ try
167
+ {
168
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
169
+
170
+ return image;
171
+ }
172
+ catch (Exception e)
173
+ {
174
+ return null;
175
+ }
176
+ }
38177
39178 // SCRIPT
40179
....@@ -145,7 +284,7 @@
145284
146285 objEditor.ctrlPanel.remove(namePanel);
147286
148
- if (!GroupEditor.allparams)
287
+ if (!allparams)
149288 return;
150289
151290 // objEditor.ctrlPanel.remove(liveCB);
....@@ -168,7 +307,8 @@
168307 // objEditor.ctrlPanel.remove(remarkButton);
169308
170309 objEditor.ctrlPanel.remove(setupPanel);
171
- objEditor.ctrlPanel.remove(commandsPanel);
310
+ objEditor.ctrlPanel.remove(setupPanel2);
311
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
172312 objEditor.ctrlPanel.remove(pushPanel);
173313 //objEditor.ctrlPanel.remove(fillPanel);
174314
....@@ -216,6 +356,14 @@
216356 client = inClient;
217357 copy = client;
218358
359
+// if (copy.versionlist == null)
360
+// {
361
+// copy.versionlist = new Object3D[100];
362
+// copy.versionindex = -1;
363
+//
364
+// callee.Save(true);
365
+// }
366
+
219367 // "this" is not called: SetupUI2(objEditor);
220368 }
221369
....@@ -229,6 +377,14 @@
229377 client = inClient;
230378 copy = client;
231379
380
+ if (copy.versionlist == null)
381
+ {
382
+ copy.versionlist = new Object3D[100];
383
+ copy.versionindex = -1;
384
+
385
+// Save(true);
386
+ }
387
+
232388 SetupUI2(callee.GetEditor());
233389 }
234390
....@@ -243,13 +399,15 @@
243399 //localCopy.parent = null;
244400
245401 frame = new JFrame();
402
+ frame.setUndecorated(false);
246403 objEditor = this;
247404 this.callee = callee;
248405
249406 //parent = p;
250407
251408 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
252
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
409
+ if (Globals.DEBUG)
410
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
253411 //gd.setFullScreenWindow(this);
254412 //setResizable(false);
255413 //if (!isDisplayable())
....@@ -260,6 +418,14 @@
260418 copy = localCopy;
261419 copy.editWindow = this;
262420
421
+// if (copy.versionlist == null)
422
+// {
423
+// copy.versionlist = new Object3D[100];
424
+// copy.versionindex = -1;
425
+//
426
+// Save(true);
427
+// }
428
+
263429 SetupMenu();
264430
265431 //SetupName(objEditor); // new
....@@ -273,12 +439,20 @@
273439 return frame.action(event, obj);
274440 }
275441
442
+ // Cannot work without static
443
+ static boolean allparams = true;
444
+
445
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
446
+
447
+ // This is to refresh the UI of the material panel.
448
+ boolean patchMaterial;
449
+
276450 void SetupMenu()
277451 {
278452 frame.setMenuBar(menuBar = new MenuBar());
279453 menuBar.add(fileMenu = new Menu("File"));
280454 fileMenu.add(newItem = new MenuItem("New"));
281
- fileMenu.add(loadItem = new MenuItem("Load..."));
455
+ fileMenu.add(openItem = new MenuItem("Open..."));
282456
283457 //oe.menuBar.add(menu = new Menu("Include"));
284458 Menu menu = new Menu("Import");
....@@ -286,8 +460,11 @@
286460 importOBJItem.addActionListener(this);
287461 import3DSItem = menu.add(new MenuItem("3DS file..."));
288462 import3DSItem.addActionListener(this);
463
+ if (Globals.ADVANCED)
464
+ {
289465 importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
290466 importVRMLX3DItem.addActionListener(this);
467
+ }
291468 menu.add("-");
292469 importGFDItem = menu.add(new MenuItem("Grafreed file..."));
293470 importGFDItem.addActionListener(this);
....@@ -310,7 +487,7 @@
310487 }
311488
312489 newItem.addActionListener(this);
313
- loadItem.addActionListener(this);
490
+ openItem.addActionListener(this);
314491 saveItem.addActionListener(this);
315492 saveAsItem.addActionListener(this);
316493 exportAsItem.addActionListener(this);
....@@ -319,28 +496,102 @@
319496 closeItem.addActionListener(this);
320497
321498 objectPanel = new JTabbedPane();
499
+
500
+ ChangeListener changeListener = new ChangeListener()
501
+ {
502
+ //String name;
503
+
504
+ public void stateChanged(ChangeEvent changeEvent)
505
+ {
506
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
507
+// {
508
+// if (latestObject != null)
509
+// {
510
+// refreshContents(true);
511
+// SetMaterial(latestObject);
512
+// }
513
+//
514
+// materialFlushed = true;
515
+// }
516
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
517
+// {
518
+// if (listUI.size() == 0)
519
+// EditSelection(false);
520
+// }
521
+
522
+// if (objectPanel.getSelectedIndex() == 4)
523
+// {
524
+// name = copy.skyboxname;
525
+//
526
+// if (name == null)
527
+// {
528
+// name = "";
529
+// }
530
+//
531
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
532
+// copy.skyboxext = "jpg";
533
+// }
534
+// else
535
+// {
536
+// if (name != null)
537
+// {
538
+// if (name.equals(""))
539
+// {
540
+// copy.skyboxname = null;
541
+// copy.skyboxext = null;
542
+// }
543
+// else
544
+// {
545
+// copy.skyboxname = name;
546
+// }
547
+// }
548
+// }
549
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
550
+
551
+// refreshContents(false); // To refresh Info tab
552
+ cameraView.repaint();
553
+ }
554
+ };
555
+ objectPanel.addChangeListener(changeListener);
556
+
322557 toolbarPanel = new JPanel();
323558 toolbarPanel.setName("Toolbar");
559
+
324560 treePanel = new cGridBag();
325561 treePanel.setName("Tree");
562
+
563
+ editPanel = new cGridBag().setVertical(true);
564
+ //editPanel.setName("Edit");
565
+
326566 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
327
- ctrlPanel.setName("Edit");
328
- materialPanel = new cGridBag().setVertical(true);
329
- materialPanel.setName("Material");
567
+
568
+ editCommandsPanel = new cGridBag();
569
+ editPanel.add(editCommandsPanel);
570
+ editPanel.add(ctrlPanel);
571
+
572
+ toolboxPanel = new cGridBag().setVertical(true);
573
+ //toolboxPanel.setName("Toolbox");
574
+
575
+ skyboxPanel = new cGridBag().setVertical(true);
576
+
577
+ materialPanel = new cGridBag().setVertical(false);
578
+ //materialPanel.setName("Material");
579
+
330580 /*JTextPane*/
331581 infoarea = createTextPane();
332582 doc = infoarea.getStyledDocument();
333583
334584 infoarea.setEditable(true);
335585 SetText();
586
+
336587 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
337588 // infoarea.setOpaque(false);
338589 // //infoarea.setForeground(textcolor);
339590 // TEXTAREA infoarea.setLineWrap(true);
340591 // TEXTAREA infoarea.setWrapStyleWord(true);
341592 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");
593
+ infoPanel.setPreferredSize(new Dimension(1, 1));
594
+ //infoPanel.setName("Info");
344595 //infoPanel.setLayout(new BorderLayout());
345596 //infoPanel.add(createTextPane());
346597
....@@ -351,7 +602,14 @@
351602 mainPanel.setDividerSize(9);
352603 mainPanel.setDividerLocation(0.5); //1.0);
353604 mainPanel.setResizeWeight(0.5);
354
-
605
+
606
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
607
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
608
+ divider.setDividerSize(15);
609
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
610
+
611
+ mainPanel.setUI(new BasicSplitPaneUI());
612
+
355613 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
356614 //mainPanel.setLayout(new GridBagLayout());
357615 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -419,10 +677,10 @@
419677 e.printStackTrace();
420678 }
421679
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();
680
+// String selection = infoarea.getText();
681
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
682
+// java.awt.datatransfer.Clipboard clipboard =
683
+// Toolkit.getDefaultToolkit().getSystemClipboard();
426684 //clipboard.setContents(data, data);
427685 }
428686
....@@ -582,21 +840,169 @@
582840 }
583841 }
584842
843
+//static GraphicsDevice device = GraphicsEnvironment
844
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
845
+
846
+ Rectangle keeprect;
847
+ cRadio radio;
848
+
849
+cButton keepButton;
850
+ cButton twoButton; // Full 3D
851
+ cButton sixButton;
852
+ cButton threeButton;
853
+ cButton sevenButton;
854
+ cButton fourButton; // full panel
855
+ cButton oneButton; // full XYZ
856
+ //cButton currentLayout;
857
+
858
+ boolean maximized;
859
+
860
+ cButton fullscreenLayout;
861
+ cButton expandedLayout;
862
+
863
+ void Minimize()
864
+ {
865
+ frame.setState(Frame.ICONIFIED);
866
+ frame.validate();
867
+ }
868
+
869
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
870
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
871
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
872
+ void Maximize()
873
+ {
874
+ if (CameraPane.FULLSCREEN)
875
+ {
876
+ ToggleFullScreen();
877
+ }
878
+
879
+ if (maximized)
880
+ {
881
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
882
+ }
883
+ else
884
+ {
885
+ keeprect = frame.getBounds();
886
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
887
+// Dimension rect2 = frame.getToolkit().getScreenSize();
888
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
889
+// frame.setState(Frame.MAXIMIZED_BOTH);
890
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
891
+ }
892
+
893
+ maximized ^= true;
894
+
895
+ frame.validate();
896
+ }
897
+
898
+ cButton minButton;
899
+ cButton maxButton;
900
+ cButton fullButton;
901
+ cButton collapseButton;
902
+ cButton maximize3DButton;
903
+
585904 void ToggleFullScreen()
586905 {
587
- if (CameraPane.FULLSCREEN)
906
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
907
+
908
+ cameraView.ToggleFullScreen();
909
+
910
+ if (!CameraPane.FULLSCREEN)
588911 {
589
- frame.getContentPane().remove(/*"Center",*/bigThree);
590
- framePanel.add(bigThree);
591
- frame.getContentPane().add(/*"Center",*/framePanel);
912
+ device.setFullScreenWindow(null);
913
+ frame.dispose();
914
+ frame.setUndecorated(false);
915
+ frame.validate();
916
+ frame.setVisible(true);
917
+
918
+ //frame.setVisible(false);
919
+// frame.removeNotify();
920
+// frame.setUndecorated(false);
921
+// frame.addNotify();
922
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
923
+
924
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
925
+// X framePanel.add(bigThree);
926
+// X frame.getContentPane().add(/*"Center",*/framePanel);
927
+// framePanel.setDividerLocation(46); // icons are 24x24
928
+
929
+ //frame.setVisible(true);
930
+// radio.layout = keepButton;
931
+ //theFrame = null;
932
+ keepButton = null;
933
+// radio.layout.doClick();
934
+
592935 } else
593936 {
594
- frame.getContentPane().remove(/*"Center",*/framePanel);
595
- framePanel.remove(bigThree);
596
- frame.getContentPane().add(/*"Center",*/bigThree);
937
+ keepButton = radio.layout;
938
+ //keeprect = frame.getBounds();
939
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
940
+// frame.getToolkit().getScreenSize().height);
941
+ //frame.setVisible(false);
942
+
943
+ frame.dispose();
944
+ frame.setUndecorated(true);
945
+ device.setFullScreenWindow(frame);
946
+ frame.validate();
947
+ frame.setVisible(true);
948
+// frame.removeNotify();
949
+// frame.setUndecorated(true);
950
+// frame.addNotify();
951
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
952
+// X framePanel.remove(bigThree);
953
+// X frame.getContentPane().add(/*"Center",*/bigThree);
954
+// framePanel.setDividerLocation(0);
955
+
956
+// radio.layout = fullscreenLayout;
957
+// radio.layout.doClick();
958
+ //frame.setVisible(true);
597959 }
598
- cameraView.ToggleFullScreen();
960
+ frame.validate();
961
+
962
+ cameraView.requestFocusInWindow();
599963 }
964
+
965
+ void CollapseToolbar()
966
+ {
967
+ framePanel.setDividerLocation(0);
968
+ //frame.validate();
969
+
970
+ cameraView.requestFocusInWindow();
971
+ }
972
+
973
+ private Object3D Duplicate(Object3D object)
974
+ {
975
+ boolean temp = CameraPane.SWITCH;
976
+ CameraPane.SWITCH = false;
977
+
978
+ if (Grafreed.grafreed.universe.versiontable == null)
979
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
980
+
981
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
982
+ // if (copy == client)
983
+
984
+ Object3D versions[] = object.versionlist;
985
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
986
+ object.versionlist = null;
987
+ object.versiontable = null;
988
+
989
+ Object3D parent = object.parent;
990
+ object.parent = null;
991
+
992
+ //byte[] compress = Compress(copy);
993
+ Object3D compress = (Object3D)Grafreed.clone(object);
994
+
995
+ object.parent = parent;
996
+
997
+ object.versionlist = versions;
998
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
999
+
1000
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
1001
+
1002
+ CameraPane.SWITCH = temp;
1003
+
1004
+ return compress;
1005
+ }
6001006
6011007 private JTextPane createTextPane()
6021008 {
....@@ -719,6 +1125,7 @@
7191125 {
7201126 SetupMaterial(materialPanel);
7211127 }
1128
+
7221129 //SetupName();
7231130 //SetupViews();
7241131 }
....@@ -728,7 +1135,7 @@
7281135 // NumberSlider vDivsField;
7291136 // JCheckBox endcaps;
7301137 JCheckBox liveCB;
731
- JCheckBox selectCB;
1138
+ JCheckBox selectableCB;
7321139 JCheckBox hideCB;
7331140 JCheckBox link2masterCB;
7341141 JCheckBox markCB;
....@@ -736,7 +1143,12 @@
7361143 JCheckBox speedupCB;
7371144 JCheckBox rewindCB;
7381145 JCheckBox flipVCB;
1146
+
1147
+ cCheckBox toggleTextureCB;
1148
+ cCheckBox toggleSwitchCB;
1149
+
7391150 JComboBox texresMenu;
1151
+
7401152 JButton resetButton;
7411153 JButton stepButton;
7421154 JButton stepAllButton;
....@@ -745,9 +1157,13 @@
7451157 JButton fasterButton;
7461158 JButton remarkButton;
7471159
1160
+ cGridBag editPanel;
1161
+ cGridBag editCommandsPanel;
1162
+
7481163 cGridBag namePanel;
7491164 cGridBag setupPanel;
750
- cGridBag commandsPanel;
1165
+ cGridBag setupPanel2;
1166
+ cGridBag objectCommandsPanel;
7511167 cGridBag pushPanel;
7521168 cGridBag fillPanel;
7531169
....@@ -918,61 +1334,81 @@
9181334
9191335 namePanel = new cGridBag();
9201336
1337
+ //if (copy.pinned)
1338
+ {
1339
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
1340
+ pinButton.setSelected(copy.pinned);
1341
+ cGridBag t = new cGridBag();
1342
+ t.preferredWidth = 2;
1343
+ t.add(pinButton);
1344
+ namePanel.add(t);
1345
+
1346
+ pinButton.addItemListener(this);
1347
+ }
1348
+
9211349 nameField = AddText(namePanel, copy.GetName());
922
- namePanel.add(nameField);
1350
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9231351 oe.ctrlPanel.add(namePanel);
9241352
9251353 oe.ctrlPanel.Return();
9261354
927
- if (!GroupEditor.allparams)
1355
+ if (!allparams)
9281356 return;
9291357
9301358 setupPanel = new cGridBag().setVertical(false);
9311359
9321360 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
9331361 liveCB.setToolTipText("Animate object");
934
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
935
- selectCB.setToolTipText("Make object selectable");
1362
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1363
+ markCB.setToolTipText("Set target transform");
1364
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1365
+ selectableCB.setToolTipText("Make object selectable");
9361366 // Return();
1367
+
9371368 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9381369 hideCB.setToolTipText("Hide object");
939
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
940
- markCB.setToolTipText("Set the animation target transform");
9411370
942
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1371
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1372
+
1373
+ setupPanel2 = new cGridBag().setVertical(false);
1374
+
1375
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9431376 rewindCB.setToolTipText("Rewind animation");
9441377
945
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
946
- randomCB.setToolTipText("Option for switch node");
1378
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1379
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9471380
1381
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1382
+ link2masterCB.setToolTipText("Attach to support");
1383
+
9481384 if (Globals.ADVANCED)
9491385 {
950
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
951
- link2masterCB.setToolTipText("Attach to support");
952
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1386
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9531387 speedupCB.setToolTipText("Option motion capture");
9541388 }
9551389
9561390 oe.ctrlPanel.add(setupPanel);
9571391 oe.ctrlPanel.Return();
1392
+ oe.ctrlPanel.add(setupPanel2);
1393
+ oe.ctrlPanel.Return();
9581394
959
- commandsPanel = new cGridBag().setVertical(false);
1395
+ objectCommandsPanel = new cGridBag().setVertical(false);
9601396
961
- resetButton = AddButton(commandsPanel, "Reset");
1397
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9621398 resetButton.setToolTipText("Jump to frame zero");
963
- stepButton = AddButton(commandsPanel, "Step");
1399
+ stepButton = AddButton(objectCommandsPanel, "Step");
9641400 stepButton.setToolTipText("Step one frame");
9651401 // resetAllButton = AddButton(oe, "Reset All");
9661402 // stepAllButton = AddButton(oe, "Step All");
9671403 // Return();
968
- slowerButton = AddButton(commandsPanel, "Slow");
1404
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9691405 slowerButton.setToolTipText("Decrease animation speed");
970
- fasterButton = AddButton(commandsPanel, "Fast");
1406
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9711407 fasterButton.setToolTipText("Increase animation speed");
972
- remarkButton = AddButton(commandsPanel, "Remark");
1408
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9731409 remarkButton.setToolTipText("Set the current transform as the target");
9741410
975
- oe.ctrlPanel.add(commandsPanel);
1411
+ oe.ctrlPanel.add(objectCommandsPanel);
9761412 oe.ctrlPanel.Return();
9771413
9781414 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1132,22 +1568,9 @@
11321568
11331569 if (cam == null || !(copy.get(0) instanceof cGroup))
11341570 {
1135
- System.out.println("CREATE CAMERAS");
1136
- cams = new cTemplate();
1137
- cams.name = "Cameras";
1138
- copy.insertElementAt(cams, 0);
1139
- //cams.parent = copy;
1140
-
1141
- cam = new Camera(); // LA.newVector(3, 2, 1));
1142
- cams.addChild(cam);
1143
- cam = new Camera(1);
1144
- cams.addChild(cam);
1145
- cam = new Camera(2);
1146
- cams.addChild(cam);
1147
- cam = new Camera(3);
1148
- cams.addChild(cam);
1149
- cam = new Camera(4); // Light
1150
- cams.addChild(cam);
1571
+ if (Globals.DEBUG)
1572
+ System.out.println("CREATE CAMERAS");
1573
+ cams = CreateCameras();
11511574 } else
11521575 {
11531576 cams = (cGroup) copy.get(0);
....@@ -1178,8 +1601,11 @@
11781601 //worldPanel.setName("World");
11791602 centralPanel = new cGridBag();
11801603 centralPanel.preferredWidth = 20;
1181
- timelinePanel = new JPanel(new BorderLayout());
1182
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1604
+
1605
+ if (Globals.ADVANCED)
1606
+ {
1607
+ timelinePanel = new JPanel(new BorderLayout());
1608
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11831609
11841610 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11851611 cameraPanel.setContinuousLayout(true);
....@@ -1188,7 +1614,10 @@
11881614 // cameraPanel.setDividerSize(9);
11891615 cameraPanel.setResizeWeight(1.0);
11901616
1617
+ }
1618
+
11911619 centralPanel.add(cameraView);
1620
+ centralPanel.setFocusable(true);
11921621 //frame.setJMenuBar(timelineMenubar);
11931622 //centralPanel.add(timelinePanel);
11941623
....@@ -1207,6 +1636,45 @@
12071636 //frontView.object = copy;
12081637 //sideView.object = copy;
12091638
1639
+ transformPanel = new cGridBag().setVertical(true);
1640
+
1641
+ cGridBag resetTransformPanel = new cGridBag();
1642
+
1643
+ resetTransformPanel.preferredHeight = 2;
1644
+
1645
+ cButton resetTransform = GetButton("Reset all", !Globals.NIMBUSLAF);
1646
+ resetTransform.setToolTipText("Reset Translation, Rotation and Scale");
1647
+ resetTransform.addMouseListener(new MouseAdapter()
1648
+ {
1649
+ public void mouseClicked(MouseEvent e)
1650
+ {
1651
+ ResetTransform();
1652
+ }
1653
+ });
1654
+ resetTransformPanel.add(resetTransform);
1655
+
1656
+ resetTransform = GetButton("T only", !Globals.NIMBUSLAF);
1657
+ resetTransform.setToolTipText("Reset Translation only");
1658
+ resetTransform.addMouseListener(new MouseAdapter()
1659
+ {
1660
+ public void mouseClicked(MouseEvent e)
1661
+ {
1662
+ ResetTransform(1);
1663
+ }
1664
+ });
1665
+ resetTransformPanel.add(resetTransform);
1666
+
1667
+ resetTransform = GetButton("RS only", !Globals.NIMBUSLAF);
1668
+ resetTransform.setToolTipText("Reset Rotation and Scale only");
1669
+ resetTransform.addMouseListener(new MouseAdapter()
1670
+ {
1671
+ public void mouseClicked(MouseEvent e)
1672
+ {
1673
+ ResetTransform(2);
1674
+ }
1675
+ });
1676
+ resetTransformPanel.add(resetTransform);
1677
+
12101678 XYZPanel = new cGridBag().setVertical(true);
12111679 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
12121680
....@@ -1214,7 +1682,11 @@
12141682 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12151683 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12161684 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1685
+ //XYZPanel.setName("XYZ");
12171686
1687
+ transformPanel.add(resetTransformPanel);
1688
+ transformPanel.add(XYZPanel);
1689
+
12181690 /*
12191691 gridPanel = new JPanel(); //new BorderLayout());
12201692 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1222,12 +1694,12 @@
12221694 gridPanel.add(cameraView);
12231695 gridPanel.add(XYZPanel);
12241696 */
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);
1697
+// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1698
+// gridPanel.setContinuousLayout(true);
1699
+// gridPanel.setOneTouchExpandable(true);
1700
+// gridPanel.setDividerLocation(1.0);
1701
+// gridPanel.setDividerSize(9);
1702
+// gridPanel.setResizeWeight(0.85);
12311703
12321704 // aConstraints.weighty = 0;
12331705 //System.out.println("THIS = " + this);
....@@ -1250,14 +1722,34 @@
12501722
12511723 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12521724 //tmp.setName("Edit");
1725
+ objectPanel.add(skyboxPanel);
1726
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1727
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1728
+
1729
+ objectPanel.add(toolboxPanel);
1730
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1731
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1732
+
12531733 objectPanel.add(materialPanel);
1734
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1735
+ objectPanel.setToolTipTextAt(2, "Material");
1736
+
12541737 // JPanel north = new JPanel(new BorderLayout());
12551738 // north.setName("Edit");
12561739 // north.add(ctrlPanel, BorderLayout.NORTH);
12571740 // objectPanel.add(north);
1258
- objectPanel.add(ctrlPanel);
1259
- objectPanel.add(infoPanel);
1260
-
1741
+ objectPanel.add(editPanel);
1742
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
1743
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1744
+
1745
+ objectPanel.add(transformPanel);
1746
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1747
+ objectPanel.setToolTipTextAt(4, "TRS transform");
1748
+
1749
+ patchMaterial = true;
1750
+ cameraView.patchMaterial = this;
1751
+ objectPanel.setSelectedIndex(2);
1752
+
12611753 /*
12621754 aConstraints.gridx = 0;
12631755 aConstraints.gridwidth = 1;
....@@ -1265,7 +1757,7 @@
12651757 aConstraints.gridy += 1;
12661758 aConstraints.gridwidth = 1;
12671759 mainPanel.add(objectPanel, aConstraints);
1268
- */
1760
+ */
12691761
12701762 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12711763 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1282,17 +1774,114 @@
12821774 JTabbedPane tabbedPane = new JTabbedPane();
12831775 tabbedPane.add(scrollpane);
12841776
1285
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1286
-
1287
- optionsPanel = new cGridBag().setVertical(true);
1777
+ optionsPanel = new cGridBag().setVertical(false);
12881778
12891779 optionsPanel.setName("Options");
12901780
12911781 AddOptions(optionsPanel); //, aConstraints);
12921782
1783
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1784
+
12931785 tabbedPane.add(optionsPanel);
12941786
12951787 scenePanel.add(tabbedPane);
1788
+
1789
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1790
+ creditsPanel.setName("Credits");
1791
+
1792
+ cLabel ogaLabel = new cLabel(" Most Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1793
+ creditsPanel.add(ogaLabel);
1794
+
1795
+ cButton creditButton;
1796
+ creditsPanel.add(creditButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1797
+ creditButton.setToolTipText("https://opengameart.org");
1798
+
1799
+ creditButton.addMouseListener(new MouseAdapter()
1800
+ {
1801
+ public void mouseClicked(MouseEvent e)
1802
+ {
1803
+ try
1804
+ {
1805
+ Desktop.getDesktop().browse(new java.net.URI("https://opengameart.org/"));
1806
+ } catch (Exception e1)
1807
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1808
+ {
1809
+ e1.printStackTrace();
1810
+ }
1811
+ }
1812
+ });
1813
+
1814
+ ogaLabel = new cLabel(" Download 3D models! (.3ds and .obj only)", !Globals.NIMBUSLAF);
1815
+ creditsPanel.add(ogaLabel);
1816
+
1817
+ creditsPanel.add(creditButton = GetButton("icons/3delicious.png", !Globals.NIMBUSLAF));
1818
+ creditButton.setToolTipText("https://3delicious.net");
1819
+
1820
+ creditButton.addMouseListener(new MouseAdapter()
1821
+ {
1822
+ public void mouseClicked(MouseEvent e)
1823
+ {
1824
+ try
1825
+ {
1826
+ Desktop.getDesktop().browse(new java.net.URI("https://3delicious.net"));
1827
+ } catch (Exception e1)
1828
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1829
+ {
1830
+ e1.printStackTrace();
1831
+ }
1832
+ }
1833
+ });
1834
+
1835
+ creditsPanel.add(creditButton = GetButton("icons/archive3d.png", !Globals.NIMBUSLAF));
1836
+ creditButton.setToolTipText("https://archive3d.net");
1837
+
1838
+ creditButton.addMouseListener(new MouseAdapter()
1839
+ {
1840
+ public void mouseClicked(MouseEvent e)
1841
+ {
1842
+ try
1843
+ {
1844
+ Desktop.getDesktop().browse(new java.net.URI("https://archive3d.net"));
1845
+ } catch (Exception e1)
1846
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1847
+ {
1848
+ e1.printStackTrace();
1849
+ }
1850
+ }
1851
+ });
1852
+
1853
+ creditsPanel.add(creditButton = GetButton("icons/turbosquid.png", !Globals.NIMBUSLAF));
1854
+ creditButton.setToolTipText("https://turbosquid.com");
1855
+
1856
+ creditButton.addMouseListener(new MouseAdapter()
1857
+ {
1858
+ public void mouseClicked(MouseEvent e)
1859
+ {
1860
+ try
1861
+ {
1862
+ Desktop.getDesktop().browse(new java.net.URI("https://www.turbosquid.com/Search/3D-Models/free"));
1863
+ } catch (Exception e1)
1864
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1865
+ {
1866
+ e1.printStackTrace();
1867
+ }
1868
+ }
1869
+ });
1870
+
1871
+ for (int i=6; --i>=0;)
1872
+ {
1873
+ creditsPanel.add(new cGridBag());
1874
+ }
1875
+
1876
+ tabbedPane.add(creditsPanel);
1877
+ tabbedPane.setToolTipTextAt(3, "Credits");
1878
+
1879
+ if (Globals.ADVANCED)
1880
+ {
1881
+ tabbedPane.add(infoPanel);
1882
+ tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1883
+ tabbedPane.setToolTipTextAt(4, "Information");
1884
+ }
12961885
12971886 /*
12981887 cTree jTree = new cTree(null);
....@@ -1314,13 +1903,13 @@
13141903 jtp.add(tree);
13151904 */
13161905
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");
1906
+// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1907
+// bigPanel.setContinuousLayout(true);
1908
+// bigPanel.setOneTouchExpandable(true);
1909
+// bigPanel.setDividerLocation(0.8);
1910
+// bigPanel.setDividerSize(15);
1911
+// bigPanel.setResizeWeight(0.15);
1912
+// bigPanel.setName("Scene");
13241913
13251914 //bigPanel.setLayout(new BorderLayout());
13261915 //bigPanel.setSize(new Dimension(10,10));
....@@ -1355,7 +1944,7 @@
13551944 bigThree = new cGridBag();
13561945 bigThree.addComponent(scenePanel);
13571946 bigThree.addComponent(centralPanel);
1358
- bigThree.addComponent(XYZPanel);
1947
+ //bigThree.addComponent(XYZPanel);
13591948
13601949 // // SIDE EFFECT!!!
13611950 // aConstraints.gridx = 0;
....@@ -1364,16 +1953,33 @@
13641953 // aConstraints.gridheight = 1;
13651954
13661955 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1367
- framePanel.setContinuousLayout(true);
1368
- framePanel.setOneTouchExpandable(true);
1369
- framePanel.setDividerLocation(0.8);
1956
+
1957
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1958
+ new java.beans.PropertyChangeListener()
1959
+ {
1960
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1961
+ {
1962
+ if ((Integer)pce.getOldValue() == 1)
1963
+ {
1964
+ if (radio.layout != expandedLayout)
1965
+ {
1966
+ radio.layout = expandedLayout;
1967
+ radio.layout.doClick();
1968
+ }
1969
+ }
1970
+ }
1971
+ });
1972
+
1973
+ framePanel.setContinuousLayout(false);
1974
+ framePanel.setOneTouchExpandable(false);
1975
+ //.setDividerLocation(0.8);
13701976 //framePanel.setDividerSize(15);
13711977 //framePanel.setResizeWeight(0.15);
13721978 framePanel.setName("Frame");
13731979
13741980 frame.getContentPane().setLayout(new BorderLayout());
13751981 /**/
1376
- JTabbedPane worldPane = new JTabbedPane();
1982
+ //JTabbedPane worldPane = new JTabbedPane();
13771983 //worldPane.add(bigPanel);
13781984 //worldPane.add(worldPanel);
13791985 /**/
....@@ -1384,14 +1990,18 @@
13841990 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13851991
13861992 frame.setSize(1280, 860);
1387
- frame.setVisible(true);
1993
+
1994
+ cameraView.requestFocusInWindow();
1995
+
1996
+// gridPanel.setDividerLocation(1.0);
1997
+
1998
+ frame.validate();
13881999
1389
- gridPanel.setDividerLocation(1.0);
2000
+ frame.setVisible(true);
13902001
13912002 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13922003 frame.addWindowListener(new WindowAdapter()
13932004 {
1394
-
13952005 public void windowClosing(WindowEvent e)
13962006 {
13972007 Close();
....@@ -1414,28 +2024,442 @@
14142024 ctrlPanel.removeAll();
14152025 }
14162026
1417
- void SetupMaterial(cGridBag panel)
2027
+ void SetupMaterial(cGridBag materialpanel)
14182028 {
1419
- /*
2029
+ cGridBag presetpanel = new cGridBag().setVertical(true);
2030
+
2031
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
2032
+ skin.setToolTipText("Skin");
2033
+ skin.addMouseListener(new MouseAdapter()
2034
+ {
2035
+ public void mouseClicked(MouseEvent e)
2036
+ {
2037
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
2038
+ cMaterial material = object.material;
2039
+
2040
+ // Skin
2041
+ colorField.setFloat(material.color);
2042
+ float saturation = material.modulation;
2043
+
2044
+ if (!cameraView.Skinshader)
2045
+ {
2046
+ saturation /= 1.5;
2047
+ }
2048
+
2049
+ saturationField.setFloat(saturation);
2050
+
2051
+ subsurfaceField.setFloat(material.subsurface);
2052
+ selfshadowField.setFloat(material.diffuseness);
2053
+ diffusenessField.setFloat(material.factor);
2054
+ shininessField.setFloat(material.shininess);
2055
+ shadowbiasField.setFloat(material.shadowbias);
2056
+ diffuseField.setFloat(material.diffuse);
2057
+ specularField.setFloat(material.specular);
2058
+
2059
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2060
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2061
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2062
+
2063
+ materialtouched = true;
2064
+ applySelf();
2065
+ }
2066
+ });
2067
+ presetpanel.add(skin);
2068
+
2069
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
2070
+ lambert.setToolTipText("Diffuse");
2071
+ lambert.addMouseListener(new MouseAdapter()
2072
+ {
2073
+ public void mouseClicked(MouseEvent e)
2074
+ {
2075
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
2076
+ cMaterial material = object.material;
2077
+
2078
+ diffusenessField.setFloat(material.factor);
2079
+ selfshadowField.setFloat(material.diffuseness);
2080
+
2081
+ materialtouched = true;
2082
+ applySelf();
2083
+ }
2084
+ });
2085
+ presetpanel.add(lambert);
2086
+
2087
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
2088
+ diffuse2.setToolTipText("Diffuse2");
2089
+ diffuse2.addMouseListener(new MouseAdapter()
2090
+ {
2091
+ public void mouseClicked(MouseEvent e)
2092
+ {
2093
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
2094
+ cMaterial material = object.material;
2095
+
2096
+ diffusenessField.setFloat(material.factor);
2097
+ selfshadowField.setFloat(material.diffuseness);
2098
+
2099
+ materialtouched = true;
2100
+ applySelf();
2101
+ }
2102
+ });
2103
+ presetpanel.add(diffuse2);
2104
+
2105
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
2106
+ diffusemoon.setToolTipText("Moon");
2107
+ diffusemoon.addMouseListener(new MouseAdapter()
2108
+ {
2109
+ public void mouseClicked(MouseEvent e)
2110
+ {
2111
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
2112
+ cMaterial material = object.material;
2113
+
2114
+ diffusenessField.setFloat(material.factor);
2115
+ selfshadowField.setFloat(material.diffuseness);
2116
+
2117
+ materialtouched = true;
2118
+ applySelf();
2119
+ }
2120
+ });
2121
+ presetpanel.add(diffusemoon);
2122
+
2123
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
2124
+ diffusemoon2.setToolTipText("Moon2");
2125
+ diffusemoon2.addMouseListener(new MouseAdapter()
2126
+ {
2127
+ public void mouseClicked(MouseEvent e)
2128
+ {
2129
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
2130
+ cMaterial material = object.material;
2131
+
2132
+ diffusenessField.setFloat(material.factor);
2133
+ selfshadowField.setFloat(material.diffuseness);
2134
+
2135
+ materialtouched = true;
2136
+ applySelf();
2137
+ }
2138
+ });
2139
+ presetpanel.add(diffusemoon2);
2140
+
2141
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
2142
+ diffusemoon3.setToolTipText("Moon3");
2143
+ diffusemoon3.addMouseListener(new MouseAdapter()
2144
+ {
2145
+ public void mouseClicked(MouseEvent e)
2146
+ {
2147
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2148
+ cMaterial material = object.material;
2149
+
2150
+ diffusenessField.setFloat(material.factor);
2151
+ selfshadowField.setFloat(material.diffuseness);
2152
+
2153
+ materialtouched = true;
2154
+ applySelf();
2155
+ }
2156
+ });
2157
+ presetpanel.add(diffusemoon3);
2158
+
2159
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
2160
+ diffusesheen.setToolTipText("Sheen");
2161
+ diffusesheen.addMouseListener(new MouseAdapter()
2162
+ {
2163
+ public void mouseClicked(MouseEvent e)
2164
+ {
2165
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2166
+ cMaterial material = object.material;
2167
+
2168
+ sheenField.setFloat(material.sheen);
2169
+
2170
+ materialtouched = true;
2171
+ applySelf();
2172
+ }
2173
+ });
2174
+ presetpanel.add(diffusesheen);
2175
+
2176
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
2177
+ rough.setToolTipText("Rough metal");
2178
+ rough.addMouseListener(new MouseAdapter()
2179
+ {
2180
+ public void mouseClicked(MouseEvent e)
2181
+ {
2182
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2183
+ cMaterial material = object.material;
2184
+
2185
+ shininessField.setFloat(material.shininess);
2186
+ velvetField.setFloat(material.velvet);
2187
+
2188
+ materialtouched = true;
2189
+ applySelf();
2190
+ }
2191
+ });
2192
+ presetpanel.add(rough);
2193
+
2194
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
2195
+ rough2.setToolTipText("Medium metal");
2196
+ rough2.addMouseListener(new MouseAdapter()
2197
+ {
2198
+ public void mouseClicked(MouseEvent e)
2199
+ {
2200
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2201
+ cMaterial material = object.material;
2202
+
2203
+ shininessField.setFloat(material.shininess);
2204
+ lightareaField.setFloat(material.lightarea);
2205
+
2206
+ materialtouched = true;
2207
+ applySelf();
2208
+ }
2209
+ });
2210
+ presetpanel.add(rough2);
2211
+
2212
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
2213
+ shini0.setToolTipText("Shiny");
2214
+ shini0.addMouseListener(new MouseAdapter()
2215
+ {
2216
+ public void mouseClicked(MouseEvent e)
2217
+ {
2218
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2219
+ cMaterial material = object.material;
2220
+
2221
+ shininessField.setFloat(material.shininess);
2222
+ lightareaField.setFloat(material.lightarea);
2223
+
2224
+ materialtouched = true;
2225
+ applySelf();
2226
+ }
2227
+ });
2228
+ presetpanel.add(shini0);
2229
+
2230
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
2231
+ shini1.setToolTipText("Shiny2");
2232
+ shini1.addMouseListener(new MouseAdapter()
2233
+ {
2234
+ public void mouseClicked(MouseEvent e)
2235
+ {
2236
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2237
+ cMaterial material = object.material;
2238
+
2239
+ shininessField.setFloat(material.shininess);
2240
+ lightareaField.setFloat(material.lightarea);
2241
+
2242
+ materialtouched = true;
2243
+ applySelf();
2244
+ }
2245
+ });
2246
+ presetpanel.add(shini1);
2247
+
2248
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
2249
+ shini2.setToolTipText("Shiny3");
2250
+ shini2.addMouseListener(new MouseAdapter()
2251
+ {
2252
+ public void mouseClicked(MouseEvent e)
2253
+ {
2254
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2255
+ cMaterial material = object.material;
2256
+
2257
+ shininessField.setFloat(material.shininess);
2258
+ lightareaField.setFloat(material.lightarea);
2259
+
2260
+ materialtouched = true;
2261
+ applySelf();
2262
+ }
2263
+ });
2264
+ presetpanel.add(shini2);
2265
+
2266
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
2267
+ aniso.setToolTipText("AnisoU");
2268
+ aniso.addMouseListener(new MouseAdapter()
2269
+ {
2270
+ public void mouseClicked(MouseEvent e)
2271
+ {
2272
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2273
+ cMaterial material = object.material;
2274
+
2275
+ anisoField.setFloat(material.aniso);
2276
+ anisoVField.setFloat(material.anisoV);
2277
+
2278
+ materialtouched = true;
2279
+ applySelf();
2280
+ }
2281
+ });
2282
+ presetpanel.add(aniso);
2283
+
2284
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
2285
+ aniso2.setToolTipText("AnisoV");
2286
+ aniso2.addMouseListener(new MouseAdapter()
2287
+ {
2288
+ public void mouseClicked(MouseEvent e)
2289
+ {
2290
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2291
+ cMaterial material = object.material;
2292
+
2293
+ anisoField.setFloat(material.aniso);
2294
+ anisoVField.setFloat(material.anisoV);
2295
+
2296
+ materialtouched = true;
2297
+ applySelf();
2298
+ }
2299
+ });
2300
+ presetpanel.add(aniso2);
2301
+
2302
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
2303
+ aniso3.setToolTipText("AnisoUV");
2304
+ aniso3.addMouseListener(new MouseAdapter()
2305
+ {
2306
+ public void mouseClicked(MouseEvent e)
2307
+ {
2308
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2309
+ cMaterial material = object.material;
2310
+
2311
+ anisoField.setFloat(material.aniso);
2312
+ anisoVField.setFloat(material.anisoV);
2313
+
2314
+ materialtouched = true;
2315
+ applySelf();
2316
+ }
2317
+ });
2318
+ presetpanel.add(aniso3);
2319
+
2320
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
2321
+ velvet0.setToolTipText("Velvet");
2322
+ velvet0.addMouseListener(new MouseAdapter()
2323
+ {
2324
+ public void mouseClicked(MouseEvent e)
2325
+ {
2326
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2327
+ cMaterial material = object.material;
2328
+
2329
+ diffusenessField.setFloat(material.factor);
2330
+ selfshadowField.setFloat(material.diffuseness);
2331
+ sheenField.setFloat(material.sheen);
2332
+ shininessField.setFloat(material.shininess);
2333
+ velvetField.setFloat(material.velvet);
2334
+ shiftField.setFloat(material.shift);
2335
+
2336
+ materialtouched = true;
2337
+ applySelf();
2338
+ }
2339
+ });
2340
+ presetpanel.add(velvet0);
2341
+
2342
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
2343
+ bump0.setToolTipText("Bump texture");
2344
+ bump0.addMouseListener(new MouseAdapter()
2345
+ {
2346
+ public void mouseClicked(MouseEvent e)
2347
+ {
2348
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2349
+ cMaterial material = object.material;
2350
+
2351
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2352
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2353
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2354
+
2355
+ materialtouched = true;
2356
+ applySelf();
2357
+ }
2358
+ });
2359
+ presetpanel.add(bump0);
2360
+
2361
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
2362
+ borderShader.setToolTipText("Border fade");
2363
+ borderShader.addMouseListener(new MouseAdapter()
2364
+ {
2365
+ public void mouseClicked(MouseEvent e)
2366
+ {
2367
+ borderfadeField.setFloat(0.5);
2368
+ opacityField.setFloat(0.75);
2369
+
2370
+ materialtouched = true;
2371
+ applySelf();
2372
+ }
2373
+ });
2374
+ presetpanel.add(borderShader);
2375
+
2376
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
2377
+ halo.setToolTipText("Halo");
2378
+ halo.addMouseListener(new MouseAdapter()
2379
+ {
2380
+ public void mouseClicked(MouseEvent e)
2381
+ {
2382
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2383
+ cMaterial material = object.material;
2384
+
2385
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2386
+
2387
+ materialtouched = true;
2388
+ applySelf();
2389
+ }
2390
+ });
2391
+ presetpanel.add(halo);
2392
+
2393
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
2394
+ candle.setToolTipText("Candle");
2395
+ candle.addMouseListener(new MouseAdapter()
2396
+ {
2397
+ public void mouseClicked(MouseEvent e)
2398
+ {
2399
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2400
+ cMaterial material = object.material;
2401
+
2402
+ subsurfaceField.setFloat(material.subsurface);
2403
+ shadowbiasField.setFloat(material.shadowbias);
2404
+ ambientField.setFloat(material.ambient);
2405
+ specularField.setFloat(material.specular);
2406
+ lightareaField.setFloat(material.lightarea);
2407
+ shininessField.setFloat(material.shininess);
2408
+
2409
+ materialtouched = true;
2410
+ applySelf();
2411
+ }
2412
+ });
2413
+ presetpanel.add(candle);
2414
+
2415
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
2416
+ shadowShader.setToolTipText("Shadow");
2417
+ shadowShader.addMouseListener(new MouseAdapter()
2418
+ {
2419
+ public void mouseClicked(MouseEvent e)
2420
+ {
2421
+ diffuseField.setFloat(0.001);
2422
+ ambientField.setFloat(0.001);
2423
+ cameraField.setFloat(0.001);
2424
+ specularField.setFloat(0.001);
2425
+ fakedepthField.setFloat(0.001);
2426
+ opacityField.setFloat(0.6);
2427
+
2428
+ materialtouched = true;
2429
+ applySelf();
2430
+ }
2431
+ });
2432
+ presetpanel.add(shadowShader);
2433
+
2434
+ cGridBag panel = new cGridBag().setVertical(true);
2435
+
2436
+ presetpanel.preferredWidth = 1;
2437
+
2438
+ materialpanel.add(presetpanel);
2439
+ materialpanel.add(panel);
2440
+
2441
+ panel.preferredWidth = 8;
2442
+
2443
+ /*
14202444 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14212445 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1422
- */
2446
+ */
14232447
14242448 cGridBag editBar = new cGridBag().setVertical(false);
14252449
1426
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2450
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
14272451 createMaterialButton.setToolTipText("Create material");
14282452
14292453 /*
14302454 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14312455 */
14322456
1433
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2457
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
14342458 clearMaterialButton.setToolTipText("Clear material");
14352459
14362460 if (Globals.ADVANCED)
14372461 {
1438
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2462
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
14392463 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
14402464 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
14412465 }
....@@ -1453,45 +2477,61 @@
14532477 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14542478
14552479 cGridBag colorSection = new cGridBag().setVertical(true);
2480
+
2481
+ cGridBag huepanel = new cGridBag();
2482
+ cGridBag huelabel = new cGridBag();
2483
+ cLabel hue = GetLabel("icons/hue.png", false);
2484
+ hue.fit = true;
2485
+
2486
+ hue.addMouseListener(new MouseAdapter()
2487
+ {
2488
+ public void mousePressed(MouseEvent e)
2489
+ {
2490
+ int x = e.getX();
2491
+
2492
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2493
+ }
2494
+ });
2495
+
2496
+ huelabel.add(hue);
2497
+ huelabel.preferredWidth = 20;
2498
+ huepanel.add(new cGridBag()); // Label
2499
+ huepanel.add(huelabel); // Field/slider
2500
+
2501
+ huepanel.preferredHeight = 7;
2502
+
2503
+ colorSection.add(huepanel);
14562504
14572505 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);
2506
+
2507
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2508
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2509
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2510
+
14612511 //colorField.preferredWidth = 200;
14622512 colorSection.add(color);
14632513
14642514 cGridBag modulation = new cGridBag();
14652515 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14662516 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1467
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2517
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14682518 colorSection.add(modulation);
14692519
2520
+ cGridBag opacity = new cGridBag();
2521
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2522
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2523
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2524
+ colorSection.add(opacity);
2525
+
2526
+ colorSection.add(GetSeparator());
2527
+
14702528 cGridBag texture = new cGridBag();
14712529 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14722530 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14732531 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14742532 colorSection.add(texture);
14752533
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());
2534
+ panel.add(GetSeparator());
14952535
14962536 panel.add(colorSection);
14972537
....@@ -1541,7 +2581,13 @@
15412581 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15422582 diffuseSection.add(fakedepth);
15432583
1544
- panel.add(new JSeparator());
2584
+ cGridBag shadowbias = new cGridBag();
2585
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2586
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2587
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2588
+ diffuseSection.add(shadowbias);
2589
+
2590
+ panel.add(GetSeparator());
15452591
15462592 panel.add(diffuseSection);
15472593
....@@ -1591,42 +2637,48 @@
15912637 // aConstraints.gridy += 1;
15922638 // aConstraints.gridwidth = 1;
15932639
2640
+ cGridBag anisoU = new cGridBag();
2641
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2642
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2643
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2644
+ specularSection.add(anisoU);
15942645
1595
- panel.add(new JSeparator());
2646
+ cGridBag anisoV = new cGridBag();
2647
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2648
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2649
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2650
+ specularSection.add(anisoV);
2651
+
2652
+
2653
+ panel.add(GetSeparator());
15962654
15972655 panel.add(specularSection);
15982656
15992657 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16002658
1601
- cGridBag globalSection = new cGridBag().setVertical(true);
2659
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16022660
16032661 cGridBag camera = new cGridBag();
16042662 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16052663 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16062664 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1607
- globalSection.add(camera);
2665
+ colorSection.add(camera);
16082666
16092667 cGridBag ambient = new cGridBag();
16102668 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16112669 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16122670 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(ambient);
2671
+ colorSection.add(ambient);
16142672
16152673 cGridBag backlit = new cGridBag();
16162674 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16172675 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16182676 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(backlit);
2677
+ colorSection.add(backlit);
16202678
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());
2679
+ //panel.add(new JSeparator());
16282680
1629
- panel.add(globalSection);
2681
+ //panel.add(globalSection);
16302682
16312683 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16322684
....@@ -1668,7 +2720,7 @@
16682720 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16692721 textureSection.add(opacityPower);
16702722
1671
- panel.add(new JSeparator());
2723
+ panel.add(GetSeparator());
16722724
16732725 panel.add(textureSection);
16742726
....@@ -1733,8 +2785,9 @@
17332785 // 3D models
17342786 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17352787 {
1736
- lastConverter = new com.jmex.model.converters.MaxToJme();
1737
- LoadFile(filename, lastConverter);
2788
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2789
+ //LoadFile(filename, lastConverter);
2790
+ LoadObjFile(filename); // New 3ds loader
17382791 continue;
17392792 }
17402793 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2072,19 +3125,19 @@
20723125
20733126 void LoadObjFile(String fullname)
20743127 {
2075
- /*
3128
+ System.out.println("Loading " + fullname);
3129
+ /**/
20763130 //lastFilename = fullname;
20773131 if(loadObjThread == null)
20783132 {
2079
- loadObjThread = new LoadOBJThread();
2080
- loadObjThread.start();
3133
+ loadObjThread = new LoadOBJThread();
3134
+ loadObjThread.start();
20813135 }
20823136
20833137 loadObjThread.add(fullname);
2084
- */
3138
+ /**/
20853139
2086
- System.out.println("Loading " + fullname);
2087
- makeSomething(new FileObject(fullname, true), true);
3140
+ //makeSomething(new FileObject(fullname, true), true);
20883141 }
20893142
20903143 void LoadGFDFile(String fullname)
....@@ -2460,6 +3513,7 @@
24603513 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24613514 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24623515 }
3516
+
24633517 //cJME.count++;
24643518 //cJME.count %= 12;
24653519 if (gc)
....@@ -2643,6 +3697,7 @@
26433697 }
26443698 }
26453699 }
3700
+
26463701 cFileSystemPane FSPane;
26473702
26483703 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2652,7 +3707,7 @@
26523707
26533708 freezematerial = true;
26543709 colorField.setFloat(mat.color);
2655
- modulationField.setFloat(mat.modulation);
3710
+ saturationField.setFloat(mat.modulation);
26563711 metalnessField.setFloat(mat.metalness);
26573712 diffuseField.setFloat(mat.diffuse);
26583713 specularField.setFloat(mat.specular);
....@@ -2696,11 +3751,14 @@
26963751 }
26973752 }
26983753 }
3754
+
26993755 freezematerial = false;
27003756 }
27013757
27023758 void SetMaterial(Object3D object)
27033759 {
3760
+ latestObject = object;
3761
+
27043762 cMaterial mat = object.material;
27053763
27063764 if (mat == null)
....@@ -2711,32 +3769,8 @@
27113769
27123770 if (multiplyToggle != null)
27133771 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
- }
3772
+
3773
+ AllocProjectedVertices(object);
27403774
27413775 SetMaterial(mat, object.projectedVertices);
27423776 }
....@@ -2812,12 +3846,17 @@
28123846 // }
28133847
28143848 /**/
2815
- if (deselect)
3849
+ if (deselect || child == null)
28163850 {
28173851 //group.deselectAll();
28183852 //freeze = true;
28193853 GetTree().clearSelection();
28203854 //freeze = false;
3855
+
3856
+ if (child == null)
3857
+ {
3858
+ return;
3859
+ }
28213860 }
28223861
28233862 //group.addSelectee(child);
....@@ -2851,6 +3890,17 @@
28513890 public void itemStateChanged(ItemEvent event)
28523891 {
28533892 // System.out.println("Propagate = " + propagate);
3893
+ if (event.getSource() == pinButton)
3894
+ {
3895
+ copy.pinned ^= true;
3896
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3897
+ {
3898
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3899
+ copy.CloseUI();
3900
+ //copy.editWindow.refreshContents();
3901
+ }
3902
+ }
3903
+ else
28543904 if (event.getSource() == propagateToggle)
28553905 {
28563906 propagate ^= true;
....@@ -2886,7 +3936,7 @@
28863936 cameraView.ToggleDL();
28873937 cameraView.repaint();
28883938 return;
2889
- } else if (event.getSource() == toggleTextureItem)
3939
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28903940 {
28913941 cameraView.ToggleTexture();
28923942 // june 2013 copy.HardTouch();
....@@ -2925,7 +3975,7 @@
29253975 frame.validate();
29263976
29273977 return;
2928
- } else if (event.getSource() == toggleSwitchItem)
3978
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29293979 {
29303980 cameraView.ToggleSwitch();
29313981 cameraView.repaint();
....@@ -2955,8 +4005,9 @@
29554005 } else if (event.getSource() == liveCB)
29564006 {
29574007 copy.live ^= true;
4008
+ objEditor.refreshContents(true); // To show item colors
29584009 return;
2959
- } else if (event.getSource() == selectCB)
4010
+ } else if (event.getSource() == selectableCB)
29604011 {
29614012 copy.dontselect ^= true;
29624013 return;
....@@ -2964,7 +4015,7 @@
29644015 {
29654016 copy.hide ^= true;
29664017 copy.Touch(); // display list issue
2967
- objEditor.refreshContents();
4018
+ objEditor.refreshContents(true); // To show item colors
29684019 return;
29694020 } else if (event.getSource() == link2masterCB)
29704021 {
....@@ -3029,7 +4080,7 @@
30294080 //System.out.println("ObjEditor " + event);
30304081 applySelf0(true);
30314082 //parent.applySelf();
3032
- objEditor.refreshContents();
4083
+ // conflicts with requestFocus objEditor.refreshContents();
30334084 } else if (source == resetButton)
30344085 {
30354086 CameraPane.fullreset = true;
....@@ -3141,9 +4192,9 @@
31414192 {
31424193 Close();
31434194 //return true;
3144
- } else if (source == loadItem)
4195
+ } else if (source == openItem)
31454196 {
3146
- load();
4197
+ Open();
31474198 //return true;
31484199 } else if (source == newItem)
31494200 {
....@@ -3168,6 +4219,10 @@
31684219 {
31694220 generatePOV();
31704221 //return true;
4222
+ } else if (event.getSource() == archiveItem)
4223
+ {
4224
+ cTools.Archive(frame);
4225
+ return;
31714226 } else if (source == zBufferItem)
31724227 {
31734228 try
....@@ -3205,31 +4260,48 @@
32054260
32064261 void New()
32074262 {
3208
- while (copy.Size() > 1)
4263
+ while (copy.Size() > 0)
32094264 {
3210
- copy.remove(1);
4265
+ copy.remove(0);
32114266 }
32124267
4268
+ copy.selection.clear();
4269
+
4270
+ if (copy == Grafreed.grafreed.universe)
4271
+ {
4272
+ CreateCameras();
4273
+ cameraView.SetCamera(GetCamera(copy, 0));
4274
+ }
32134275 ResetModel();
32144276 objEditor.refreshContents();
32154277 }
32164278
3217
- static public byte[] Compress(Object o)
4279
+ static public byte[] Compress(Object3D o)
32184280 {
4281
+ // Slower to actually compress.
32194282 try
32204283 {
32214284 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3222
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3223
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4285
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4286
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
32244287
4288
+ Object3D parent = o.parent;
4289
+ o.parent = null;
4290
+
32254291 out.writeObject(o);
32264292
4293
+ o.parent = parent;
4294
+
32274295 out.flush();
32284296
3229
- zstream.close();
4297
+ baos //zstream
4298
+ .close();
32304299 out.close();
32314300
3232
- return baos.toByteArray();
4301
+ byte[] bytes = baos.toByteArray();
4302
+
4303
+ System.out.println("save #bytes = " + bytes.length);
4304
+ return bytes;
32334305 } catch (Exception e)
32344306 {
32354307 System.err.println(e);
....@@ -3239,13 +4311,16 @@
32394311
32404312 static public Object Uncompress(byte[] bytes)
32414313 {
3242
- System.out.println("#bytes = " + bytes.length);
4314
+ System.out.println("restore #bytes = " + bytes.length);
32434315 try
32444316 {
32454317 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3246
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3247
- ObjectInputStream in = new ObjectInputStream(istream);
4318
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4319
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
32484320 Object obj = in.readObject();
4321
+
4322
+ bais //istream
4323
+ .close();
32494324 in.close();
32504325
32514326 return obj;
....@@ -3300,32 +4375,97 @@
33004375 return null;
33014376 }
33024377
3303
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
33044378
33054379 public void Save()
33064380 {
3307
- cRadio tab = GetCurrentTab();
4381
+ //Save(true);
4382
+ Replace();
4383
+ SetVersionStates();
4384
+ }
4385
+
4386
+ private boolean Equal(byte[] compress, byte[] name)
4387
+ {
4388
+ if (compress.length != name.length)
4389
+ {
4390
+ return false;
4391
+ }
33084392
3309
- copy.ExtractBigData(hashtable);
4393
+ for (int i=compress.length; --i>=0;)
4394
+ {
4395
+ if (compress[i] != name[i])
4396
+ return false;
4397
+ }
4398
+
4399
+ return true;
4400
+ }
4401
+
4402
+ void DeleteVersion()
4403
+ {
4404
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4405
+ {
4406
+ copy.versionlist[i] = copy.versionlist[i+1];
4407
+ }
4408
+
4409
+ if (copy.versionlist[copy.versionindex] == null)
4410
+ copy.versionindex -= 1;
4411
+
4412
+ if (copy.versionindex != -1)
4413
+ CopyChanged();
4414
+
4415
+ SetVersionStates();
4416
+ }
4417
+
4418
+ public boolean Save(boolean user)
4419
+ {
4420
+ System.err.println("Save");
4421
+ Replace();
4422
+
4423
+ //cRadio tab = GetCurrentTab();
4424
+
4425
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
4426
+
4427
+ boolean thesame = false;
4428
+
4429
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4430
+// {
4431
+// thesame = true;
4432
+// }
33104433
33114434 //EditorFrame.m_MainFrame.requestFocusInWindow();
3312
- tab.graphs[tab.undoindex++] = Compress(copy);
3313
-
3314
- copy.RestoreBigData(hashtable);
3315
-
3316
- //assert(hashtable.isEmpty());
3317
-
3318
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
4435
+ if (!thesame)
33194436 {
3320
- tab.graphs[i] = null;
4437
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4438
+ {
4439
+ copy.versionlist[i] = copy.versionlist[i-1];
4440
+ }
4441
+
4442
+ //tab.user[tab.versionindex] = user;
4443
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4444
+
4445
+ copy.versionlist[++copy.versionindex] = compress;
4446
+
4447
+ // if (increment)
4448
+ // tab.versionindex++;
33214449 }
33224450
4451
+ //copy.RestoreBigData(versiontable);
4452
+
4453
+ //assert(hashtable.isEmpty());
4454
+
4455
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4456
+// {
4457
+// //tab.user[i] = false;
4458
+// copy.versionlist[i] = null;
4459
+// }
4460
+
4461
+ SetVersionStates();
4462
+
33234463 // test save
33244464 if (false)
33254465 {
33264466 try
33274467 {
3328
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4468
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
33294469 ObjectOutputStream p = new ObjectOutputStream(ostream);
33304470
33314471 p.writeObject(copy);
....@@ -3338,21 +4478,68 @@
33384478 e.printStackTrace();
33394479 }
33404480 }
4481
+
4482
+ return !thesame;
4483
+ }
4484
+
4485
+ boolean flashIt = true;
4486
+
4487
+ void RefreshSelection()
4488
+ {
4489
+ Object3D selection = new Object3D();
4490
+
4491
+ for (int i = 0; i < copy.selection.size(); i++)
4492
+ {
4493
+ Object3D elem = copy.selection.elementAt(i);
4494
+
4495
+ Object3D obj = copy.GetObject(elem.GetUUID());
4496
+
4497
+ if (obj == null)
4498
+ {
4499
+ copy.selection.remove(i--);
4500
+ }
4501
+ else
4502
+ {
4503
+ selection.add(obj);
4504
+ copy.selection.setElementAt(obj, i);
4505
+ }
4506
+ }
4507
+
4508
+ flashIt = false;
4509
+ GetTree().clearSelection();
4510
+ for (int i = 0; i < selection.size(); i++)
4511
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4512
+ flashIt = true;
4513
+
4514
+ //refreshContents(false);
33414515 }
33424516
3343
- void CopyChanged(Object3D obj)
4517
+ void CopyChanged()
33444518 {
3345
- copy.ExtractBigData(hashtable);
4519
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4520
+
4521
+ SetVersionStates();
4522
+
4523
+ boolean temp = CameraPane.SWITCH;
4524
+ CameraPane.SWITCH = false;
4525
+
4526
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
33464527
33474528 copy.clear();
33484529
4530
+ copy.skyboxname = obj.skyboxname;
4531
+ copy.skyboxext = obj.skyboxext;
4532
+
33494533 for (int i=0; i<obj.Size(); i++)
33504534 {
33514535 copy.add(obj.get(i));
33524536 }
33534537
3354
- copy.RestoreBigData(hashtable);
4538
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
33554539
4540
+ CameraPane.SWITCH = temp;
4541
+
4542
+ RefreshSelection();
33564543 //assert(hashtable.isEmpty());
33574544
33584545 copy.Touch();
....@@ -3373,43 +4560,161 @@
33734560 }
33744561 }
33754562
3376
- refreshContents();
4563
+ refreshContents(true);
33774564 }
33784565
3379
- public void Undo()
3380
- {
3381
- cRadio tab = GetCurrentTab();
4566
+ cButton previousVersionButton;
4567
+ cButton restoreButton;
4568
+ cButton replaceButton;
4569
+ cButton nextVersionButton;
4570
+ cButton saveVersionButton;
4571
+ cButton deleteVersionButton;
33824572
3383
- if (tab.undoindex == 0)
4573
+ boolean muteSlider;
4574
+
4575
+ int VersionCount()
4576
+ {
4577
+ int count = 0;
4578
+
4579
+ for (int i = copy.versionlist.length; --i >= 0;)
4580
+ {
4581
+ if (copy.versionlist[i] != null)
4582
+ count++;
4583
+ }
4584
+
4585
+ return count;
4586
+ }
4587
+
4588
+ public cGridBag versionSliderPane;
4589
+
4590
+ void SetVersionStates()
4591
+ {
4592
+ //if (true)
4593
+ // return;
4594
+
4595
+ //cRadio tab = GetCurrentTab();
4596
+
4597
+ if (copy.versionlist == null)
4598
+ {
4599
+ saveVersionButton.setEnabled(false);
4600
+ restoreButton.setEnabled(false);
4601
+ replaceButton.setEnabled(false);
4602
+ previousVersionButton.setEnabled(false);
4603
+ nextVersionButton.setEnabled(false);
4604
+ deleteVersionButton.setEnabled(false);
4605
+ versionSliderPane.setVisible(false);
4606
+ }
4607
+ else
4608
+ {
4609
+ restoreButton.setEnabled(copy.versionindex != -1);
4610
+ replaceButton.setEnabled(copy.versionindex != -1);
4611
+
4612
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4613
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4614
+
4615
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4616
+ //copy.versionlist[copy.versionindex + 1] != null);
4617
+
4618
+ muteSlider = true;
4619
+ versionSlider.setMinimum(0);
4620
+ versionSlider.setMaximum(VersionCount() - 1);
4621
+ versionSlider.setInteger(copy.versionindex);
4622
+ versionSlider.setEnabled(copy.versionindex != -1);
4623
+ muteSlider = false;
4624
+
4625
+ versionSliderPane.setVisible(true);
4626
+ }
4627
+ }
4628
+
4629
+ public boolean PreviousVersion()
4630
+ {
4631
+ // Option?
4632
+ Replace();
4633
+
4634
+ System.err.println("Undo");
4635
+
4636
+ //cRadio tab = GetCurrentTab();
4637
+
4638
+ if (copy.versionindex == 0)
33844639 {
33854640 java.awt.Toolkit.getDefaultToolkit().beep();
3386
- return;
4641
+ return false;
33874642 }
33884643
3389
- if (tab.graphs[tab.undoindex] == null)
3390
- {
3391
- Save();
3392
- tab.undoindex -= 1;
3393
- }
4644
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4645
+// {
4646
+// if (Save(false))
4647
+// tab.versionindex -= 1;
4648
+// else
4649
+// {
4650
+// if (tab.versionindex <= 0)
4651
+// return false;
4652
+// else
4653
+// tab.versionindex -= 1;
4654
+// }
4655
+// }
33944656
3395
- tab.undoindex -= 1;
4657
+ copy.versionindex -= 1;
33964658
3397
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4659
+ CopyChanged();
4660
+
4661
+ return true;
33984662 }
33994663
3400
- public void Redo()
4664
+ public boolean Restore()
34014665 {
3402
- cRadio tab = GetCurrentTab();
4666
+ System.err.println("Restore");
34034667
3404
- if (tab.graphs[tab.undoindex + 1] == null)
4668
+ //cRadio tab = GetCurrentTab();
4669
+
4670
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4671
+ {
4672
+ java.awt.Toolkit.getDefaultToolkit().beep();
4673
+ return false;
4674
+ }
4675
+
4676
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4677
+ CopyChanged();
4678
+
4679
+ return true;
4680
+ }
4681
+
4682
+ public boolean Replace()
4683
+ {
4684
+ //System.err.println("Replace");
4685
+
4686
+ //cRadio tab = GetCurrentTab();
4687
+
4688
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4689
+ {
4690
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4691
+ return false;
4692
+ }
4693
+
4694
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4695
+
4696
+ return true;
4697
+ }
4698
+
4699
+ public void NextVersion()
4700
+ {
4701
+ // Option?
4702
+ Replace();
4703
+
4704
+ //cRadio tab = GetCurrentTab();
4705
+
4706
+ if (copy.versionlist[copy.versionindex + 1] == null)
34054707 {
34064708 java.awt.Toolkit.getDefaultToolkit().beep();
34074709 return;
34084710 }
34094711
3410
- tab.undoindex += 1;
4712
+ copy.versionindex += 1;
34114713
3412
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4714
+ CopyChanged();
4715
+
4716
+ //if (!tab.user[tab.versionindex])
4717
+ // tab.graphs[tab.versionindex] = null;
34134718 }
34144719
34154720 void ImportGFD()
....@@ -3561,7 +4866,7 @@
35614866 assert false;
35624867 }
35634868
3564
- void EditSelection()
4869
+ void EditSelection(boolean newWindow)
35654870 {
35664871 }
35674872
....@@ -3603,6 +4908,12 @@
36034908 // else
36044909 // applySelf(true);
36054910 // }
4911
+
4912
+ boolean Equal(double a, double b)
4913
+ {
4914
+ return Math.abs(a - b) < 0.001;
4915
+ }
4916
+
36064917 void applySelf0(boolean name)
36074918 {
36084919 if (name)
....@@ -3620,7 +4931,7 @@
36204931 //copy.material = new cMaterial(copy.GetMaterial());
36214932
36224933 current.color = (float) colorField.getFloat();
3623
- current.modulation = (float) modulationField.getFloat();
4934
+ current.modulation = (float) saturationField.getFloat();
36244935 current.metalness = (float) metalnessField.getFloat();
36254936 current.diffuse = (float) diffuseField.getFloat();
36264937 current.specular = (float) specularField.getFloat();
....@@ -3652,29 +4963,52 @@
36524963 {
36534964 cMaterial mat = copy.material;
36544965
3655
- colorField.SetToolTipValue((mat.color));
3656
- modulationField.SetToolTipValue((mat.modulation));
3657
- metalnessField.SetToolTipValue((mat.metalness));
3658
- diffuseField.SetToolTipValue((mat.diffuse));
3659
- specularField.SetToolTipValue((mat.specular));
3660
- shininessField.SetToolTipValue((mat.shininess));
3661
- shiftField.SetToolTipValue((mat.shift));
3662
- ambientField.SetToolTipValue((mat.ambient));
3663
- lightareaField.SetToolTipValue((mat.lightarea));
3664
- diffusenessField.SetToolTipValue((mat.factor));
3665
- velvetField.SetToolTipValue((mat.velvet));
3666
- sheenField.SetToolTipValue((mat.sheen));
3667
- subsurfaceField.SetToolTipValue((mat.subsurface));
3668
- backlitField.SetToolTipValue((mat.bump));
3669
- anisoField.SetToolTipValue((mat.aniso));
3670
- anisoVField.SetToolTipValue((mat.anisoV));
3671
- cameraField.SetToolTipValue((mat.cameralight));
3672
- selfshadowField.SetToolTipValue((mat.diffuseness));
3673
- shadowField.SetToolTipValue((mat.shadow));
3674
- textureField.SetToolTipValue((mat.texture));
3675
- opacityField.SetToolTipValue((mat.opacity));
3676
- fakedepthField.SetToolTipValue((mat.fakedepth));
3677
- shadowbiasField.SetToolTipValue((mat.shadowbias));
4966
+ if (!Equal(colorField.getFloat(), mat.color))
4967
+ colorField.SetToolTipValue((mat.color));
4968
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4969
+ saturationField.SetToolTipValue((mat.modulation));
4970
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4971
+ metalnessField.SetToolTipValue((mat.metalness));
4972
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4973
+ diffuseField.SetToolTipValue((mat.diffuse));
4974
+ if (!Equal(specularField.getFloat(), mat.specular))
4975
+ specularField.SetToolTipValue((mat.specular));
4976
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4977
+ shininessField.SetToolTipValue((mat.shininess));
4978
+ if (!Equal(shiftField.getFloat(), mat.shift))
4979
+ shiftField.SetToolTipValue((mat.shift));
4980
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4981
+ ambientField.SetToolTipValue((mat.ambient));
4982
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4983
+ lightareaField.SetToolTipValue((mat.lightarea));
4984
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4985
+ diffusenessField.SetToolTipValue((mat.factor));
4986
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4987
+ velvetField.SetToolTipValue((mat.velvet));
4988
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4989
+ sheenField.SetToolTipValue((mat.sheen));
4990
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4991
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4992
+ if (!Equal(backlitField.getFloat(), mat.bump))
4993
+ backlitField.SetToolTipValue((mat.bump));
4994
+ if (!Equal(anisoField.getFloat(), mat.aniso))
4995
+ anisoField.SetToolTipValue((mat.aniso));
4996
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
4997
+ anisoVField.SetToolTipValue((mat.anisoV));
4998
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
4999
+ cameraField.SetToolTipValue((mat.cameralight));
5000
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
5001
+ selfshadowField.SetToolTipValue((mat.diffuseness));
5002
+ if (!Equal(shadowField.getFloat(), mat.shadow))
5003
+ shadowField.SetToolTipValue((mat.shadow));
5004
+ if (!Equal(textureField.getFloat(), mat.texture))
5005
+ textureField.SetToolTipValue((mat.texture));
5006
+ if (!Equal(opacityField.getFloat(), mat.opacity))
5007
+ opacityField.SetToolTipValue((mat.opacity));
5008
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
5009
+ fakedepthField.SetToolTipValue((mat.fakedepth));
5010
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
5011
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
36785012 }
36795013
36805014 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -3705,9 +5039,28 @@
37055039 //copy.Touch();
37065040 }
37075041
5042
+ cNumberSlider versionSlider;
5043
+
37085044 public void stateChanged(ChangeEvent e)
37095045 {
3710
- // assert(false);
5046
+ // assert(false);
5047
+ if (e.getSource() == versionSlider)
5048
+ {
5049
+ if (muteSlider)
5050
+ return;
5051
+
5052
+ Replace();
5053
+
5054
+ int version = versionSlider.getInteger();
5055
+
5056
+ if (version != -1 && copy.versionlist[version] != null)
5057
+ {
5058
+ copy.versionindex = version;
5059
+ CopyChanged();
5060
+ }
5061
+
5062
+ return;
5063
+ }
37115064
37125065 if (freezematerial)
37135066 {
....@@ -3743,6 +5096,12 @@
37435096 {
37445097 //System.out.println("stateChanged = " + this);
37455098 materialtouched = true;
5099
+
5100
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
5101
+ {
5102
+ saturationField.setFloat(1);
5103
+ }
5104
+
37465105 applySelf();
37475106 //System.out.println("this = " + this);
37485107 //System.out.println("PARENT = " + parent);
....@@ -4042,6 +5401,7 @@
40425401 {
40435402 if (GetTree() != null)
40445403 {
5404
+ GetTree().revalidate();
40455405 GetTree().repaint();
40465406 }
40475407
....@@ -4050,13 +5410,19 @@
40505410 ctrlPanel.validate(); // ? new
40515411 ctrlPanel.repaint();
40525412 }
5413
+
5414
+ if (previousVersionButton != null && copy.versionlist != null)
5415
+ SetVersionStates();
5416
+
5417
+ cameraView.requestFocusInWindow();
40535418 }
40545419
40555420 static TweenManager tweenManager = new TweenManager();
40565421
40575422 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
40585423 {
4059
- Save();
5424
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5425
+ Save();
40605426 //Tween.set(thing, 0).target(1).start(tweenManager);
40615427 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
40625428 // if (thing instanceof GenericJointDemo)
....@@ -4080,7 +5446,7 @@
40805446 // group = (Composite) group.get(0);
40815447 // }
40825448
4083
- System.out.println("makeSomething of " + thing);
5449
+ //System.out.println("makeSomething of " + thing);
40845450
40855451 /*
40865452 if (deselect && jList != null)
....@@ -4143,6 +5509,12 @@
41435509 {
41445510 ResetModel();
41455511 Select(thing.GetTreePath(), true, false); // unselect... false);
5512
+
5513
+ if (thing.Size() == 0)
5514
+ {
5515
+ //EditSelection(false);
5516
+ }
5517
+
41465518 refreshContents();
41475519 }
41485520
....@@ -4280,6 +5652,7 @@
42805652
42815653 try
42825654 {
5655
+ // Try compressed version first.
42835656 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
42845657 java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
42855658 java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
....@@ -4290,7 +5663,9 @@
42905663 readobj.ResetDisplayList();
42915664 } catch (Exception e)
42925665 {
4293
- //e.printStackTrace();
5666
+ if (!e.toString().contains("GZIP"))
5667
+ e.printStackTrace();
5668
+
42945669 try
42955670 {
42965671 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4349,6 +5724,12 @@
43495724
43505725 void LoadIt(Object obj)
43515726 {
5727
+ if (obj == null)
5728
+ {
5729
+ // Invalid file
5730
+ return;
5731
+ }
5732
+
43525733 System.out.println("Loaded " + obj);
43535734 //new Exception().printStackTrace();
43545735 Object3D readobj = (Object3D) obj;
....@@ -4358,11 +5739,14 @@
43585739
43595740 if (readobj != null)
43605741 {
4361
- Save();
5742
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5743
+ // Save();
43625744 try
43635745 {
43645746 //readobj.deepCopySelf(copy);
43655747 copy.clear(); // june 2014
5748
+ copy.skyboxname = readobj.skyboxname;
5749
+ copy.skyboxext = readobj.skyboxext;
43665750 for (int i = 0; i < readobj.size(); i++)
43675751 {
43685752 Object3D child = readobj.get(i); // reserve(i);
....@@ -4403,6 +5787,7 @@
44035787 }
44045788 } catch (ClassCastException e)
44055789 {
5790
+ e.printStackTrace();
44065791 assert (false);
44075792 Composite c = (Composite) copy;
44085793 c.children.clear();
....@@ -4413,17 +5798,32 @@
44135798 c.addChild(csg);
44145799 }
44155800
5801
+ copy.versionlist = readobj.versionlist;
5802
+ copy.versionindex = readobj.versionindex;
5803
+ copy.versiontable = readobj.versiontable;
5804
+
5805
+ if (copy.versionlist == null)
5806
+ {
5807
+ // Backward compatibility
5808
+ copy.versionlist = new Object3D[100];
5809
+ copy.versionindex = -1;
5810
+
5811
+ //Save(true);
5812
+ }
5813
+
5814
+ //? SetUndoStates();
5815
+
44165816 ResetModel();
44175817 copy.HardTouch(); // recompile?
44185818 refreshContents();
44195819 }
44205820 }
44215821
4422
- void load() // throws ClassNotFoundException
5822
+ void Open() // throws ClassNotFoundException
44235823 {
44245824 if (Grafreed.standAlone)
44255825 {
4426
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5826
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
44275827 browser.show();
44285828 String filename = browser.getFile();
44295829 if (filename != null && filename.length() > 0)
....@@ -4500,6 +5900,8 @@
45005900
45015901 void save()
45025902 {
5903
+ Replace();
5904
+
45035905 if (lastname == null)
45045906 {
45055907 return;
....@@ -4522,6 +5924,7 @@
45225924 //ps.print(buffer.toString());
45235925 } catch (IOException e)
45245926 {
5927
+ e.printStackTrace();
45255928 }
45265929 }
45275930
....@@ -4536,6 +5939,8 @@
45365939 String filename = browser.getFile();
45375940 if (filename != null && filename.length() > 0)
45385941 {
5942
+ if (!filename.endsWith(".gfd"))
5943
+ filename += ".gfd";
45395944 lastname = browser.getDirectory() + filename;
45405945 save();
45415946 }
....@@ -4702,7 +6107,7 @@
47026107 MenuBar menuBar;
47036108 Menu fileMenu;
47046109 MenuItem newItem;
4705
- MenuItem loadItem;
6110
+ MenuItem openItem;
47066111 MenuItem saveItem;
47076112 MenuItem saveAsItem;
47086113 MenuItem exportAsItem;
....@@ -4725,22 +6130,38 @@
47256130 CheckboxMenuItem toggleSwitchItem;
47266131 CheckboxMenuItem toggleRootItem;
47276132 CheckboxMenuItem animationItem;
6133
+ MenuItem archiveItem;
47286134 CheckboxMenuItem toggleHandleItem;
47296135 CheckboxMenuItem togglePaintItem;
47306136 JSplitPane mainPanel;
47316137 JScrollPane scrollpane;
6138
+
47326139 JPanel toolbarPanel;
6140
+
47336141 cGridBag treePanel;
6142
+
47346143 JPanel radioPanel;
47356144 ButtonGroup buttonGroup;
4736
- cGridBag ctrlPanel;
6145
+
6146
+ cGridBag toolboxPanel;
6147
+ cGridBag skyboxPanel;
47376148 cGridBag materialPanel;
6149
+ cGridBag ctrlPanel;
6150
+
47386151 JScrollPane infoPanel;
6152
+
47396153 cGridBag optionsPanel;
6154
+
47406155 JTabbedPane objectPanel;
6156
+ boolean materialFlushed;
6157
+ Object3D latestObject;
6158
+
6159
+ cGridBag transformPanel;
47416160 cGridBag XYZPanel;
6161
+
47426162 JSplitPane gridPanel;
47436163 JSplitPane bigPanel;
6164
+
47446165 cGridBag bigThree;
47456166 cGridBag scenePanel;
47466167 cGridBag centralPanel;
....@@ -4798,7 +6219,7 @@
47986219 JLabel colorLabel;
47996220 cNumberSlider colorField;
48006221 JLabel modulationLabel;
4801
- cNumberSlider modulationField;
6222
+ cNumberSlider saturationField;
48026223 JLabel metalnessLabel;
48036224 cNumberSlider metalnessField;
48046225 JLabel diffuseLabel;
....@@ -4829,6 +6250,7 @@
48296250 cNumberSlider anisoField;
48306251 JLabel anisoVLabel;
48316252 cNumberSlider anisoVField;
6253
+
48326254 JLabel cameraLabel;
48336255 cNumberSlider cameraField;
48346256 JLabel selfshadowLabel;
....@@ -4843,6 +6265,7 @@
48436265 cNumberSlider fakedepthField;
48446266 JLabel shadowbiasLabel;
48456267 cNumberSlider shadowbiasField;
6268
+
48466269 JLabel bumpLabel;
48476270 cNumberSlider bumpField;
48486271 JLabel noiseLabel;
....@@ -4855,7 +6278,7 @@
48556278 cNumberSlider fogField;
48566279 JLabel opacityPowerLabel;
48576280 cNumberSlider opacityPowerField;
4858
- JTree jTree;
6281
+ cTree jTree;
48596282 //ObjectUI parent;
48606283
48616284 cNumberSlider normalpushField;