Normand Briere
2019-08-17 07c0c67b88160b51e61c5c1d2b9b602daafa44a9
ObjEditor.java
....@@ -34,6 +34,7 @@
3434 iSendInfo
3535 //KeyListener
3636 {
37
+ public cToggleButton pinButton;
3738 boolean timeline;
3839 boolean wasFullScreen;
3940
....@@ -41,64 +42,119 @@
4142 JFrame frame;
4243
4344 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
+ }
4482
4583 cButton GetButton(String name, boolean border)
4684 {
47
- try
48
- {
49
- ImageIcon icon = GetIcon(name);
50
- return new cButton(icon, border);
51
- }
52
- catch (Exception e)
53
- {
54
- return new cButton(name, border);
55
- }
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);
5693 }
5794
5895 cToggleButton GetToggleButton(String name, boolean border)
5996 {
60
- try
61
- {
62
- ImageIcon icon = GetIcon(name);
63
- return new cToggleButton(icon, border);
64
- }
65
- catch (Exception e)
66
- {
67
- return new cToggleButton(name, border);
68
- }
97
+ ImageIcon icon = GetIcon(name);
98
+ return new cToggleButton(icon, border);
6999 }
70100
71101 cCheckBox GetCheckBox(String name, boolean border)
72102 {
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
+
73117 try
74118 {
75
- ImageIcon icon = GetIcon(name);
76
- return new cCheckBox(icon, border);
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;
77138 }
78139 catch (Exception e)
79140 {
80
- return new cCheckBox(name, border);
141
+ //icons.put(name, null);
142
+ return null;
81143 }
82144 }
83
-
84
- private ImageIcon GetIcon(String name) throws IOException
145
+
146
+ BufferedImage GetImage(String name)
85147 {
86
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
-
88
- if (image.getWidth() != 24 && image.getHeight() != 24)
148
+ try
89149 {
90
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
91
- Graphics2D g = resized.createGraphics();
92
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
93
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
94
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
95
- g.dispose();
96
-
97
- image = resized;
150
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
151
+
152
+ return image;
98153 }
99
-
100
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
- return icon;
154
+ catch (Exception e)
155
+ {
156
+ return null;
157
+ }
102158 }
103159
104160 // SCRIPT
....@@ -282,6 +338,14 @@
282338 client = inClient;
283339 copy = client;
284340
341
+// if (copy.versionlist == null)
342
+// {
343
+// copy.versionlist = new Object3D[100];
344
+// copy.versionindex = -1;
345
+//
346
+// callee.Save(true);
347
+// }
348
+
285349 // "this" is not called: SetupUI2(objEditor);
286350 }
287351
....@@ -295,6 +359,14 @@
295359 client = inClient;
296360 copy = client;
297361
362
+ if (copy.versionlist == null)
363
+ {
364
+ copy.versionlist = new Object3D[100];
365
+ copy.versionindex = -1;
366
+
367
+// Save(true);
368
+ }
369
+
298370 SetupUI2(callee.GetEditor());
299371 }
300372
....@@ -309,14 +381,15 @@
309381 //localCopy.parent = null;
310382
311383 frame = new JFrame();
312
- frame.setUndecorated(true);
384
+ frame.setUndecorated(false);
313385 objEditor = this;
314386 this.callee = callee;
315387
316388 //parent = p;
317389
318390 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
319
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
391
+ if (Globals.DEBUG)
392
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
320393 //gd.setFullScreenWindow(this);
321394 //setResizable(false);
322395 //if (!isDisplayable())
....@@ -327,6 +400,14 @@
327400 copy = localCopy;
328401 copy.editWindow = this;
329402
403
+// if (copy.versionlist == null)
404
+// {
405
+// copy.versionlist = new Object3D[100];
406
+// copy.versionindex = -1;
407
+//
408
+// Save(true);
409
+// }
410
+
330411 SetupMenu();
331412
332413 //SetupName(objEditor); // new
....@@ -345,12 +426,15 @@
345426
346427 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347428
429
+ // This is to refresh the UI of the material panel.
430
+ boolean patchMaterial;
431
+
348432 void SetupMenu()
349433 {
350434 frame.setMenuBar(menuBar = new MenuBar());
351435 menuBar.add(fileMenu = new Menu("File"));
352436 fileMenu.add(newItem = new MenuItem("New"));
353
- fileMenu.add(loadItem = new MenuItem("Open..."));
437
+ fileMenu.add(openItem = new MenuItem("Open..."));
354438
355439 //oe.menuBar.add(menu = new Menu("Include"));
356440 Menu menu = new Menu("Import");
....@@ -382,7 +466,7 @@
382466 }
383467
384468 newItem.addActionListener(this);
385
- loadItem.addActionListener(this);
469
+ openItem.addActionListener(this);
386470 saveItem.addActionListener(this);
387471 saveAsItem.addActionListener(this);
388472 exportAsItem.addActionListener(this);
....@@ -394,6 +478,8 @@
394478
395479 ChangeListener changeListener = new ChangeListener()
396480 {
481
+ //String name;
482
+
397483 public void stateChanged(ChangeEvent changeEvent)
398484 {
399485 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -412,18 +498,49 @@
412498 // EditSelection(false);
413499 // }
414500
415
- refreshContents(false); // To refresh Info tab
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();
416532 }
417533 };
418534 objectPanel.addChangeListener(changeListener);
419535
420536 toolbarPanel = new JPanel();
421537 toolbarPanel.setName("Toolbar");
538
+
422539 treePanel = new cGridBag();
423540 treePanel.setName("Tree");
424541
425542 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
543
+ //editPanel.setName("Edit");
427544
428545 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429546
....@@ -431,11 +548,13 @@
431548 editPanel.add(editCommandsPanel);
432549 editPanel.add(ctrlPanel);
433550
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
551
+ toolboxPanel = new cGridBag().setVertical(true);
552
+ //toolboxPanel.setName("Toolbox");
436553
437
- materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
554
+ skyboxPanel = new cGridBag().setVertical(true);
555
+
556
+ materialPanel = new cGridBag().setVertical(false);
557
+ //materialPanel.setName("Material");
439558
440559 /*JTextPane*/
441560 infoarea = createTextPane();
....@@ -443,14 +562,15 @@
443562
444563 infoarea.setEditable(true);
445564 SetText();
565
+
446566 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447567 // infoarea.setOpaque(false);
448568 // //infoarea.setForeground(textcolor);
449569 // TEXTAREA infoarea.setLineWrap(true);
450570 // TEXTAREA infoarea.setWrapStyleWord(true);
451571 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452
- infoPanel.setPreferredSize(new Dimension(50, 200));
453
- infoPanel.setName("Info");
572
+ infoPanel.setPreferredSize(new Dimension(1, 1));
573
+ //infoPanel.setName("Info");
454574 //infoPanel.setLayout(new BorderLayout());
455575 //infoPanel.add(createTextPane());
456576
....@@ -699,8 +819,8 @@
699819 }
700820 }
701821
702
-static GraphicsDevice device = GraphicsEnvironment
703
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
822
+//static GraphicsDevice device = GraphicsEnvironment
823
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
704824
705825 Rectangle keeprect;
706826 cRadio radio;
....@@ -717,14 +837,24 @@
717837 boolean maximized;
718838
719839 cButton fullscreenLayout;
840
+ cButton expandedLayout;
720841
721842 void Minimize()
722843 {
723844 frame.setState(Frame.ICONIFIED);
845
+ frame.validate();
724846 }
725847
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={}
726851 void Maximize()
727852 {
853
+ if (CameraPane.FULLSCREEN)
854
+ {
855
+ ToggleFullScreen();
856
+ }
857
+
728858 if (maximized)
729859 {
730860 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -732,22 +862,38 @@
732862 else
733863 {
734864 keeprect = frame.getBounds();
735
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
736
- Dimension rect2 = frame.getToolkit().getScreenSize();
737
- 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);
738868 // frame.setState(Frame.MAXIMIZED_BOTH);
869
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
739870 }
740871
741872 maximized ^= true;
873
+
874
+ frame.validate();
742875 }
876
+
877
+ cButton minButton;
878
+ cButton maxButton;
879
+ cButton fullButton;
880
+ cButton collapseButton;
881
+ cButton maximize3DButton;
743882
744883 void ToggleFullScreen()
745884 {
885
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
886
+
746887 cameraView.ToggleFullScreen();
747888
748889 if (!CameraPane.FULLSCREEN)
749890 {
750891 device.setFullScreenWindow(null);
892
+ frame.dispose();
893
+ frame.setUndecorated(false);
894
+ frame.validate();
895
+ frame.setVisible(true);
896
+
751897 //frame.setVisible(false);
752898 // frame.removeNotify();
753899 // frame.setUndecorated(false);
....@@ -757,13 +903,13 @@
757903 // X frame.getContentPane().remove(/*"Center",*/bigThree);
758904 // X framePanel.add(bigThree);
759905 // X frame.getContentPane().add(/*"Center",*/framePanel);
760
- framePanel.setDividerLocation(1);
906
+// framePanel.setDividerLocation(46); // icons are 24x24
761907
762908 //frame.setVisible(true);
763
- radio.layout = keepButton;
909
+// radio.layout = keepButton;
764910 //theFrame = null;
765911 keepButton = null;
766
- radio.layout.doClick();
912
+// radio.layout.doClick();
767913
768914 } else
769915 {
....@@ -772,20 +918,65 @@
772918 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
773919 // frame.getToolkit().getScreenSize().height);
774920 //frame.setVisible(false);
921
+
922
+ frame.dispose();
923
+ frame.setUndecorated(true);
775924 device.setFullScreenWindow(frame);
925
+ frame.validate();
926
+ frame.setVisible(true);
776927 // frame.removeNotify();
777928 // frame.setUndecorated(true);
778929 // frame.addNotify();
779930 // X frame.getContentPane().remove(/*"Center",*/framePanel);
780931 // X framePanel.remove(bigThree);
781932 // X frame.getContentPane().add(/*"Center",*/bigThree);
782
- framePanel.setDividerLocation(0);
933
+// framePanel.setDividerLocation(0);
783934
784
- radio.layout = fullscreenLayout;
785
- radio.layout.doClick();
935
+// radio.layout = fullscreenLayout;
936
+// radio.layout.doClick();
786937 //frame.setVisible(true);
787938 }
939
+ frame.validate();
940
+
941
+ cameraView.requestFocusInWindow();
788942 }
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
+ }
789980
790981 private JTextPane createTextPane()
791982 {
....@@ -908,6 +1099,7 @@
9081099 {
9091100 SetupMaterial(materialPanel);
9101101 }
1102
+
9111103 //SetupName();
9121104 //SetupViews();
9131105 }
....@@ -917,7 +1109,7 @@
9171109 // NumberSlider vDivsField;
9181110 // JCheckBox endcaps;
9191111 JCheckBox liveCB;
920
- JCheckBox selectCB;
1112
+ JCheckBox selectableCB;
9211113 JCheckBox hideCB;
9221114 JCheckBox link2masterCB;
9231115 JCheckBox markCB;
....@@ -1116,8 +1308,20 @@
11161308
11171309 namePanel = new cGridBag();
11181310
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
+
11191323 nameField = AddText(namePanel, copy.GetName());
1120
- namePanel.add(nameField);
1324
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11211325 oe.ctrlPanel.add(namePanel);
11221326
11231327 oe.ctrlPanel.Return();
....@@ -1129,26 +1333,30 @@
11291333
11301334 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11311335 liveCB.setToolTipText("Animate object");
1132
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1133
- 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");
11341340 // Return();
1341
+
11351342 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11361343 hideCB.setToolTipText("Hide object");
1137
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1138
- markCB.setToolTipText("As animation target transform");
1344
+
1345
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11391346
11401347 setupPanel2 = new cGridBag().setVertical(false);
11411348
11421349 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11431350 rewindCB.setToolTipText("Rewind animation");
11441351
1145
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1352
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11461353 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11471354
1355
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1356
+ link2masterCB.setToolTipText("Attach to support");
1357
+
11481358 if (Globals.ADVANCED)
11491359 {
1150
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1151
- link2masterCB.setToolTipText("Attach to support");
11521360 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11531361 speedupCB.setToolTipText("Option motion capture");
11541362 }
....@@ -1334,6 +1542,7 @@
13341542
13351543 if (cam == null || !(copy.get(0) instanceof cGroup))
13361544 {
1545
+ if (Globals.DEBUG)
13371546 System.out.println("CREATE CAMERAS");
13381547 cams = new cTemplate();
13391548 cams.name = "Cameras";
....@@ -1422,6 +1631,7 @@
14221631 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14231632 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14241633 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1634
+ //XYZPanel.setName("XYZ");
14251635
14261636 /*
14271637 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1458,15 +1668,34 @@
14581668
14591669 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14601670 //tmp.setName("Edit");
1671
+ objectPanel.add(toolboxPanel);
1672
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1673
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
1674
+
14611675 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
+
14621683 // JPanel north = new JPanel(new BorderLayout());
14631684 // north.setName("Edit");
14641685 // north.add(ctrlPanel, BorderLayout.NORTH);
14651686 // objectPanel.add(north);
14661687 objectPanel.add(editPanel);
1467
- objectPanel.add(infoPanel);
1468
- objectPanel.add(toolboxPanel);
1469
-
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
+
14701699 /*
14711700 aConstraints.gridx = 0;
14721701 aConstraints.gridwidth = 1;
....@@ -1486,7 +1715,7 @@
14861715 scrollpane.addMouseWheelListener(this); // Default not fast enough
14871716
14881717 /*JTabbedPane*/ scenePanel = new cGridBag();
1489
- scenePanel.preferredWidth = 6;
1718
+ scenePanel.preferredWidth = 5;
14901719
14911720 JTabbedPane tabbedPane = new JTabbedPane();
14921721 tabbedPane.add(scrollpane);
....@@ -1503,6 +1732,11 @@
15031732
15041733 scenePanel.add(tabbedPane);
15051734
1735
+ //if (Globals.ADVANCED)
1736
+// tabbedPane.add(infoPanel);
1737
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1738
+// tabbedPane.setToolTipTextAt(3, "Information");
1739
+
15061740 /*
15071741 cTree jTree = new cTree(null);
15081742 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1564,7 +1798,7 @@
15641798 bigThree = new cGridBag();
15651799 bigThree.addComponent(scenePanel);
15661800 bigThree.addComponent(centralPanel);
1567
- bigThree.addComponent(XYZPanel);
1801
+ //bigThree.addComponent(XYZPanel);
15681802
15691803 // // SIDE EFFECT!!!
15701804 // aConstraints.gridx = 0;
....@@ -1573,16 +1807,33 @@
15731807 // aConstraints.gridheight = 1;
15741808
15751809 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1576
- framePanel.setContinuousLayout(true);
1577
- framePanel.setOneTouchExpandable(true);
1578
- 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);
15791830 //framePanel.setDividerSize(15);
15801831 //framePanel.setResizeWeight(0.15);
15811832 framePanel.setName("Frame");
15821833
15831834 frame.getContentPane().setLayout(new BorderLayout());
15841835 /**/
1585
- JTabbedPane worldPane = new JTabbedPane();
1836
+ //JTabbedPane worldPane = new JTabbedPane();
15861837 //worldPane.add(bigPanel);
15871838 //worldPane.add(worldPanel);
15881839 /**/
....@@ -1594,17 +1845,17 @@
15941845
15951846 frame.setSize(1280, 860);
15961847
1597
- frame.validate();
1598
- frame.setVisible(true);
1599
-
16001848 cameraView.requestFocusInWindow();
16011849
16021850 gridPanel.setDividerLocation(1.0);
1851
+
1852
+ frame.validate();
1853
+
1854
+ frame.setVisible(true);
16031855
16041856 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16051857 frame.addWindowListener(new WindowAdapter()
16061858 {
1607
-
16081859 public void windowClosing(WindowEvent e)
16091860 {
16101861 Close();
....@@ -1627,12 +1878,426 @@
16271878 ctrlPanel.removeAll();
16281879 }
16291880
1630
- void SetupMaterial(cGridBag panel)
1881
+ void SetupMaterial(cGridBag materialpanel)
16311882 {
1632
- /*
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
+ /*
16332298 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16342299 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1635
- */
2300
+ */
16362301
16372302 cGridBag editBar = new cGridBag().setVertical(false);
16382303
....@@ -1666,45 +2331,61 @@
16662331 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16672332
16682333 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);
16692358
16702359 cGridBag color = new cGridBag();
1671
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1672
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1673
- 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
+
16742365 //colorField.preferredWidth = 200;
16752366 colorSection.add(color);
16762367
16772368 cGridBag modulation = new cGridBag();
16782369 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16792370 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1680
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2371
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16812372 colorSection.add(modulation);
16822373
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
+
16832382 cGridBag texture = new cGridBag();
16842383 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16852384 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16862385 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16872386 colorSection.add(texture);
16882387
1689
- cGridBag anisoU = new cGridBag();
1690
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1691
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1692
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1693
- colorSection.add(anisoU);
1694
-
1695
- cGridBag anisoV = new cGridBag();
1696
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1697
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1698
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1699
- colorSection.add(anisoV);
1700
-
1701
- cGridBag shadowbias = new cGridBag();
1702
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1703
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1704
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1705
- colorSection.add(shadowbias);
1706
-
1707
- panel.add(new JSeparator());
2388
+ panel.add(GetSeparator());
17082389
17092390 panel.add(colorSection);
17102391
....@@ -1754,7 +2435,13 @@
17542435 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17552436 diffuseSection.add(fakedepth);
17562437
1757
- 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());
17582445
17592446 panel.add(diffuseSection);
17602447
....@@ -1804,42 +2491,48 @@
18042491 // aConstraints.gridy += 1;
18052492 // aConstraints.gridwidth = 1;
18062493
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);
18072499
1808
- 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());
18092508
18102509 panel.add(specularSection);
18112510
18122511 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18132512
1814
- cGridBag globalSection = new cGridBag().setVertical(true);
2513
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18152514
18162515 cGridBag camera = new cGridBag();
18172516 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18182517 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18192518 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1820
- globalSection.add(camera);
2519
+ colorSection.add(camera);
18212520
18222521 cGridBag ambient = new cGridBag();
18232522 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18242523 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18252524 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1826
- globalSection.add(ambient);
2525
+ colorSection.add(ambient);
18272526
18282527 cGridBag backlit = new cGridBag();
18292528 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18302529 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18312530 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1832
- globalSection.add(backlit);
2531
+ colorSection.add(backlit);
18332532
1834
- cGridBag opacity = new cGridBag();
1835
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1836
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1837
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
- globalSection.add(opacity);
1839
-
1840
- panel.add(new JSeparator());
2533
+ //panel.add(new JSeparator());
18412534
1842
- panel.add(globalSection);
2535
+ //panel.add(globalSection);
18432536
18442537 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18452538
....@@ -1881,7 +2574,7 @@
18812574 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18822575 textureSection.add(opacityPower);
18832576
1884
- panel.add(new JSeparator());
2577
+ panel.add(GetSeparator());
18852578
18862579 panel.add(textureSection);
18872580
....@@ -1946,8 +2639,9 @@
19462639 // 3D models
19472640 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19482641 {
1949
- lastConverter = new com.jmex.model.converters.MaxToJme();
1950
- LoadFile(filename, lastConverter);
2642
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2643
+ //LoadFile(filename, lastConverter);
2644
+ LoadObjFile(filename); // New 3ds loader
19512645 continue;
19522646 }
19532647 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2673,6 +3367,7 @@
26733367 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26743368 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26753369 }
3370
+
26763371 //cJME.count++;
26773372 //cJME.count %= 12;
26783373 if (gc)
....@@ -2856,6 +3551,7 @@
28563551 }
28573552 }
28583553 }
3554
+
28593555 cFileSystemPane FSPane;
28603556
28613557 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2865,7 +3561,7 @@
28653561
28663562 freezematerial = true;
28673563 colorField.setFloat(mat.color);
2868
- modulationField.setFloat(mat.modulation);
3564
+ saturationField.setFloat(mat.modulation);
28693565 metalnessField.setFloat(mat.metalness);
28703566 diffuseField.setFloat(mat.diffuse);
28713567 specularField.setFloat(mat.specular);
....@@ -2909,6 +3605,7 @@
29093605 }
29103606 }
29113607 }
3608
+
29123609 freezematerial = false;
29133610 }
29143611
....@@ -2926,32 +3623,8 @@
29263623
29273624 if (multiplyToggle != null)
29283625 multiplyToggle.setSelected(mat.multiply);
2929
-
2930
- assert (object.projectedVertices != null);
2931
-
2932
- if (object.projectedVertices.length <= 2)
2933
- {
2934
- // Side effect...
2935
- Object3D.cVector2[] keep = object.projectedVertices;
2936
- object.projectedVertices = new Object3D.cVector2[3];
2937
- for (int i = 0; i < 3; i++)
2938
- {
2939
- if (i < keep.length)
2940
- {
2941
- object.projectedVertices[i] = keep[i];
2942
- } else
2943
- {
2944
- object.projectedVertices[i] = new Object3D.cVector2();
2945
- }
2946
- /*
2947
- if(keep.length == 0)
2948
- object.projectedVertices[0] = new Object3D.cVector2();
2949
- else
2950
- object.projectedVertices[0] = keep[0];
2951
- object.projectedVertices[1] = new Object3D.cVector2();
2952
- */
2953
- }
2954
- }
3626
+
3627
+ AllocProjectedVertices(object);
29553628
29563629 SetMaterial(mat, object.projectedVertices);
29573630 }
....@@ -3071,6 +3744,17 @@
30713744 public void itemStateChanged(ItemEvent event)
30723745 {
30733746 // 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
30743758 if (event.getSource() == propagateToggle)
30753759 {
30763760 propagate ^= true;
....@@ -3175,8 +3859,9 @@
31753859 } else if (event.getSource() == liveCB)
31763860 {
31773861 copy.live ^= true;
3862
+ objEditor.refreshContents(true); // To show item colors
31783863 return;
3179
- } else if (event.getSource() == selectCB)
3864
+ } else if (event.getSource() == selectableCB)
31803865 {
31813866 copy.dontselect ^= true;
31823867 return;
....@@ -3184,7 +3869,7 @@
31843869 {
31853870 copy.hide ^= true;
31863871 copy.Touch(); // display list issue
3187
- objEditor.refreshContents();
3872
+ objEditor.refreshContents(true); // To show item colors
31883873 return;
31893874 } else if (event.getSource() == link2masterCB)
31903875 {
....@@ -3249,7 +3934,7 @@
32493934 //System.out.println("ObjEditor " + event);
32503935 applySelf0(true);
32513936 //parent.applySelf();
3252
- objEditor.refreshContents();
3937
+ // conflicts with requestFocus objEditor.refreshContents();
32533938 } else if (source == resetButton)
32543939 {
32553940 CameraPane.fullreset = true;
....@@ -3361,9 +4046,9 @@
33614046 {
33624047 Close();
33634048 //return true;
3364
- } else if (source == loadItem)
4049
+ } else if (source == openItem)
33654050 {
3366
- load();
4051
+ Open();
33674052 //return true;
33684053 } else if (source == newItem)
33694054 {
....@@ -3388,6 +4073,10 @@
33884073 {
33894074 generatePOV();
33904075 //return true;
4076
+ } else if (event.getSource() == archiveItem)
4077
+ {
4078
+ cTools.Archive(frame);
4079
+ return;
33914080 } else if (source == zBufferItem)
33924081 {
33934082 try
....@@ -3436,11 +4125,12 @@
34364125
34374126 static public byte[] Compress(Object3D o)
34384127 {
4128
+ // Slower to actually compress.
34394129 try
34404130 {
34414131 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3442
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3443
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4132
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4133
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34444134
34454135 Object3D parent = o.parent;
34464136 o.parent = null;
....@@ -3451,10 +4141,14 @@
34514141
34524142 out.flush();
34534143
3454
- zstream.close();
4144
+ baos //zstream
4145
+ .close();
34554146 out.close();
34564147
3457
- return baos.toByteArray();
4148
+ byte[] bytes = baos.toByteArray();
4149
+
4150
+ System.out.println("save #bytes = " + bytes.length);
4151
+ return bytes;
34584152 } catch (Exception e)
34594153 {
34604154 System.err.println(e);
....@@ -3464,13 +4158,16 @@
34644158
34654159 static public Object Uncompress(byte[] bytes)
34664160 {
3467
- System.out.println("#bytes = " + bytes.length);
4161
+ System.out.println("restore #bytes = " + bytes.length);
34684162 try
34694163 {
34704164 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3471
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3472
- ObjectInputStream in = new ObjectInputStream(istream);
4165
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4166
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34734167 Object obj = in.readObject();
4168
+
4169
+ bais //istream
4170
+ .close();
34744171 in.close();
34754172
34764173 return obj;
....@@ -3525,41 +4222,97 @@
35254222 return null;
35264223 }
35274224
3528
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35294225
35304226 public void Save()
35314227 {
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
+ }
4239
+
4240
+ for (int i=compress.length; --i>=0;)
4241
+ {
4242
+ if (compress[i] != name[i])
4243
+ return false;
4244
+ }
4245
+
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
+ {
35324267 System.err.println("Save");
4268
+ Replace();
35334269
3534
- cRadio tab = GetCurrentTab();
4270
+ //cRadio tab = GetCurrentTab();
35354271
3536
- boolean temp = CameraPane.SWITCH;
3537
- CameraPane.SWITCH = false;
4272
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
35384273
3539
- copy.ExtractBigData(hashtable);
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
+// }
35404280
35414281 //EditorFrame.m_MainFrame.requestFocusInWindow();
3542
- tab.graphs[tab.undoindex++] = Compress(copy);
3543
-
3544
- copy.RestoreBigData(hashtable);
3545
-
3546
- CameraPane.SWITCH = temp;
3547
-
3548
- //assert(hashtable.isEmpty());
3549
-
3550
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
4282
+ if (!thesame)
35514283 {
3552
- 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++;
35534296 }
35544297
3555
- SetUndoStates();
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();
35564309
35574310 // test save
35584311 if (false)
35594312 {
35604313 try
35614314 {
3562
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4315
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35634316 ObjectOutputStream p = new ObjectOutputStream(ostream);
35644317
35654318 p.writeObject(copy);
....@@ -3572,28 +4325,68 @@
35724325 e.printStackTrace();
35734326 }
35744327 }
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);
35754362 }
35764363
3577
- void CopyChanged(Object3D obj)
4364
+ void CopyChanged()
35784365 {
3579
- SetUndoStates();
4366
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4367
+
4368
+ SetVersionStates();
35804369
35814370 boolean temp = CameraPane.SWITCH;
35824371 CameraPane.SWITCH = false;
35834372
3584
- copy.ExtractBigData(hashtable);
4373
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
35854374
35864375 copy.clear();
35874376
4377
+ copy.skyboxname = obj.skyboxname;
4378
+ copy.skyboxext = obj.skyboxext;
4379
+
35884380 for (int i=0; i<obj.Size(); i++)
35894381 {
35904382 copy.add(obj.get(i));
35914383 }
35924384
3593
- copy.RestoreBigData(hashtable);
4385
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
35944386
35954387 CameraPane.SWITCH = temp;
35964388
4389
+ RefreshSelection();
35974390 //assert(hashtable.isEmpty());
35984391
35994392 copy.Touch();
....@@ -3614,56 +4407,144 @@
36144407 }
36154408 }
36164409
3617
- refreshContents();
4410
+ refreshContents(true);
36184411 }
36194412
3620
- cButton undoButton;
3621
- cButton redoButton;
4413
+ cButton previousVersionButton;
4414
+ cButton restoreButton;
4415
+ cButton replaceButton;
4416
+ cButton nextVersionButton;
4417
+ cButton saveVersionButton;
4418
+ cButton deleteVersionButton;
36224419
3623
- void SetUndoStates()
4420
+ boolean muteSlider;
4421
+
4422
+ int VersionCount()
36244423 {
3625
- cRadio tab = GetCurrentTab();
4424
+ int count = 0;
36264425
3627
- undoButton.setEnabled(tab.undoindex > 0);
3628
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
4426
+ for (int i = copy.versionlist.length; --i >= 0;)
4427
+ {
4428
+ if (copy.versionlist[i] != null)
4429
+ count++;
4430
+ }
4431
+
4432
+ return count;
36294433 }
36304434
3631
- public void Undo()
4435
+ void SetVersionStates()
36324436 {
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
+
36334464 System.err.println("Undo");
36344465
3635
- cRadio tab = GetCurrentTab();
4466
+ //cRadio tab = GetCurrentTab();
36364467
3637
- if (tab.undoindex == 0)
4468
+ if (copy.versionindex == 0)
36384469 {
36394470 java.awt.Toolkit.getDefaultToolkit().beep();
3640
- return;
4471
+ return false;
36414472 }
36424473
3643
- if (tab.graphs[tab.undoindex] == null)
3644
- {
3645
- Save();
3646
- tab.undoindex -= 1;
3647
- }
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
+// }
36484486
3649
- tab.undoindex -= 1;
4487
+ copy.versionindex -= 1;
36504488
3651
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4489
+ CopyChanged();
4490
+
4491
+ return true;
36524492 }
36534493
3654
- public void Redo()
4494
+ public boolean Restore()
36554495 {
3656
- cRadio tab = GetCurrentTab();
4496
+ System.err.println("Restore");
36574497
3658
- 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)
36594537 {
36604538 java.awt.Toolkit.getDefaultToolkit().beep();
36614539 return;
36624540 }
36634541
3664
- tab.undoindex += 1;
4542
+ copy.versionindex += 1;
36654543
3666
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4544
+ CopyChanged();
4545
+
4546
+ //if (!tab.user[tab.versionindex])
4547
+ // tab.graphs[tab.versionindex] = null;
36674548 }
36684549
36694550 void ImportGFD()
....@@ -3874,7 +4755,7 @@
38744755 //copy.material = new cMaterial(copy.GetMaterial());
38754756
38764757 current.color = (float) colorField.getFloat();
3877
- current.modulation = (float) modulationField.getFloat();
4758
+ current.modulation = (float) saturationField.getFloat();
38784759 current.metalness = (float) metalnessField.getFloat();
38794760 current.diffuse = (float) diffuseField.getFloat();
38804761 current.specular = (float) specularField.getFloat();
....@@ -3907,7 +4788,7 @@
39074788 cMaterial mat = copy.material;
39084789
39094790 colorField.SetToolTipValue((mat.color));
3910
- modulationField.SetToolTipValue((mat.modulation));
4791
+ saturationField.SetToolTipValue((mat.modulation));
39114792 metalnessField.SetToolTipValue((mat.metalness));
39124793 diffuseField.SetToolTipValue((mat.diffuse));
39134794 specularField.SetToolTipValue((mat.specular));
....@@ -3959,9 +4840,28 @@
39594840 //copy.Touch();
39604841 }
39614842
4843
+ cNumberSlider versionSlider;
4844
+
39624845 public void stateChanged(ChangeEvent e)
39634846 {
39644847 // 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
+ }
39654865
39664866 if (freezematerial)
39674867 {
....@@ -3997,6 +4897,12 @@
39974897 {
39984898 //System.out.println("stateChanged = " + this);
39994899 materialtouched = true;
4900
+
4901
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4902
+ {
4903
+ saturationField.setFloat(1);
4904
+ }
4905
+
40004906 applySelf();
40014907 //System.out.println("this = " + this);
40024908 //System.out.println("PARENT = " + parent);
....@@ -4296,6 +5202,7 @@
42965202 {
42975203 if (GetTree() != null)
42985204 {
5205
+ GetTree().revalidate();
42995206 GetTree().repaint();
43005207 }
43015208
....@@ -4304,13 +5211,18 @@
43045211 ctrlPanel.validate(); // ? new
43055212 ctrlPanel.repaint();
43065213 }
5214
+
5215
+ if (previousVersionButton != null && copy.versionlist != null)
5216
+ SetVersionStates();
5217
+
5218
+ cameraView.requestFocusInWindow();
43075219 }
43085220
43095221 static TweenManager tweenManager = new TweenManager();
43105222
43115223 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43125224 {
4313
- if (Globals.SAVEONMAKE) // && resetmodel)
5225
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43145226 Save();
43155227 //Tween.set(thing, 0).target(1).start(tweenManager);
43165228 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4335,7 +5247,7 @@
43355247 // group = (Composite) group.get(0);
43365248 // }
43375249
4338
- System.out.println("makeSomething of " + thing);
5250
+ //System.out.println("makeSomething of " + thing);
43395251
43405252 /*
43415253 if (deselect && jList != null)
....@@ -4552,7 +5464,9 @@
45525464 readobj.ResetDisplayList();
45535465 } catch (Exception e)
45545466 {
4555
- //e.printStackTrace();
5467
+ if (!e.toString().contains("GZIP"))
5468
+ e.printStackTrace();
5469
+
45565470 try
45575471 {
45585472 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4626,12 +5540,14 @@
46265540
46275541 if (readobj != null)
46285542 {
4629
- if (Globals.SAVEONMAKE)
4630
- Save();
5543
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5544
+ // Save();
46315545 try
46325546 {
46335547 //readobj.deepCopySelf(copy);
46345548 copy.clear(); // june 2014
5549
+ copy.skyboxname = readobj.skyboxname;
5550
+ copy.skyboxext = readobj.skyboxext;
46355551 for (int i = 0; i < readobj.size(); i++)
46365552 {
46375553 Object3D child = readobj.get(i); // reserve(i);
....@@ -4672,6 +5588,7 @@
46725588 }
46735589 } catch (ClassCastException e)
46745590 {
5591
+ e.printStackTrace();
46755592 assert (false);
46765593 Composite c = (Composite) copy;
46775594 c.children.clear();
....@@ -4682,17 +5599,32 @@
46825599 c.addChild(csg);
46835600 }
46845601
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
+
46855617 ResetModel();
46865618 copy.HardTouch(); // recompile?
46875619 refreshContents();
46885620 }
46895621 }
46905622
4691
- void load() // throws ClassNotFoundException
5623
+ void Open() // throws ClassNotFoundException
46925624 {
46935625 if (Grafreed.standAlone)
46945626 {
4695
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5627
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
46965628 browser.show();
46975629 String filename = browser.getFile();
46985630 if (filename != null && filename.length() > 0)
....@@ -4769,6 +5701,8 @@
47695701
47705702 void save()
47715703 {
5704
+ Replace();
5705
+
47725706 if (lastname == null)
47735707 {
47745708 return;
....@@ -4791,6 +5725,7 @@
47915725 //ps.print(buffer.toString());
47925726 } catch (IOException e)
47935727 {
5728
+ e.printStackTrace();
47945729 }
47955730 }
47965731
....@@ -4973,7 +5908,7 @@
49735908 MenuBar menuBar;
49745909 Menu fileMenu;
49755910 MenuItem newItem;
4976
- MenuItem loadItem;
5911
+ MenuItem openItem;
49775912 MenuItem saveItem;
49785913 MenuItem saveAsItem;
49795914 MenuItem exportAsItem;
....@@ -4996,6 +5931,7 @@
49965931 CheckboxMenuItem toggleSwitchItem;
49975932 CheckboxMenuItem toggleRootItem;
49985933 CheckboxMenuItem animationItem;
5934
+ MenuItem archiveItem;
49995935 CheckboxMenuItem toggleHandleItem;
50005936 CheckboxMenuItem togglePaintItem;
50015937 JSplitPane mainPanel;
....@@ -5009,6 +5945,7 @@
50095945 ButtonGroup buttonGroup;
50105946
50115947 cGridBag toolboxPanel;
5948
+ cGridBag skyboxPanel;
50125949 cGridBag materialPanel;
50135950 cGridBag ctrlPanel;
50145951
....@@ -5082,7 +6019,7 @@
50826019 JLabel colorLabel;
50836020 cNumberSlider colorField;
50846021 JLabel modulationLabel;
5085
- cNumberSlider modulationField;
6022
+ cNumberSlider saturationField;
50866023 JLabel metalnessLabel;
50876024 cNumberSlider metalnessField;
50886025 JLabel diffuseLabel;
....@@ -5113,6 +6050,7 @@
51136050 cNumberSlider anisoField;
51146051 JLabel anisoVLabel;
51156052 cNumberSlider anisoVField;
6053
+
51166054 JLabel cameraLabel;
51176055 cNumberSlider cameraField;
51186056 JLabel selfshadowLabel;
....@@ -5127,6 +6065,7 @@
51276065 cNumberSlider fakedepthField;
51286066 JLabel shadowbiasLabel;
51296067 cNumberSlider shadowbiasField;
6068
+
51306069 JLabel bumpLabel;
51316070 cNumberSlider bumpField;
51326071 JLabel noiseLabel;