Normand Briere
2019-08-16 83d0c2fa0bd2e96448f776144e1a89cdb1bb6998
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
....@@ -350,7 +431,7 @@
350431 frame.setMenuBar(menuBar = new MenuBar());
351432 menuBar.add(fileMenu = new Menu("File"));
352433 fileMenu.add(newItem = new MenuItem("New"));
353
- fileMenu.add(loadItem = new MenuItem("Open..."));
434
+ fileMenu.add(openItem = new MenuItem("Open..."));
354435
355436 //oe.menuBar.add(menu = new Menu("Include"));
356437 Menu menu = new Menu("Import");
....@@ -382,7 +463,7 @@
382463 }
383464
384465 newItem.addActionListener(this);
385
- loadItem.addActionListener(this);
466
+ openItem.addActionListener(this);
386467 saveItem.addActionListener(this);
387468 saveAsItem.addActionListener(this);
388469 exportAsItem.addActionListener(this);
....@@ -394,6 +475,8 @@
394475
395476 ChangeListener changeListener = new ChangeListener()
396477 {
478
+ //String name;
479
+
397480 public void stateChanged(ChangeEvent changeEvent)
398481 {
399482 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -412,18 +495,49 @@
412495 // EditSelection(false);
413496 // }
414497
415
- refreshContents(false); // To refresh Info tab
498
+// if (objectPanel.getSelectedIndex() == 4)
499
+// {
500
+// name = copy.skyboxname;
501
+//
502
+// if (name == null)
503
+// {
504
+// name = "";
505
+// }
506
+//
507
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
508
+// copy.skyboxext = "jpg";
509
+// }
510
+// else
511
+// {
512
+// if (name != null)
513
+// {
514
+// if (name.equals(""))
515
+// {
516
+// copy.skyboxname = null;
517
+// copy.skyboxext = null;
518
+// }
519
+// else
520
+// {
521
+// copy.skyboxname = name;
522
+// }
523
+// }
524
+// }
525
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
526
+
527
+// refreshContents(false); // To refresh Info tab
528
+ cameraView.repaint();
416529 }
417530 };
418531 objectPanel.addChangeListener(changeListener);
419532
420533 toolbarPanel = new JPanel();
421534 toolbarPanel.setName("Toolbar");
535
+
422536 treePanel = new cGridBag();
423537 treePanel.setName("Tree");
424538
425539 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
540
+ //editPanel.setName("Edit");
427541
428542 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429543
....@@ -431,11 +545,13 @@
431545 editPanel.add(editCommandsPanel);
432546 editPanel.add(ctrlPanel);
433547
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
548
+ toolboxPanel = new cGridBag().setVertical(true);
549
+ //toolboxPanel.setName("Toolbox");
436550
437
- materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
551
+ skyboxPanel = new cGridBag().setVertical(true);
552
+
553
+ materialPanel = new cGridBag().setVertical(false);
554
+ //materialPanel.setName("Material");
439555
440556 /*JTextPane*/
441557 infoarea = createTextPane();
....@@ -443,14 +559,15 @@
443559
444560 infoarea.setEditable(true);
445561 SetText();
562
+
446563 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447564 // infoarea.setOpaque(false);
448565 // //infoarea.setForeground(textcolor);
449566 // TEXTAREA infoarea.setLineWrap(true);
450567 // TEXTAREA infoarea.setWrapStyleWord(true);
451568 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");
569
+ infoPanel.setPreferredSize(new Dimension(1, 1));
570
+ //infoPanel.setName("Info");
454571 //infoPanel.setLayout(new BorderLayout());
455572 //infoPanel.add(createTextPane());
456573
....@@ -699,8 +816,8 @@
699816 }
700817 }
701818
702
-static GraphicsDevice device = GraphicsEnvironment
703
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
819
+//static GraphicsDevice device = GraphicsEnvironment
820
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
704821
705822 Rectangle keeprect;
706823 cRadio radio;
....@@ -717,14 +834,24 @@
717834 boolean maximized;
718835
719836 cButton fullscreenLayout;
837
+ cButton expandedLayout;
720838
721839 void Minimize()
722840 {
723841 frame.setState(Frame.ICONIFIED);
842
+ frame.validate();
724843 }
725844
845
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
846
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
847
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
726848 void Maximize()
727849 {
850
+ if (CameraPane.FULLSCREEN)
851
+ {
852
+ ToggleFullScreen();
853
+ }
854
+
728855 if (maximized)
729856 {
730857 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -732,22 +859,38 @@
732859 else
733860 {
734861 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);
862
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
863
+// Dimension rect2 = frame.getToolkit().getScreenSize();
864
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
738865 // frame.setState(Frame.MAXIMIZED_BOTH);
866
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
739867 }
740868
741869 maximized ^= true;
870
+
871
+ frame.validate();
742872 }
873
+
874
+ cButton minButton;
875
+ cButton maxButton;
876
+ cButton fullButton;
877
+ cButton collapseButton;
878
+ cButton maximize3DButton;
743879
744880 void ToggleFullScreen()
745881 {
882
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
883
+
746884 cameraView.ToggleFullScreen();
747885
748886 if (!CameraPane.FULLSCREEN)
749887 {
750888 device.setFullScreenWindow(null);
889
+ frame.dispose();
890
+ frame.setUndecorated(false);
891
+ frame.validate();
892
+ frame.setVisible(true);
893
+
751894 //frame.setVisible(false);
752895 // frame.removeNotify();
753896 // frame.setUndecorated(false);
....@@ -757,13 +900,13 @@
757900 // X frame.getContentPane().remove(/*"Center",*/bigThree);
758901 // X framePanel.add(bigThree);
759902 // X frame.getContentPane().add(/*"Center",*/framePanel);
760
- framePanel.setDividerLocation(1);
903
+// framePanel.setDividerLocation(46); // icons are 24x24
761904
762905 //frame.setVisible(true);
763
- radio.layout = keepButton;
906
+// radio.layout = keepButton;
764907 //theFrame = null;
765908 keepButton = null;
766
- radio.layout.doClick();
909
+// radio.layout.doClick();
767910
768911 } else
769912 {
....@@ -772,20 +915,65 @@
772915 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
773916 // frame.getToolkit().getScreenSize().height);
774917 //frame.setVisible(false);
918
+
919
+ frame.dispose();
920
+ frame.setUndecorated(true);
775921 device.setFullScreenWindow(frame);
922
+ frame.validate();
923
+ frame.setVisible(true);
776924 // frame.removeNotify();
777925 // frame.setUndecorated(true);
778926 // frame.addNotify();
779927 // X frame.getContentPane().remove(/*"Center",*/framePanel);
780928 // X framePanel.remove(bigThree);
781929 // X frame.getContentPane().add(/*"Center",*/bigThree);
782
- framePanel.setDividerLocation(0);
930
+// framePanel.setDividerLocation(0);
783931
784
- radio.layout = fullscreenLayout;
785
- radio.layout.doClick();
932
+// radio.layout = fullscreenLayout;
933
+// radio.layout.doClick();
786934 //frame.setVisible(true);
787935 }
936
+ frame.validate();
937
+
938
+ cameraView.requestFocusInWindow();
788939 }
940
+
941
+ void CollapseToolbar()
942
+ {
943
+ framePanel.setDividerLocation(0);
944
+ //frame.validate();
945
+
946
+ cameraView.requestFocusInWindow();
947
+ }
948
+
949
+ private Object3D Duplicate(Object3D object)
950
+ {
951
+ boolean temp = CameraPane.SWITCH;
952
+ CameraPane.SWITCH = false;
953
+
954
+ if (Grafreed.grafreed.universe.versiontable == null)
955
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
956
+
957
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
958
+ // if (copy == client)
959
+
960
+ Object3D versions[] = object.versionlist;
961
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
962
+ object.versionlist = null;
963
+ object.versiontable = null;
964
+
965
+ //byte[] compress = Compress(copy);
966
+ Object3D compress = (Object3D)Grafreed.clone(object);
967
+
968
+ object.versionlist = versions;
969
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
970
+
971
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
972
+
973
+ CameraPane.SWITCH = temp;
974
+
975
+ return compress;
976
+ }
789977
790978 private JTextPane createTextPane()
791979 {
....@@ -908,6 +1096,7 @@
9081096 {
9091097 SetupMaterial(materialPanel);
9101098 }
1099
+
9111100 //SetupName();
9121101 //SetupViews();
9131102 }
....@@ -917,7 +1106,7 @@
9171106 // NumberSlider vDivsField;
9181107 // JCheckBox endcaps;
9191108 JCheckBox liveCB;
920
- JCheckBox selectCB;
1109
+ JCheckBox selectableCB;
9211110 JCheckBox hideCB;
9221111 JCheckBox link2masterCB;
9231112 JCheckBox markCB;
....@@ -1116,8 +1305,20 @@
11161305
11171306 namePanel = new cGridBag();
11181307
1308
+ //if (copy.pinned)
1309
+ {
1310
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1311
+ pinButton.setSelected(copy.pinned);
1312
+ cGridBag t = new cGridBag();
1313
+ t.preferredWidth = 2;
1314
+ t.add(pinButton);
1315
+ namePanel.add(t);
1316
+
1317
+ pinButton.addItemListener(this);
1318
+ }
1319
+
11191320 nameField = AddText(namePanel, copy.GetName());
1120
- namePanel.add(nameField);
1321
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11211322 oe.ctrlPanel.add(namePanel);
11221323
11231324 oe.ctrlPanel.Return();
....@@ -1129,26 +1330,30 @@
11291330
11301331 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11311332 liveCB.setToolTipText("Animate object");
1132
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1133
- selectCB.setToolTipText("Make object selectable");
1333
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1334
+ markCB.setToolTipText("Set target transform");
1335
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1336
+ selectableCB.setToolTipText("Make object selectable");
11341337 // Return();
1338
+
11351339 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11361340 hideCB.setToolTipText("Hide object");
1137
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1138
- markCB.setToolTipText("As animation target transform");
1341
+
1342
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11391343
11401344 setupPanel2 = new cGridBag().setVertical(false);
11411345
11421346 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11431347 rewindCB.setToolTipText("Rewind animation");
11441348
1145
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1349
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11461350 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11471351
1352
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1353
+ link2masterCB.setToolTipText("Attach to support");
1354
+
11481355 if (Globals.ADVANCED)
11491356 {
1150
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1151
- link2masterCB.setToolTipText("Attach to support");
11521357 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11531358 speedupCB.setToolTipText("Option motion capture");
11541359 }
....@@ -1334,6 +1539,7 @@
13341539
13351540 if (cam == null || !(copy.get(0) instanceof cGroup))
13361541 {
1542
+ if (Globals.DEBUG)
13371543 System.out.println("CREATE CAMERAS");
13381544 cams = new cTemplate();
13391545 cams.name = "Cameras";
....@@ -1422,6 +1628,7 @@
14221628 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14231629 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14241630 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1631
+ //XYZPanel.setName("XYZ");
14251632
14261633 /*
14271634 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1458,15 +1665,30 @@
14581665
14591666 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14601667 //tmp.setName("Edit");
1668
+ objectPanel.add(toolboxPanel);
1669
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1670
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
1671
+
14611672 objectPanel.add(materialPanel);
1673
+ objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1674
+ objectPanel.setToolTipTextAt(1, "Material");
1675
+
1676
+ objectPanel.add(skyboxPanel);
1677
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1678
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1679
+
14621680 // JPanel north = new JPanel(new BorderLayout());
14631681 // north.setName("Edit");
14641682 // north.add(ctrlPanel, BorderLayout.NORTH);
14651683 // objectPanel.add(north);
14661684 objectPanel.add(editPanel);
1467
- objectPanel.add(infoPanel);
1468
- objectPanel.add(toolboxPanel);
1469
-
1685
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1686
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1687
+
1688
+ objectPanel.add(XYZPanel);
1689
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1690
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1691
+
14701692 /*
14711693 aConstraints.gridx = 0;
14721694 aConstraints.gridwidth = 1;
....@@ -1486,7 +1708,7 @@
14861708 scrollpane.addMouseWheelListener(this); // Default not fast enough
14871709
14881710 /*JTabbedPane*/ scenePanel = new cGridBag();
1489
- scenePanel.preferredWidth = 6;
1711
+ scenePanel.preferredWidth = 5;
14901712
14911713 JTabbedPane tabbedPane = new JTabbedPane();
14921714 tabbedPane.add(scrollpane);
....@@ -1503,6 +1725,11 @@
15031725
15041726 scenePanel.add(tabbedPane);
15051727
1728
+ //if (Globals.ADVANCED)
1729
+// tabbedPane.add(infoPanel);
1730
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1731
+// tabbedPane.setToolTipTextAt(3, "Information");
1732
+
15061733 /*
15071734 cTree jTree = new cTree(null);
15081735 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1564,7 +1791,7 @@
15641791 bigThree = new cGridBag();
15651792 bigThree.addComponent(scenePanel);
15661793 bigThree.addComponent(centralPanel);
1567
- bigThree.addComponent(XYZPanel);
1794
+ //bigThree.addComponent(XYZPanel);
15681795
15691796 // // SIDE EFFECT!!!
15701797 // aConstraints.gridx = 0;
....@@ -1573,16 +1800,33 @@
15731800 // aConstraints.gridheight = 1;
15741801
15751802 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1576
- framePanel.setContinuousLayout(true);
1577
- framePanel.setOneTouchExpandable(true);
1578
- framePanel.setDividerLocation(0.8);
1803
+
1804
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1805
+ new java.beans.PropertyChangeListener()
1806
+ {
1807
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1808
+ {
1809
+ if ((Integer)pce.getOldValue() == 1)
1810
+ {
1811
+ if (radio.layout != expandedLayout)
1812
+ {
1813
+ radio.layout = expandedLayout;
1814
+ radio.layout.doClick();
1815
+ }
1816
+ }
1817
+ }
1818
+ });
1819
+
1820
+ framePanel.setContinuousLayout(false);
1821
+ framePanel.setOneTouchExpandable(false);
1822
+ //.setDividerLocation(0.8);
15791823 //framePanel.setDividerSize(15);
15801824 //framePanel.setResizeWeight(0.15);
15811825 framePanel.setName("Frame");
15821826
15831827 frame.getContentPane().setLayout(new BorderLayout());
15841828 /**/
1585
- JTabbedPane worldPane = new JTabbedPane();
1829
+ //JTabbedPane worldPane = new JTabbedPane();
15861830 //worldPane.add(bigPanel);
15871831 //worldPane.add(worldPanel);
15881832 /**/
....@@ -1594,17 +1838,17 @@
15941838
15951839 frame.setSize(1280, 860);
15961840
1597
- frame.validate();
1598
- frame.setVisible(true);
1599
-
16001841 cameraView.requestFocusInWindow();
16011842
16021843 gridPanel.setDividerLocation(1.0);
1844
+
1845
+ frame.validate();
1846
+
1847
+ frame.setVisible(true);
16031848
16041849 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16051850 frame.addWindowListener(new WindowAdapter()
16061851 {
1607
-
16081852 public void windowClosing(WindowEvent e)
16091853 {
16101854 Close();
....@@ -1627,12 +1871,418 @@
16271871 ctrlPanel.removeAll();
16281872 }
16291873
1630
- void SetupMaterial(cGridBag panel)
1874
+ void SetupMaterial(cGridBag materialpanel)
16311875 {
1632
- /*
1876
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1877
+
1878
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1879
+ skin.setToolTipText("Skin");
1880
+ skin.addMouseListener(new MouseAdapter()
1881
+ {
1882
+ public void mouseClicked(MouseEvent e)
1883
+ {
1884
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1885
+ cMaterial material = object.material;
1886
+
1887
+ // Skin
1888
+ colorField.setFloat(material.color);
1889
+ saturationField.setFloat(material.modulation);
1890
+ subsurfaceField.setFloat(material.subsurface);
1891
+ selfshadowField.setFloat(material.diffuseness);
1892
+ diffusenessField.setFloat(material.factor);
1893
+ shininessField.setFloat(material.shininess);
1894
+ shadowbiasField.setFloat(material.shadowbias);
1895
+ diffuseField.setFloat(material.diffuse);
1896
+ specularField.setFloat(material.specular);
1897
+
1898
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1899
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1900
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1901
+
1902
+ materialtouched = true;
1903
+ applySelf();
1904
+ }
1905
+ });
1906
+ presetpanel.add(skin);
1907
+
1908
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1909
+ lambert.setToolTipText("Diffuse");
1910
+ lambert.addMouseListener(new MouseAdapter()
1911
+ {
1912
+ public void mouseClicked(MouseEvent e)
1913
+ {
1914
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1915
+ cMaterial material = object.material;
1916
+
1917
+ diffusenessField.setFloat(material.factor);
1918
+ selfshadowField.setFloat(material.diffuseness);
1919
+
1920
+ materialtouched = true;
1921
+ applySelf();
1922
+ }
1923
+ });
1924
+ presetpanel.add(lambert);
1925
+
1926
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1927
+ diffuse2.setToolTipText("Diffuse2");
1928
+ diffuse2.addMouseListener(new MouseAdapter()
1929
+ {
1930
+ public void mouseClicked(MouseEvent e)
1931
+ {
1932
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1933
+ cMaterial material = object.material;
1934
+
1935
+ diffusenessField.setFloat(material.factor);
1936
+ selfshadowField.setFloat(material.diffuseness);
1937
+
1938
+ materialtouched = true;
1939
+ applySelf();
1940
+ }
1941
+ });
1942
+ presetpanel.add(diffuse2);
1943
+
1944
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1945
+ diffusemoon.setToolTipText("Moon");
1946
+ diffusemoon.addMouseListener(new MouseAdapter()
1947
+ {
1948
+ public void mouseClicked(MouseEvent e)
1949
+ {
1950
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1951
+ cMaterial material = object.material;
1952
+
1953
+ diffusenessField.setFloat(material.factor);
1954
+ selfshadowField.setFloat(material.diffuseness);
1955
+
1956
+ materialtouched = true;
1957
+ applySelf();
1958
+ }
1959
+ });
1960
+ presetpanel.add(diffusemoon);
1961
+
1962
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1963
+ diffusemoon2.setToolTipText("Moon2");
1964
+ diffusemoon2.addMouseListener(new MouseAdapter()
1965
+ {
1966
+ public void mouseClicked(MouseEvent e)
1967
+ {
1968
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1969
+ cMaterial material = object.material;
1970
+
1971
+ diffusenessField.setFloat(material.factor);
1972
+ selfshadowField.setFloat(material.diffuseness);
1973
+
1974
+ materialtouched = true;
1975
+ applySelf();
1976
+ }
1977
+ });
1978
+ presetpanel.add(diffusemoon2);
1979
+
1980
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1981
+ diffusemoon3.setToolTipText("Moon3");
1982
+ diffusemoon3.addMouseListener(new MouseAdapter()
1983
+ {
1984
+ public void mouseClicked(MouseEvent e)
1985
+ {
1986
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1987
+ cMaterial material = object.material;
1988
+
1989
+ diffusenessField.setFloat(material.factor);
1990
+ selfshadowField.setFloat(material.diffuseness);
1991
+
1992
+ materialtouched = true;
1993
+ applySelf();
1994
+ }
1995
+ });
1996
+ presetpanel.add(diffusemoon3);
1997
+
1998
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1999
+ diffusesheen.setToolTipText("Sheen");
2000
+ diffusesheen.addMouseListener(new MouseAdapter()
2001
+ {
2002
+ public void mouseClicked(MouseEvent e)
2003
+ {
2004
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2005
+ cMaterial material = object.material;
2006
+
2007
+ sheenField.setFloat(material.sheen);
2008
+
2009
+ materialtouched = true;
2010
+ applySelf();
2011
+ }
2012
+ });
2013
+ presetpanel.add(diffusesheen);
2014
+
2015
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2016
+ rough.setToolTipText("Rough metal");
2017
+ rough.addMouseListener(new MouseAdapter()
2018
+ {
2019
+ public void mouseClicked(MouseEvent e)
2020
+ {
2021
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2022
+ cMaterial material = object.material;
2023
+
2024
+ shininessField.setFloat(material.shininess);
2025
+ velvetField.setFloat(material.velvet);
2026
+
2027
+ materialtouched = true;
2028
+ applySelf();
2029
+ }
2030
+ });
2031
+ presetpanel.add(rough);
2032
+
2033
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2034
+ rough2.setToolTipText("Medium metal");
2035
+ rough2.addMouseListener(new MouseAdapter()
2036
+ {
2037
+ public void mouseClicked(MouseEvent e)
2038
+ {
2039
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2040
+ cMaterial material = object.material;
2041
+
2042
+ shininessField.setFloat(material.shininess);
2043
+ lightareaField.setFloat(material.lightarea);
2044
+
2045
+ materialtouched = true;
2046
+ applySelf();
2047
+ }
2048
+ });
2049
+ presetpanel.add(rough2);
2050
+
2051
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2052
+ shini0.setToolTipText("Shiny");
2053
+ shini0.addMouseListener(new MouseAdapter()
2054
+ {
2055
+ public void mouseClicked(MouseEvent e)
2056
+ {
2057
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2058
+ cMaterial material = object.material;
2059
+
2060
+ shininessField.setFloat(material.shininess);
2061
+ lightareaField.setFloat(material.lightarea);
2062
+
2063
+ materialtouched = true;
2064
+ applySelf();
2065
+ }
2066
+ });
2067
+ presetpanel.add(shini0);
2068
+
2069
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2070
+ shini1.setToolTipText("Shiny2");
2071
+ shini1.addMouseListener(new MouseAdapter()
2072
+ {
2073
+ public void mouseClicked(MouseEvent e)
2074
+ {
2075
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2076
+ cMaterial material = object.material;
2077
+
2078
+ shininessField.setFloat(material.shininess);
2079
+ lightareaField.setFloat(material.lightarea);
2080
+
2081
+ materialtouched = true;
2082
+ applySelf();
2083
+ }
2084
+ });
2085
+ presetpanel.add(shini1);
2086
+
2087
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2088
+ shini2.setToolTipText("Shiny3");
2089
+ shini2.addMouseListener(new MouseAdapter()
2090
+ {
2091
+ public void mouseClicked(MouseEvent e)
2092
+ {
2093
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2094
+ cMaterial material = object.material;
2095
+
2096
+ shininessField.setFloat(material.shininess);
2097
+ lightareaField.setFloat(material.lightarea);
2098
+
2099
+ materialtouched = true;
2100
+ applySelf();
2101
+ }
2102
+ });
2103
+ presetpanel.add(shini2);
2104
+
2105
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2106
+ aniso.setToolTipText("AnisoU");
2107
+ aniso.addMouseListener(new MouseAdapter()
2108
+ {
2109
+ public void mouseClicked(MouseEvent e)
2110
+ {
2111
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2112
+ cMaterial material = object.material;
2113
+
2114
+ anisoField.setFloat(material.aniso);
2115
+ anisoVField.setFloat(material.anisoV);
2116
+
2117
+ materialtouched = true;
2118
+ applySelf();
2119
+ }
2120
+ });
2121
+ presetpanel.add(aniso);
2122
+
2123
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2124
+ aniso2.setToolTipText("AnisoV");
2125
+ aniso2.addMouseListener(new MouseAdapter()
2126
+ {
2127
+ public void mouseClicked(MouseEvent e)
2128
+ {
2129
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2130
+ cMaterial material = object.material;
2131
+
2132
+ anisoField.setFloat(material.aniso);
2133
+ anisoVField.setFloat(material.anisoV);
2134
+
2135
+ materialtouched = true;
2136
+ applySelf();
2137
+ }
2138
+ });
2139
+ presetpanel.add(aniso2);
2140
+
2141
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2142
+ aniso3.setToolTipText("AnisoUV");
2143
+ aniso3.addMouseListener(new MouseAdapter()
2144
+ {
2145
+ public void mouseClicked(MouseEvent e)
2146
+ {
2147
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2148
+ cMaterial material = object.material;
2149
+
2150
+ anisoField.setFloat(material.aniso);
2151
+ anisoVField.setFloat(material.anisoV);
2152
+
2153
+ materialtouched = true;
2154
+ applySelf();
2155
+ }
2156
+ });
2157
+ presetpanel.add(aniso3);
2158
+
2159
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2160
+ velvet0.setToolTipText("Velvet");
2161
+ velvet0.addMouseListener(new MouseAdapter()
2162
+ {
2163
+ public void mouseClicked(MouseEvent e)
2164
+ {
2165
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2166
+ cMaterial material = object.material;
2167
+
2168
+ diffusenessField.setFloat(material.factor);
2169
+ selfshadowField.setFloat(material.diffuseness);
2170
+ sheenField.setFloat(material.sheen);
2171
+ shininessField.setFloat(material.shininess);
2172
+ velvetField.setFloat(material.velvet);
2173
+ shiftField.setFloat(material.shift);
2174
+
2175
+ materialtouched = true;
2176
+ applySelf();
2177
+ }
2178
+ });
2179
+ presetpanel.add(velvet0);
2180
+
2181
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2182
+ bump0.setToolTipText("Bump texture");
2183
+ bump0.addMouseListener(new MouseAdapter()
2184
+ {
2185
+ public void mouseClicked(MouseEvent e)
2186
+ {
2187
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2188
+ cMaterial material = object.material;
2189
+
2190
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2191
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2192
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2193
+
2194
+ materialtouched = true;
2195
+ applySelf();
2196
+ }
2197
+ });
2198
+ presetpanel.add(bump0);
2199
+
2200
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2201
+ borderShader.setToolTipText("Border fade");
2202
+ borderShader.addMouseListener(new MouseAdapter()
2203
+ {
2204
+ public void mouseClicked(MouseEvent e)
2205
+ {
2206
+ borderfadeField.setFloat(0.5);
2207
+ opacityField.setFloat(0.75);
2208
+
2209
+ materialtouched = true;
2210
+ applySelf();
2211
+ }
2212
+ });
2213
+ presetpanel.add(borderShader);
2214
+
2215
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2216
+ halo.setToolTipText("Halo");
2217
+ halo.addMouseListener(new MouseAdapter()
2218
+ {
2219
+ public void mouseClicked(MouseEvent e)
2220
+ {
2221
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2222
+ cMaterial material = object.material;
2223
+
2224
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2225
+
2226
+ materialtouched = true;
2227
+ applySelf();
2228
+ }
2229
+ });
2230
+ presetpanel.add(halo);
2231
+
2232
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2233
+ candle.setToolTipText("Candle");
2234
+ candle.addMouseListener(new MouseAdapter()
2235
+ {
2236
+ public void mouseClicked(MouseEvent e)
2237
+ {
2238
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2239
+ cMaterial material = object.material;
2240
+
2241
+ subsurfaceField.setFloat(material.subsurface);
2242
+ shadowbiasField.setFloat(material.shadowbias);
2243
+ ambientField.setFloat(material.ambient);
2244
+ specularField.setFloat(material.specular);
2245
+ lightareaField.setFloat(material.lightarea);
2246
+ shininessField.setFloat(material.shininess);
2247
+
2248
+ materialtouched = true;
2249
+ applySelf();
2250
+ }
2251
+ });
2252
+ presetpanel.add(candle);
2253
+
2254
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2255
+ shadowShader.setToolTipText("Shadow");
2256
+ shadowShader.addMouseListener(new MouseAdapter()
2257
+ {
2258
+ public void mouseClicked(MouseEvent e)
2259
+ {
2260
+ diffuseField.setFloat(0.001);
2261
+ ambientField.setFloat(0.001);
2262
+ cameraField.setFloat(0.001);
2263
+ specularField.setFloat(0.001);
2264
+ fakedepthField.setFloat(0.001);
2265
+ opacityField.setFloat(0.6);
2266
+
2267
+ materialtouched = true;
2268
+ applySelf();
2269
+ }
2270
+ });
2271
+ presetpanel.add(shadowShader);
2272
+
2273
+ cGridBag panel = new cGridBag().setVertical(true);
2274
+
2275
+ presetpanel.preferredWidth = 1;
2276
+
2277
+ materialpanel.add(presetpanel);
2278
+ materialpanel.add(panel);
2279
+
2280
+ panel.preferredWidth = 8;
2281
+
2282
+ /*
16332283 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16342284 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1635
- */
2285
+ */
16362286
16372287 cGridBag editBar = new cGridBag().setVertical(false);
16382288
....@@ -1666,45 +2316,61 @@
16662316 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16672317
16682318 cGridBag colorSection = new cGridBag().setVertical(true);
2319
+
2320
+ cGridBag huepanel = new cGridBag();
2321
+ cGridBag huelabel = new cGridBag();
2322
+ cLabel hue = GetLabel("icons/hue.png", false);
2323
+ hue.fit = true;
2324
+
2325
+ hue.addMouseListener(new MouseAdapter()
2326
+ {
2327
+ public void mousePressed(MouseEvent e)
2328
+ {
2329
+ int x = e.getX();
2330
+
2331
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2332
+ }
2333
+ });
2334
+
2335
+ huelabel.add(hue);
2336
+ huelabel.preferredWidth = 20;
2337
+ huepanel.add(new cGridBag()); // Label
2338
+ huepanel.add(huelabel); // Field/slider
2339
+
2340
+ huepanel.preferredHeight = 7;
2341
+
2342
+ colorSection.add(huepanel);
16692343
16702344 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);
2345
+
2346
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2347
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2348
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2349
+
16742350 //colorField.preferredWidth = 200;
16752351 colorSection.add(color);
16762352
16772353 cGridBag modulation = new cGridBag();
16782354 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16792355 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1680
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2356
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16812357 colorSection.add(modulation);
16822358
2359
+ cGridBag opacity = new cGridBag();
2360
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2361
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2362
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2363
+ colorSection.add(opacity);
2364
+
2365
+ colorSection.add(GetSeparator());
2366
+
16832367 cGridBag texture = new cGridBag();
16842368 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16852369 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16862370 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16872371 colorSection.add(texture);
16882372
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());
2373
+ panel.add(GetSeparator());
17082374
17092375 panel.add(colorSection);
17102376
....@@ -1754,7 +2420,13 @@
17542420 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17552421 diffuseSection.add(fakedepth);
17562422
1757
- panel.add(new JSeparator());
2423
+ cGridBag shadowbias = new cGridBag();
2424
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2425
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2426
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2427
+ diffuseSection.add(shadowbias);
2428
+
2429
+ panel.add(GetSeparator());
17582430
17592431 panel.add(diffuseSection);
17602432
....@@ -1804,42 +2476,48 @@
18042476 // aConstraints.gridy += 1;
18052477 // aConstraints.gridwidth = 1;
18062478
2479
+ cGridBag anisoU = new cGridBag();
2480
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2481
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2482
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2483
+ specularSection.add(anisoU);
18072484
1808
- panel.add(new JSeparator());
2485
+ cGridBag anisoV = new cGridBag();
2486
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2487
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2488
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2489
+ specularSection.add(anisoV);
2490
+
2491
+
2492
+ panel.add(GetSeparator());
18092493
18102494 panel.add(specularSection);
18112495
18122496 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18132497
1814
- cGridBag globalSection = new cGridBag().setVertical(true);
2498
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18152499
18162500 cGridBag camera = new cGridBag();
18172501 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18182502 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18192503 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1820
- globalSection.add(camera);
2504
+ colorSection.add(camera);
18212505
18222506 cGridBag ambient = new cGridBag();
18232507 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18242508 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18252509 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1826
- globalSection.add(ambient);
2510
+ colorSection.add(ambient);
18272511
18282512 cGridBag backlit = new cGridBag();
18292513 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18302514 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18312515 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1832
- globalSection.add(backlit);
2516
+ colorSection.add(backlit);
18332517
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());
2518
+ //panel.add(new JSeparator());
18412519
1842
- panel.add(globalSection);
2520
+ //panel.add(globalSection);
18432521
18442522 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18452523
....@@ -1881,7 +2559,7 @@
18812559 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18822560 textureSection.add(opacityPower);
18832561
1884
- panel.add(new JSeparator());
2562
+ panel.add(GetSeparator());
18852563
18862564 panel.add(textureSection);
18872565
....@@ -1946,8 +2624,9 @@
19462624 // 3D models
19472625 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19482626 {
1949
- lastConverter = new com.jmex.model.converters.MaxToJme();
1950
- LoadFile(filename, lastConverter);
2627
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2628
+ //LoadFile(filename, lastConverter);
2629
+ LoadObjFile(filename); // New 3ds loader
19512630 continue;
19522631 }
19532632 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2673,6 +3352,7 @@
26733352 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26743353 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26753354 }
3355
+
26763356 //cJME.count++;
26773357 //cJME.count %= 12;
26783358 if (gc)
....@@ -2856,6 +3536,7 @@
28563536 }
28573537 }
28583538 }
3539
+
28593540 cFileSystemPane FSPane;
28603541
28613542 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2865,7 +3546,7 @@
28653546
28663547 freezematerial = true;
28673548 colorField.setFloat(mat.color);
2868
- modulationField.setFloat(mat.modulation);
3549
+ saturationField.setFloat(mat.modulation);
28693550 metalnessField.setFloat(mat.metalness);
28703551 diffuseField.setFloat(mat.diffuse);
28713552 specularField.setFloat(mat.specular);
....@@ -2909,6 +3590,7 @@
29093590 }
29103591 }
29113592 }
3593
+
29123594 freezematerial = false;
29133595 }
29143596
....@@ -2926,32 +3608,8 @@
29263608
29273609 if (multiplyToggle != null)
29283610 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
- }
3611
+
3612
+ AllocProjectedVertices(object);
29553613
29563614 SetMaterial(mat, object.projectedVertices);
29573615 }
....@@ -3071,6 +3729,17 @@
30713729 public void itemStateChanged(ItemEvent event)
30723730 {
30733731 // System.out.println("Propagate = " + propagate);
3732
+ if (event.getSource() == pinButton)
3733
+ {
3734
+ copy.pinned ^= true;
3735
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3736
+ {
3737
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3738
+ copy.CloseUI();
3739
+ //copy.editWindow.refreshContents();
3740
+ }
3741
+ }
3742
+ else
30743743 if (event.getSource() == propagateToggle)
30753744 {
30763745 propagate ^= true;
....@@ -3175,8 +3844,9 @@
31753844 } else if (event.getSource() == liveCB)
31763845 {
31773846 copy.live ^= true;
3847
+ objEditor.refreshContents(true); // To show item colors
31783848 return;
3179
- } else if (event.getSource() == selectCB)
3849
+ } else if (event.getSource() == selectableCB)
31803850 {
31813851 copy.dontselect ^= true;
31823852 return;
....@@ -3184,7 +3854,7 @@
31843854 {
31853855 copy.hide ^= true;
31863856 copy.Touch(); // display list issue
3187
- objEditor.refreshContents();
3857
+ objEditor.refreshContents(true); // To show item colors
31883858 return;
31893859 } else if (event.getSource() == link2masterCB)
31903860 {
....@@ -3249,7 +3919,7 @@
32493919 //System.out.println("ObjEditor " + event);
32503920 applySelf0(true);
32513921 //parent.applySelf();
3252
- objEditor.refreshContents();
3922
+ // conflicts with requestFocus objEditor.refreshContents();
32533923 } else if (source == resetButton)
32543924 {
32553925 CameraPane.fullreset = true;
....@@ -3361,9 +4031,9 @@
33614031 {
33624032 Close();
33634033 //return true;
3364
- } else if (source == loadItem)
4034
+ } else if (source == openItem)
33654035 {
3366
- load();
4036
+ Open();
33674037 //return true;
33684038 } else if (source == newItem)
33694039 {
....@@ -3388,6 +4058,10 @@
33884058 {
33894059 generatePOV();
33904060 //return true;
4061
+ } else if (event.getSource() == archiveItem)
4062
+ {
4063
+ cTools.Archive(frame);
4064
+ return;
33914065 } else if (source == zBufferItem)
33924066 {
33934067 try
....@@ -3436,11 +4110,12 @@
34364110
34374111 static public byte[] Compress(Object3D o)
34384112 {
4113
+ // Slower to actually compress.
34394114 try
34404115 {
34414116 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3442
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3443
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4117
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4118
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34444119
34454120 Object3D parent = o.parent;
34464121 o.parent = null;
....@@ -3451,10 +4126,14 @@
34514126
34524127 out.flush();
34534128
3454
- zstream.close();
4129
+ baos //zstream
4130
+ .close();
34554131 out.close();
34564132
3457
- return baos.toByteArray();
4133
+ byte[] bytes = baos.toByteArray();
4134
+
4135
+ System.out.println("save #bytes = " + bytes.length);
4136
+ return bytes;
34584137 } catch (Exception e)
34594138 {
34604139 System.err.println(e);
....@@ -3464,13 +4143,16 @@
34644143
34654144 static public Object Uncompress(byte[] bytes)
34664145 {
3467
- System.out.println("#bytes = " + bytes.length);
4146
+ System.out.println("restore #bytes = " + bytes.length);
34684147 try
34694148 {
34704149 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3471
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3472
- ObjectInputStream in = new ObjectInputStream(istream);
4150
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4151
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34734152 Object obj = in.readObject();
4153
+
4154
+ bais //istream
4155
+ .close();
34744156 in.close();
34754157
34764158 return obj;
....@@ -3525,41 +4207,97 @@
35254207 return null;
35264208 }
35274209
3528
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35294210
35304211 public void Save()
35314212 {
4213
+ //Save(true);
4214
+ Replace();
4215
+ SetVersionStates();
4216
+ }
4217
+
4218
+ private boolean Equal(byte[] compress, byte[] name)
4219
+ {
4220
+ if (compress.length != name.length)
4221
+ {
4222
+ return false;
4223
+ }
4224
+
4225
+ for (int i=compress.length; --i>=0;)
4226
+ {
4227
+ if (compress[i] != name[i])
4228
+ return false;
4229
+ }
4230
+
4231
+ return true;
4232
+ }
4233
+
4234
+ void DeleteVersion()
4235
+ {
4236
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4237
+ {
4238
+ copy.versionlist[i] = copy.versionlist[i+1];
4239
+ }
4240
+
4241
+ if (copy.versionlist[copy.versionindex] == null)
4242
+ copy.versionindex -= 1;
4243
+
4244
+ if (copy.versionindex != -1)
4245
+ CopyChanged();
4246
+
4247
+ SetVersionStates();
4248
+ }
4249
+
4250
+ public boolean Save(boolean user)
4251
+ {
35324252 System.err.println("Save");
4253
+ Replace();
35334254
3534
- cRadio tab = GetCurrentTab();
4255
+ //cRadio tab = GetCurrentTab();
35354256
3536
- boolean temp = CameraPane.SWITCH;
3537
- CameraPane.SWITCH = false;
4257
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
35384258
3539
- copy.ExtractBigData(hashtable);
4259
+ boolean thesame = false;
4260
+
4261
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4262
+// {
4263
+// thesame = true;
4264
+// }
35404265
35414266 //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++)
4267
+ if (!thesame)
35514268 {
3552
- tab.graphs[i] = null;
4269
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4270
+ {
4271
+ copy.versionlist[i] = copy.versionlist[i-1];
4272
+ }
4273
+
4274
+ //tab.user[tab.versionindex] = user;
4275
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4276
+
4277
+ copy.versionlist[++copy.versionindex] = compress;
4278
+
4279
+ // if (increment)
4280
+ // tab.versionindex++;
35534281 }
35544282
3555
- SetUndoStates();
4283
+ //copy.RestoreBigData(versiontable);
4284
+
4285
+ //assert(hashtable.isEmpty());
4286
+
4287
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4288
+// {
4289
+// //tab.user[i] = false;
4290
+// copy.versionlist[i] = null;
4291
+// }
4292
+
4293
+ SetVersionStates();
35564294
35574295 // test save
35584296 if (false)
35594297 {
35604298 try
35614299 {
3562
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4300
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35634301 ObjectOutputStream p = new ObjectOutputStream(ostream);
35644302
35654303 p.writeObject(copy);
....@@ -3572,28 +4310,68 @@
35724310 e.printStackTrace();
35734311 }
35744312 }
4313
+
4314
+ return !thesame;
4315
+ }
4316
+
4317
+ boolean flashIt = true;
4318
+
4319
+ void RefreshSelection()
4320
+ {
4321
+ Object3D selection = new Object3D();
4322
+
4323
+ for (int i = 0; i < copy.selection.size(); i++)
4324
+ {
4325
+ Object3D elem = copy.selection.elementAt(i);
4326
+
4327
+ Object3D obj = copy.GetObject(elem.GetUUID());
4328
+
4329
+ if (obj == null)
4330
+ {
4331
+ copy.selection.remove(i--);
4332
+ }
4333
+ else
4334
+ {
4335
+ selection.add(obj);
4336
+ copy.selection.setElementAt(obj, i);
4337
+ }
4338
+ }
4339
+
4340
+ flashIt = false;
4341
+ GetTree().clearSelection();
4342
+ for (int i = 0; i < selection.size(); i++)
4343
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4344
+ flashIt = true;
4345
+
4346
+ //refreshContents(false);
35754347 }
35764348
3577
- void CopyChanged(Object3D obj)
4349
+ void CopyChanged()
35784350 {
3579
- SetUndoStates();
4351
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4352
+
4353
+ SetVersionStates();
35804354
35814355 boolean temp = CameraPane.SWITCH;
35824356 CameraPane.SWITCH = false;
35834357
3584
- copy.ExtractBigData(hashtable);
4358
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
35854359
35864360 copy.clear();
35874361
4362
+ copy.skyboxname = obj.skyboxname;
4363
+ copy.skyboxext = obj.skyboxext;
4364
+
35884365 for (int i=0; i<obj.Size(); i++)
35894366 {
35904367 copy.add(obj.get(i));
35914368 }
35924369
3593
- copy.RestoreBigData(hashtable);
4370
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
35944371
35954372 CameraPane.SWITCH = temp;
35964373
4374
+ RefreshSelection();
35974375 //assert(hashtable.isEmpty());
35984376
35994377 copy.Touch();
....@@ -3614,56 +4392,144 @@
36144392 }
36154393 }
36164394
3617
- refreshContents();
4395
+ refreshContents(true);
36184396 }
36194397
3620
- cButton undoButton;
3621
- cButton redoButton;
4398
+ cButton previousVersionButton;
4399
+ cButton restoreButton;
4400
+ cButton replaceButton;
4401
+ cButton nextVersionButton;
4402
+ cButton saveVersionButton;
4403
+ cButton deleteVersionButton;
36224404
3623
- void SetUndoStates()
4405
+ boolean muteSlider;
4406
+
4407
+ int VersionCount()
36244408 {
3625
- cRadio tab = GetCurrentTab();
4409
+ int count = 0;
36264410
3627
- undoButton.setEnabled(tab.undoindex > 0);
3628
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
4411
+ for (int i = copy.versionlist.length; --i >= 0;)
4412
+ {
4413
+ if (copy.versionlist[i] != null)
4414
+ count++;
4415
+ }
4416
+
4417
+ return count;
36294418 }
36304419
3631
- public void Undo()
4420
+ void SetVersionStates()
36324421 {
4422
+ //if (true)
4423
+ // return;
4424
+
4425
+ //cRadio tab = GetCurrentTab();
4426
+
4427
+ restoreButton.setEnabled(copy.versionindex != -1);
4428
+ replaceButton.setEnabled(copy.versionindex != -1);
4429
+
4430
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4431
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4432
+
4433
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4434
+ //copy.versionlist[copy.versionindex + 1] != null);
4435
+
4436
+ muteSlider = true;
4437
+ versionSlider.setMinimum(0);
4438
+ versionSlider.setMaximum(VersionCount() - 1);
4439
+ versionSlider.setInteger(copy.versionindex);
4440
+ versionSlider.setEnabled(copy.versionindex != -1);
4441
+ muteSlider = false;
4442
+ }
4443
+
4444
+ public boolean PreviousVersion()
4445
+ {
4446
+ // Option?
4447
+ Replace();
4448
+
36334449 System.err.println("Undo");
36344450
3635
- cRadio tab = GetCurrentTab();
4451
+ //cRadio tab = GetCurrentTab();
36364452
3637
- if (tab.undoindex == 0)
4453
+ if (copy.versionindex == 0)
36384454 {
36394455 java.awt.Toolkit.getDefaultToolkit().beep();
3640
- return;
4456
+ return false;
36414457 }
36424458
3643
- if (tab.graphs[tab.undoindex] == null)
3644
- {
3645
- Save();
3646
- tab.undoindex -= 1;
3647
- }
4459
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4460
+// {
4461
+// if (Save(false))
4462
+// tab.versionindex -= 1;
4463
+// else
4464
+// {
4465
+// if (tab.versionindex <= 0)
4466
+// return false;
4467
+// else
4468
+// tab.versionindex -= 1;
4469
+// }
4470
+// }
36484471
3649
- tab.undoindex -= 1;
4472
+ copy.versionindex -= 1;
36504473
3651
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4474
+ CopyChanged();
4475
+
4476
+ return true;
36524477 }
36534478
3654
- public void Redo()
4479
+ public boolean Restore()
36554480 {
3656
- cRadio tab = GetCurrentTab();
4481
+ System.err.println("Restore");
36574482
3658
- if (tab.graphs[tab.undoindex + 1] == null)
4483
+ //cRadio tab = GetCurrentTab();
4484
+
4485
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4486
+ {
4487
+ java.awt.Toolkit.getDefaultToolkit().beep();
4488
+ return false;
4489
+ }
4490
+
4491
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4492
+ CopyChanged();
4493
+
4494
+ return true;
4495
+ }
4496
+
4497
+ public boolean Replace()
4498
+ {
4499
+ //System.err.println("Replace");
4500
+
4501
+ //cRadio tab = GetCurrentTab();
4502
+
4503
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4504
+ {
4505
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4506
+ return false;
4507
+ }
4508
+
4509
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4510
+
4511
+ return true;
4512
+ }
4513
+
4514
+ public void NextVersion()
4515
+ {
4516
+ // Option?
4517
+ Replace();
4518
+
4519
+ //cRadio tab = GetCurrentTab();
4520
+
4521
+ if (copy.versionlist[copy.versionindex + 1] == null)
36594522 {
36604523 java.awt.Toolkit.getDefaultToolkit().beep();
36614524 return;
36624525 }
36634526
3664
- tab.undoindex += 1;
4527
+ copy.versionindex += 1;
36654528
3666
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4529
+ CopyChanged();
4530
+
4531
+ //if (!tab.user[tab.versionindex])
4532
+ // tab.graphs[tab.versionindex] = null;
36674533 }
36684534
36694535 void ImportGFD()
....@@ -3874,7 +4740,7 @@
38744740 //copy.material = new cMaterial(copy.GetMaterial());
38754741
38764742 current.color = (float) colorField.getFloat();
3877
- current.modulation = (float) modulationField.getFloat();
4743
+ current.modulation = (float) saturationField.getFloat();
38784744 current.metalness = (float) metalnessField.getFloat();
38794745 current.diffuse = (float) diffuseField.getFloat();
38804746 current.specular = (float) specularField.getFloat();
....@@ -3907,7 +4773,7 @@
39074773 cMaterial mat = copy.material;
39084774
39094775 colorField.SetToolTipValue((mat.color));
3910
- modulationField.SetToolTipValue((mat.modulation));
4776
+ saturationField.SetToolTipValue((mat.modulation));
39114777 metalnessField.SetToolTipValue((mat.metalness));
39124778 diffuseField.SetToolTipValue((mat.diffuse));
39134779 specularField.SetToolTipValue((mat.specular));
....@@ -3959,9 +4825,28 @@
39594825 //copy.Touch();
39604826 }
39614827
4828
+ cNumberSlider versionSlider;
4829
+
39624830 public void stateChanged(ChangeEvent e)
39634831 {
39644832 // assert(false);
4833
+ if (e.getSource() == versionSlider)
4834
+ {
4835
+ if (muteSlider)
4836
+ return;
4837
+
4838
+ Replace();
4839
+
4840
+ int version = versionSlider.getInteger();
4841
+
4842
+ if (version != -1 && copy.versionlist[version] != null)
4843
+ {
4844
+ copy.versionindex = version;
4845
+ CopyChanged();
4846
+ }
4847
+
4848
+ return;
4849
+ }
39654850
39664851 if (freezematerial)
39674852 {
....@@ -3997,6 +4882,12 @@
39974882 {
39984883 //System.out.println("stateChanged = " + this);
39994884 materialtouched = true;
4885
+
4886
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4887
+ {
4888
+ saturationField.setFloat(1);
4889
+ }
4890
+
40004891 applySelf();
40014892 //System.out.println("this = " + this);
40024893 //System.out.println("PARENT = " + parent);
....@@ -4296,6 +5187,7 @@
42965187 {
42975188 if (GetTree() != null)
42985189 {
5190
+ GetTree().revalidate();
42995191 GetTree().repaint();
43005192 }
43015193
....@@ -4304,13 +5196,18 @@
43045196 ctrlPanel.validate(); // ? new
43055197 ctrlPanel.repaint();
43065198 }
5199
+
5200
+ if (previousVersionButton != null && copy.versionlist != null)
5201
+ SetVersionStates();
5202
+
5203
+ cameraView.requestFocusInWindow();
43075204 }
43085205
43095206 static TweenManager tweenManager = new TweenManager();
43105207
43115208 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43125209 {
4313
- if (Globals.SAVEONMAKE) // && resetmodel)
5210
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43145211 Save();
43155212 //Tween.set(thing, 0).target(1).start(tweenManager);
43165213 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4335,7 +5232,7 @@
43355232 // group = (Composite) group.get(0);
43365233 // }
43375234
4338
- System.out.println("makeSomething of " + thing);
5235
+ //System.out.println("makeSomething of " + thing);
43395236
43405237 /*
43415238 if (deselect && jList != null)
....@@ -4552,7 +5449,9 @@
45525449 readobj.ResetDisplayList();
45535450 } catch (Exception e)
45545451 {
4555
- //e.printStackTrace();
5452
+ if (!e.toString().contains("GZIP"))
5453
+ e.printStackTrace();
5454
+
45565455 try
45575456 {
45585457 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4626,12 +5525,14 @@
46265525
46275526 if (readobj != null)
46285527 {
4629
- if (Globals.SAVEONMAKE)
4630
- Save();
5528
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5529
+ // Save();
46315530 try
46325531 {
46335532 //readobj.deepCopySelf(copy);
46345533 copy.clear(); // june 2014
5534
+ copy.skyboxname = readobj.skyboxname;
5535
+ copy.skyboxext = readobj.skyboxext;
46355536 for (int i = 0; i < readobj.size(); i++)
46365537 {
46375538 Object3D child = readobj.get(i); // reserve(i);
....@@ -4672,6 +5573,7 @@
46725573 }
46735574 } catch (ClassCastException e)
46745575 {
5576
+ e.printStackTrace();
46755577 assert (false);
46765578 Composite c = (Composite) copy;
46775579 c.children.clear();
....@@ -4682,17 +5584,32 @@
46825584 c.addChild(csg);
46835585 }
46845586
5587
+ copy.versionlist = readobj.versionlist;
5588
+ copy.versionindex = readobj.versionindex;
5589
+ copy.versiontable = readobj.versiontable;
5590
+
5591
+ if (copy.versionlist == null)
5592
+ {
5593
+ // Backward compatibility
5594
+ copy.versionlist = new Object3D[100];
5595
+ copy.versionindex = -1;
5596
+
5597
+ //Save(true);
5598
+ }
5599
+
5600
+ //? SetUndoStates();
5601
+
46855602 ResetModel();
46865603 copy.HardTouch(); // recompile?
46875604 refreshContents();
46885605 }
46895606 }
46905607
4691
- void load() // throws ClassNotFoundException
5608
+ void Open() // throws ClassNotFoundException
46925609 {
46935610 if (Grafreed.standAlone)
46945611 {
4695
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5612
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
46965613 browser.show();
46975614 String filename = browser.getFile();
46985615 if (filename != null && filename.length() > 0)
....@@ -4769,6 +5686,8 @@
47695686
47705687 void save()
47715688 {
5689
+ Replace();
5690
+
47725691 if (lastname == null)
47735692 {
47745693 return;
....@@ -4791,6 +5710,7 @@
47915710 //ps.print(buffer.toString());
47925711 } catch (IOException e)
47935712 {
5713
+ e.printStackTrace();
47945714 }
47955715 }
47965716
....@@ -4973,7 +5893,7 @@
49735893 MenuBar menuBar;
49745894 Menu fileMenu;
49755895 MenuItem newItem;
4976
- MenuItem loadItem;
5896
+ MenuItem openItem;
49775897 MenuItem saveItem;
49785898 MenuItem saveAsItem;
49795899 MenuItem exportAsItem;
....@@ -4996,6 +5916,7 @@
49965916 CheckboxMenuItem toggleSwitchItem;
49975917 CheckboxMenuItem toggleRootItem;
49985918 CheckboxMenuItem animationItem;
5919
+ MenuItem archiveItem;
49995920 CheckboxMenuItem toggleHandleItem;
50005921 CheckboxMenuItem togglePaintItem;
50015922 JSplitPane mainPanel;
....@@ -5009,6 +5930,7 @@
50095930 ButtonGroup buttonGroup;
50105931
50115932 cGridBag toolboxPanel;
5933
+ cGridBag skyboxPanel;
50125934 cGridBag materialPanel;
50135935 cGridBag ctrlPanel;
50145936
....@@ -5082,7 +6004,7 @@
50826004 JLabel colorLabel;
50836005 cNumberSlider colorField;
50846006 JLabel modulationLabel;
5085
- cNumberSlider modulationField;
6007
+ cNumberSlider saturationField;
50866008 JLabel metalnessLabel;
50876009 cNumberSlider metalnessField;
50886010 JLabel diffuseLabel;
....@@ -5113,6 +6035,7 @@
51136035 cNumberSlider anisoField;
51146036 JLabel anisoVLabel;
51156037 cNumberSlider anisoVField;
6038
+
51166039 JLabel cameraLabel;
51176040 cNumberSlider cameraField;
51186041 JLabel selfshadowLabel;
....@@ -5127,6 +6050,7 @@
51276050 cNumberSlider fakedepthField;
51286051 JLabel shadowbiasLabel;
51296052 cNumberSlider shadowbiasField;
6053
+
51306054 JLabel bumpLabel;
51316055 cNumberSlider bumpField;
51326056 JLabel noiseLabel;