Normand Briere
2019-08-15 24a2a946b35279605e645349bd6b82e9e60aac88
ObjEditor.java
....@@ -15,6 +15,9 @@
1515 //import javax.swing.plaf.ColorUIResource;
1616 //import javax.swing.plaf.metal.DefaultMetalTheme;
1717
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1821 //import javax.media.opengl.GLCanvas;
1922
2023 import //weka.core.
....@@ -31,6 +34,7 @@
3134 iSendInfo
3235 //KeyListener
3336 {
37
+ public cToggleButton pinButton;
3438 boolean timeline;
3539 boolean wasFullScreen;
3640
....@@ -38,64 +42,90 @@
3842 JFrame frame;
3943
4044 static ObjEditor theFrame;
45
+
46
+ public cGridBag GetSeparator()
47
+ {
48
+ cGridBag separator = new cGridBag();
49
+ separator.add(new JSeparator());
50
+ separator.preferredHeight = 5;
51
+ return separator;
52
+ }
4153
4254 cButton GetButton(String name, boolean border)
4355 {
44
- try
45
- {
46
- ImageIcon icon = GetIcon(name);
47
- return new cButton(icon, border);
48
- }
49
- catch (Exception e)
50
- {
51
- return new cButton(name, border);
52
- }
56
+ ImageIcon icon = GetIcon(name);
57
+ return new cButton(icon, border);
58
+ }
59
+
60
+ cLabel GetLabel(String name, boolean border)
61
+ {
62
+ //ImageIcon icon = GetIcon(name);
63
+ return new cLabel(GetImage(name), border);
5364 }
5465
5566 cToggleButton GetToggleButton(String name, boolean border)
5667 {
57
- try
58
- {
59
- ImageIcon icon = GetIcon(name);
60
- return new cToggleButton(icon, border);
61
- }
62
- catch (Exception e)
63
- {
64
- return new cToggleButton(name, border);
65
- }
68
+ ImageIcon icon = GetIcon(name);
69
+ return new cToggleButton(icon, border);
6670 }
6771
6872 cCheckBox GetCheckBox(String name, boolean border)
6973 {
74
+ ImageIcon icon = GetIcon(name);
75
+ return new cCheckBox(icon, border);
76
+ }
77
+
78
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
79
+
80
+ ImageIcon GetIcon(String name)
81
+ {
82
+ javax.swing.ImageIcon iconCache = icons.get(name);
83
+ if (iconCache != null)
84
+ {
85
+ return iconCache;
86
+ }
87
+
7088 try
7189 {
72
- ImageIcon icon = GetIcon(name);
73
- return new cCheckBox(icon, border);
90
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
91
+
92
+// if (image.getWidth() > 48 && image.getHeight() > 48)
93
+// {
94
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
95
+// Graphics2D g = resized.createGraphics();
96
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
97
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
98
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
99
+// g.dispose();
100
+//
101
+// image = resized;
102
+// }
103
+
104
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
105
+
106
+ icons.put(name, icon);
107
+
108
+ return icon;
74109 }
75110 catch (Exception e)
76111 {
77
- return new cCheckBox(name, border);
112
+ //icons.put(name, null);
113
+ return null;
78114 }
79115 }
80
-
81
- private ImageIcon GetIcon(String name) throws IOException
116
+
117
+ BufferedImage GetImage(String name)
82118 {
83
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
-
85
- if (image.getWidth() != 24 && image.getHeight() != 24)
119
+ try
86120 {
87
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
88
- Graphics2D g = resized.createGraphics();
89
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
90
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
92
- g.dispose();
93
-
94
- image = resized;
121
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
122
+
123
+ return image;
95124 }
96
-
97
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
- return icon;
125
+ catch (Exception e)
126
+ {
127
+ return null;
128
+ }
99129 }
100130
101131 // SCRIPT
....@@ -207,7 +237,7 @@
207237
208238 objEditor.ctrlPanel.remove(namePanel);
209239
210
- if (!GroupEditor.allparams)
240
+ if (!allparams)
211241 return;
212242
213243 // objEditor.ctrlPanel.remove(liveCB);
....@@ -279,6 +309,14 @@
279309 client = inClient;
280310 copy = client;
281311
312
+// if (copy.versionlist == null)
313
+// {
314
+// copy.versionlist = new Object3D[100];
315
+// copy.versionindex = -1;
316
+//
317
+// callee.Save(true);
318
+// }
319
+
282320 // "this" is not called: SetupUI2(objEditor);
283321 }
284322
....@@ -292,6 +330,14 @@
292330 client = inClient;
293331 copy = client;
294332
333
+ if (copy.versionlist == null)
334
+ {
335
+ copy.versionlist = new Object3D[100];
336
+ copy.versionindex = -1;
337
+
338
+// Save(true);
339
+ }
340
+
295341 SetupUI2(callee.GetEditor());
296342 }
297343
....@@ -306,7 +352,7 @@
306352 //localCopy.parent = null;
307353
308354 frame = new JFrame();
309
- frame.setUndecorated(true);
355
+ frame.setUndecorated(false);
310356 objEditor = this;
311357 this.callee = callee;
312358
....@@ -324,6 +370,14 @@
324370 copy = localCopy;
325371 copy.editWindow = this;
326372
373
+// if (copy.versionlist == null)
374
+// {
375
+// copy.versionlist = new Object3D[100];
376
+// copy.versionindex = -1;
377
+//
378
+// Save(true);
379
+// }
380
+
327381 SetupMenu();
328382
329383 //SetupName(objEditor); // new
....@@ -337,12 +391,17 @@
337391 return frame.action(event, obj);
338392 }
339393
394
+ // Cannot work without static
395
+ static boolean allparams = true;
396
+
397
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
398
+
340399 void SetupMenu()
341400 {
342401 frame.setMenuBar(menuBar = new MenuBar());
343402 menuBar.add(fileMenu = new Menu("File"));
344403 fileMenu.add(newItem = new MenuItem("New"));
345
- fileMenu.add(loadItem = new MenuItem("Open..."));
404
+ fileMenu.add(openItem = new MenuItem("Open..."));
346405
347406 //oe.menuBar.add(menu = new Menu("Include"));
348407 Menu menu = new Menu("Import");
....@@ -374,7 +433,7 @@
374433 }
375434
376435 newItem.addActionListener(this);
377
- loadItem.addActionListener(this);
436
+ openItem.addActionListener(this);
378437 saveItem.addActionListener(this);
379438 saveAsItem.addActionListener(this);
380439 exportAsItem.addActionListener(this);
....@@ -383,13 +442,72 @@
383442 closeItem.addActionListener(this);
384443
385444 objectPanel = new JTabbedPane();
445
+
446
+ ChangeListener changeListener = new ChangeListener()
447
+ {
448
+ //String name;
449
+
450
+ public void stateChanged(ChangeEvent changeEvent)
451
+ {
452
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
453
+// {
454
+// if (latestObject != null)
455
+// {
456
+// refreshContents(true);
457
+// SetMaterial(latestObject);
458
+// }
459
+//
460
+// materialFlushed = true;
461
+// }
462
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
463
+// {
464
+// if (listUI.size() == 0)
465
+// EditSelection(false);
466
+// }
467
+
468
+// if (objectPanel.getSelectedIndex() == 4)
469
+// {
470
+// name = copy.skyboxname;
471
+//
472
+// if (name == null)
473
+// {
474
+// name = "";
475
+// }
476
+//
477
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
478
+// copy.skyboxext = "jpg";
479
+// }
480
+// else
481
+// {
482
+// if (name != null)
483
+// {
484
+// if (name.equals(""))
485
+// {
486
+// copy.skyboxname = null;
487
+// copy.skyboxext = null;
488
+// }
489
+// else
490
+// {
491
+// copy.skyboxname = name;
492
+// }
493
+// }
494
+// }
495
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
496
+
497
+// refreshContents(false); // To refresh Info tab
498
+ cameraView.repaint();
499
+ }
500
+ };
501
+ objectPanel.addChangeListener(changeListener);
502
+
386503 toolbarPanel = new JPanel();
387504 toolbarPanel.setName("Toolbar");
505
+
388506 treePanel = new cGridBag();
389507 treePanel.setName("Tree");
390508
391509 editPanel = new cGridBag().setVertical(true);
392
- editPanel.setName("Edit");
510
+ //editPanel.setName("Edit");
393511
394512 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
395513
....@@ -397,11 +515,13 @@
397515 editPanel.add(editCommandsPanel);
398516 editPanel.add(ctrlPanel);
399517
400
- toolboxPanel = new cGridBag().setVertical(false);
401
- toolboxPanel.setName("Toolbox");
518
+ toolboxPanel = new cGridBag().setVertical(true);
519
+ //toolboxPanel.setName("Toolbox");
402520
403
- materialPanel = new cGridBag().setVertical(true);
404
- materialPanel.setName("Material");
521
+ skyboxPanel = new cGridBag().setVertical(true);
522
+
523
+ materialPanel = new cGridBag().setVertical(false);
524
+ //materialPanel.setName("Material");
405525
406526 /*JTextPane*/
407527 infoarea = createTextPane();
....@@ -409,14 +529,15 @@
409529
410530 infoarea.setEditable(true);
411531 SetText();
532
+
412533 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
413534 // infoarea.setOpaque(false);
414535 // //infoarea.setForeground(textcolor);
415536 // TEXTAREA infoarea.setLineWrap(true);
416537 // TEXTAREA infoarea.setWrapStyleWord(true);
417538 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
418
- infoPanel.setPreferredSize(new Dimension(50, 200));
419
- infoPanel.setName("Info");
539
+ infoPanel.setPreferredSize(new Dimension(1, 1));
540
+ //infoPanel.setName("Info");
420541 //infoPanel.setLayout(new BorderLayout());
421542 //infoPanel.add(createTextPane());
422543
....@@ -427,7 +548,14 @@
427548 mainPanel.setDividerSize(9);
428549 mainPanel.setDividerLocation(0.5); //1.0);
429550 mainPanel.setResizeWeight(0.5);
430
-
551
+
552
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
553
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
554
+ divider.setDividerSize(15);
555
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
556
+
557
+ mainPanel.setUI(new BasicSplitPaneUI());
558
+
431559 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
432560 //mainPanel.setLayout(new GridBagLayout());
433561 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -658,8 +786,8 @@
658786 }
659787 }
660788
661
-static GraphicsDevice device = GraphicsEnvironment
662
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
789
+//static GraphicsDevice device = GraphicsEnvironment
790
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
663791
664792 Rectangle keeprect;
665793 cRadio radio;
....@@ -676,14 +804,24 @@
676804 boolean maximized;
677805
678806 cButton fullscreenLayout;
807
+ cButton expandedLayout;
679808
680809 void Minimize()
681810 {
682811 frame.setState(Frame.ICONIFIED);
812
+ frame.validate();
683813 }
684814
815
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
816
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
817
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
685818 void Maximize()
686819 {
820
+ if (CameraPane.FULLSCREEN)
821
+ {
822
+ ToggleFullScreen();
823
+ }
824
+
687825 if (maximized)
688826 {
689827 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -691,20 +829,38 @@
691829 else
692830 {
693831 keeprect = frame.getBounds();
694
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
695
- Dimension rect2 = frame.getToolkit().getScreenSize();
696
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
832
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
833
+// Dimension rect2 = frame.getToolkit().getScreenSize();
834
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
697835 // frame.setState(Frame.MAXIMIZED_BOTH);
836
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
698837 }
699838
700839 maximized ^= true;
840
+
841
+ frame.validate();
701842 }
843
+
844
+ cButton minButton;
845
+ cButton maxButton;
846
+ cButton fullButton;
847
+ cButton collapseButton;
848
+ cButton maximize3DButton;
702849
703850 void ToggleFullScreen()
704851 {
705
- if (CameraPane.FULLSCREEN)
852
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
853
+
854
+ cameraView.ToggleFullScreen();
855
+
856
+ if (!CameraPane.FULLSCREEN)
706857 {
707858 device.setFullScreenWindow(null);
859
+ frame.dispose();
860
+ frame.setUndecorated(false);
861
+ frame.validate();
862
+ frame.setVisible(true);
863
+
708864 //frame.setVisible(false);
709865 // frame.removeNotify();
710866 // frame.setUndecorated(false);
....@@ -714,13 +870,13 @@
714870 // X frame.getContentPane().remove(/*"Center",*/bigThree);
715871 // X framePanel.add(bigThree);
716872 // X frame.getContentPane().add(/*"Center",*/framePanel);
717
- framePanel.setDividerLocation(1);
873
+// framePanel.setDividerLocation(46); // icons are 24x24
718874
719875 //frame.setVisible(true);
720
- radio.layout = keepButton;
876
+// radio.layout = keepButton;
721877 //theFrame = null;
722878 keepButton = null;
723
- radio.layout.doClick();
879
+// radio.layout.doClick();
724880
725881 } else
726882 {
....@@ -729,22 +885,59 @@
729885 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
730886 // frame.getToolkit().getScreenSize().height);
731887 //frame.setVisible(false);
888
+
889
+ frame.dispose();
890
+ frame.setUndecorated(true);
732891 device.setFullScreenWindow(frame);
892
+ frame.validate();
893
+ frame.setVisible(true);
733894 // frame.removeNotify();
734895 // frame.setUndecorated(true);
735896 // frame.addNotify();
736897 // X frame.getContentPane().remove(/*"Center",*/framePanel);
737898 // X framePanel.remove(bigThree);
738899 // X frame.getContentPane().add(/*"Center",*/bigThree);
739
- framePanel.setDividerLocation(0);
900
+// framePanel.setDividerLocation(0);
740901
741
- radio.layout = fullscreenLayout;
742
- radio.layout.doClick();
902
+// radio.layout = fullscreenLayout;
903
+// radio.layout.doClick();
743904 //frame.setVisible(true);
744905 }
745
-
746
- cameraView.ToggleFullScreen();
906
+ frame.validate();
907
+
908
+ cameraView.requestFocusInWindow();
747909 }
910
+
911
+ void CollapseToolbar()
912
+ {
913
+ framePanel.setDividerLocation(0);
914
+ //frame.validate();
915
+
916
+ cameraView.requestFocusInWindow();
917
+ }
918
+
919
+ private Object3D Duplicate(Object3D object)
920
+ {
921
+ boolean temp = CameraPane.SWITCH;
922
+ CameraPane.SWITCH = false;
923
+
924
+ object.ExtractBigData(versiontable);
925
+ // if (copy == client)
926
+
927
+ Object3D versions[] = object.versionlist;
928
+ object.versionlist = null;
929
+
930
+ //byte[] compress = Compress(copy);
931
+ Object3D compress = (Object3D)Grafreed.clone(object);
932
+
933
+ object.versionlist = versions;
934
+
935
+ object.RestoreBigData(versiontable);
936
+
937
+ CameraPane.SWITCH = temp;
938
+
939
+ return compress;
940
+ }
748941
749942 private JTextPane createTextPane()
750943 {
....@@ -867,6 +1060,7 @@
8671060 {
8681061 SetupMaterial(materialPanel);
8691062 }
1063
+
8701064 //SetupName();
8711065 //SetupViews();
8721066 }
....@@ -876,7 +1070,7 @@
8761070 // NumberSlider vDivsField;
8771071 // JCheckBox endcaps;
8781072 JCheckBox liveCB;
879
- JCheckBox selectCB;
1073
+ JCheckBox selectableCB;
8801074 JCheckBox hideCB;
8811075 JCheckBox link2masterCB;
8821076 JCheckBox markCB;
....@@ -884,7 +1078,12 @@
8841078 JCheckBox speedupCB;
8851079 JCheckBox rewindCB;
8861080 JCheckBox flipVCB;
1081
+
1082
+ cCheckBox toggleTextureCB;
1083
+ cCheckBox toggleSwitchCB;
1084
+
8871085 JComboBox texresMenu;
1086
+
8881087 JButton resetButton;
8891088 JButton stepButton;
8901089 JButton stepAllButton;
....@@ -1070,39 +1269,55 @@
10701269
10711270 namePanel = new cGridBag();
10721271
1272
+ //if (copy.pinned)
1273
+ {
1274
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1275
+ pinButton.setSelected(copy.pinned);
1276
+ cGridBag t = new cGridBag();
1277
+ t.preferredWidth = 2;
1278
+ t.add(pinButton);
1279
+ namePanel.add(t);
1280
+
1281
+ pinButton.addItemListener(this);
1282
+ }
1283
+
10731284 nameField = AddText(namePanel, copy.GetName());
1074
- namePanel.add(nameField);
1285
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10751286 oe.ctrlPanel.add(namePanel);
10761287
10771288 oe.ctrlPanel.Return();
10781289
1079
- if (!GroupEditor.allparams)
1290
+ if (!allparams)
10801291 return;
10811292
10821293 setupPanel = new cGridBag().setVertical(false);
10831294
10841295 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
10851296 liveCB.setToolTipText("Animate object");
1086
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1087
- selectCB.setToolTipText("Make object selectable");
1297
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1298
+ selectableCB.setToolTipText("Make object selectable");
10881299 // Return();
1300
+
10891301 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10901302 hideCB.setToolTipText("Hide object");
10911303 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1092
- markCB.setToolTipText("Set the animation target transform");
1304
+ markCB.setToolTipText("As animation target transform");
1305
+
1306
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
10931307
10941308 setupPanel2 = new cGridBag().setVertical(false);
10951309
10961310 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10971311 rewindCB.setToolTipText("Rewind animation");
10981312
1099
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1100
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1313
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1314
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11011315
1316
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1317
+ link2masterCB.setToolTipText("Attach to support");
1318
+
11021319 if (Globals.ADVANCED)
11031320 {
1104
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1105
- link2masterCB.setToolTipText("Attach to support");
11061321 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11071322 speedupCB.setToolTipText("Option motion capture");
11081323 }
....@@ -1376,6 +1591,7 @@
13761591 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
13771592 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
13781593 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1594
+ //XYZPanel.setName("XYZ");
13791595
13801596 /*
13811597 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1412,15 +1628,30 @@
14121628
14131629 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14141630 //tmp.setName("Edit");
1415
- objectPanel.add(toolboxPanel);
14161631 objectPanel.add(materialPanel);
1632
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1633
+ objectPanel.setToolTipTextAt(0, "Material");
1634
+
1635
+ objectPanel.add(toolboxPanel);
1636
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1637
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1638
+
1639
+ objectPanel.add(skyboxPanel);
1640
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1641
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1642
+
14171643 // JPanel north = new JPanel(new BorderLayout());
14181644 // north.setName("Edit");
14191645 // north.add(ctrlPanel, BorderLayout.NORTH);
14201646 // objectPanel.add(north);
14211647 objectPanel.add(editPanel);
1422
- objectPanel.add(infoPanel);
1423
-
1648
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1649
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1650
+
1651
+ objectPanel.add(XYZPanel);
1652
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1653
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1654
+
14241655 /*
14251656 aConstraints.gridx = 0;
14261657 aConstraints.gridwidth = 1;
....@@ -1428,7 +1659,7 @@
14281659 aConstraints.gridy += 1;
14291660 aConstraints.gridwidth = 1;
14301661 mainPanel.add(objectPanel, aConstraints);
1431
- */
1662
+ */
14321663
14331664 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14341665 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1440,14 +1671,12 @@
14401671 scrollpane.addMouseWheelListener(this); // Default not fast enough
14411672
14421673 /*JTabbedPane*/ scenePanel = new cGridBag();
1443
- scenePanel.preferredWidth = 6;
1674
+ scenePanel.preferredWidth = 5;
14441675
14451676 JTabbedPane tabbedPane = new JTabbedPane();
14461677 tabbedPane.add(scrollpane);
14471678
1448
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1449
-
1450
- optionsPanel = new cGridBag().setVertical(true);
1679
+ optionsPanel = new cGridBag().setVertical(false);
14511680
14521681 optionsPanel.setName("Options");
14531682
....@@ -1455,8 +1684,15 @@
14551684
14561685 tabbedPane.add(optionsPanel);
14571686
1687
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1688
+
14581689 scenePanel.add(tabbedPane);
14591690
1691
+ //if (Globals.ADVANCED)
1692
+// tabbedPane.add(infoPanel);
1693
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1694
+// tabbedPane.setToolTipTextAt(3, "Information");
1695
+
14601696 /*
14611697 cTree jTree = new cTree(null);
14621698 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1518,7 +1754,7 @@
15181754 bigThree = new cGridBag();
15191755 bigThree.addComponent(scenePanel);
15201756 bigThree.addComponent(centralPanel);
1521
- bigThree.addComponent(XYZPanel);
1757
+ //bigThree.addComponent(XYZPanel);
15221758
15231759 // // SIDE EFFECT!!!
15241760 // aConstraints.gridx = 0;
....@@ -1527,16 +1763,33 @@
15271763 // aConstraints.gridheight = 1;
15281764
15291765 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1530
- framePanel.setContinuousLayout(true);
1531
- framePanel.setOneTouchExpandable(true);
1532
- framePanel.setDividerLocation(0.8);
1766
+
1767
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1768
+ new java.beans.PropertyChangeListener()
1769
+ {
1770
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1771
+ {
1772
+ if ((Integer)pce.getOldValue() == 1)
1773
+ {
1774
+ if (radio.layout != expandedLayout)
1775
+ {
1776
+ radio.layout = expandedLayout;
1777
+ radio.layout.doClick();
1778
+ }
1779
+ }
1780
+ }
1781
+ });
1782
+
1783
+ framePanel.setContinuousLayout(false);
1784
+ framePanel.setOneTouchExpandable(false);
1785
+ //.setDividerLocation(0.8);
15331786 //framePanel.setDividerSize(15);
15341787 //framePanel.setResizeWeight(0.15);
15351788 framePanel.setName("Frame");
15361789
15371790 frame.getContentPane().setLayout(new BorderLayout());
15381791 /**/
1539
- JTabbedPane worldPane = new JTabbedPane();
1792
+ //JTabbedPane worldPane = new JTabbedPane();
15401793 //worldPane.add(bigPanel);
15411794 //worldPane.add(worldPanel);
15421795 /**/
....@@ -1547,16 +1800,18 @@
15471800 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
15481801
15491802 frame.setSize(1280, 860);
1550
- frame.setVisible(true);
1551
-
1803
+
15521804 cameraView.requestFocusInWindow();
15531805
15541806 gridPanel.setDividerLocation(1.0);
1807
+
1808
+ frame.validate();
1809
+
1810
+ frame.setVisible(true);
15551811
15561812 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15571813 frame.addWindowListener(new WindowAdapter()
15581814 {
1559
-
15601815 public void windowClosing(WindowEvent e)
15611816 {
15621817 Close();
....@@ -1579,12 +1834,403 @@
15791834 ctrlPanel.removeAll();
15801835 }
15811836
1582
- void SetupMaterial(cGridBag panel)
1837
+ void SetupMaterial(cGridBag materialpanel)
15831838 {
1584
- /*
1839
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1840
+
1841
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1842
+ skin.setToolTipText("Skin");
1843
+ skin.addMouseListener(new MouseAdapter()
1844
+ {
1845
+ public void mouseClicked(MouseEvent e)
1846
+ {
1847
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1848
+ cMaterial material = object.material;
1849
+
1850
+ // Skin
1851
+ colorField.setFloat(material.color);
1852
+ saturationField.setFloat(material.modulation);
1853
+ subsurfaceField.setFloat(material.subsurface);
1854
+ selfshadowField.setFloat(material.diffuseness);
1855
+ diffusenessField.setFloat(material.factor);
1856
+ shininessField.setFloat(material.shininess);
1857
+ shadowbiasField.setFloat(material.shadowbias);
1858
+ diffuseField.setFloat(material.diffuse);
1859
+ specularField.setFloat(material.specular);
1860
+
1861
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1862
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1863
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1864
+
1865
+ materialtouched = true;
1866
+ applySelf();
1867
+ }
1868
+ });
1869
+ presetpanel.add(skin);
1870
+
1871
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1872
+ lambert.setToolTipText("Diffuse");
1873
+ lambert.addMouseListener(new MouseAdapter()
1874
+ {
1875
+ public void mouseClicked(MouseEvent e)
1876
+ {
1877
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1878
+ cMaterial material = object.material;
1879
+
1880
+ diffusenessField.setFloat(material.factor);
1881
+ selfshadowField.setFloat(material.diffuseness);
1882
+
1883
+ materialtouched = true;
1884
+ applySelf();
1885
+ }
1886
+ });
1887
+ presetpanel.add(lambert);
1888
+
1889
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1890
+ diffuse2.setToolTipText("Diffuse2");
1891
+ diffuse2.addMouseListener(new MouseAdapter()
1892
+ {
1893
+ public void mouseClicked(MouseEvent e)
1894
+ {
1895
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1896
+ cMaterial material = object.material;
1897
+
1898
+ diffusenessField.setFloat(material.factor);
1899
+ selfshadowField.setFloat(material.diffuseness);
1900
+
1901
+ materialtouched = true;
1902
+ applySelf();
1903
+ }
1904
+ });
1905
+ presetpanel.add(diffuse2);
1906
+
1907
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1908
+ diffusemoon.setToolTipText("Moon");
1909
+ diffusemoon.addMouseListener(new MouseAdapter()
1910
+ {
1911
+ public void mouseClicked(MouseEvent e)
1912
+ {
1913
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1914
+ cMaterial material = object.material;
1915
+
1916
+ diffusenessField.setFloat(material.factor);
1917
+ selfshadowField.setFloat(material.diffuseness);
1918
+
1919
+ materialtouched = true;
1920
+ applySelf();
1921
+ }
1922
+ });
1923
+ presetpanel.add(diffusemoon);
1924
+
1925
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1926
+ diffusemoon2.setToolTipText("Moon2");
1927
+ diffusemoon2.addMouseListener(new MouseAdapter()
1928
+ {
1929
+ public void mouseClicked(MouseEvent e)
1930
+ {
1931
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1932
+ cMaterial material = object.material;
1933
+
1934
+ diffusenessField.setFloat(material.factor);
1935
+ selfshadowField.setFloat(material.diffuseness);
1936
+
1937
+ materialtouched = true;
1938
+ applySelf();
1939
+ }
1940
+ });
1941
+ presetpanel.add(diffusemoon2);
1942
+
1943
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1944
+ diffusemoon3.setToolTipText("Moon3");
1945
+ diffusemoon3.addMouseListener(new MouseAdapter()
1946
+ {
1947
+ public void mouseClicked(MouseEvent e)
1948
+ {
1949
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1950
+ cMaterial material = object.material;
1951
+
1952
+ diffusenessField.setFloat(material.factor);
1953
+ selfshadowField.setFloat(material.diffuseness);
1954
+
1955
+ materialtouched = true;
1956
+ applySelf();
1957
+ }
1958
+ });
1959
+ presetpanel.add(diffusemoon3);
1960
+
1961
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1962
+ diffusesheen.setToolTipText("Sheen");
1963
+ diffusesheen.addMouseListener(new MouseAdapter()
1964
+ {
1965
+ public void mouseClicked(MouseEvent e)
1966
+ {
1967
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1968
+ cMaterial material = object.material;
1969
+
1970
+ sheenField.setFloat(material.sheen);
1971
+
1972
+ materialtouched = true;
1973
+ applySelf();
1974
+ }
1975
+ });
1976
+ presetpanel.add(diffusesheen);
1977
+
1978
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1979
+ rough.setToolTipText("Rough metal");
1980
+ rough.addMouseListener(new MouseAdapter()
1981
+ {
1982
+ public void mouseClicked(MouseEvent e)
1983
+ {
1984
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1985
+ cMaterial material = object.material;
1986
+
1987
+ shininessField.setFloat(material.shininess);
1988
+ velvetField.setFloat(material.velvet);
1989
+
1990
+ materialtouched = true;
1991
+ applySelf();
1992
+ }
1993
+ });
1994
+ presetpanel.add(rough);
1995
+
1996
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
1997
+ rough2.setToolTipText("Medium metal");
1998
+ rough2.addMouseListener(new MouseAdapter()
1999
+ {
2000
+ public void mouseClicked(MouseEvent e)
2001
+ {
2002
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2003
+ cMaterial material = object.material;
2004
+
2005
+ shininessField.setFloat(material.shininess);
2006
+ lightareaField.setFloat(material.lightarea);
2007
+
2008
+ materialtouched = true;
2009
+ applySelf();
2010
+ }
2011
+ });
2012
+ presetpanel.add(rough2);
2013
+
2014
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2015
+ shini0.setToolTipText("Shiny");
2016
+ shini0.addMouseListener(new MouseAdapter()
2017
+ {
2018
+ public void mouseClicked(MouseEvent e)
2019
+ {
2020
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2021
+ cMaterial material = object.material;
2022
+
2023
+ shininessField.setFloat(material.shininess);
2024
+ lightareaField.setFloat(material.lightarea);
2025
+
2026
+ materialtouched = true;
2027
+ applySelf();
2028
+ }
2029
+ });
2030
+ presetpanel.add(shini0);
2031
+
2032
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2033
+ shini1.setToolTipText("Shiny2");
2034
+ shini1.addMouseListener(new MouseAdapter()
2035
+ {
2036
+ public void mouseClicked(MouseEvent e)
2037
+ {
2038
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2039
+ cMaterial material = object.material;
2040
+
2041
+ shininessField.setFloat(material.shininess);
2042
+ lightareaField.setFloat(material.lightarea);
2043
+
2044
+ materialtouched = true;
2045
+ applySelf();
2046
+ }
2047
+ });
2048
+ presetpanel.add(shini1);
2049
+
2050
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2051
+ shini2.setToolTipText("Shiny3");
2052
+ shini2.addMouseListener(new MouseAdapter()
2053
+ {
2054
+ public void mouseClicked(MouseEvent e)
2055
+ {
2056
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2057
+ cMaterial material = object.material;
2058
+
2059
+ shininessField.setFloat(material.shininess);
2060
+ lightareaField.setFloat(material.lightarea);
2061
+
2062
+ materialtouched = true;
2063
+ applySelf();
2064
+ }
2065
+ });
2066
+ presetpanel.add(shini2);
2067
+
2068
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2069
+ aniso.setToolTipText("AnisoU");
2070
+ aniso.addMouseListener(new MouseAdapter()
2071
+ {
2072
+ public void mouseClicked(MouseEvent e)
2073
+ {
2074
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2075
+ cMaterial material = object.material;
2076
+
2077
+ anisoField.setFloat(material.aniso);
2078
+ anisoVField.setFloat(material.anisoV);
2079
+
2080
+ materialtouched = true;
2081
+ applySelf();
2082
+ }
2083
+ });
2084
+ presetpanel.add(aniso);
2085
+
2086
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2087
+ aniso2.setToolTipText("AnisoV");
2088
+ aniso2.addMouseListener(new MouseAdapter()
2089
+ {
2090
+ public void mouseClicked(MouseEvent e)
2091
+ {
2092
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2093
+ cMaterial material = object.material;
2094
+
2095
+ anisoField.setFloat(material.aniso);
2096
+ anisoVField.setFloat(material.anisoV);
2097
+
2098
+ materialtouched = true;
2099
+ applySelf();
2100
+ }
2101
+ });
2102
+ presetpanel.add(aniso2);
2103
+
2104
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2105
+ aniso3.setToolTipText("AnisoUV");
2106
+ aniso3.addMouseListener(new MouseAdapter()
2107
+ {
2108
+ public void mouseClicked(MouseEvent e)
2109
+ {
2110
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2111
+ cMaterial material = object.material;
2112
+
2113
+ anisoField.setFloat(material.aniso);
2114
+ anisoVField.setFloat(material.anisoV);
2115
+
2116
+ materialtouched = true;
2117
+ applySelf();
2118
+ }
2119
+ });
2120
+ presetpanel.add(aniso3);
2121
+
2122
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2123
+ velvet0.setToolTipText("Velvet");
2124
+ velvet0.addMouseListener(new MouseAdapter()
2125
+ {
2126
+ public void mouseClicked(MouseEvent e)
2127
+ {
2128
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2129
+ cMaterial material = object.material;
2130
+
2131
+ diffusenessField.setFloat(material.factor);
2132
+ selfshadowField.setFloat(material.diffuseness);
2133
+ sheenField.setFloat(material.sheen);
2134
+ shininessField.setFloat(material.shininess);
2135
+ velvetField.setFloat(material.velvet);
2136
+ shiftField.setFloat(material.shift);
2137
+
2138
+ materialtouched = true;
2139
+ applySelf();
2140
+ }
2141
+ });
2142
+ presetpanel.add(velvet0);
2143
+
2144
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2145
+ bump0.setToolTipText("Bump texture");
2146
+ bump0.addMouseListener(new MouseAdapter()
2147
+ {
2148
+ public void mouseClicked(MouseEvent e)
2149
+ {
2150
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2151
+ cMaterial material = object.material;
2152
+
2153
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2154
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2155
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2156
+
2157
+ materialtouched = true;
2158
+ applySelf();
2159
+ }
2160
+ });
2161
+ presetpanel.add(bump0);
2162
+
2163
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2164
+ halo.setToolTipText("Halo");
2165
+ halo.addMouseListener(new MouseAdapter()
2166
+ {
2167
+ public void mouseClicked(MouseEvent e)
2168
+ {
2169
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2170
+ cMaterial material = object.material;
2171
+
2172
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2173
+
2174
+ materialtouched = true;
2175
+ applySelf();
2176
+ }
2177
+ });
2178
+ presetpanel.add(halo);
2179
+
2180
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2181
+ candle.setToolTipText("Candle");
2182
+ candle.addMouseListener(new MouseAdapter()
2183
+ {
2184
+ public void mouseClicked(MouseEvent e)
2185
+ {
2186
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2187
+ cMaterial material = object.material;
2188
+
2189
+ subsurfaceField.setFloat(material.subsurface);
2190
+ shadowbiasField.setFloat(material.shadowbias);
2191
+ ambientField.setFloat(material.ambient);
2192
+ specularField.setFloat(material.specular);
2193
+ lightareaField.setFloat(material.lightarea);
2194
+ shininessField.setFloat(material.shininess);
2195
+
2196
+ materialtouched = true;
2197
+ applySelf();
2198
+ }
2199
+ });
2200
+ presetpanel.add(candle);
2201
+
2202
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2203
+ shadowShader.setToolTipText("Shadow");
2204
+ shadowShader.addMouseListener(new MouseAdapter()
2205
+ {
2206
+ public void mouseClicked(MouseEvent e)
2207
+ {
2208
+ diffuseField.setFloat(0.001);
2209
+ ambientField.setFloat(0.001);
2210
+ cameraField.setFloat(0.001);
2211
+ specularField.setFloat(0.001);
2212
+ fakedepthField.setFloat(0.001);
2213
+ opacityField.setFloat(0.6);
2214
+
2215
+ materialtouched = true;
2216
+ applySelf();
2217
+ }
2218
+ });
2219
+ presetpanel.add(shadowShader);
2220
+
2221
+ cGridBag panel = new cGridBag().setVertical(true);
2222
+
2223
+ presetpanel.preferredWidth = 1;
2224
+
2225
+ materialpanel.add(presetpanel);
2226
+ materialpanel.add(panel);
2227
+
2228
+ panel.preferredWidth = 8;
2229
+
2230
+ /*
15852231 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
15862232 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1587
- */
2233
+ */
15882234
15892235 cGridBag editBar = new cGridBag().setVertical(false);
15902236
....@@ -1618,45 +2264,50 @@
16182264 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16192265
16202266 cGridBag colorSection = new cGridBag().setVertical(true);
2267
+
2268
+ cGridBag huepanel = new cGridBag();
2269
+ cGridBag huelabel = new cGridBag();
2270
+ skin = GetLabel("icons/hue.png", false);
2271
+ skin.fit = true;
2272
+ huelabel.add(skin);
2273
+ huelabel.preferredWidth = 20;
2274
+ huepanel.add(new cGridBag()); // Label
2275
+ huepanel.add(huelabel); // Field/slider
2276
+
2277
+ huepanel.preferredHeight = 7;
2278
+
2279
+ colorSection.add(huepanel);
16212280
16222281 cGridBag color = new cGridBag();
1623
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1624
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1625
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2282
+
2283
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2284
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2285
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2286
+
16262287 //colorField.preferredWidth = 200;
16272288 colorSection.add(color);
16282289
16292290 cGridBag modulation = new cGridBag();
16302291 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16312292 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1632
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2293
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16332294 colorSection.add(modulation);
16342295
2296
+ cGridBag opacity = new cGridBag();
2297
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2298
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2299
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2300
+ colorSection.add(opacity);
2301
+
2302
+ colorSection.add(GetSeparator());
2303
+
16352304 cGridBag texture = new cGridBag();
16362305 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16372306 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16382307 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16392308 colorSection.add(texture);
16402309
1641
- cGridBag anisoU = new cGridBag();
1642
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1643
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1644
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1645
- colorSection.add(anisoU);
1646
-
1647
- cGridBag anisoV = new cGridBag();
1648
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1649
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1650
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1651
- colorSection.add(anisoV);
1652
-
1653
- cGridBag shadowbias = new cGridBag();
1654
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1655
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1656
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1657
- colorSection.add(shadowbias);
1658
-
1659
- panel.add(new JSeparator());
2310
+ panel.add(GetSeparator());
16602311
16612312 panel.add(colorSection);
16622313
....@@ -1706,7 +2357,13 @@
17062357 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17072358 diffuseSection.add(fakedepth);
17082359
1709
- panel.add(new JSeparator());
2360
+ cGridBag shadowbias = new cGridBag();
2361
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2362
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2363
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2364
+ diffuseSection.add(shadowbias);
2365
+
2366
+ panel.add(GetSeparator());
17102367
17112368 panel.add(diffuseSection);
17122369
....@@ -1756,42 +2413,48 @@
17562413 // aConstraints.gridy += 1;
17572414 // aConstraints.gridwidth = 1;
17582415
2416
+ cGridBag anisoU = new cGridBag();
2417
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2418
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2419
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2420
+ specularSection.add(anisoU);
17592421
1760
- panel.add(new JSeparator());
2422
+ cGridBag anisoV = new cGridBag();
2423
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2424
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2425
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2426
+ specularSection.add(anisoV);
2427
+
2428
+
2429
+ panel.add(GetSeparator());
17612430
17622431 panel.add(specularSection);
17632432
17642433 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17652434
1766
- cGridBag globalSection = new cGridBag().setVertical(true);
2435
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17672436
17682437 cGridBag camera = new cGridBag();
17692438 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17702439 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17712440 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1772
- globalSection.add(camera);
2441
+ colorSection.add(camera);
17732442
17742443 cGridBag ambient = new cGridBag();
17752444 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17762445 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17772446 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1778
- globalSection.add(ambient);
2447
+ colorSection.add(ambient);
17792448
17802449 cGridBag backlit = new cGridBag();
17812450 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17822451 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17832452 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1784
- globalSection.add(backlit);
2453
+ colorSection.add(backlit);
17852454
1786
- cGridBag opacity = new cGridBag();
1787
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1788
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1789
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1790
- globalSection.add(opacity);
1791
-
1792
- panel.add(new JSeparator());
2455
+ //panel.add(new JSeparator());
17932456
1794
- panel.add(globalSection);
2457
+ //panel.add(globalSection);
17952458
17962459 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17972460
....@@ -1833,7 +2496,7 @@
18332496 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18342497 textureSection.add(opacityPower);
18352498
1836
- panel.add(new JSeparator());
2499
+ panel.add(GetSeparator());
18372500
18382501 panel.add(textureSection);
18392502
....@@ -1898,8 +2561,9 @@
18982561 // 3D models
18992562 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19002563 {
1901
- lastConverter = new com.jmex.model.converters.MaxToJme();
1902
- LoadFile(filename, lastConverter);
2564
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2565
+ //LoadFile(filename, lastConverter);
2566
+ LoadObjFile(filename); // New 3ds loader
19032567 continue;
19042568 }
19052569 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2625,6 +3289,7 @@
26253289 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26263290 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26273291 }
3292
+
26283293 //cJME.count++;
26293294 //cJME.count %= 12;
26303295 if (gc)
....@@ -2808,6 +3473,7 @@
28083473 }
28093474 }
28103475 }
3476
+
28113477 cFileSystemPane FSPane;
28123478
28133479 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2817,7 +3483,7 @@
28173483
28183484 freezematerial = true;
28193485 colorField.setFloat(mat.color);
2820
- modulationField.setFloat(mat.modulation);
3486
+ saturationField.setFloat(mat.modulation);
28213487 metalnessField.setFloat(mat.metalness);
28223488 diffuseField.setFloat(mat.diffuse);
28233489 specularField.setFloat(mat.specular);
....@@ -2861,11 +3527,14 @@
28613527 }
28623528 }
28633529 }
3530
+
28643531 freezematerial = false;
28653532 }
28663533
28673534 void SetMaterial(Object3D object)
28683535 {
3536
+ latestObject = object;
3537
+
28693538 cMaterial mat = object.material;
28703539
28713540 if (mat == null)
....@@ -2977,12 +3646,17 @@
29773646 // }
29783647
29793648 /**/
2980
- if (deselect)
3649
+ if (deselect || child == null)
29813650 {
29823651 //group.deselectAll();
29833652 //freeze = true;
29843653 GetTree().clearSelection();
29853654 //freeze = false;
3655
+
3656
+ if (child == null)
3657
+ {
3658
+ return;
3659
+ }
29863660 }
29873661
29883662 //group.addSelectee(child);
....@@ -3016,6 +3690,17 @@
30163690 public void itemStateChanged(ItemEvent event)
30173691 {
30183692 // System.out.println("Propagate = " + propagate);
3693
+ if (event.getSource() == pinButton)
3694
+ {
3695
+ copy.pinned ^= true;
3696
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3697
+ {
3698
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3699
+ copy.CloseUI();
3700
+ //copy.editWindow.refreshContents();
3701
+ }
3702
+ }
3703
+ else
30193704 if (event.getSource() == propagateToggle)
30203705 {
30213706 propagate ^= true;
....@@ -3051,7 +3736,7 @@
30513736 cameraView.ToggleDL();
30523737 cameraView.repaint();
30533738 return;
3054
- } else if (event.getSource() == toggleTextureItem)
3739
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
30553740 {
30563741 cameraView.ToggleTexture();
30573742 // june 2013 copy.HardTouch();
....@@ -3090,7 +3775,7 @@
30903775 frame.validate();
30913776
30923777 return;
3093
- } else if (event.getSource() == toggleSwitchItem)
3778
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30943779 {
30953780 cameraView.ToggleSwitch();
30963781 cameraView.repaint();
....@@ -3120,8 +3805,9 @@
31203805 } else if (event.getSource() == liveCB)
31213806 {
31223807 copy.live ^= true;
3808
+ objEditor.refreshContents(true); // To show item colors
31233809 return;
3124
- } else if (event.getSource() == selectCB)
3810
+ } else if (event.getSource() == selectableCB)
31253811 {
31263812 copy.dontselect ^= true;
31273813 return;
....@@ -3129,7 +3815,7 @@
31293815 {
31303816 copy.hide ^= true;
31313817 copy.Touch(); // display list issue
3132
- objEditor.refreshContents();
3818
+ objEditor.refreshContents(true); // To show item colors
31333819 return;
31343820 } else if (event.getSource() == link2masterCB)
31353821 {
....@@ -3306,9 +3992,9 @@
33063992 {
33073993 Close();
33083994 //return true;
3309
- } else if (source == loadItem)
3995
+ } else if (source == openItem)
33103996 {
3311
- load();
3997
+ Open();
33123998 //return true;
33133999 } else if (source == newItem)
33144000 {
....@@ -3333,6 +4019,10 @@
33334019 {
33344020 generatePOV();
33354021 //return true;
4022
+ } else if (event.getSource() == archiveItem)
4023
+ {
4024
+ cTools.Archive(frame);
4025
+ return;
33364026 } else if (source == zBufferItem)
33374027 {
33384028 try
....@@ -3381,11 +4071,12 @@
33814071
33824072 static public byte[] Compress(Object3D o)
33834073 {
4074
+ // Slower to actually compress.
33844075 try
33854076 {
33864077 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3387
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3388
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4078
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4079
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33894080
33904081 Object3D parent = o.parent;
33914082 o.parent = null;
....@@ -3396,10 +4087,14 @@
33964087
33974088 out.flush();
33984089
3399
- zstream.close();
4090
+ baos //zstream
4091
+ .close();
34004092 out.close();
34014093
3402
- return baos.toByteArray();
4094
+ byte[] bytes = baos.toByteArray();
4095
+
4096
+ System.out.println("save #bytes = " + bytes.length);
4097
+ return bytes;
34034098 } catch (Exception e)
34044099 {
34054100 System.err.println(e);
....@@ -3409,13 +4104,16 @@
34094104
34104105 static public Object Uncompress(byte[] bytes)
34114106 {
3412
- System.out.println("#bytes = " + bytes.length);
4107
+ System.out.println("restore #bytes = " + bytes.length);
34134108 try
34144109 {
34154110 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3416
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3417
- ObjectInputStream in = new ObjectInputStream(istream);
4111
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4112
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34184113 Object obj = in.readObject();
4114
+
4115
+ bais //istream
4116
+ .close();
34194117 in.close();
34204118
34214119 return obj;
....@@ -3470,39 +4168,95 @@
34704168 return null;
34714169 }
34724170
3473
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
34744171
34754172 public void Save()
34764173 {
4174
+ //Save(true);
4175
+ Replace();
4176
+ SetVersionStates();
4177
+ }
4178
+
4179
+ private boolean Equal(byte[] compress, byte[] name)
4180
+ {
4181
+ if (compress.length != name.length)
4182
+ {
4183
+ return false;
4184
+ }
4185
+
4186
+ for (int i=compress.length; --i>=0;)
4187
+ {
4188
+ if (compress[i] != name[i])
4189
+ return false;
4190
+ }
4191
+
4192
+ return true;
4193
+ }
4194
+
4195
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4196
+
4197
+ void DeleteVersion()
4198
+ {
4199
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4200
+ {
4201
+ copy.versionlist[i] = copy.versionlist[i+1];
4202
+ }
4203
+
4204
+ CopyChanged();
4205
+
4206
+ SetVersionStates();
4207
+ }
4208
+
4209
+ public boolean Save(boolean user)
4210
+ {
34774211 System.err.println("Save");
4212
+ Replace();
34784213
3479
- cRadio tab = GetCurrentTab();
4214
+ //cRadio tab = GetCurrentTab();
34804215
3481
- boolean temp = CameraPane.SWITCH;
3482
- CameraPane.SWITCH = false;
4216
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
34834217
3484
- copy.ExtractBigData(hashtable);
4218
+ boolean thesame = false;
4219
+
4220
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4221
+// {
4222
+// thesame = true;
4223
+// }
34854224
34864225 //EditorFrame.m_MainFrame.requestFocusInWindow();
3487
- tab.graphs[tab.undoindex++] = Compress(copy);
3488
-
3489
- copy.RestoreBigData(hashtable);
3490
-
3491
- CameraPane.SWITCH = temp;
3492
-
3493
- //assert(hashtable.isEmpty());
3494
-
3495
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
4226
+ if (!thesame)
34964227 {
3497
- tab.graphs[i] = null;
4228
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4229
+ {
4230
+ copy.versionlist[i] = copy.versionlist[i-1];
4231
+ }
4232
+
4233
+ //tab.user[tab.versionindex] = user;
4234
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4235
+
4236
+ copy.versionlist[++copy.versionindex] = compress;
4237
+
4238
+ // if (increment)
4239
+ // tab.versionindex++;
34984240 }
34994241
4242
+ //copy.RestoreBigData(versiontable);
4243
+
4244
+ //assert(hashtable.isEmpty());
4245
+
4246
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4247
+// {
4248
+// //tab.user[i] = false;
4249
+// copy.versionlist[i] = null;
4250
+// }
4251
+
4252
+ SetVersionStates();
4253
+
35004254 // test save
35014255 if (false)
35024256 {
35034257 try
35044258 {
3505
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4259
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35064260 ObjectOutputStream p = new ObjectOutputStream(ostream);
35074261
35084262 p.writeObject(copy);
....@@ -3515,26 +4269,68 @@
35154269 e.printStackTrace();
35164270 }
35174271 }
4272
+
4273
+ return !thesame;
4274
+ }
4275
+
4276
+ boolean flashIt = true;
4277
+
4278
+ void RefreshSelection()
4279
+ {
4280
+ Object3D selection = new Object3D();
4281
+
4282
+ for (int i = 0; i < copy.selection.size(); i++)
4283
+ {
4284
+ Object3D elem = copy.selection.elementAt(i);
4285
+
4286
+ Object3D obj = copy.GetObject(elem.GetUUID());
4287
+
4288
+ if (obj == null)
4289
+ {
4290
+ copy.selection.remove(i--);
4291
+ }
4292
+ else
4293
+ {
4294
+ selection.add(obj);
4295
+ copy.selection.setElementAt(obj, i);
4296
+ }
4297
+ }
4298
+
4299
+ flashIt = false;
4300
+ GetTree().clearSelection();
4301
+ for (int i = 0; i < selection.size(); i++)
4302
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4303
+ flashIt = true;
4304
+
4305
+ //refreshContents(false);
35184306 }
35194307
3520
- void CopyChanged(Object3D obj)
4308
+ void CopyChanged()
35214309 {
4310
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4311
+
4312
+ SetVersionStates();
4313
+
35224314 boolean temp = CameraPane.SWITCH;
35234315 CameraPane.SWITCH = false;
35244316
3525
- copy.ExtractBigData(hashtable);
4317
+ copy.ExtractBigData(versiontable);
35264318
35274319 copy.clear();
35284320
4321
+ copy.skyboxname = obj.skyboxname;
4322
+ copy.skyboxext = obj.skyboxext;
4323
+
35294324 for (int i=0; i<obj.Size(); i++)
35304325 {
35314326 copy.add(obj.get(i));
35324327 }
35334328
3534
- copy.RestoreBigData(hashtable);
4329
+ copy.RestoreBigData(versiontable);
35354330
35364331 CameraPane.SWITCH = temp;
35374332
4333
+ RefreshSelection();
35384334 //assert(hashtable.isEmpty());
35394335
35404336 copy.Touch();
....@@ -3555,45 +4351,144 @@
35554351 }
35564352 }
35574353
3558
- refreshContents();
4354
+ refreshContents(true);
35594355 }
35604356
3561
- public void Undo()
4357
+ cButton previousVersionButton;
4358
+ cButton restoreButton;
4359
+ cButton replaceButton;
4360
+ cButton nextVersionButton;
4361
+ cButton saveVersionButton;
4362
+ cButton deleteVersionButton;
4363
+
4364
+ boolean muteSlider;
4365
+
4366
+ int VersionCount()
35624367 {
4368
+ int count = 0;
4369
+
4370
+ for (int i = copy.versionlist.length; --i >= 0;)
4371
+ {
4372
+ if (copy.versionlist[i] != null)
4373
+ count++;
4374
+ }
4375
+
4376
+ return count;
4377
+ }
4378
+
4379
+ void SetVersionStates()
4380
+ {
4381
+ //if (true)
4382
+ // return;
4383
+
4384
+ //cRadio tab = GetCurrentTab();
4385
+
4386
+ restoreButton.setEnabled(copy.versionindex != -1);
4387
+ replaceButton.setEnabled(copy.versionindex != -1);
4388
+
4389
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4390
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4391
+
4392
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4393
+ copy.versionlist[copy.versionindex + 1] != null);
4394
+
4395
+ muteSlider = true;
4396
+ versionSlider.setMinimum(0);
4397
+ versionSlider.setMaximum(VersionCount() - 1);
4398
+ versionSlider.setInteger(copy.versionindex);
4399
+ versionSlider.setEnabled(copy.versionindex != -1);
4400
+ muteSlider = false;
4401
+ }
4402
+
4403
+ public boolean PreviousVersion()
4404
+ {
4405
+ // Option?
4406
+ Replace();
4407
+
35634408 System.err.println("Undo");
35644409
3565
- cRadio tab = GetCurrentTab();
4410
+ //cRadio tab = GetCurrentTab();
35664411
3567
- if (tab.undoindex == 0)
4412
+ if (copy.versionindex == 0)
35684413 {
35694414 java.awt.Toolkit.getDefaultToolkit().beep();
3570
- return;
4415
+ return false;
35714416 }
35724417
3573
- if (tab.graphs[tab.undoindex] == null)
3574
- {
3575
- Save();
3576
- tab.undoindex -= 1;
3577
- }
4418
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4419
+// {
4420
+// if (Save(false))
4421
+// tab.versionindex -= 1;
4422
+// else
4423
+// {
4424
+// if (tab.versionindex <= 0)
4425
+// return false;
4426
+// else
4427
+// tab.versionindex -= 1;
4428
+// }
4429
+// }
35784430
3579
- tab.undoindex -= 1;
4431
+ copy.versionindex -= 1;
35804432
3581
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4433
+ CopyChanged();
4434
+
4435
+ return true;
35824436 }
35834437
3584
- public void Redo()
4438
+ public boolean Restore()
35854439 {
3586
- cRadio tab = GetCurrentTab();
4440
+ System.err.println("Restore");
35874441
3588
- if (tab.graphs[tab.undoindex + 1] == null)
4442
+ //cRadio tab = GetCurrentTab();
4443
+
4444
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4445
+ {
4446
+ java.awt.Toolkit.getDefaultToolkit().beep();
4447
+ return false;
4448
+ }
4449
+
4450
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4451
+ CopyChanged();
4452
+
4453
+ return true;
4454
+ }
4455
+
4456
+ public boolean Replace()
4457
+ {
4458
+ System.err.println("Replace");
4459
+
4460
+ //cRadio tab = GetCurrentTab();
4461
+
4462
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4463
+ {
4464
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4465
+ return false;
4466
+ }
4467
+
4468
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4469
+
4470
+ return true;
4471
+ }
4472
+
4473
+ public void NextVersion()
4474
+ {
4475
+ // Option?
4476
+ Replace();
4477
+
4478
+ //cRadio tab = GetCurrentTab();
4479
+
4480
+ if (copy.versionlist[copy.versionindex + 1] == null)
35894481 {
35904482 java.awt.Toolkit.getDefaultToolkit().beep();
35914483 return;
35924484 }
35934485
3594
- tab.undoindex += 1;
4486
+ copy.versionindex += 1;
35954487
3596
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4488
+ CopyChanged();
4489
+
4490
+ //if (!tab.user[tab.versionindex])
4491
+ // tab.graphs[tab.versionindex] = null;
35974492 }
35984493
35994494 void ImportGFD()
....@@ -3804,7 +4699,7 @@
38044699 //copy.material = new cMaterial(copy.GetMaterial());
38054700
38064701 current.color = (float) colorField.getFloat();
3807
- current.modulation = (float) modulationField.getFloat();
4702
+ current.modulation = (float) saturationField.getFloat();
38084703 current.metalness = (float) metalnessField.getFloat();
38094704 current.diffuse = (float) diffuseField.getFloat();
38104705 current.specular = (float) specularField.getFloat();
....@@ -3837,7 +4732,7 @@
38374732 cMaterial mat = copy.material;
38384733
38394734 colorField.SetToolTipValue((mat.color));
3840
- modulationField.SetToolTipValue((mat.modulation));
4735
+ saturationField.SetToolTipValue((mat.modulation));
38414736 metalnessField.SetToolTipValue((mat.metalness));
38424737 diffuseField.SetToolTipValue((mat.diffuse));
38434738 specularField.SetToolTipValue((mat.specular));
....@@ -3889,9 +4784,28 @@
38894784 //copy.Touch();
38904785 }
38914786
4787
+ cNumberSlider versionSlider;
4788
+
38924789 public void stateChanged(ChangeEvent e)
38934790 {
38944791 // assert(false);
4792
+ if (e.getSource() == versionSlider)
4793
+ {
4794
+ if (muteSlider)
4795
+ return;
4796
+
4797
+ Replace();
4798
+
4799
+ int version = versionSlider.getInteger();
4800
+
4801
+ if (version != -1 && copy.versionlist[version] != null)
4802
+ {
4803
+ copy.versionindex = version;
4804
+ CopyChanged();
4805
+ }
4806
+
4807
+ return;
4808
+ }
38954809
38964810 if (freezematerial)
38974811 {
....@@ -3927,6 +4841,12 @@
39274841 {
39284842 //System.out.println("stateChanged = " + this);
39294843 materialtouched = true;
4844
+
4845
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4846
+ {
4847
+ saturationField.setFloat(1);
4848
+ }
4849
+
39304850 applySelf();
39314851 //System.out.println("this = " + this);
39324852 //System.out.println("PARENT = " + parent);
....@@ -4226,6 +5146,7 @@
42265146 {
42275147 if (GetTree() != null)
42285148 {
5149
+ GetTree().revalidate();
42295150 GetTree().repaint();
42305151 }
42315152
....@@ -4234,13 +5155,16 @@
42345155 ctrlPanel.validate(); // ? new
42355156 ctrlPanel.repaint();
42365157 }
5158
+
5159
+ if (previousVersionButton != null && copy.versionlist != null)
5160
+ SetVersionStates();
42375161 }
42385162
42395163 static TweenManager tweenManager = new TweenManager();
42405164
42415165 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42425166 {
4243
- if (Globals.SAVEONMAKE) // && resetmodel)
5167
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42445168 Save();
42455169 //Tween.set(thing, 0).target(1).start(tweenManager);
42465170 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4482,7 +5406,9 @@
44825406 readobj.ResetDisplayList();
44835407 } catch (Exception e)
44845408 {
4485
- //e.printStackTrace();
5409
+ if (!e.toString().contains("GZIP"))
5410
+ e.printStackTrace();
5411
+
44865412 try
44875413 {
44885414 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4556,12 +5482,14 @@
45565482
45575483 if (readobj != null)
45585484 {
4559
- if (Globals.SAVEONMAKE)
4560
- Save();
5485
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5486
+ // Save();
45615487 try
45625488 {
45635489 //readobj.deepCopySelf(copy);
45645490 copy.clear(); // june 2014
5491
+ copy.skyboxname = readobj.skyboxname;
5492
+ copy.skyboxext = readobj.skyboxext;
45655493 for (int i = 0; i < readobj.size(); i++)
45665494 {
45675495 Object3D child = readobj.get(i); // reserve(i);
....@@ -4602,6 +5530,7 @@
46025530 }
46035531 } catch (ClassCastException e)
46045532 {
5533
+ e.printStackTrace();
46055534 assert (false);
46065535 Composite c = (Composite) copy;
46075536 c.children.clear();
....@@ -4612,17 +5541,31 @@
46125541 c.addChild(csg);
46135542 }
46145543
5544
+ copy.versionlist = readobj.versionlist;
5545
+ copy.versionindex = readobj.versionindex;
5546
+
5547
+ if (copy.versionlist == null)
5548
+ {
5549
+ // Backward compatibility
5550
+ copy.versionlist = new Object3D[100];
5551
+ copy.versionindex = -1;
5552
+
5553
+ //Save(true);
5554
+ }
5555
+
5556
+ //? SetUndoStates();
5557
+
46155558 ResetModel();
46165559 copy.HardTouch(); // recompile?
46175560 refreshContents();
46185561 }
46195562 }
46205563
4621
- void load() // throws ClassNotFoundException
5564
+ void Open() // throws ClassNotFoundException
46225565 {
46235566 if (Grafreed.standAlone)
46245567 {
4625
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5568
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
46265569 browser.show();
46275570 String filename = browser.getFile();
46285571 if (filename != null && filename.length() > 0)
....@@ -4699,6 +5642,8 @@
46995642
47005643 void save()
47015644 {
5645
+ Replace();
5646
+
47025647 if (lastname == null)
47035648 {
47045649 return;
....@@ -4721,6 +5666,7 @@
47215666 //ps.print(buffer.toString());
47225667 } catch (IOException e)
47235668 {
5669
+ e.printStackTrace();
47245670 }
47255671 }
47265672
....@@ -4735,6 +5681,8 @@
47355681 String filename = browser.getFile();
47365682 if (filename != null && filename.length() > 0)
47375683 {
5684
+ if (!filename.endsWith(".gfd"))
5685
+ filename += ".gfd";
47385686 lastname = browser.getDirectory() + filename;
47395687 save();
47405688 }
....@@ -4901,7 +5849,7 @@
49015849 MenuBar menuBar;
49025850 Menu fileMenu;
49035851 MenuItem newItem;
4904
- MenuItem loadItem;
5852
+ MenuItem openItem;
49055853 MenuItem saveItem;
49065854 MenuItem saveAsItem;
49075855 MenuItem exportAsItem;
....@@ -4924,6 +5872,7 @@
49245872 CheckboxMenuItem toggleSwitchItem;
49255873 CheckboxMenuItem toggleRootItem;
49265874 CheckboxMenuItem animationItem;
5875
+ MenuItem archiveItem;
49275876 CheckboxMenuItem toggleHandleItem;
49285877 CheckboxMenuItem togglePaintItem;
49295878 JSplitPane mainPanel;
....@@ -4937,6 +5886,7 @@
49375886 ButtonGroup buttonGroup;
49385887
49395888 cGridBag toolboxPanel;
5889
+ cGridBag skyboxPanel;
49405890 cGridBag materialPanel;
49415891 cGridBag ctrlPanel;
49425892
....@@ -4945,6 +5895,8 @@
49455895 cGridBag optionsPanel;
49465896
49475897 JTabbedPane objectPanel;
5898
+ boolean materialFlushed;
5899
+ Object3D latestObject;
49485900
49495901 cGridBag XYZPanel;
49505902
....@@ -5008,7 +5960,7 @@
50085960 JLabel colorLabel;
50095961 cNumberSlider colorField;
50105962 JLabel modulationLabel;
5011
- cNumberSlider modulationField;
5963
+ cNumberSlider saturationField;
50125964 JLabel metalnessLabel;
50135965 cNumberSlider metalnessField;
50145966 JLabel diffuseLabel;
....@@ -5039,6 +5991,7 @@
50395991 cNumberSlider anisoField;
50405992 JLabel anisoVLabel;
50415993 cNumberSlider anisoVField;
5994
+
50425995 JLabel cameraLabel;
50435996 cNumberSlider cameraField;
50445997 JLabel selfshadowLabel;
....@@ -5053,6 +6006,7 @@
50536006 cNumberSlider fakedepthField;
50546007 JLabel shadowbiasLabel;
50556008 cNumberSlider shadowbiasField;
6009
+
50566010 JLabel bumpLabel;
50576011 cNumberSlider bumpField;
50586012 JLabel noiseLabel;