Normand Briere
2019-08-17 07c0c67b88160b51e61c5c1d2b9b602daafa44a9
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,6 +34,7 @@
3034 iSendInfo
3135 //KeyListener
3236 {
37
+ public cToggleButton pinButton;
3338 boolean timeline;
3439 boolean wasFullScreen;
3540
....@@ -37,6 +42,120 @@
3742 JFrame frame;
3843
3944 static ObjEditor theFrame;
45
+
46
+ public void AllocProjectedVertices(Object3D object)
47
+ {
48
+ assert (object.projectedVertices != null);
49
+
50
+ if (object.projectedVertices.length <= 2)
51
+ {
52
+ // Side effect...
53
+ Object3D.cVector2[] keep = object.projectedVertices;
54
+ object.projectedVertices = new Object3D.cVector2[3];
55
+ for (int i = 0; i < 3; i++)
56
+ {
57
+ if (i < keep.length)
58
+ {
59
+ object.projectedVertices[i] = keep[i];
60
+ } else
61
+ {
62
+ object.projectedVertices[i] = new Object3D.cVector2();
63
+ }
64
+ /*
65
+ if(keep.length == 0)
66
+ object.projectedVertices[0] = new Object3D.cVector2();
67
+ else
68
+ object.projectedVertices[0] = keep[0];
69
+ object.projectedVertices[1] = new Object3D.cVector2();
70
+ */
71
+ }
72
+ }
73
+ }
74
+
75
+ public cGridBag GetSeparator()
76
+ {
77
+ cGridBag separator = new cGridBag();
78
+ separator.add(new JSeparator());
79
+ separator.preferredHeight = 5;
80
+ return separator;
81
+ }
82
+
83
+ cButton GetButton(String name, boolean border)
84
+ {
85
+ ImageIcon icon = GetIcon(name);
86
+ return new cButton(icon, border);
87
+ }
88
+
89
+ cLabel GetLabel(String name, boolean border)
90
+ {
91
+ //ImageIcon icon = GetIcon(name);
92
+ return new cLabel(GetImage(name), border);
93
+ }
94
+
95
+ cToggleButton GetToggleButton(String name, boolean border)
96
+ {
97
+ ImageIcon icon = GetIcon(name);
98
+ return new cToggleButton(icon, border);
99
+ }
100
+
101
+ cCheckBox GetCheckBox(String name, boolean border)
102
+ {
103
+ ImageIcon icon = GetIcon(name);
104
+ return new cCheckBox(icon, border);
105
+ }
106
+
107
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
108
+
109
+ ImageIcon GetIcon(String name)
110
+ {
111
+ javax.swing.ImageIcon iconCache = icons.get(name);
112
+ if (iconCache != null)
113
+ {
114
+ return iconCache;
115
+ }
116
+
117
+ try
118
+ {
119
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
120
+
121
+// if (image.getWidth() > 48 && image.getHeight() > 48)
122
+// {
123
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
124
+// Graphics2D g = resized.createGraphics();
125
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
126
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
127
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
128
+// g.dispose();
129
+//
130
+// image = resized;
131
+// }
132
+
133
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
134
+
135
+ icons.put(name, icon);
136
+
137
+ return icon;
138
+ }
139
+ catch (Exception e)
140
+ {
141
+ //icons.put(name, null);
142
+ return null;
143
+ }
144
+ }
145
+
146
+ BufferedImage GetImage(String name)
147
+ {
148
+ try
149
+ {
150
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
151
+
152
+ return image;
153
+ }
154
+ catch (Exception e)
155
+ {
156
+ return null;
157
+ }
158
+ }
40159
41160 // SCRIPT
42161
....@@ -147,7 +266,7 @@
147266
148267 objEditor.ctrlPanel.remove(namePanel);
149268
150
- if (!GroupEditor.allparams)
269
+ if (!allparams)
151270 return;
152271
153272 // objEditor.ctrlPanel.remove(liveCB);
....@@ -219,6 +338,14 @@
219338 client = inClient;
220339 copy = client;
221340
341
+// if (copy.versionlist == null)
342
+// {
343
+// copy.versionlist = new Object3D[100];
344
+// copy.versionindex = -1;
345
+//
346
+// callee.Save(true);
347
+// }
348
+
222349 // "this" is not called: SetupUI2(objEditor);
223350 }
224351
....@@ -232,6 +359,14 @@
232359 client = inClient;
233360 copy = client;
234361
362
+ if (copy.versionlist == null)
363
+ {
364
+ copy.versionlist = new Object3D[100];
365
+ copy.versionindex = -1;
366
+
367
+// Save(true);
368
+ }
369
+
235370 SetupUI2(callee.GetEditor());
236371 }
237372
....@@ -246,14 +381,15 @@
246381 //localCopy.parent = null;
247382
248383 frame = new JFrame();
249
- frame.setUndecorated(true);
384
+ frame.setUndecorated(false);
250385 objEditor = this;
251386 this.callee = callee;
252387
253388 //parent = p;
254389
255390 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
256
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
391
+ if (Globals.DEBUG)
392
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
257393 //gd.setFullScreenWindow(this);
258394 //setResizable(false);
259395 //if (!isDisplayable())
....@@ -264,6 +400,14 @@
264400 copy = localCopy;
265401 copy.editWindow = this;
266402
403
+// if (copy.versionlist == null)
404
+// {
405
+// copy.versionlist = new Object3D[100];
406
+// copy.versionindex = -1;
407
+//
408
+// Save(true);
409
+// }
410
+
267411 SetupMenu();
268412
269413 //SetupName(objEditor); // new
....@@ -277,12 +421,20 @@
277421 return frame.action(event, obj);
278422 }
279423
424
+ // Cannot work without static
425
+ static boolean allparams = true;
426
+
427
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
428
+
429
+ // This is to refresh the UI of the material panel.
430
+ boolean patchMaterial;
431
+
280432 void SetupMenu()
281433 {
282434 frame.setMenuBar(menuBar = new MenuBar());
283435 menuBar.add(fileMenu = new Menu("File"));
284436 fileMenu.add(newItem = new MenuItem("New"));
285
- fileMenu.add(loadItem = new MenuItem("Open..."));
437
+ fileMenu.add(openItem = new MenuItem("Open..."));
286438
287439 //oe.menuBar.add(menu = new Menu("Include"));
288440 Menu menu = new Menu("Import");
....@@ -314,7 +466,7 @@
314466 }
315467
316468 newItem.addActionListener(this);
317
- loadItem.addActionListener(this);
469
+ openItem.addActionListener(this);
318470 saveItem.addActionListener(this);
319471 saveAsItem.addActionListener(this);
320472 exportAsItem.addActionListener(this);
....@@ -323,13 +475,72 @@
323475 closeItem.addActionListener(this);
324476
325477 objectPanel = new JTabbedPane();
478
+
479
+ ChangeListener changeListener = new ChangeListener()
480
+ {
481
+ //String name;
482
+
483
+ public void stateChanged(ChangeEvent changeEvent)
484
+ {
485
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
486
+// {
487
+// if (latestObject != null)
488
+// {
489
+// refreshContents(true);
490
+// SetMaterial(latestObject);
491
+// }
492
+//
493
+// materialFlushed = true;
494
+// }
495
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
496
+// {
497
+// if (listUI.size() == 0)
498
+// EditSelection(false);
499
+// }
500
+
501
+// if (objectPanel.getSelectedIndex() == 4)
502
+// {
503
+// name = copy.skyboxname;
504
+//
505
+// if (name == null)
506
+// {
507
+// name = "";
508
+// }
509
+//
510
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
511
+// copy.skyboxext = "jpg";
512
+// }
513
+// else
514
+// {
515
+// if (name != null)
516
+// {
517
+// if (name.equals(""))
518
+// {
519
+// copy.skyboxname = null;
520
+// copy.skyboxext = null;
521
+// }
522
+// else
523
+// {
524
+// copy.skyboxname = name;
525
+// }
526
+// }
527
+// }
528
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
529
+
530
+// refreshContents(false); // To refresh Info tab
531
+ cameraView.repaint();
532
+ }
533
+ };
534
+ objectPanel.addChangeListener(changeListener);
535
+
326536 toolbarPanel = new JPanel();
327537 toolbarPanel.setName("Toolbar");
538
+
328539 treePanel = new cGridBag();
329540 treePanel.setName("Tree");
330541
331542 editPanel = new cGridBag().setVertical(true);
332
- editPanel.setName("Edit");
543
+ //editPanel.setName("Edit");
333544
334545 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
335546
....@@ -337,23 +548,29 @@
337548 editPanel.add(editCommandsPanel);
338549 editPanel.add(ctrlPanel);
339550
340
- materialPanel = new cGridBag().setVertical(true);
551
+ toolboxPanel = new cGridBag().setVertical(true);
552
+ //toolboxPanel.setName("Toolbox");
341553
342
- materialPanel.setName("Material");
554
+ skyboxPanel = new cGridBag().setVertical(true);
555
+
556
+ materialPanel = new cGridBag().setVertical(false);
557
+ //materialPanel.setName("Material");
558
+
343559 /*JTextPane*/
344560 infoarea = createTextPane();
345561 doc = infoarea.getStyledDocument();
346562
347563 infoarea.setEditable(true);
348564 SetText();
565
+
349566 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
350567 // infoarea.setOpaque(false);
351568 // //infoarea.setForeground(textcolor);
352569 // TEXTAREA infoarea.setLineWrap(true);
353570 // TEXTAREA infoarea.setWrapStyleWord(true);
354571 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
355
- infoPanel.setPreferredSize(new Dimension(50, 200));
356
- infoPanel.setName("Info");
572
+ infoPanel.setPreferredSize(new Dimension(1, 1));
573
+ //infoPanel.setName("Info");
357574 //infoPanel.setLayout(new BorderLayout());
358575 //infoPanel.add(createTextPane());
359576
....@@ -364,7 +581,14 @@
364581 mainPanel.setDividerSize(9);
365582 mainPanel.setDividerLocation(0.5); //1.0);
366583 mainPanel.setResizeWeight(0.5);
367
-
584
+
585
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
586
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
587
+ divider.setDividerSize(15);
588
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
589
+
590
+ mainPanel.setUI(new BasicSplitPaneUI());
591
+
368592 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
369593 //mainPanel.setLayout(new GridBagLayout());
370594 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -595,8 +819,8 @@
595819 }
596820 }
597821
598
-static GraphicsDevice device = GraphicsEnvironment
599
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
822
+//static GraphicsDevice device = GraphicsEnvironment
823
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
600824
601825 Rectangle keeprect;
602826 cRadio radio;
....@@ -612,13 +836,25 @@
612836
613837 boolean maximized;
614838
839
+ cButton fullscreenLayout;
840
+ cButton expandedLayout;
841
+
615842 void Minimize()
616843 {
617844 frame.setState(Frame.ICONIFIED);
845
+ frame.validate();
618846 }
619847
848
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
849
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
850
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
620851 void Maximize()
621852 {
853
+ if (CameraPane.FULLSCREEN)
854
+ {
855
+ ToggleFullScreen();
856
+ }
857
+
622858 if (maximized)
623859 {
624860 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -626,20 +862,38 @@
626862 else
627863 {
628864 keeprect = frame.getBounds();
629
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
630
- Dimension rect2 = frame.getToolkit().getScreenSize();
631
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
865
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
866
+// Dimension rect2 = frame.getToolkit().getScreenSize();
867
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
632868 // frame.setState(Frame.MAXIMIZED_BOTH);
869
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
633870 }
634871
635872 maximized ^= true;
873
+
874
+ frame.validate();
636875 }
876
+
877
+ cButton minButton;
878
+ cButton maxButton;
879
+ cButton fullButton;
880
+ cButton collapseButton;
881
+ cButton maximize3DButton;
637882
638883 void ToggleFullScreen()
639884 {
640
- if (CameraPane.FULLSCREEN)
885
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
886
+
887
+ cameraView.ToggleFullScreen();
888
+
889
+ if (!CameraPane.FULLSCREEN)
641890 {
642891 device.setFullScreenWindow(null);
892
+ frame.dispose();
893
+ frame.setUndecorated(false);
894
+ frame.validate();
895
+ frame.setVisible(true);
896
+
643897 //frame.setVisible(false);
644898 // frame.removeNotify();
645899 // frame.setUndecorated(false);
....@@ -649,13 +903,13 @@
649903 // X frame.getContentPane().remove(/*"Center",*/bigThree);
650904 // X framePanel.add(bigThree);
651905 // X frame.getContentPane().add(/*"Center",*/framePanel);
652
- framePanel.setDividerLocation(1);
906
+// framePanel.setDividerLocation(46); // icons are 24x24
653907
654908 //frame.setVisible(true);
655
- radio.layout = keepButton;
909
+// radio.layout = keepButton;
656910 //theFrame = null;
657911 keepButton = null;
658
- radio.layout.doClick();
912
+// radio.layout.doClick();
659913
660914 } else
661915 {
....@@ -664,22 +918,65 @@
664918 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
665919 // frame.getToolkit().getScreenSize().height);
666920 //frame.setVisible(false);
921
+
922
+ frame.dispose();
923
+ frame.setUndecorated(true);
667924 device.setFullScreenWindow(frame);
925
+ frame.validate();
926
+ frame.setVisible(true);
668927 // frame.removeNotify();
669928 // frame.setUndecorated(true);
670929 // frame.addNotify();
671930 // X frame.getContentPane().remove(/*"Center",*/framePanel);
672931 // X framePanel.remove(bigThree);
673932 // X frame.getContentPane().add(/*"Center",*/bigThree);
674
- framePanel.setDividerLocation(0);
933
+// framePanel.setDividerLocation(0);
675934
676
- radio.layout = twoButton;
677
- radio.layout.doClick();
935
+// radio.layout = fullscreenLayout;
936
+// radio.layout.doClick();
678937 //frame.setVisible(true);
679938 }
680
-
681
- cameraView.ToggleFullScreen();
939
+ frame.validate();
940
+
941
+ cameraView.requestFocusInWindow();
682942 }
943
+
944
+ void CollapseToolbar()
945
+ {
946
+ framePanel.setDividerLocation(0);
947
+ //frame.validate();
948
+
949
+ cameraView.requestFocusInWindow();
950
+ }
951
+
952
+ private Object3D Duplicate(Object3D object)
953
+ {
954
+ boolean temp = CameraPane.SWITCH;
955
+ CameraPane.SWITCH = false;
956
+
957
+ if (Grafreed.grafreed.universe.versiontable == null)
958
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
959
+
960
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
961
+ // if (copy == client)
962
+
963
+ Object3D versions[] = object.versionlist;
964
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
965
+ object.versionlist = null;
966
+ object.versiontable = null;
967
+
968
+ //byte[] compress = Compress(copy);
969
+ Object3D compress = (Object3D)Grafreed.clone(object);
970
+
971
+ object.versionlist = versions;
972
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
973
+
974
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
975
+
976
+ CameraPane.SWITCH = temp;
977
+
978
+ return compress;
979
+ }
683980
684981 private JTextPane createTextPane()
685982 {
....@@ -802,6 +1099,7 @@
8021099 {
8031100 SetupMaterial(materialPanel);
8041101 }
1102
+
8051103 //SetupName();
8061104 //SetupViews();
8071105 }
....@@ -811,7 +1109,7 @@
8111109 // NumberSlider vDivsField;
8121110 // JCheckBox endcaps;
8131111 JCheckBox liveCB;
814
- JCheckBox selectCB;
1112
+ JCheckBox selectableCB;
8151113 JCheckBox hideCB;
8161114 JCheckBox link2masterCB;
8171115 JCheckBox markCB;
....@@ -819,7 +1117,12 @@
8191117 JCheckBox speedupCB;
8201118 JCheckBox rewindCB;
8211119 JCheckBox flipVCB;
1120
+
1121
+ cCheckBox toggleTextureCB;
1122
+ cCheckBox toggleSwitchCB;
1123
+
8221124 JComboBox texresMenu;
1125
+
8231126 JButton resetButton;
8241127 JButton stepButton;
8251128 JButton stepAllButton;
....@@ -1005,39 +1308,55 @@
10051308
10061309 namePanel = new cGridBag();
10071310
1311
+ //if (copy.pinned)
1312
+ {
1313
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1314
+ pinButton.setSelected(copy.pinned);
1315
+ cGridBag t = new cGridBag();
1316
+ t.preferredWidth = 2;
1317
+ t.add(pinButton);
1318
+ namePanel.add(t);
1319
+
1320
+ pinButton.addItemListener(this);
1321
+ }
1322
+
10081323 nameField = AddText(namePanel, copy.GetName());
1009
- namePanel.add(nameField);
1324
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10101325 oe.ctrlPanel.add(namePanel);
10111326
10121327 oe.ctrlPanel.Return();
10131328
1014
- if (!GroupEditor.allparams)
1329
+ if (!allparams)
10151330 return;
10161331
10171332 setupPanel = new cGridBag().setVertical(false);
10181333
10191334 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
10201335 liveCB.setToolTipText("Animate object");
1021
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1022
- selectCB.setToolTipText("Make object selectable");
1336
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1337
+ markCB.setToolTipText("Set target transform");
1338
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1339
+ selectableCB.setToolTipText("Make object selectable");
10231340 // Return();
1341
+
10241342 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10251343 hideCB.setToolTipText("Hide object");
1026
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1027
- markCB.setToolTipText("Set the animation target transform");
1344
+
1345
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
10281346
10291347 setupPanel2 = new cGridBag().setVertical(false);
10301348
10311349 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10321350 rewindCB.setToolTipText("Rewind animation");
10331351
1034
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1035
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1352
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1353
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
10361354
1355
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1356
+ link2masterCB.setToolTipText("Attach to support");
1357
+
10371358 if (Globals.ADVANCED)
10381359 {
1039
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1040
- link2masterCB.setToolTipText("Attach to support");
10411360 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10421361 speedupCB.setToolTipText("Option motion capture");
10431362 }
....@@ -1223,6 +1542,7 @@
12231542
12241543 if (cam == null || !(copy.get(0) instanceof cGroup))
12251544 {
1545
+ if (Globals.DEBUG)
12261546 System.out.println("CREATE CAMERAS");
12271547 cams = new cTemplate();
12281548 cams.name = "Cameras";
....@@ -1311,6 +1631,7 @@
13111631 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
13121632 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
13131633 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1634
+ //XYZPanel.setName("XYZ");
13141635
13151636 /*
13161637 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1347,14 +1668,34 @@
13471668
13481669 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
13491670 //tmp.setName("Edit");
1671
+ objectPanel.add(toolboxPanel);
1672
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1673
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
1674
+
13501675 objectPanel.add(materialPanel);
1676
+ objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1677
+ objectPanel.setToolTipTextAt(1, "Material");
1678
+
1679
+ objectPanel.add(skyboxPanel);
1680
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1681
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1682
+
13511683 // JPanel north = new JPanel(new BorderLayout());
13521684 // north.setName("Edit");
13531685 // north.add(ctrlPanel, BorderLayout.NORTH);
13541686 // objectPanel.add(north);
13551687 objectPanel.add(editPanel);
1356
- objectPanel.add(infoPanel);
1357
-
1688
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1689
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1690
+
1691
+ objectPanel.add(XYZPanel);
1692
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1693
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1694
+
1695
+ patchMaterial = true;
1696
+ cameraView.patchMaterial = this;
1697
+ objectPanel.setSelectedIndex(1);
1698
+
13581699 /*
13591700 aConstraints.gridx = 0;
13601701 aConstraints.gridwidth = 1;
....@@ -1362,7 +1703,7 @@
13621703 aConstraints.gridy += 1;
13631704 aConstraints.gridwidth = 1;
13641705 mainPanel.add(objectPanel, aConstraints);
1365
- */
1706
+ */
13661707
13671708 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
13681709 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1374,14 +1715,12 @@
13741715 scrollpane.addMouseWheelListener(this); // Default not fast enough
13751716
13761717 /*JTabbedPane*/ scenePanel = new cGridBag();
1377
- scenePanel.preferredWidth = 6;
1718
+ scenePanel.preferredWidth = 5;
13781719
13791720 JTabbedPane tabbedPane = new JTabbedPane();
13801721 tabbedPane.add(scrollpane);
13811722
1382
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1383
-
1384
- optionsPanel = new cGridBag().setVertical(true);
1723
+ optionsPanel = new cGridBag().setVertical(false);
13851724
13861725 optionsPanel.setName("Options");
13871726
....@@ -1389,8 +1728,15 @@
13891728
13901729 tabbedPane.add(optionsPanel);
13911730
1731
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1732
+
13921733 scenePanel.add(tabbedPane);
13931734
1735
+ //if (Globals.ADVANCED)
1736
+// tabbedPane.add(infoPanel);
1737
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1738
+// tabbedPane.setToolTipTextAt(3, "Information");
1739
+
13941740 /*
13951741 cTree jTree = new cTree(null);
13961742 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1452,7 +1798,7 @@
14521798 bigThree = new cGridBag();
14531799 bigThree.addComponent(scenePanel);
14541800 bigThree.addComponent(centralPanel);
1455
- bigThree.addComponent(XYZPanel);
1801
+ //bigThree.addComponent(XYZPanel);
14561802
14571803 // // SIDE EFFECT!!!
14581804 // aConstraints.gridx = 0;
....@@ -1461,16 +1807,33 @@
14611807 // aConstraints.gridheight = 1;
14621808
14631809 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1464
- framePanel.setContinuousLayout(true);
1465
- framePanel.setOneTouchExpandable(true);
1466
- framePanel.setDividerLocation(0.8);
1810
+
1811
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1812
+ new java.beans.PropertyChangeListener()
1813
+ {
1814
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1815
+ {
1816
+ if ((Integer)pce.getOldValue() == 1)
1817
+ {
1818
+ if (radio.layout != expandedLayout)
1819
+ {
1820
+ radio.layout = expandedLayout;
1821
+ radio.layout.doClick();
1822
+ }
1823
+ }
1824
+ }
1825
+ });
1826
+
1827
+ framePanel.setContinuousLayout(false);
1828
+ framePanel.setOneTouchExpandable(false);
1829
+ //.setDividerLocation(0.8);
14671830 //framePanel.setDividerSize(15);
14681831 //framePanel.setResizeWeight(0.15);
14691832 framePanel.setName("Frame");
14701833
14711834 frame.getContentPane().setLayout(new BorderLayout());
14721835 /**/
1473
- JTabbedPane worldPane = new JTabbedPane();
1836
+ //JTabbedPane worldPane = new JTabbedPane();
14741837 //worldPane.add(bigPanel);
14751838 //worldPane.add(worldPanel);
14761839 /**/
....@@ -1481,16 +1844,18 @@
14811844 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14821845
14831846 frame.setSize(1280, 860);
1484
- frame.setVisible(true);
1485
-
1847
+
14861848 cameraView.requestFocusInWindow();
14871849
14881850 gridPanel.setDividerLocation(1.0);
1851
+
1852
+ frame.validate();
1853
+
1854
+ frame.setVisible(true);
14891855
14901856 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14911857 frame.addWindowListener(new WindowAdapter()
14921858 {
1493
-
14941859 public void windowClosing(WindowEvent e)
14951860 {
14961861 Close();
....@@ -1513,12 +1878,426 @@
15131878 ctrlPanel.removeAll();
15141879 }
15151880
1516
- void SetupMaterial(cGridBag panel)
1881
+ void SetupMaterial(cGridBag materialpanel)
15171882 {
1518
- /*
1883
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1884
+
1885
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1886
+ skin.setToolTipText("Skin");
1887
+ skin.addMouseListener(new MouseAdapter()
1888
+ {
1889
+ public void mouseClicked(MouseEvent e)
1890
+ {
1891
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1892
+ cMaterial material = object.material;
1893
+
1894
+ // Skin
1895
+ colorField.setFloat(material.color);
1896
+ float saturation = material.modulation;
1897
+
1898
+ if (!cameraView.Skinshader)
1899
+ {
1900
+ saturation /= 1.5;
1901
+ }
1902
+
1903
+ saturationField.setFloat(saturation);
1904
+
1905
+ subsurfaceField.setFloat(material.subsurface);
1906
+ selfshadowField.setFloat(material.diffuseness);
1907
+ diffusenessField.setFloat(material.factor);
1908
+ shininessField.setFloat(material.shininess);
1909
+ shadowbiasField.setFloat(material.shadowbias);
1910
+ diffuseField.setFloat(material.diffuse);
1911
+ specularField.setFloat(material.specular);
1912
+
1913
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1914
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1915
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1916
+
1917
+ materialtouched = true;
1918
+ applySelf();
1919
+ }
1920
+ });
1921
+ presetpanel.add(skin);
1922
+
1923
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1924
+ lambert.setToolTipText("Diffuse");
1925
+ lambert.addMouseListener(new MouseAdapter()
1926
+ {
1927
+ public void mouseClicked(MouseEvent e)
1928
+ {
1929
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1930
+ cMaterial material = object.material;
1931
+
1932
+ diffusenessField.setFloat(material.factor);
1933
+ selfshadowField.setFloat(material.diffuseness);
1934
+
1935
+ materialtouched = true;
1936
+ applySelf();
1937
+ }
1938
+ });
1939
+ presetpanel.add(lambert);
1940
+
1941
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1942
+ diffuse2.setToolTipText("Diffuse2");
1943
+ diffuse2.addMouseListener(new MouseAdapter()
1944
+ {
1945
+ public void mouseClicked(MouseEvent e)
1946
+ {
1947
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1948
+ cMaterial material = object.material;
1949
+
1950
+ diffusenessField.setFloat(material.factor);
1951
+ selfshadowField.setFloat(material.diffuseness);
1952
+
1953
+ materialtouched = true;
1954
+ applySelf();
1955
+ }
1956
+ });
1957
+ presetpanel.add(diffuse2);
1958
+
1959
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1960
+ diffusemoon.setToolTipText("Moon");
1961
+ diffusemoon.addMouseListener(new MouseAdapter()
1962
+ {
1963
+ public void mouseClicked(MouseEvent e)
1964
+ {
1965
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1966
+ cMaterial material = object.material;
1967
+
1968
+ diffusenessField.setFloat(material.factor);
1969
+ selfshadowField.setFloat(material.diffuseness);
1970
+
1971
+ materialtouched = true;
1972
+ applySelf();
1973
+ }
1974
+ });
1975
+ presetpanel.add(diffusemoon);
1976
+
1977
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1978
+ diffusemoon2.setToolTipText("Moon2");
1979
+ diffusemoon2.addMouseListener(new MouseAdapter()
1980
+ {
1981
+ public void mouseClicked(MouseEvent e)
1982
+ {
1983
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1984
+ cMaterial material = object.material;
1985
+
1986
+ diffusenessField.setFloat(material.factor);
1987
+ selfshadowField.setFloat(material.diffuseness);
1988
+
1989
+ materialtouched = true;
1990
+ applySelf();
1991
+ }
1992
+ });
1993
+ presetpanel.add(diffusemoon2);
1994
+
1995
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1996
+ diffusemoon3.setToolTipText("Moon3");
1997
+ diffusemoon3.addMouseListener(new MouseAdapter()
1998
+ {
1999
+ public void mouseClicked(MouseEvent e)
2000
+ {
2001
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2002
+ cMaterial material = object.material;
2003
+
2004
+ diffusenessField.setFloat(material.factor);
2005
+ selfshadowField.setFloat(material.diffuseness);
2006
+
2007
+ materialtouched = true;
2008
+ applySelf();
2009
+ }
2010
+ });
2011
+ presetpanel.add(diffusemoon3);
2012
+
2013
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
2014
+ diffusesheen.setToolTipText("Sheen");
2015
+ diffusesheen.addMouseListener(new MouseAdapter()
2016
+ {
2017
+ public void mouseClicked(MouseEvent e)
2018
+ {
2019
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2020
+ cMaterial material = object.material;
2021
+
2022
+ sheenField.setFloat(material.sheen);
2023
+
2024
+ materialtouched = true;
2025
+ applySelf();
2026
+ }
2027
+ });
2028
+ presetpanel.add(diffusesheen);
2029
+
2030
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2031
+ rough.setToolTipText("Rough metal");
2032
+ rough.addMouseListener(new MouseAdapter()
2033
+ {
2034
+ public void mouseClicked(MouseEvent e)
2035
+ {
2036
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2037
+ cMaterial material = object.material;
2038
+
2039
+ shininessField.setFloat(material.shininess);
2040
+ velvetField.setFloat(material.velvet);
2041
+
2042
+ materialtouched = true;
2043
+ applySelf();
2044
+ }
2045
+ });
2046
+ presetpanel.add(rough);
2047
+
2048
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2049
+ rough2.setToolTipText("Medium metal");
2050
+ rough2.addMouseListener(new MouseAdapter()
2051
+ {
2052
+ public void mouseClicked(MouseEvent e)
2053
+ {
2054
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2055
+ cMaterial material = object.material;
2056
+
2057
+ shininessField.setFloat(material.shininess);
2058
+ lightareaField.setFloat(material.lightarea);
2059
+
2060
+ materialtouched = true;
2061
+ applySelf();
2062
+ }
2063
+ });
2064
+ presetpanel.add(rough2);
2065
+
2066
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2067
+ shini0.setToolTipText("Shiny");
2068
+ shini0.addMouseListener(new MouseAdapter()
2069
+ {
2070
+ public void mouseClicked(MouseEvent e)
2071
+ {
2072
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2073
+ cMaterial material = object.material;
2074
+
2075
+ shininessField.setFloat(material.shininess);
2076
+ lightareaField.setFloat(material.lightarea);
2077
+
2078
+ materialtouched = true;
2079
+ applySelf();
2080
+ }
2081
+ });
2082
+ presetpanel.add(shini0);
2083
+
2084
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2085
+ shini1.setToolTipText("Shiny2");
2086
+ shini1.addMouseListener(new MouseAdapter()
2087
+ {
2088
+ public void mouseClicked(MouseEvent e)
2089
+ {
2090
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2091
+ cMaterial material = object.material;
2092
+
2093
+ shininessField.setFloat(material.shininess);
2094
+ lightareaField.setFloat(material.lightarea);
2095
+
2096
+ materialtouched = true;
2097
+ applySelf();
2098
+ }
2099
+ });
2100
+ presetpanel.add(shini1);
2101
+
2102
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2103
+ shini2.setToolTipText("Shiny3");
2104
+ shini2.addMouseListener(new MouseAdapter()
2105
+ {
2106
+ public void mouseClicked(MouseEvent e)
2107
+ {
2108
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2109
+ cMaterial material = object.material;
2110
+
2111
+ shininessField.setFloat(material.shininess);
2112
+ lightareaField.setFloat(material.lightarea);
2113
+
2114
+ materialtouched = true;
2115
+ applySelf();
2116
+ }
2117
+ });
2118
+ presetpanel.add(shini2);
2119
+
2120
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2121
+ aniso.setToolTipText("AnisoU");
2122
+ aniso.addMouseListener(new MouseAdapter()
2123
+ {
2124
+ public void mouseClicked(MouseEvent e)
2125
+ {
2126
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2127
+ cMaterial material = object.material;
2128
+
2129
+ anisoField.setFloat(material.aniso);
2130
+ anisoVField.setFloat(material.anisoV);
2131
+
2132
+ materialtouched = true;
2133
+ applySelf();
2134
+ }
2135
+ });
2136
+ presetpanel.add(aniso);
2137
+
2138
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2139
+ aniso2.setToolTipText("AnisoV");
2140
+ aniso2.addMouseListener(new MouseAdapter()
2141
+ {
2142
+ public void mouseClicked(MouseEvent e)
2143
+ {
2144
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2145
+ cMaterial material = object.material;
2146
+
2147
+ anisoField.setFloat(material.aniso);
2148
+ anisoVField.setFloat(material.anisoV);
2149
+
2150
+ materialtouched = true;
2151
+ applySelf();
2152
+ }
2153
+ });
2154
+ presetpanel.add(aniso2);
2155
+
2156
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2157
+ aniso3.setToolTipText("AnisoUV");
2158
+ aniso3.addMouseListener(new MouseAdapter()
2159
+ {
2160
+ public void mouseClicked(MouseEvent e)
2161
+ {
2162
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2163
+ cMaterial material = object.material;
2164
+
2165
+ anisoField.setFloat(material.aniso);
2166
+ anisoVField.setFloat(material.anisoV);
2167
+
2168
+ materialtouched = true;
2169
+ applySelf();
2170
+ }
2171
+ });
2172
+ presetpanel.add(aniso3);
2173
+
2174
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2175
+ velvet0.setToolTipText("Velvet");
2176
+ velvet0.addMouseListener(new MouseAdapter()
2177
+ {
2178
+ public void mouseClicked(MouseEvent e)
2179
+ {
2180
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2181
+ cMaterial material = object.material;
2182
+
2183
+ diffusenessField.setFloat(material.factor);
2184
+ selfshadowField.setFloat(material.diffuseness);
2185
+ sheenField.setFloat(material.sheen);
2186
+ shininessField.setFloat(material.shininess);
2187
+ velvetField.setFloat(material.velvet);
2188
+ shiftField.setFloat(material.shift);
2189
+
2190
+ materialtouched = true;
2191
+ applySelf();
2192
+ }
2193
+ });
2194
+ presetpanel.add(velvet0);
2195
+
2196
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2197
+ bump0.setToolTipText("Bump texture");
2198
+ bump0.addMouseListener(new MouseAdapter()
2199
+ {
2200
+ public void mouseClicked(MouseEvent e)
2201
+ {
2202
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2203
+ cMaterial material = object.material;
2204
+
2205
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2206
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2207
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2208
+
2209
+ materialtouched = true;
2210
+ applySelf();
2211
+ }
2212
+ });
2213
+ presetpanel.add(bump0);
2214
+
2215
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2216
+ borderShader.setToolTipText("Border fade");
2217
+ borderShader.addMouseListener(new MouseAdapter()
2218
+ {
2219
+ public void mouseClicked(MouseEvent e)
2220
+ {
2221
+ borderfadeField.setFloat(0.5);
2222
+ opacityField.setFloat(0.75);
2223
+
2224
+ materialtouched = true;
2225
+ applySelf();
2226
+ }
2227
+ });
2228
+ presetpanel.add(borderShader);
2229
+
2230
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2231
+ halo.setToolTipText("Halo");
2232
+ halo.addMouseListener(new MouseAdapter()
2233
+ {
2234
+ public void mouseClicked(MouseEvent e)
2235
+ {
2236
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2237
+ cMaterial material = object.material;
2238
+
2239
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2240
+
2241
+ materialtouched = true;
2242
+ applySelf();
2243
+ }
2244
+ });
2245
+ presetpanel.add(halo);
2246
+
2247
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2248
+ candle.setToolTipText("Candle");
2249
+ candle.addMouseListener(new MouseAdapter()
2250
+ {
2251
+ public void mouseClicked(MouseEvent e)
2252
+ {
2253
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2254
+ cMaterial material = object.material;
2255
+
2256
+ subsurfaceField.setFloat(material.subsurface);
2257
+ shadowbiasField.setFloat(material.shadowbias);
2258
+ ambientField.setFloat(material.ambient);
2259
+ specularField.setFloat(material.specular);
2260
+ lightareaField.setFloat(material.lightarea);
2261
+ shininessField.setFloat(material.shininess);
2262
+
2263
+ materialtouched = true;
2264
+ applySelf();
2265
+ }
2266
+ });
2267
+ presetpanel.add(candle);
2268
+
2269
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2270
+ shadowShader.setToolTipText("Shadow");
2271
+ shadowShader.addMouseListener(new MouseAdapter()
2272
+ {
2273
+ public void mouseClicked(MouseEvent e)
2274
+ {
2275
+ diffuseField.setFloat(0.001);
2276
+ ambientField.setFloat(0.001);
2277
+ cameraField.setFloat(0.001);
2278
+ specularField.setFloat(0.001);
2279
+ fakedepthField.setFloat(0.001);
2280
+ opacityField.setFloat(0.6);
2281
+
2282
+ materialtouched = true;
2283
+ applySelf();
2284
+ }
2285
+ });
2286
+ presetpanel.add(shadowShader);
2287
+
2288
+ cGridBag panel = new cGridBag().setVertical(true);
2289
+
2290
+ presetpanel.preferredWidth = 1;
2291
+
2292
+ materialpanel.add(presetpanel);
2293
+ materialpanel.add(panel);
2294
+
2295
+ panel.preferredWidth = 8;
2296
+
2297
+ /*
15192298 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
15202299 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1521
- */
2300
+ */
15222301
15232302 cGridBag editBar = new cGridBag().setVertical(false);
15242303
....@@ -1552,45 +2331,61 @@
15522331 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15532332
15542333 cGridBag colorSection = new cGridBag().setVertical(true);
2334
+
2335
+ cGridBag huepanel = new cGridBag();
2336
+ cGridBag huelabel = new cGridBag();
2337
+ cLabel hue = GetLabel("icons/hue.png", false);
2338
+ hue.fit = true;
2339
+
2340
+ hue.addMouseListener(new MouseAdapter()
2341
+ {
2342
+ public void mousePressed(MouseEvent e)
2343
+ {
2344
+ int x = e.getX();
2345
+
2346
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2347
+ }
2348
+ });
2349
+
2350
+ huelabel.add(hue);
2351
+ huelabel.preferredWidth = 20;
2352
+ huepanel.add(new cGridBag()); // Label
2353
+ huepanel.add(huelabel); // Field/slider
2354
+
2355
+ huepanel.preferredHeight = 7;
2356
+
2357
+ colorSection.add(huepanel);
15552358
15562359 cGridBag color = new cGridBag();
1557
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1558
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1559
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2360
+
2361
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2362
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2363
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2364
+
15602365 //colorField.preferredWidth = 200;
15612366 colorSection.add(color);
15622367
15632368 cGridBag modulation = new cGridBag();
15642369 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
15652370 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1566
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2371
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
15672372 colorSection.add(modulation);
15682373
2374
+ cGridBag opacity = new cGridBag();
2375
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2376
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2377
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2378
+ colorSection.add(opacity);
2379
+
2380
+ colorSection.add(GetSeparator());
2381
+
15692382 cGridBag texture = new cGridBag();
15702383 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
15712384 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15722385 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
15732386 colorSection.add(texture);
15742387
1575
- cGridBag anisoU = new cGridBag();
1576
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1577
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1578
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1579
- colorSection.add(anisoU);
1580
-
1581
- cGridBag anisoV = new cGridBag();
1582
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1583
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1584
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1585
- colorSection.add(anisoV);
1586
-
1587
- cGridBag shadowbias = new cGridBag();
1588
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1589
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1590
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1591
- colorSection.add(shadowbias);
1592
-
1593
- panel.add(new JSeparator());
2388
+ panel.add(GetSeparator());
15942389
15952390 panel.add(colorSection);
15962391
....@@ -1640,7 +2435,13 @@
16402435 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
16412436 diffuseSection.add(fakedepth);
16422437
1643
- panel.add(new JSeparator());
2438
+ cGridBag shadowbias = new cGridBag();
2439
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2440
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2441
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2442
+ diffuseSection.add(shadowbias);
2443
+
2444
+ panel.add(GetSeparator());
16442445
16452446 panel.add(diffuseSection);
16462447
....@@ -1690,42 +2491,48 @@
16902491 // aConstraints.gridy += 1;
16912492 // aConstraints.gridwidth = 1;
16922493
2494
+ cGridBag anisoU = new cGridBag();
2495
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2496
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2497
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2498
+ specularSection.add(anisoU);
16932499
1694
- panel.add(new JSeparator());
2500
+ cGridBag anisoV = new cGridBag();
2501
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2502
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2503
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2504
+ specularSection.add(anisoV);
2505
+
2506
+
2507
+ panel.add(GetSeparator());
16952508
16962509 panel.add(specularSection);
16972510
16982511 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16992512
1700
- cGridBag globalSection = new cGridBag().setVertical(true);
2513
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17012514
17022515 cGridBag camera = new cGridBag();
17032516 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17042517 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17052518 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1706
- globalSection.add(camera);
2519
+ colorSection.add(camera);
17072520
17082521 cGridBag ambient = new cGridBag();
17092522 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17102523 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17112524 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1712
- globalSection.add(ambient);
2525
+ colorSection.add(ambient);
17132526
17142527 cGridBag backlit = new cGridBag();
17152528 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17162529 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17172530 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1718
- globalSection.add(backlit);
2531
+ colorSection.add(backlit);
17192532
1720
- cGridBag opacity = new cGridBag();
1721
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1722
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1723
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1724
- globalSection.add(opacity);
1725
-
1726
- panel.add(new JSeparator());
2533
+ //panel.add(new JSeparator());
17272534
1728
- panel.add(globalSection);
2535
+ //panel.add(globalSection);
17292536
17302537 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17312538
....@@ -1767,7 +2574,7 @@
17672574 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
17682575 textureSection.add(opacityPower);
17692576
1770
- panel.add(new JSeparator());
2577
+ panel.add(GetSeparator());
17712578
17722579 panel.add(textureSection);
17732580
....@@ -1832,8 +2639,9 @@
18322639 // 3D models
18332640 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
18342641 {
1835
- lastConverter = new com.jmex.model.converters.MaxToJme();
1836
- LoadFile(filename, lastConverter);
2642
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2643
+ //LoadFile(filename, lastConverter);
2644
+ LoadObjFile(filename); // New 3ds loader
18372645 continue;
18382646 }
18392647 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2559,6 +3367,7 @@
25593367 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
25603368 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
25613369 }
3370
+
25623371 //cJME.count++;
25633372 //cJME.count %= 12;
25643373 if (gc)
....@@ -2742,6 +3551,7 @@
27423551 }
27433552 }
27443553 }
3554
+
27453555 cFileSystemPane FSPane;
27463556
27473557 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2751,7 +3561,7 @@
27513561
27523562 freezematerial = true;
27533563 colorField.setFloat(mat.color);
2754
- modulationField.setFloat(mat.modulation);
3564
+ saturationField.setFloat(mat.modulation);
27553565 metalnessField.setFloat(mat.metalness);
27563566 diffuseField.setFloat(mat.diffuse);
27573567 specularField.setFloat(mat.specular);
....@@ -2795,11 +3605,14 @@
27953605 }
27963606 }
27973607 }
3608
+
27983609 freezematerial = false;
27993610 }
28003611
28013612 void SetMaterial(Object3D object)
28023613 {
3614
+ latestObject = object;
3615
+
28033616 cMaterial mat = object.material;
28043617
28053618 if (mat == null)
....@@ -2810,32 +3623,8 @@
28103623
28113624 if (multiplyToggle != null)
28123625 multiplyToggle.setSelected(mat.multiply);
2813
-
2814
- assert (object.projectedVertices != null);
2815
-
2816
- if (object.projectedVertices.length <= 2)
2817
- {
2818
- // Side effect...
2819
- Object3D.cVector2[] keep = object.projectedVertices;
2820
- object.projectedVertices = new Object3D.cVector2[3];
2821
- for (int i = 0; i < 3; i++)
2822
- {
2823
- if (i < keep.length)
2824
- {
2825
- object.projectedVertices[i] = keep[i];
2826
- } else
2827
- {
2828
- object.projectedVertices[i] = new Object3D.cVector2();
2829
- }
2830
- /*
2831
- if(keep.length == 0)
2832
- object.projectedVertices[0] = new Object3D.cVector2();
2833
- else
2834
- object.projectedVertices[0] = keep[0];
2835
- object.projectedVertices[1] = new Object3D.cVector2();
2836
- */
2837
- }
2838
- }
3626
+
3627
+ AllocProjectedVertices(object);
28393628
28403629 SetMaterial(mat, object.projectedVertices);
28413630 }
....@@ -2911,12 +3700,17 @@
29113700 // }
29123701
29133702 /**/
2914
- if (deselect)
3703
+ if (deselect || child == null)
29153704 {
29163705 //group.deselectAll();
29173706 //freeze = true;
29183707 GetTree().clearSelection();
29193708 //freeze = false;
3709
+
3710
+ if (child == null)
3711
+ {
3712
+ return;
3713
+ }
29203714 }
29213715
29223716 //group.addSelectee(child);
....@@ -2950,6 +3744,17 @@
29503744 public void itemStateChanged(ItemEvent event)
29513745 {
29523746 // System.out.println("Propagate = " + propagate);
3747
+ if (event.getSource() == pinButton)
3748
+ {
3749
+ copy.pinned ^= true;
3750
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3751
+ {
3752
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3753
+ copy.CloseUI();
3754
+ //copy.editWindow.refreshContents();
3755
+ }
3756
+ }
3757
+ else
29533758 if (event.getSource() == propagateToggle)
29543759 {
29553760 propagate ^= true;
....@@ -2985,7 +3790,7 @@
29853790 cameraView.ToggleDL();
29863791 cameraView.repaint();
29873792 return;
2988
- } else if (event.getSource() == toggleTextureItem)
3793
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29893794 {
29903795 cameraView.ToggleTexture();
29913796 // june 2013 copy.HardTouch();
....@@ -3024,7 +3829,7 @@
30243829 frame.validate();
30253830
30263831 return;
3027
- } else if (event.getSource() == toggleSwitchItem)
3832
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30283833 {
30293834 cameraView.ToggleSwitch();
30303835 cameraView.repaint();
....@@ -3054,8 +3859,9 @@
30543859 } else if (event.getSource() == liveCB)
30553860 {
30563861 copy.live ^= true;
3862
+ objEditor.refreshContents(true); // To show item colors
30573863 return;
3058
- } else if (event.getSource() == selectCB)
3864
+ } else if (event.getSource() == selectableCB)
30593865 {
30603866 copy.dontselect ^= true;
30613867 return;
....@@ -3063,7 +3869,7 @@
30633869 {
30643870 copy.hide ^= true;
30653871 copy.Touch(); // display list issue
3066
- objEditor.refreshContents();
3872
+ objEditor.refreshContents(true); // To show item colors
30673873 return;
30683874 } else if (event.getSource() == link2masterCB)
30693875 {
....@@ -3128,7 +3934,7 @@
31283934 //System.out.println("ObjEditor " + event);
31293935 applySelf0(true);
31303936 //parent.applySelf();
3131
- objEditor.refreshContents();
3937
+ // conflicts with requestFocus objEditor.refreshContents();
31323938 } else if (source == resetButton)
31333939 {
31343940 CameraPane.fullreset = true;
....@@ -3240,9 +4046,9 @@
32404046 {
32414047 Close();
32424048 //return true;
3243
- } else if (source == loadItem)
4049
+ } else if (source == openItem)
32444050 {
3245
- load();
4051
+ Open();
32464052 //return true;
32474053 } else if (source == newItem)
32484054 {
....@@ -3267,6 +4073,10 @@
32674073 {
32684074 generatePOV();
32694075 //return true;
4076
+ } else if (event.getSource() == archiveItem)
4077
+ {
4078
+ cTools.Archive(frame);
4079
+ return;
32704080 } else if (source == zBufferItem)
32714081 {
32724082 try
....@@ -3315,11 +4125,12 @@
33154125
33164126 static public byte[] Compress(Object3D o)
33174127 {
4128
+ // Slower to actually compress.
33184129 try
33194130 {
33204131 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3321
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3322
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4132
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4133
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33234134
33244135 Object3D parent = o.parent;
33254136 o.parent = null;
....@@ -3330,10 +4141,14 @@
33304141
33314142 out.flush();
33324143
3333
- zstream.close();
4144
+ baos //zstream
4145
+ .close();
33344146 out.close();
33354147
3336
- return baos.toByteArray();
4148
+ byte[] bytes = baos.toByteArray();
4149
+
4150
+ System.out.println("save #bytes = " + bytes.length);
4151
+ return bytes;
33374152 } catch (Exception e)
33384153 {
33394154 System.err.println(e);
....@@ -3343,13 +4158,16 @@
33434158
33444159 static public Object Uncompress(byte[] bytes)
33454160 {
3346
- System.out.println("#bytes = " + bytes.length);
4161
+ System.out.println("restore #bytes = " + bytes.length);
33474162 try
33484163 {
33494164 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3350
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3351
- ObjectInputStream in = new ObjectInputStream(istream);
4165
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4166
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
33524167 Object obj = in.readObject();
4168
+
4169
+ bais //istream
4170
+ .close();
33534171 in.close();
33544172
33554173 return obj;
....@@ -3404,37 +4222,97 @@
34044222 return null;
34054223 }
34064224
3407
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
34084225
34094226 public void Save()
34104227 {
3411
- cRadio tab = GetCurrentTab();
4228
+ //Save(true);
4229
+ Replace();
4230
+ SetVersionStates();
4231
+ }
4232
+
4233
+ private boolean Equal(byte[] compress, byte[] name)
4234
+ {
4235
+ if (compress.length != name.length)
4236
+ {
4237
+ return false;
4238
+ }
34124239
3413
- boolean temp = CameraPane.SWITCH;
3414
- CameraPane.SWITCH = false;
4240
+ for (int i=compress.length; --i>=0;)
4241
+ {
4242
+ if (compress[i] != name[i])
4243
+ return false;
4244
+ }
34154245
3416
- copy.ExtractBigData(hashtable);
4246
+ return true;
4247
+ }
4248
+
4249
+ void DeleteVersion()
4250
+ {
4251
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4252
+ {
4253
+ copy.versionlist[i] = copy.versionlist[i+1];
4254
+ }
4255
+
4256
+ if (copy.versionlist[copy.versionindex] == null)
4257
+ copy.versionindex -= 1;
4258
+
4259
+ if (copy.versionindex != -1)
4260
+ CopyChanged();
4261
+
4262
+ SetVersionStates();
4263
+ }
4264
+
4265
+ public boolean Save(boolean user)
4266
+ {
4267
+ System.err.println("Save");
4268
+ Replace();
4269
+
4270
+ //cRadio tab = GetCurrentTab();
4271
+
4272
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
4273
+
4274
+ boolean thesame = false;
4275
+
4276
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4277
+// {
4278
+// thesame = true;
4279
+// }
34174280
34184281 //EditorFrame.m_MainFrame.requestFocusInWindow();
3419
- tab.graphs[tab.undoindex++] = Compress(copy);
3420
-
3421
- copy.RestoreBigData(hashtable);
3422
-
3423
- CameraPane.SWITCH = temp;
3424
-
3425
- //assert(hashtable.isEmpty());
3426
-
3427
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
4282
+ if (!thesame)
34284283 {
3429
- tab.graphs[i] = null;
4284
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4285
+ {
4286
+ copy.versionlist[i] = copy.versionlist[i-1];
4287
+ }
4288
+
4289
+ //tab.user[tab.versionindex] = user;
4290
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4291
+
4292
+ copy.versionlist[++copy.versionindex] = compress;
4293
+
4294
+ // if (increment)
4295
+ // tab.versionindex++;
34304296 }
34314297
4298
+ //copy.RestoreBigData(versiontable);
4299
+
4300
+ //assert(hashtable.isEmpty());
4301
+
4302
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4303
+// {
4304
+// //tab.user[i] = false;
4305
+// copy.versionlist[i] = null;
4306
+// }
4307
+
4308
+ SetVersionStates();
4309
+
34324310 // test save
34334311 if (false)
34344312 {
34354313 try
34364314 {
3437
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4315
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
34384316 ObjectOutputStream p = new ObjectOutputStream(ostream);
34394317
34404318 p.writeObject(copy);
....@@ -3447,26 +4325,68 @@
34474325 e.printStackTrace();
34484326 }
34494327 }
4328
+
4329
+ return !thesame;
4330
+ }
4331
+
4332
+ boolean flashIt = true;
4333
+
4334
+ void RefreshSelection()
4335
+ {
4336
+ Object3D selection = new Object3D();
4337
+
4338
+ for (int i = 0; i < copy.selection.size(); i++)
4339
+ {
4340
+ Object3D elem = copy.selection.elementAt(i);
4341
+
4342
+ Object3D obj = copy.GetObject(elem.GetUUID());
4343
+
4344
+ if (obj == null)
4345
+ {
4346
+ copy.selection.remove(i--);
4347
+ }
4348
+ else
4349
+ {
4350
+ selection.add(obj);
4351
+ copy.selection.setElementAt(obj, i);
4352
+ }
4353
+ }
4354
+
4355
+ flashIt = false;
4356
+ GetTree().clearSelection();
4357
+ for (int i = 0; i < selection.size(); i++)
4358
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4359
+ flashIt = true;
4360
+
4361
+ //refreshContents(false);
34504362 }
34514363
3452
- void CopyChanged(Object3D obj)
4364
+ void CopyChanged()
34534365 {
4366
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4367
+
4368
+ SetVersionStates();
4369
+
34544370 boolean temp = CameraPane.SWITCH;
34554371 CameraPane.SWITCH = false;
34564372
3457
- copy.ExtractBigData(hashtable);
4373
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
34584374
34594375 copy.clear();
34604376
4377
+ copy.skyboxname = obj.skyboxname;
4378
+ copy.skyboxext = obj.skyboxext;
4379
+
34614380 for (int i=0; i<obj.Size(); i++)
34624381 {
34634382 copy.add(obj.get(i));
34644383 }
34654384
3466
- copy.RestoreBigData(hashtable);
4385
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
34674386
34684387 CameraPane.SWITCH = temp;
34694388
4389
+ RefreshSelection();
34704390 //assert(hashtable.isEmpty());
34714391
34724392 copy.Touch();
....@@ -3487,43 +4407,144 @@
34874407 }
34884408 }
34894409
3490
- refreshContents();
4410
+ refreshContents(true);
34914411 }
34924412
3493
- public void Undo()
3494
- {
3495
- cRadio tab = GetCurrentTab();
4413
+ cButton previousVersionButton;
4414
+ cButton restoreButton;
4415
+ cButton replaceButton;
4416
+ cButton nextVersionButton;
4417
+ cButton saveVersionButton;
4418
+ cButton deleteVersionButton;
34964419
3497
- if (tab.undoindex == 0)
4420
+ boolean muteSlider;
4421
+
4422
+ int VersionCount()
4423
+ {
4424
+ int count = 0;
4425
+
4426
+ for (int i = copy.versionlist.length; --i >= 0;)
4427
+ {
4428
+ if (copy.versionlist[i] != null)
4429
+ count++;
4430
+ }
4431
+
4432
+ return count;
4433
+ }
4434
+
4435
+ void SetVersionStates()
4436
+ {
4437
+ //if (true)
4438
+ // return;
4439
+
4440
+ //cRadio tab = GetCurrentTab();
4441
+
4442
+ restoreButton.setEnabled(copy.versionindex != -1);
4443
+ replaceButton.setEnabled(copy.versionindex != -1);
4444
+
4445
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4446
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4447
+
4448
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4449
+ //copy.versionlist[copy.versionindex + 1] != null);
4450
+
4451
+ muteSlider = true;
4452
+ versionSlider.setMinimum(0);
4453
+ versionSlider.setMaximum(VersionCount() - 1);
4454
+ versionSlider.setInteger(copy.versionindex);
4455
+ versionSlider.setEnabled(copy.versionindex != -1);
4456
+ muteSlider = false;
4457
+ }
4458
+
4459
+ public boolean PreviousVersion()
4460
+ {
4461
+ // Option?
4462
+ Replace();
4463
+
4464
+ System.err.println("Undo");
4465
+
4466
+ //cRadio tab = GetCurrentTab();
4467
+
4468
+ if (copy.versionindex == 0)
34984469 {
34994470 java.awt.Toolkit.getDefaultToolkit().beep();
3500
- return;
4471
+ return false;
35014472 }
35024473
3503
- if (tab.graphs[tab.undoindex] == null)
3504
- {
3505
- Save();
3506
- tab.undoindex -= 1;
3507
- }
4474
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4475
+// {
4476
+// if (Save(false))
4477
+// tab.versionindex -= 1;
4478
+// else
4479
+// {
4480
+// if (tab.versionindex <= 0)
4481
+// return false;
4482
+// else
4483
+// tab.versionindex -= 1;
4484
+// }
4485
+// }
35084486
3509
- tab.undoindex -= 1;
4487
+ copy.versionindex -= 1;
35104488
3511
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4489
+ CopyChanged();
4490
+
4491
+ return true;
35124492 }
35134493
3514
- public void Redo()
4494
+ public boolean Restore()
35154495 {
3516
- cRadio tab = GetCurrentTab();
4496
+ System.err.println("Restore");
35174497
3518
- if (tab.graphs[tab.undoindex + 1] == null)
4498
+ //cRadio tab = GetCurrentTab();
4499
+
4500
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4501
+ {
4502
+ java.awt.Toolkit.getDefaultToolkit().beep();
4503
+ return false;
4504
+ }
4505
+
4506
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4507
+ CopyChanged();
4508
+
4509
+ return true;
4510
+ }
4511
+
4512
+ public boolean Replace()
4513
+ {
4514
+ //System.err.println("Replace");
4515
+
4516
+ //cRadio tab = GetCurrentTab();
4517
+
4518
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4519
+ {
4520
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4521
+ return false;
4522
+ }
4523
+
4524
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4525
+
4526
+ return true;
4527
+ }
4528
+
4529
+ public void NextVersion()
4530
+ {
4531
+ // Option?
4532
+ Replace();
4533
+
4534
+ //cRadio tab = GetCurrentTab();
4535
+
4536
+ if (copy.versionlist[copy.versionindex + 1] == null)
35194537 {
35204538 java.awt.Toolkit.getDefaultToolkit().beep();
35214539 return;
35224540 }
35234541
3524
- tab.undoindex += 1;
4542
+ copy.versionindex += 1;
35254543
3526
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4544
+ CopyChanged();
4545
+
4546
+ //if (!tab.user[tab.versionindex])
4547
+ // tab.graphs[tab.versionindex] = null;
35274548 }
35284549
35294550 void ImportGFD()
....@@ -3675,7 +4696,7 @@
36754696 assert false;
36764697 }
36774698
3678
- void EditSelection()
4699
+ void EditSelection(boolean newWindow)
36794700 {
36804701 }
36814702
....@@ -3734,7 +4755,7 @@
37344755 //copy.material = new cMaterial(copy.GetMaterial());
37354756
37364757 current.color = (float) colorField.getFloat();
3737
- current.modulation = (float) modulationField.getFloat();
4758
+ current.modulation = (float) saturationField.getFloat();
37384759 current.metalness = (float) metalnessField.getFloat();
37394760 current.diffuse = (float) diffuseField.getFloat();
37404761 current.specular = (float) specularField.getFloat();
....@@ -3767,7 +4788,7 @@
37674788 cMaterial mat = copy.material;
37684789
37694790 colorField.SetToolTipValue((mat.color));
3770
- modulationField.SetToolTipValue((mat.modulation));
4791
+ saturationField.SetToolTipValue((mat.modulation));
37714792 metalnessField.SetToolTipValue((mat.metalness));
37724793 diffuseField.SetToolTipValue((mat.diffuse));
37734794 specularField.SetToolTipValue((mat.specular));
....@@ -3819,9 +4840,28 @@
38194840 //copy.Touch();
38204841 }
38214842
4843
+ cNumberSlider versionSlider;
4844
+
38224845 public void stateChanged(ChangeEvent e)
38234846 {
38244847 // assert(false);
4848
+ if (e.getSource() == versionSlider)
4849
+ {
4850
+ if (muteSlider)
4851
+ return;
4852
+
4853
+ Replace();
4854
+
4855
+ int version = versionSlider.getInteger();
4856
+
4857
+ if (version != -1 && copy.versionlist[version] != null)
4858
+ {
4859
+ copy.versionindex = version;
4860
+ CopyChanged();
4861
+ }
4862
+
4863
+ return;
4864
+ }
38254865
38264866 if (freezematerial)
38274867 {
....@@ -3857,6 +4897,12 @@
38574897 {
38584898 //System.out.println("stateChanged = " + this);
38594899 materialtouched = true;
4900
+
4901
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4902
+ {
4903
+ saturationField.setFloat(1);
4904
+ }
4905
+
38604906 applySelf();
38614907 //System.out.println("this = " + this);
38624908 //System.out.println("PARENT = " + parent);
....@@ -4156,6 +5202,7 @@
41565202 {
41575203 if (GetTree() != null)
41585204 {
5205
+ GetTree().revalidate();
41595206 GetTree().repaint();
41605207 }
41615208
....@@ -4164,13 +5211,19 @@
41645211 ctrlPanel.validate(); // ? new
41655212 ctrlPanel.repaint();
41665213 }
5214
+
5215
+ if (previousVersionButton != null && copy.versionlist != null)
5216
+ SetVersionStates();
5217
+
5218
+ cameraView.requestFocusInWindow();
41675219 }
41685220
41695221 static TweenManager tweenManager = new TweenManager();
41705222
41715223 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
41725224 {
4173
- Save();
5225
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5226
+ Save();
41745227 //Tween.set(thing, 0).target(1).start(tweenManager);
41755228 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
41765229 // if (thing instanceof GenericJointDemo)
....@@ -4194,7 +5247,7 @@
41945247 // group = (Composite) group.get(0);
41955248 // }
41965249
4197
- System.out.println("makeSomething of " + thing);
5250
+ //System.out.println("makeSomething of " + thing);
41985251
41995252 /*
42005253 if (deselect && jList != null)
....@@ -4257,6 +5310,12 @@
42575310 {
42585311 ResetModel();
42595312 Select(thing.GetTreePath(), true, false); // unselect... false);
5313
+
5314
+ if (thing.Size() == 0)
5315
+ {
5316
+ //EditSelection(false);
5317
+ }
5318
+
42605319 refreshContents();
42615320 }
42625321
....@@ -4405,7 +5464,9 @@
44055464 readobj.ResetDisplayList();
44065465 } catch (Exception e)
44075466 {
4408
- //e.printStackTrace();
5467
+ if (!e.toString().contains("GZIP"))
5468
+ e.printStackTrace();
5469
+
44095470 try
44105471 {
44115472 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4479,11 +5540,14 @@
44795540
44805541 if (readobj != null)
44815542 {
4482
- Save();
5543
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5544
+ // Save();
44835545 try
44845546 {
44855547 //readobj.deepCopySelf(copy);
44865548 copy.clear(); // june 2014
5549
+ copy.skyboxname = readobj.skyboxname;
5550
+ copy.skyboxext = readobj.skyboxext;
44875551 for (int i = 0; i < readobj.size(); i++)
44885552 {
44895553 Object3D child = readobj.get(i); // reserve(i);
....@@ -4524,6 +5588,7 @@
45245588 }
45255589 } catch (ClassCastException e)
45265590 {
5591
+ e.printStackTrace();
45275592 assert (false);
45285593 Composite c = (Composite) copy;
45295594 c.children.clear();
....@@ -4534,17 +5599,32 @@
45345599 c.addChild(csg);
45355600 }
45365601
5602
+ copy.versionlist = readobj.versionlist;
5603
+ copy.versionindex = readobj.versionindex;
5604
+ copy.versiontable = readobj.versiontable;
5605
+
5606
+ if (copy.versionlist == null)
5607
+ {
5608
+ // Backward compatibility
5609
+ copy.versionlist = new Object3D[100];
5610
+ copy.versionindex = -1;
5611
+
5612
+ //Save(true);
5613
+ }
5614
+
5615
+ //? SetUndoStates();
5616
+
45375617 ResetModel();
45385618 copy.HardTouch(); // recompile?
45395619 refreshContents();
45405620 }
45415621 }
45425622
4543
- void load() // throws ClassNotFoundException
5623
+ void Open() // throws ClassNotFoundException
45445624 {
45455625 if (Grafreed.standAlone)
45465626 {
4547
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5627
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
45485628 browser.show();
45495629 String filename = browser.getFile();
45505630 if (filename != null && filename.length() > 0)
....@@ -4621,6 +5701,8 @@
46215701
46225702 void save()
46235703 {
5704
+ Replace();
5705
+
46245706 if (lastname == null)
46255707 {
46265708 return;
....@@ -4643,6 +5725,7 @@
46435725 //ps.print(buffer.toString());
46445726 } catch (IOException e)
46455727 {
5728
+ e.printStackTrace();
46465729 }
46475730 }
46485731
....@@ -4657,6 +5740,8 @@
46575740 String filename = browser.getFile();
46585741 if (filename != null && filename.length() > 0)
46595742 {
5743
+ if (!filename.endsWith(".gfd"))
5744
+ filename += ".gfd";
46605745 lastname = browser.getDirectory() + filename;
46615746 save();
46625747 }
....@@ -4823,7 +5908,7 @@
48235908 MenuBar menuBar;
48245909 Menu fileMenu;
48255910 MenuItem newItem;
4826
- MenuItem loadItem;
5911
+ MenuItem openItem;
48275912 MenuItem saveItem;
48285913 MenuItem saveAsItem;
48295914 MenuItem exportAsItem;
....@@ -4846,22 +5931,37 @@
48465931 CheckboxMenuItem toggleSwitchItem;
48475932 CheckboxMenuItem toggleRootItem;
48485933 CheckboxMenuItem animationItem;
5934
+ MenuItem archiveItem;
48495935 CheckboxMenuItem toggleHandleItem;
48505936 CheckboxMenuItem togglePaintItem;
48515937 JSplitPane mainPanel;
48525938 JScrollPane scrollpane;
5939
+
48535940 JPanel toolbarPanel;
5941
+
48545942 cGridBag treePanel;
5943
+
48555944 JPanel radioPanel;
48565945 ButtonGroup buttonGroup;
4857
- cGridBag ctrlPanel;
5946
+
5947
+ cGridBag toolboxPanel;
5948
+ cGridBag skyboxPanel;
48585949 cGridBag materialPanel;
5950
+ cGridBag ctrlPanel;
5951
+
48595952 JScrollPane infoPanel;
5953
+
48605954 cGridBag optionsPanel;
5955
+
48615956 JTabbedPane objectPanel;
5957
+ boolean materialFlushed;
5958
+ Object3D latestObject;
5959
+
48625960 cGridBag XYZPanel;
5961
+
48635962 JSplitPane gridPanel;
48645963 JSplitPane bigPanel;
5964
+
48655965 cGridBag bigThree;
48665966 cGridBag scenePanel;
48675967 cGridBag centralPanel;
....@@ -4919,7 +6019,7 @@
49196019 JLabel colorLabel;
49206020 cNumberSlider colorField;
49216021 JLabel modulationLabel;
4922
- cNumberSlider modulationField;
6022
+ cNumberSlider saturationField;
49236023 JLabel metalnessLabel;
49246024 cNumberSlider metalnessField;
49256025 JLabel diffuseLabel;
....@@ -4950,6 +6050,7 @@
49506050 cNumberSlider anisoField;
49516051 JLabel anisoVLabel;
49526052 cNumberSlider anisoVField;
6053
+
49536054 JLabel cameraLabel;
49546055 cNumberSlider cameraField;
49556056 JLabel selfshadowLabel;
....@@ -4964,6 +6065,7 @@
49646065 cNumberSlider fakedepthField;
49656066 JLabel shadowbiasLabel;
49666067 cNumberSlider shadowbiasField;
6068
+
49676069 JLabel bumpLabel;
49686070 cNumberSlider bumpField;
49696071 JLabel noiseLabel;
....@@ -4976,7 +6078,7 @@
49766078 cNumberSlider fogField;
49776079 JLabel opacityPowerLabel;
49786080 cNumberSlider opacityPowerField;
4979
- JTree jTree;
6081
+ cTree jTree;
49806082 //ObjectUI parent;
49816083
49826084 cNumberSlider normalpushField;