Normand Briere
2019-08-20 7dc9a8879ed29a7693d617afcb48014504ddc4a9
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,51 +42,137 @@
3842 JFrame frame;
3943
4044 static ObjEditor theFrame;
45
+
46
+ public void AllocProjectedVertices(Object3D object)
47
+ {
48
+ assert (object.projectedVertices != null);
49
+
50
+ if (object.projectedVertices.length <= 2)
51
+ {
52
+ // Side effect...
53
+ Object3D.cVector2[] keep = object.projectedVertices;
54
+ object.projectedVertices = new Object3D.cVector2[3];
55
+ for (int i = 0; i < 3; i++)
56
+ {
57
+ if (i < keep.length)
58
+ {
59
+ object.projectedVertices[i] = keep[i];
60
+ } else
61
+ {
62
+ object.projectedVertices[i] = new Object3D.cVector2();
63
+ }
64
+ /*
65
+ if(keep.length == 0)
66
+ object.projectedVertices[0] = new Object3D.cVector2();
67
+ else
68
+ object.projectedVertices[0] = keep[0];
69
+ object.projectedVertices[1] = new Object3D.cVector2();
70
+ */
71
+ }
72
+ }
73
+ }
74
+
75
+ public Composite CreateCameras()
76
+ {
77
+ Composite cams = new cTemplate();
78
+ cams.name = "Cameras";
79
+ copy.insertElementAt(cams, 0);
80
+
81
+ cams.addChild(new Camera());
82
+ cams.addChild(new Camera(1));
83
+ cams.addChild(new Camera(2));
84
+ cams.addChild(new Camera(3));
85
+ cams.addChild(new Camera(4));
86
+
87
+ return cams;
88
+ }
89
+
90
+ public cGridBag GetSeparator()
91
+ {
92
+ cGridBag separator = new cGridBag();
93
+ separator.add(new JSeparator());
94
+ separator.preferredHeight = 5;
95
+ return separator;
96
+ }
4197
4298 cButton GetButton(String name, boolean border)
4399 {
44
- try
45
- {
46
- ImageIcon icon = GetIcon(name);
100
+ ImageIcon icon = GetIcon(name);
101
+ if (icon != null || name.contains("/"))
47102 return new cButton(icon, border);
48
- }
49
- catch (Exception e)
50
- {
103
+ else
51104 return new cButton(name, border);
52
- }
105
+ }
106
+
107
+ cLabel GetLabel(String name, boolean border)
108
+ {
109
+ //ImageIcon icon = GetIcon(name);
110
+ return new cLabel(GetImage(name), border);
111
+ }
112
+
113
+ cToggleButton GetToggleButton(String name, boolean border)
114
+ {
115
+ ImageIcon icon = GetIcon(name);
116
+ return new cToggleButton(icon, border);
53117 }
54118
55119 cCheckBox GetCheckBox(String name, boolean border)
56120 {
121
+ ImageIcon icon = GetIcon(name);
122
+ return new cCheckBox(icon, border);
123
+ }
124
+
125
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
126
+
127
+ static ImageIcon GetIcon(String name)
128
+ {
129
+ javax.swing.ImageIcon iconCache = icons.get(name);
130
+ if (iconCache != null)
131
+ {
132
+ return iconCache;
133
+ }
134
+
57135 try
58136 {
59
- ImageIcon icon = GetIcon(name);
60
- return new cCheckBox(icon, border);
137
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
138
+
139
+// if (image.getWidth() > 48 && image.getHeight() > 48)
140
+// {
141
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
142
+// Graphics2D g = resized.createGraphics();
143
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
144
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
145
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
146
+// g.dispose();
147
+//
148
+// image = resized;
149
+// }
150
+
151
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
152
+
153
+ icons.put(name, icon);
154
+
155
+ return icon;
61156 }
62157 catch (Exception e)
63158 {
64
- return new cCheckBox(name, border);
159
+ //icons.put(name, null);
160
+ return null;
65161 }
66162 }
67
-
68
- private ImageIcon GetIcon(String name) throws IOException
163
+
164
+ BufferedImage GetImage(String name)
69165 {
70
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
71
-
72
- if (image.getWidth() != 24 && image.getHeight() != 24)
166
+ try
73167 {
74
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
75
- Graphics2D g = resized.createGraphics();
76
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
77
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
78
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
79
- g.dispose();
80
-
81
- image = resized;
168
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
169
+
170
+ return image;
82171 }
83
-
84
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
85
- return icon;
172
+ catch (Exception e)
173
+ {
174
+ return null;
175
+ }
86176 }
87177
88178 // SCRIPT
....@@ -194,7 +284,7 @@
194284
195285 objEditor.ctrlPanel.remove(namePanel);
196286
197
- if (!GroupEditor.allparams)
287
+ if (!allparams)
198288 return;
199289
200290 // objEditor.ctrlPanel.remove(liveCB);
....@@ -266,6 +356,14 @@
266356 client = inClient;
267357 copy = client;
268358
359
+// if (copy.versionlist == null)
360
+// {
361
+// copy.versionlist = new Object3D[100];
362
+// copy.versionindex = -1;
363
+//
364
+// callee.Save(true);
365
+// }
366
+
269367 // "this" is not called: SetupUI2(objEditor);
270368 }
271369
....@@ -279,6 +377,14 @@
279377 client = inClient;
280378 copy = client;
281379
380
+ if (copy.versionlist == null)
381
+ {
382
+ copy.versionlist = new Object3D[100];
383
+ copy.versionindex = -1;
384
+
385
+// Save(true);
386
+ }
387
+
282388 SetupUI2(callee.GetEditor());
283389 }
284390
....@@ -293,14 +399,15 @@
293399 //localCopy.parent = null;
294400
295401 frame = new JFrame();
296
- frame.setUndecorated(true);
402
+ frame.setUndecorated(false);
297403 objEditor = this;
298404 this.callee = callee;
299405
300406 //parent = p;
301407
302408 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
303
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
409
+ if (Globals.DEBUG)
410
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
304411 //gd.setFullScreenWindow(this);
305412 //setResizable(false);
306413 //if (!isDisplayable())
....@@ -311,6 +418,14 @@
311418 copy = localCopy;
312419 copy.editWindow = this;
313420
421
+// if (copy.versionlist == null)
422
+// {
423
+// copy.versionlist = new Object3D[100];
424
+// copy.versionindex = -1;
425
+//
426
+// Save(true);
427
+// }
428
+
314429 SetupMenu();
315430
316431 //SetupName(objEditor); // new
....@@ -324,12 +439,20 @@
324439 return frame.action(event, obj);
325440 }
326441
442
+ // Cannot work without static
443
+ static boolean allparams = true;
444
+
445
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
446
+
447
+ // This is to refresh the UI of the material panel.
448
+ boolean patchMaterial;
449
+
327450 void SetupMenu()
328451 {
329452 frame.setMenuBar(menuBar = new MenuBar());
330453 menuBar.add(fileMenu = new Menu("File"));
331454 fileMenu.add(newItem = new MenuItem("New"));
332
- fileMenu.add(loadItem = new MenuItem("Open..."));
455
+ fileMenu.add(openItem = new MenuItem("Open..."));
333456
334457 //oe.menuBar.add(menu = new Menu("Include"));
335458 Menu menu = new Menu("Import");
....@@ -337,8 +460,11 @@
337460 importOBJItem.addActionListener(this);
338461 import3DSItem = menu.add(new MenuItem("3DS file..."));
339462 import3DSItem.addActionListener(this);
463
+ if (Globals.ADVANCED)
464
+ {
340465 importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
341466 importVRMLX3DItem.addActionListener(this);
467
+ }
342468 menu.add("-");
343469 importGFDItem = menu.add(new MenuItem("Grafreed file..."));
344470 importGFDItem.addActionListener(this);
....@@ -361,7 +487,7 @@
361487 }
362488
363489 newItem.addActionListener(this);
364
- loadItem.addActionListener(this);
490
+ openItem.addActionListener(this);
365491 saveItem.addActionListener(this);
366492 saveAsItem.addActionListener(this);
367493 exportAsItem.addActionListener(this);
....@@ -370,13 +496,72 @@
370496 closeItem.addActionListener(this);
371497
372498 objectPanel = new JTabbedPane();
499
+
500
+ ChangeListener changeListener = new ChangeListener()
501
+ {
502
+ //String name;
503
+
504
+ public void stateChanged(ChangeEvent changeEvent)
505
+ {
506
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
507
+// {
508
+// if (latestObject != null)
509
+// {
510
+// refreshContents(true);
511
+// SetMaterial(latestObject);
512
+// }
513
+//
514
+// materialFlushed = true;
515
+// }
516
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
517
+// {
518
+// if (listUI.size() == 0)
519
+// EditSelection(false);
520
+// }
521
+
522
+// if (objectPanel.getSelectedIndex() == 4)
523
+// {
524
+// name = copy.skyboxname;
525
+//
526
+// if (name == null)
527
+// {
528
+// name = "";
529
+// }
530
+//
531
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
532
+// copy.skyboxext = "jpg";
533
+// }
534
+// else
535
+// {
536
+// if (name != null)
537
+// {
538
+// if (name.equals(""))
539
+// {
540
+// copy.skyboxname = null;
541
+// copy.skyboxext = null;
542
+// }
543
+// else
544
+// {
545
+// copy.skyboxname = name;
546
+// }
547
+// }
548
+// }
549
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
550
+
551
+// refreshContents(false); // To refresh Info tab
552
+ cameraView.repaint();
553
+ }
554
+ };
555
+ objectPanel.addChangeListener(changeListener);
556
+
373557 toolbarPanel = new JPanel();
374558 toolbarPanel.setName("Toolbar");
559
+
375560 treePanel = new cGridBag();
376561 treePanel.setName("Tree");
377562
378563 editPanel = new cGridBag().setVertical(true);
379
- editPanel.setName("Edit");
564
+ //editPanel.setName("Edit");
380565
381566 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
382567
....@@ -384,23 +569,29 @@
384569 editPanel.add(editCommandsPanel);
385570 editPanel.add(ctrlPanel);
386571
387
- materialPanel = new cGridBag().setVertical(true);
572
+ toolboxPanel = new cGridBag().setVertical(true);
573
+ //toolboxPanel.setName("Toolbox");
388574
389
- materialPanel.setName("Material");
575
+ skyboxPanel = new cGridBag().setVertical(true);
576
+
577
+ materialPanel = new cGridBag().setVertical(false);
578
+ //materialPanel.setName("Material");
579
+
390580 /*JTextPane*/
391581 infoarea = createTextPane();
392582 doc = infoarea.getStyledDocument();
393583
394584 infoarea.setEditable(true);
395585 SetText();
586
+
396587 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
397588 // infoarea.setOpaque(false);
398589 // //infoarea.setForeground(textcolor);
399590 // TEXTAREA infoarea.setLineWrap(true);
400591 // TEXTAREA infoarea.setWrapStyleWord(true);
401592 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
402
- infoPanel.setPreferredSize(new Dimension(50, 200));
403
- infoPanel.setName("Info");
593
+ infoPanel.setPreferredSize(new Dimension(1, 1));
594
+ //infoPanel.setName("Info");
404595 //infoPanel.setLayout(new BorderLayout());
405596 //infoPanel.add(createTextPane());
406597
....@@ -411,7 +602,14 @@
411602 mainPanel.setDividerSize(9);
412603 mainPanel.setDividerLocation(0.5); //1.0);
413604 mainPanel.setResizeWeight(0.5);
414
-
605
+
606
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
607
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
608
+ divider.setDividerSize(15);
609
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
610
+
611
+ mainPanel.setUI(new BasicSplitPaneUI());
612
+
415613 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
416614 //mainPanel.setLayout(new GridBagLayout());
417615 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -642,8 +840,8 @@
642840 }
643841 }
644842
645
-static GraphicsDevice device = GraphicsEnvironment
646
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
843
+//static GraphicsDevice device = GraphicsEnvironment
844
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
647845
648846 Rectangle keeprect;
649847 cRadio radio;
....@@ -659,13 +857,25 @@
659857
660858 boolean maximized;
661859
860
+ cButton fullscreenLayout;
861
+ cButton expandedLayout;
862
+
662863 void Minimize()
663864 {
664865 frame.setState(Frame.ICONIFIED);
866
+ frame.validate();
665867 }
666868
869
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
870
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
871
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
667872 void Maximize()
668873 {
874
+ if (CameraPane.FULLSCREEN)
875
+ {
876
+ ToggleFullScreen();
877
+ }
878
+
669879 if (maximized)
670880 {
671881 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -673,20 +883,38 @@
673883 else
674884 {
675885 keeprect = frame.getBounds();
676
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
677
- Dimension rect2 = frame.getToolkit().getScreenSize();
678
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
886
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
887
+// Dimension rect2 = frame.getToolkit().getScreenSize();
888
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
679889 // frame.setState(Frame.MAXIMIZED_BOTH);
890
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
680891 }
681892
682893 maximized ^= true;
894
+
895
+ frame.validate();
683896 }
897
+
898
+ cButton minButton;
899
+ cButton maxButton;
900
+ cButton fullButton;
901
+ cButton collapseButton;
902
+ cButton maximize3DButton;
684903
685904 void ToggleFullScreen()
686905 {
687
- if (CameraPane.FULLSCREEN)
906
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
907
+
908
+ cameraView.ToggleFullScreen();
909
+
910
+ if (!CameraPane.FULLSCREEN)
688911 {
689912 device.setFullScreenWindow(null);
913
+ frame.dispose();
914
+ frame.setUndecorated(false);
915
+ frame.validate();
916
+ frame.setVisible(true);
917
+
690918 //frame.setVisible(false);
691919 // frame.removeNotify();
692920 // frame.setUndecorated(false);
....@@ -696,13 +924,13 @@
696924 // X frame.getContentPane().remove(/*"Center",*/bigThree);
697925 // X framePanel.add(bigThree);
698926 // X frame.getContentPane().add(/*"Center",*/framePanel);
699
- framePanel.setDividerLocation(1);
927
+// framePanel.setDividerLocation(46); // icons are 24x24
700928
701929 //frame.setVisible(true);
702
- radio.layout = keepButton;
930
+// radio.layout = keepButton;
703931 //theFrame = null;
704932 keepButton = null;
705
- radio.layout.doClick();
933
+// radio.layout.doClick();
706934
707935 } else
708936 {
....@@ -711,22 +939,70 @@
711939 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
712940 // frame.getToolkit().getScreenSize().height);
713941 //frame.setVisible(false);
942
+
943
+ frame.dispose();
944
+ frame.setUndecorated(true);
714945 device.setFullScreenWindow(frame);
946
+ frame.validate();
947
+ frame.setVisible(true);
715948 // frame.removeNotify();
716949 // frame.setUndecorated(true);
717950 // frame.addNotify();
718951 // X frame.getContentPane().remove(/*"Center",*/framePanel);
719952 // X framePanel.remove(bigThree);
720953 // X frame.getContentPane().add(/*"Center",*/bigThree);
721
- framePanel.setDividerLocation(0);
954
+// framePanel.setDividerLocation(0);
722955
723
- radio.layout = twoButton;
724
- radio.layout.doClick();
956
+// radio.layout = fullscreenLayout;
957
+// radio.layout.doClick();
725958 //frame.setVisible(true);
726959 }
727
-
728
- cameraView.ToggleFullScreen();
960
+ frame.validate();
961
+
962
+ cameraView.requestFocusInWindow();
729963 }
964
+
965
+ void CollapseToolbar()
966
+ {
967
+ framePanel.setDividerLocation(0);
968
+ //frame.validate();
969
+
970
+ cameraView.requestFocusInWindow();
971
+ }
972
+
973
+ private Object3D Duplicate(Object3D object)
974
+ {
975
+ boolean temp = CameraPane.SWITCH;
976
+ CameraPane.SWITCH = false;
977
+
978
+ if (Grafreed.grafreed.universe.versiontable == null)
979
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
980
+
981
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
982
+ // if (copy == client)
983
+
984
+ Object3D versions[] = object.versionlist;
985
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
986
+ object.versionlist = null;
987
+ object.versiontable = null;
988
+
989
+ Object3D parent = object.parent;
990
+ object.parent = null;
991
+
992
+ //byte[] compress = Compress(copy);
993
+ Object3D compress = (Object3D)Grafreed.clone(object);
994
+
995
+ object.parent = parent;
996
+
997
+ object.versionlist = versions;
998
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
999
+
1000
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
1001
+
1002
+ CameraPane.SWITCH = temp;
1003
+
1004
+ return compress;
1005
+ }
7301006
7311007 private JTextPane createTextPane()
7321008 {
....@@ -849,6 +1125,7 @@
8491125 {
8501126 SetupMaterial(materialPanel);
8511127 }
1128
+
8521129 //SetupName();
8531130 //SetupViews();
8541131 }
....@@ -858,7 +1135,7 @@
8581135 // NumberSlider vDivsField;
8591136 // JCheckBox endcaps;
8601137 JCheckBox liveCB;
861
- JCheckBox selectCB;
1138
+ JCheckBox selectableCB;
8621139 JCheckBox hideCB;
8631140 JCheckBox link2masterCB;
8641141 JCheckBox markCB;
....@@ -866,7 +1143,12 @@
8661143 JCheckBox speedupCB;
8671144 JCheckBox rewindCB;
8681145 JCheckBox flipVCB;
1146
+
1147
+ cCheckBox toggleTextureCB;
1148
+ cCheckBox toggleSwitchCB;
1149
+
8691150 JComboBox texresMenu;
1151
+
8701152 JButton resetButton;
8711153 JButton stepButton;
8721154 JButton stepAllButton;
....@@ -1052,39 +1334,55 @@
10521334
10531335 namePanel = new cGridBag();
10541336
1337
+ //if (copy.pinned)
1338
+ {
1339
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
1340
+ pinButton.setSelected(copy.pinned);
1341
+ cGridBag t = new cGridBag();
1342
+ t.preferredWidth = 2;
1343
+ t.add(pinButton);
1344
+ namePanel.add(t);
1345
+
1346
+ pinButton.addItemListener(this);
1347
+ }
1348
+
10551349 nameField = AddText(namePanel, copy.GetName());
1056
- namePanel.add(nameField);
1350
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10571351 oe.ctrlPanel.add(namePanel);
10581352
10591353 oe.ctrlPanel.Return();
10601354
1061
- if (!GroupEditor.allparams)
1355
+ if (!allparams)
10621356 return;
10631357
10641358 setupPanel = new cGridBag().setVertical(false);
10651359
10661360 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
10671361 liveCB.setToolTipText("Animate object");
1068
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1069
- selectCB.setToolTipText("Make object selectable");
1362
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1363
+ markCB.setToolTipText("Set target transform");
1364
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1365
+ selectableCB.setToolTipText("Make object selectable");
10701366 // Return();
1367
+
10711368 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10721369 hideCB.setToolTipText("Hide object");
1073
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1074
- markCB.setToolTipText("Set the animation target transform");
1370
+
1371
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
10751372
10761373 setupPanel2 = new cGridBag().setVertical(false);
10771374
10781375 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10791376 rewindCB.setToolTipText("Rewind animation");
10801377
1081
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1082
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1378
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1379
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
10831380
1381
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1382
+ link2masterCB.setToolTipText("Attach to support");
1383
+
10841384 if (Globals.ADVANCED)
10851385 {
1086
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1087
- link2masterCB.setToolTipText("Attach to support");
10881386 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10891387 speedupCB.setToolTipText("Option motion capture");
10901388 }
....@@ -1270,22 +1568,9 @@
12701568
12711569 if (cam == null || !(copy.get(0) instanceof cGroup))
12721570 {
1273
- System.out.println("CREATE CAMERAS");
1274
- cams = new cTemplate();
1275
- cams.name = "Cameras";
1276
- copy.insertElementAt(cams, 0);
1277
- //cams.parent = copy;
1278
-
1279
- cam = new Camera(); // LA.newVector(3, 2, 1));
1280
- cams.addChild(cam);
1281
- cam = new Camera(1);
1282
- cams.addChild(cam);
1283
- cam = new Camera(2);
1284
- cams.addChild(cam);
1285
- cam = new Camera(3);
1286
- cams.addChild(cam);
1287
- cam = new Camera(4); // Light
1288
- cams.addChild(cam);
1571
+ if (Globals.DEBUG)
1572
+ System.out.println("CREATE CAMERAS");
1573
+ cams = CreateCameras();
12891574 } else
12901575 {
12911576 cams = (cGroup) copy.get(0);
....@@ -1351,6 +1636,45 @@
13511636 //frontView.object = copy;
13521637 //sideView.object = copy;
13531638
1639
+ transformPanel = new cGridBag().setVertical(true);
1640
+
1641
+ cGridBag resetTransformPanel = new cGridBag();
1642
+
1643
+ resetTransformPanel.preferredHeight = 2;
1644
+
1645
+ cButton resetTransform = GetButton("Reset all", !Globals.NIMBUSLAF);
1646
+ resetTransform.setToolTipText("Reset Translation, Rotation and Scale");
1647
+ resetTransform.addMouseListener(new MouseAdapter()
1648
+ {
1649
+ public void mouseClicked(MouseEvent e)
1650
+ {
1651
+ ResetTransform();
1652
+ }
1653
+ });
1654
+ resetTransformPanel.add(resetTransform);
1655
+
1656
+ resetTransform = GetButton("T only", !Globals.NIMBUSLAF);
1657
+ resetTransform.setToolTipText("Reset Translation only");
1658
+ resetTransform.addMouseListener(new MouseAdapter()
1659
+ {
1660
+ public void mouseClicked(MouseEvent e)
1661
+ {
1662
+ ResetTransform(1);
1663
+ }
1664
+ });
1665
+ resetTransformPanel.add(resetTransform);
1666
+
1667
+ resetTransform = GetButton("RS only", !Globals.NIMBUSLAF);
1668
+ resetTransform.setToolTipText("Reset Rotation and Scale only");
1669
+ resetTransform.addMouseListener(new MouseAdapter()
1670
+ {
1671
+ public void mouseClicked(MouseEvent e)
1672
+ {
1673
+ ResetTransform(2);
1674
+ }
1675
+ });
1676
+ resetTransformPanel.add(resetTransform);
1677
+
13541678 XYZPanel = new cGridBag().setVertical(true);
13551679 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
13561680
....@@ -1358,7 +1682,11 @@
13581682 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
13591683 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
13601684 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1685
+ //XYZPanel.setName("XYZ");
13611686
1687
+ transformPanel.add(resetTransformPanel);
1688
+ transformPanel.add(XYZPanel);
1689
+
13621690 /*
13631691 gridPanel = new JPanel(); //new BorderLayout());
13641692 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1366,12 +1694,12 @@
13661694 gridPanel.add(cameraView);
13671695 gridPanel.add(XYZPanel);
13681696 */
1369
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1370
- gridPanel.setContinuousLayout(true);
1371
- gridPanel.setOneTouchExpandable(true);
1372
- gridPanel.setDividerLocation(1.0);
1373
- gridPanel.setDividerSize(9);
1374
- gridPanel.setResizeWeight(0.85);
1697
+// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1698
+// gridPanel.setContinuousLayout(true);
1699
+// gridPanel.setOneTouchExpandable(true);
1700
+// gridPanel.setDividerLocation(1.0);
1701
+// gridPanel.setDividerSize(9);
1702
+// gridPanel.setResizeWeight(0.85);
13751703
13761704 // aConstraints.weighty = 0;
13771705 //System.out.println("THIS = " + this);
....@@ -1394,14 +1722,34 @@
13941722
13951723 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
13961724 //tmp.setName("Edit");
1725
+ objectPanel.add(skyboxPanel);
1726
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1727
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1728
+
1729
+ objectPanel.add(toolboxPanel);
1730
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1731
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1732
+
13971733 objectPanel.add(materialPanel);
1734
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1735
+ objectPanel.setToolTipTextAt(2, "Material");
1736
+
13981737 // JPanel north = new JPanel(new BorderLayout());
13991738 // north.setName("Edit");
14001739 // north.add(ctrlPanel, BorderLayout.NORTH);
14011740 // objectPanel.add(north);
14021741 objectPanel.add(editPanel);
1403
- objectPanel.add(infoPanel);
1404
-
1742
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
1743
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1744
+
1745
+ objectPanel.add(transformPanel);
1746
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1747
+ objectPanel.setToolTipTextAt(4, "TRS transform");
1748
+
1749
+ patchMaterial = true;
1750
+ cameraView.patchMaterial = this;
1751
+ objectPanel.setSelectedIndex(2);
1752
+
14051753 /*
14061754 aConstraints.gridx = 0;
14071755 aConstraints.gridwidth = 1;
....@@ -1409,7 +1757,7 @@
14091757 aConstraints.gridy += 1;
14101758 aConstraints.gridwidth = 1;
14111759 mainPanel.add(objectPanel, aConstraints);
1412
- */
1760
+ */
14131761
14141762 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14151763 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1426,17 +1774,114 @@
14261774 JTabbedPane tabbedPane = new JTabbedPane();
14271775 tabbedPane.add(scrollpane);
14281776
1429
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1430
-
1431
- optionsPanel = new cGridBag().setVertical(true);
1777
+ optionsPanel = new cGridBag().setVertical(false);
14321778
14331779 optionsPanel.setName("Options");
14341780
14351781 AddOptions(optionsPanel); //, aConstraints);
14361782
1783
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1784
+
14371785 tabbedPane.add(optionsPanel);
14381786
14391787 scenePanel.add(tabbedPane);
1788
+
1789
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1790
+ creditsPanel.setName("Credits");
1791
+
1792
+ cLabel ogaLabel = new cLabel(" Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1793
+ creditsPanel.add(ogaLabel);
1794
+
1795
+ cButton creditButton;
1796
+ creditsPanel.add(creditButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1797
+ creditButton.setToolTipText("https://opengameart.org");
1798
+
1799
+ creditButton.addMouseListener(new MouseAdapter()
1800
+ {
1801
+ public void mouseClicked(MouseEvent e)
1802
+ {
1803
+ try
1804
+ {
1805
+ Desktop.getDesktop().browse(new java.net.URI("https://opengameart.org/"));
1806
+ } catch (Exception e1)
1807
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1808
+ {
1809
+ e1.printStackTrace();
1810
+ }
1811
+ }
1812
+ });
1813
+
1814
+ ogaLabel = new cLabel(" Download 3D models! (.3ds and .obj only)", !Globals.NIMBUSLAF);
1815
+ creditsPanel.add(ogaLabel);
1816
+
1817
+ creditsPanel.add(creditButton = GetButton("icons/3delicious.png", !Globals.NIMBUSLAF));
1818
+ creditButton.setToolTipText("https://3delicious.net");
1819
+
1820
+ creditButton.addMouseListener(new MouseAdapter()
1821
+ {
1822
+ public void mouseClicked(MouseEvent e)
1823
+ {
1824
+ try
1825
+ {
1826
+ Desktop.getDesktop().browse(new java.net.URI("https://3delicious.net"));
1827
+ } catch (Exception e1)
1828
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1829
+ {
1830
+ e1.printStackTrace();
1831
+ }
1832
+ }
1833
+ });
1834
+
1835
+ creditsPanel.add(creditButton = GetButton("icons/archive3d.png", !Globals.NIMBUSLAF));
1836
+ creditButton.setToolTipText("https://archive3d.net");
1837
+
1838
+ creditButton.addMouseListener(new MouseAdapter()
1839
+ {
1840
+ public void mouseClicked(MouseEvent e)
1841
+ {
1842
+ try
1843
+ {
1844
+ Desktop.getDesktop().browse(new java.net.URI("https://archive3d.net"));
1845
+ } catch (Exception e1)
1846
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1847
+ {
1848
+ e1.printStackTrace();
1849
+ }
1850
+ }
1851
+ });
1852
+
1853
+ creditsPanel.add(creditButton = GetButton("icons/turbosquid.png", !Globals.NIMBUSLAF));
1854
+ creditButton.setToolTipText("https://turbosquid.com");
1855
+
1856
+ creditButton.addMouseListener(new MouseAdapter()
1857
+ {
1858
+ public void mouseClicked(MouseEvent e)
1859
+ {
1860
+ try
1861
+ {
1862
+ Desktop.getDesktop().browse(new java.net.URI("https://www.turbosquid.com/Search/3D-Models/free"));
1863
+ } catch (Exception e1)
1864
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1865
+ {
1866
+ e1.printStackTrace();
1867
+ }
1868
+ }
1869
+ });
1870
+
1871
+ for (int i=6; --i>=0;)
1872
+ {
1873
+ creditsPanel.add(new cGridBag());
1874
+ }
1875
+
1876
+ tabbedPane.add(creditsPanel);
1877
+ tabbedPane.setToolTipTextAt(3, "Credits");
1878
+
1879
+ if (Globals.ADVANCED)
1880
+ {
1881
+ tabbedPane.add(infoPanel);
1882
+ tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1883
+ tabbedPane.setToolTipTextAt(4, "Information");
1884
+ }
14401885
14411886 /*
14421887 cTree jTree = new cTree(null);
....@@ -1458,13 +1903,13 @@
14581903 jtp.add(tree);
14591904 */
14601905
1461
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1462
- bigPanel.setContinuousLayout(true);
1463
- bigPanel.setOneTouchExpandable(true);
1464
- bigPanel.setDividerLocation(0.8);
1465
- bigPanel.setDividerSize(15);
1466
- bigPanel.setResizeWeight(0.15);
1467
- bigPanel.setName("Scene");
1906
+// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1907
+// bigPanel.setContinuousLayout(true);
1908
+// bigPanel.setOneTouchExpandable(true);
1909
+// bigPanel.setDividerLocation(0.8);
1910
+// bigPanel.setDividerSize(15);
1911
+// bigPanel.setResizeWeight(0.15);
1912
+// bigPanel.setName("Scene");
14681913
14691914 //bigPanel.setLayout(new BorderLayout());
14701915 //bigPanel.setSize(new Dimension(10,10));
....@@ -1499,7 +1944,7 @@
14991944 bigThree = new cGridBag();
15001945 bigThree.addComponent(scenePanel);
15011946 bigThree.addComponent(centralPanel);
1502
- bigThree.addComponent(XYZPanel);
1947
+ //bigThree.addComponent(XYZPanel);
15031948
15041949 // // SIDE EFFECT!!!
15051950 // aConstraints.gridx = 0;
....@@ -1508,16 +1953,33 @@
15081953 // aConstraints.gridheight = 1;
15091954
15101955 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1511
- framePanel.setContinuousLayout(true);
1512
- framePanel.setOneTouchExpandable(true);
1513
- framePanel.setDividerLocation(0.8);
1956
+
1957
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1958
+ new java.beans.PropertyChangeListener()
1959
+ {
1960
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1961
+ {
1962
+ if ((Integer)pce.getOldValue() == 1)
1963
+ {
1964
+ if (radio.layout != expandedLayout)
1965
+ {
1966
+ radio.layout = expandedLayout;
1967
+ radio.layout.doClick();
1968
+ }
1969
+ }
1970
+ }
1971
+ });
1972
+
1973
+ framePanel.setContinuousLayout(false);
1974
+ framePanel.setOneTouchExpandable(false);
1975
+ //.setDividerLocation(0.8);
15141976 //framePanel.setDividerSize(15);
15151977 //framePanel.setResizeWeight(0.15);
15161978 framePanel.setName("Frame");
15171979
15181980 frame.getContentPane().setLayout(new BorderLayout());
15191981 /**/
1520
- JTabbedPane worldPane = new JTabbedPane();
1982
+ //JTabbedPane worldPane = new JTabbedPane();
15211983 //worldPane.add(bigPanel);
15221984 //worldPane.add(worldPanel);
15231985 /**/
....@@ -1528,16 +1990,18 @@
15281990 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
15291991
15301992 frame.setSize(1280, 860);
1531
- frame.setVisible(true);
1532
-
1993
+
15331994 cameraView.requestFocusInWindow();
15341995
1535
- gridPanel.setDividerLocation(1.0);
1996
+// gridPanel.setDividerLocation(1.0);
1997
+
1998
+ frame.validate();
1999
+
2000
+ frame.setVisible(true);
15362001
15372002 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15382003 frame.addWindowListener(new WindowAdapter()
15392004 {
1540
-
15412005 public void windowClosing(WindowEvent e)
15422006 {
15432007 Close();
....@@ -1560,28 +2024,442 @@
15602024 ctrlPanel.removeAll();
15612025 }
15622026
1563
- void SetupMaterial(cGridBag panel)
2027
+ void SetupMaterial(cGridBag materialpanel)
15642028 {
1565
- /*
2029
+ cGridBag presetpanel = new cGridBag().setVertical(true);
2030
+
2031
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
2032
+ skin.setToolTipText("Skin");
2033
+ skin.addMouseListener(new MouseAdapter()
2034
+ {
2035
+ public void mouseClicked(MouseEvent e)
2036
+ {
2037
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
2038
+ cMaterial material = object.material;
2039
+
2040
+ // Skin
2041
+ colorField.setFloat(material.color);
2042
+ float saturation = material.modulation;
2043
+
2044
+ if (!cameraView.Skinshader)
2045
+ {
2046
+ saturation /= 1.5;
2047
+ }
2048
+
2049
+ saturationField.setFloat(saturation);
2050
+
2051
+ subsurfaceField.setFloat(material.subsurface);
2052
+ selfshadowField.setFloat(material.diffuseness);
2053
+ diffusenessField.setFloat(material.factor);
2054
+ shininessField.setFloat(material.shininess);
2055
+ shadowbiasField.setFloat(material.shadowbias);
2056
+ diffuseField.setFloat(material.diffuse);
2057
+ specularField.setFloat(material.specular);
2058
+
2059
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2060
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2061
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2062
+
2063
+ materialtouched = true;
2064
+ applySelf();
2065
+ }
2066
+ });
2067
+ presetpanel.add(skin);
2068
+
2069
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
2070
+ lambert.setToolTipText("Diffuse");
2071
+ lambert.addMouseListener(new MouseAdapter()
2072
+ {
2073
+ public void mouseClicked(MouseEvent e)
2074
+ {
2075
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
2076
+ cMaterial material = object.material;
2077
+
2078
+ diffusenessField.setFloat(material.factor);
2079
+ selfshadowField.setFloat(material.diffuseness);
2080
+
2081
+ materialtouched = true;
2082
+ applySelf();
2083
+ }
2084
+ });
2085
+ presetpanel.add(lambert);
2086
+
2087
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
2088
+ diffuse2.setToolTipText("Diffuse2");
2089
+ diffuse2.addMouseListener(new MouseAdapter()
2090
+ {
2091
+ public void mouseClicked(MouseEvent e)
2092
+ {
2093
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
2094
+ cMaterial material = object.material;
2095
+
2096
+ diffusenessField.setFloat(material.factor);
2097
+ selfshadowField.setFloat(material.diffuseness);
2098
+
2099
+ materialtouched = true;
2100
+ applySelf();
2101
+ }
2102
+ });
2103
+ presetpanel.add(diffuse2);
2104
+
2105
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
2106
+ diffusemoon.setToolTipText("Moon");
2107
+ diffusemoon.addMouseListener(new MouseAdapter()
2108
+ {
2109
+ public void mouseClicked(MouseEvent e)
2110
+ {
2111
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
2112
+ cMaterial material = object.material;
2113
+
2114
+ diffusenessField.setFloat(material.factor);
2115
+ selfshadowField.setFloat(material.diffuseness);
2116
+
2117
+ materialtouched = true;
2118
+ applySelf();
2119
+ }
2120
+ });
2121
+ presetpanel.add(diffusemoon);
2122
+
2123
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
2124
+ diffusemoon2.setToolTipText("Moon2");
2125
+ diffusemoon2.addMouseListener(new MouseAdapter()
2126
+ {
2127
+ public void mouseClicked(MouseEvent e)
2128
+ {
2129
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
2130
+ cMaterial material = object.material;
2131
+
2132
+ diffusenessField.setFloat(material.factor);
2133
+ selfshadowField.setFloat(material.diffuseness);
2134
+
2135
+ materialtouched = true;
2136
+ applySelf();
2137
+ }
2138
+ });
2139
+ presetpanel.add(diffusemoon2);
2140
+
2141
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
2142
+ diffusemoon3.setToolTipText("Moon3");
2143
+ diffusemoon3.addMouseListener(new MouseAdapter()
2144
+ {
2145
+ public void mouseClicked(MouseEvent e)
2146
+ {
2147
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2148
+ cMaterial material = object.material;
2149
+
2150
+ diffusenessField.setFloat(material.factor);
2151
+ selfshadowField.setFloat(material.diffuseness);
2152
+
2153
+ materialtouched = true;
2154
+ applySelf();
2155
+ }
2156
+ });
2157
+ presetpanel.add(diffusemoon3);
2158
+
2159
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
2160
+ diffusesheen.setToolTipText("Sheen");
2161
+ diffusesheen.addMouseListener(new MouseAdapter()
2162
+ {
2163
+ public void mouseClicked(MouseEvent e)
2164
+ {
2165
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2166
+ cMaterial material = object.material;
2167
+
2168
+ sheenField.setFloat(material.sheen);
2169
+
2170
+ materialtouched = true;
2171
+ applySelf();
2172
+ }
2173
+ });
2174
+ presetpanel.add(diffusesheen);
2175
+
2176
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
2177
+ rough.setToolTipText("Rough metal");
2178
+ rough.addMouseListener(new MouseAdapter()
2179
+ {
2180
+ public void mouseClicked(MouseEvent e)
2181
+ {
2182
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2183
+ cMaterial material = object.material;
2184
+
2185
+ shininessField.setFloat(material.shininess);
2186
+ velvetField.setFloat(material.velvet);
2187
+
2188
+ materialtouched = true;
2189
+ applySelf();
2190
+ }
2191
+ });
2192
+ presetpanel.add(rough);
2193
+
2194
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
2195
+ rough2.setToolTipText("Medium metal");
2196
+ rough2.addMouseListener(new MouseAdapter()
2197
+ {
2198
+ public void mouseClicked(MouseEvent e)
2199
+ {
2200
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2201
+ cMaterial material = object.material;
2202
+
2203
+ shininessField.setFloat(material.shininess);
2204
+ lightareaField.setFloat(material.lightarea);
2205
+
2206
+ materialtouched = true;
2207
+ applySelf();
2208
+ }
2209
+ });
2210
+ presetpanel.add(rough2);
2211
+
2212
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
2213
+ shini0.setToolTipText("Shiny");
2214
+ shini0.addMouseListener(new MouseAdapter()
2215
+ {
2216
+ public void mouseClicked(MouseEvent e)
2217
+ {
2218
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2219
+ cMaterial material = object.material;
2220
+
2221
+ shininessField.setFloat(material.shininess);
2222
+ lightareaField.setFloat(material.lightarea);
2223
+
2224
+ materialtouched = true;
2225
+ applySelf();
2226
+ }
2227
+ });
2228
+ presetpanel.add(shini0);
2229
+
2230
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
2231
+ shini1.setToolTipText("Shiny2");
2232
+ shini1.addMouseListener(new MouseAdapter()
2233
+ {
2234
+ public void mouseClicked(MouseEvent e)
2235
+ {
2236
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2237
+ cMaterial material = object.material;
2238
+
2239
+ shininessField.setFloat(material.shininess);
2240
+ lightareaField.setFloat(material.lightarea);
2241
+
2242
+ materialtouched = true;
2243
+ applySelf();
2244
+ }
2245
+ });
2246
+ presetpanel.add(shini1);
2247
+
2248
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
2249
+ shini2.setToolTipText("Shiny3");
2250
+ shini2.addMouseListener(new MouseAdapter()
2251
+ {
2252
+ public void mouseClicked(MouseEvent e)
2253
+ {
2254
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2255
+ cMaterial material = object.material;
2256
+
2257
+ shininessField.setFloat(material.shininess);
2258
+ lightareaField.setFloat(material.lightarea);
2259
+
2260
+ materialtouched = true;
2261
+ applySelf();
2262
+ }
2263
+ });
2264
+ presetpanel.add(shini2);
2265
+
2266
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
2267
+ aniso.setToolTipText("AnisoU");
2268
+ aniso.addMouseListener(new MouseAdapter()
2269
+ {
2270
+ public void mouseClicked(MouseEvent e)
2271
+ {
2272
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2273
+ cMaterial material = object.material;
2274
+
2275
+ anisoField.setFloat(material.aniso);
2276
+ anisoVField.setFloat(material.anisoV);
2277
+
2278
+ materialtouched = true;
2279
+ applySelf();
2280
+ }
2281
+ });
2282
+ presetpanel.add(aniso);
2283
+
2284
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
2285
+ aniso2.setToolTipText("AnisoV");
2286
+ aniso2.addMouseListener(new MouseAdapter()
2287
+ {
2288
+ public void mouseClicked(MouseEvent e)
2289
+ {
2290
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2291
+ cMaterial material = object.material;
2292
+
2293
+ anisoField.setFloat(material.aniso);
2294
+ anisoVField.setFloat(material.anisoV);
2295
+
2296
+ materialtouched = true;
2297
+ applySelf();
2298
+ }
2299
+ });
2300
+ presetpanel.add(aniso2);
2301
+
2302
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
2303
+ aniso3.setToolTipText("AnisoUV");
2304
+ aniso3.addMouseListener(new MouseAdapter()
2305
+ {
2306
+ public void mouseClicked(MouseEvent e)
2307
+ {
2308
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2309
+ cMaterial material = object.material;
2310
+
2311
+ anisoField.setFloat(material.aniso);
2312
+ anisoVField.setFloat(material.anisoV);
2313
+
2314
+ materialtouched = true;
2315
+ applySelf();
2316
+ }
2317
+ });
2318
+ presetpanel.add(aniso3);
2319
+
2320
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
2321
+ velvet0.setToolTipText("Velvet");
2322
+ velvet0.addMouseListener(new MouseAdapter()
2323
+ {
2324
+ public void mouseClicked(MouseEvent e)
2325
+ {
2326
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2327
+ cMaterial material = object.material;
2328
+
2329
+ diffusenessField.setFloat(material.factor);
2330
+ selfshadowField.setFloat(material.diffuseness);
2331
+ sheenField.setFloat(material.sheen);
2332
+ shininessField.setFloat(material.shininess);
2333
+ velvetField.setFloat(material.velvet);
2334
+ shiftField.setFloat(material.shift);
2335
+
2336
+ materialtouched = true;
2337
+ applySelf();
2338
+ }
2339
+ });
2340
+ presetpanel.add(velvet0);
2341
+
2342
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
2343
+ bump0.setToolTipText("Bump texture");
2344
+ bump0.addMouseListener(new MouseAdapter()
2345
+ {
2346
+ public void mouseClicked(MouseEvent e)
2347
+ {
2348
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2349
+ cMaterial material = object.material;
2350
+
2351
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2352
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2353
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2354
+
2355
+ materialtouched = true;
2356
+ applySelf();
2357
+ }
2358
+ });
2359
+ presetpanel.add(bump0);
2360
+
2361
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
2362
+ borderShader.setToolTipText("Border fade");
2363
+ borderShader.addMouseListener(new MouseAdapter()
2364
+ {
2365
+ public void mouseClicked(MouseEvent e)
2366
+ {
2367
+ borderfadeField.setFloat(0.5);
2368
+ opacityField.setFloat(0.75);
2369
+
2370
+ materialtouched = true;
2371
+ applySelf();
2372
+ }
2373
+ });
2374
+ presetpanel.add(borderShader);
2375
+
2376
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
2377
+ halo.setToolTipText("Halo");
2378
+ halo.addMouseListener(new MouseAdapter()
2379
+ {
2380
+ public void mouseClicked(MouseEvent e)
2381
+ {
2382
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2383
+ cMaterial material = object.material;
2384
+
2385
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2386
+
2387
+ materialtouched = true;
2388
+ applySelf();
2389
+ }
2390
+ });
2391
+ presetpanel.add(halo);
2392
+
2393
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
2394
+ candle.setToolTipText("Candle");
2395
+ candle.addMouseListener(new MouseAdapter()
2396
+ {
2397
+ public void mouseClicked(MouseEvent e)
2398
+ {
2399
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2400
+ cMaterial material = object.material;
2401
+
2402
+ subsurfaceField.setFloat(material.subsurface);
2403
+ shadowbiasField.setFloat(material.shadowbias);
2404
+ ambientField.setFloat(material.ambient);
2405
+ specularField.setFloat(material.specular);
2406
+ lightareaField.setFloat(material.lightarea);
2407
+ shininessField.setFloat(material.shininess);
2408
+
2409
+ materialtouched = true;
2410
+ applySelf();
2411
+ }
2412
+ });
2413
+ presetpanel.add(candle);
2414
+
2415
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
2416
+ shadowShader.setToolTipText("Shadow");
2417
+ shadowShader.addMouseListener(new MouseAdapter()
2418
+ {
2419
+ public void mouseClicked(MouseEvent e)
2420
+ {
2421
+ diffuseField.setFloat(0.001);
2422
+ ambientField.setFloat(0.001);
2423
+ cameraField.setFloat(0.001);
2424
+ specularField.setFloat(0.001);
2425
+ fakedepthField.setFloat(0.001);
2426
+ opacityField.setFloat(0.6);
2427
+
2428
+ materialtouched = true;
2429
+ applySelf();
2430
+ }
2431
+ });
2432
+ presetpanel.add(shadowShader);
2433
+
2434
+ cGridBag panel = new cGridBag().setVertical(true);
2435
+
2436
+ presetpanel.preferredWidth = 1;
2437
+
2438
+ materialpanel.add(presetpanel);
2439
+ materialpanel.add(panel);
2440
+
2441
+ panel.preferredWidth = 8;
2442
+
2443
+ /*
15662444 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
15672445 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1568
- */
2446
+ */
15692447
15702448 cGridBag editBar = new cGridBag().setVertical(false);
15712449
1572
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2450
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
15732451 createMaterialButton.setToolTipText("Create material");
15742452
15752453 /*
15762454 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
15772455 */
15782456
1579
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2457
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
15802458 clearMaterialButton.setToolTipText("Clear material");
15812459
15822460 if (Globals.ADVANCED)
15832461 {
1584
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2462
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
15852463 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
15862464 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
15872465 }
....@@ -1599,45 +2477,61 @@
15992477 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16002478
16012479 cGridBag colorSection = new cGridBag().setVertical(true);
2480
+
2481
+ cGridBag huepanel = new cGridBag();
2482
+ cGridBag huelabel = new cGridBag();
2483
+ cLabel hue = GetLabel("icons/hue.png", false);
2484
+ hue.fit = true;
2485
+
2486
+ hue.addMouseListener(new MouseAdapter()
2487
+ {
2488
+ public void mousePressed(MouseEvent e)
2489
+ {
2490
+ int x = e.getX();
2491
+
2492
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2493
+ }
2494
+ });
2495
+
2496
+ huelabel.add(hue);
2497
+ huelabel.preferredWidth = 20;
2498
+ huepanel.add(new cGridBag()); // Label
2499
+ huepanel.add(huelabel); // Field/slider
2500
+
2501
+ huepanel.preferredHeight = 7;
2502
+
2503
+ colorSection.add(huepanel);
16022504
16032505 cGridBag color = new cGridBag();
1604
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1605
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1606
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2506
+
2507
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2508
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2509
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2510
+
16072511 //colorField.preferredWidth = 200;
16082512 colorSection.add(color);
16092513
16102514 cGridBag modulation = new cGridBag();
16112515 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16122516 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1613
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2517
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16142518 colorSection.add(modulation);
16152519
2520
+ cGridBag opacity = new cGridBag();
2521
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2522
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2523
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2524
+ colorSection.add(opacity);
2525
+
2526
+ colorSection.add(GetSeparator());
2527
+
16162528 cGridBag texture = new cGridBag();
16172529 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16182530 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16192531 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16202532 colorSection.add(texture);
16212533
1622
- cGridBag anisoU = new cGridBag();
1623
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1624
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1625
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1626
- colorSection.add(anisoU);
1627
-
1628
- cGridBag anisoV = new cGridBag();
1629
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1630
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1631
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1632
- colorSection.add(anisoV);
1633
-
1634
- cGridBag shadowbias = new cGridBag();
1635
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1636
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1637
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1638
- colorSection.add(shadowbias);
1639
-
1640
- panel.add(new JSeparator());
2534
+ panel.add(GetSeparator());
16412535
16422536 panel.add(colorSection);
16432537
....@@ -1687,7 +2581,13 @@
16872581 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
16882582 diffuseSection.add(fakedepth);
16892583
1690
- panel.add(new JSeparator());
2584
+ cGridBag shadowbias = new cGridBag();
2585
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2586
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2587
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2588
+ diffuseSection.add(shadowbias);
2589
+
2590
+ panel.add(GetSeparator());
16912591
16922592 panel.add(diffuseSection);
16932593
....@@ -1737,42 +2637,48 @@
17372637 // aConstraints.gridy += 1;
17382638 // aConstraints.gridwidth = 1;
17392639
2640
+ cGridBag anisoU = new cGridBag();
2641
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2642
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2643
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2644
+ specularSection.add(anisoU);
17402645
1741
- panel.add(new JSeparator());
2646
+ cGridBag anisoV = new cGridBag();
2647
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2648
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2649
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2650
+ specularSection.add(anisoV);
2651
+
2652
+
2653
+ panel.add(GetSeparator());
17422654
17432655 panel.add(specularSection);
17442656
17452657 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17462658
1747
- cGridBag globalSection = new cGridBag().setVertical(true);
2659
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17482660
17492661 cGridBag camera = new cGridBag();
17502662 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17512663 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17522664 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1753
- globalSection.add(camera);
2665
+ colorSection.add(camera);
17542666
17552667 cGridBag ambient = new cGridBag();
17562668 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17572669 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17582670 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1759
- globalSection.add(ambient);
2671
+ colorSection.add(ambient);
17602672
17612673 cGridBag backlit = new cGridBag();
17622674 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17632675 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17642676 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1765
- globalSection.add(backlit);
2677
+ colorSection.add(backlit);
17662678
1767
- cGridBag opacity = new cGridBag();
1768
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1769
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1770
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1771
- globalSection.add(opacity);
1772
-
1773
- panel.add(new JSeparator());
2679
+ //panel.add(new JSeparator());
17742680
1775
- panel.add(globalSection);
2681
+ //panel.add(globalSection);
17762682
17772683 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17782684
....@@ -1814,7 +2720,7 @@
18142720 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18152721 textureSection.add(opacityPower);
18162722
1817
- panel.add(new JSeparator());
2723
+ panel.add(GetSeparator());
18182724
18192725 panel.add(textureSection);
18202726
....@@ -1879,8 +2785,9 @@
18792785 // 3D models
18802786 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
18812787 {
1882
- lastConverter = new com.jmex.model.converters.MaxToJme();
1883
- LoadFile(filename, lastConverter);
2788
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2789
+ //LoadFile(filename, lastConverter);
2790
+ LoadObjFile(filename); // New 3ds loader
18842791 continue;
18852792 }
18862793 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2606,6 +3513,7 @@
26063513 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26073514 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26083515 }
3516
+
26093517 //cJME.count++;
26103518 //cJME.count %= 12;
26113519 if (gc)
....@@ -2789,6 +3697,7 @@
27893697 }
27903698 }
27913699 }
3700
+
27923701 cFileSystemPane FSPane;
27933702
27943703 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2798,7 +3707,7 @@
27983707
27993708 freezematerial = true;
28003709 colorField.setFloat(mat.color);
2801
- modulationField.setFloat(mat.modulation);
3710
+ saturationField.setFloat(mat.modulation);
28023711 metalnessField.setFloat(mat.metalness);
28033712 diffuseField.setFloat(mat.diffuse);
28043713 specularField.setFloat(mat.specular);
....@@ -2842,11 +3751,14 @@
28423751 }
28433752 }
28443753 }
3754
+
28453755 freezematerial = false;
28463756 }
28473757
28483758 void SetMaterial(Object3D object)
28493759 {
3760
+ latestObject = object;
3761
+
28503762 cMaterial mat = object.material;
28513763
28523764 if (mat == null)
....@@ -2857,32 +3769,8 @@
28573769
28583770 if (multiplyToggle != null)
28593771 multiplyToggle.setSelected(mat.multiply);
2860
-
2861
- assert (object.projectedVertices != null);
2862
-
2863
- if (object.projectedVertices.length <= 2)
2864
- {
2865
- // Side effect...
2866
- Object3D.cVector2[] keep = object.projectedVertices;
2867
- object.projectedVertices = new Object3D.cVector2[3];
2868
- for (int i = 0; i < 3; i++)
2869
- {
2870
- if (i < keep.length)
2871
- {
2872
- object.projectedVertices[i] = keep[i];
2873
- } else
2874
- {
2875
- object.projectedVertices[i] = new Object3D.cVector2();
2876
- }
2877
- /*
2878
- if(keep.length == 0)
2879
- object.projectedVertices[0] = new Object3D.cVector2();
2880
- else
2881
- object.projectedVertices[0] = keep[0];
2882
- object.projectedVertices[1] = new Object3D.cVector2();
2883
- */
2884
- }
2885
- }
3772
+
3773
+ AllocProjectedVertices(object);
28863774
28873775 SetMaterial(mat, object.projectedVertices);
28883776 }
....@@ -2958,12 +3846,17 @@
29583846 // }
29593847
29603848 /**/
2961
- if (deselect)
3849
+ if (deselect || child == null)
29623850 {
29633851 //group.deselectAll();
29643852 //freeze = true;
29653853 GetTree().clearSelection();
29663854 //freeze = false;
3855
+
3856
+ if (child == null)
3857
+ {
3858
+ return;
3859
+ }
29673860 }
29683861
29693862 //group.addSelectee(child);
....@@ -2997,6 +3890,17 @@
29973890 public void itemStateChanged(ItemEvent event)
29983891 {
29993892 // System.out.println("Propagate = " + propagate);
3893
+ if (event.getSource() == pinButton)
3894
+ {
3895
+ copy.pinned ^= true;
3896
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3897
+ {
3898
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3899
+ copy.CloseUI();
3900
+ //copy.editWindow.refreshContents();
3901
+ }
3902
+ }
3903
+ else
30003904 if (event.getSource() == propagateToggle)
30013905 {
30023906 propagate ^= true;
....@@ -3032,7 +3936,7 @@
30323936 cameraView.ToggleDL();
30333937 cameraView.repaint();
30343938 return;
3035
- } else if (event.getSource() == toggleTextureItem)
3939
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
30363940 {
30373941 cameraView.ToggleTexture();
30383942 // june 2013 copy.HardTouch();
....@@ -3071,7 +3975,7 @@
30713975 frame.validate();
30723976
30733977 return;
3074
- } else if (event.getSource() == toggleSwitchItem)
3978
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30753979 {
30763980 cameraView.ToggleSwitch();
30773981 cameraView.repaint();
....@@ -3101,8 +4005,9 @@
31014005 } else if (event.getSource() == liveCB)
31024006 {
31034007 copy.live ^= true;
4008
+ objEditor.refreshContents(true); // To show item colors
31044009 return;
3105
- } else if (event.getSource() == selectCB)
4010
+ } else if (event.getSource() == selectableCB)
31064011 {
31074012 copy.dontselect ^= true;
31084013 return;
....@@ -3110,7 +4015,7 @@
31104015 {
31114016 copy.hide ^= true;
31124017 copy.Touch(); // display list issue
3113
- objEditor.refreshContents();
4018
+ objEditor.refreshContents(true); // To show item colors
31144019 return;
31154020 } else if (event.getSource() == link2masterCB)
31164021 {
....@@ -3175,7 +4080,7 @@
31754080 //System.out.println("ObjEditor " + event);
31764081 applySelf0(true);
31774082 //parent.applySelf();
3178
- objEditor.refreshContents();
4083
+ // conflicts with requestFocus objEditor.refreshContents();
31794084 } else if (source == resetButton)
31804085 {
31814086 CameraPane.fullreset = true;
....@@ -3287,9 +4192,9 @@
32874192 {
32884193 Close();
32894194 //return true;
3290
- } else if (source == loadItem)
4195
+ } else if (source == openItem)
32914196 {
3292
- load();
4197
+ Open();
32934198 //return true;
32944199 } else if (source == newItem)
32954200 {
....@@ -3314,6 +4219,10 @@
33144219 {
33154220 generatePOV();
33164221 //return true;
4222
+ } else if (event.getSource() == archiveItem)
4223
+ {
4224
+ cTools.Archive(frame);
4225
+ return;
33174226 } else if (source == zBufferItem)
33184227 {
33194228 try
....@@ -3351,22 +4260,30 @@
33514260
33524261 void New()
33534262 {
3354
- while (copy.Size() > 1)
4263
+ while (copy.Size() > 0)
33554264 {
3356
- copy.remove(1);
4265
+ copy.remove(0);
33574266 }
33584267
4268
+ copy.selection.clear();
4269
+
4270
+ if (copy == Grafreed.grafreed.universe)
4271
+ {
4272
+ CreateCameras();
4273
+ cameraView.SetCamera(GetCamera(copy, 0));
4274
+ }
33594275 ResetModel();
33604276 objEditor.refreshContents();
33614277 }
33624278
33634279 static public byte[] Compress(Object3D o)
33644280 {
4281
+ // Slower to actually compress.
33654282 try
33664283 {
33674284 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3368
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3369
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4285
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4286
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33704287
33714288 Object3D parent = o.parent;
33724289 o.parent = null;
....@@ -3377,10 +4294,14 @@
33774294
33784295 out.flush();
33794296
3380
- zstream.close();
4297
+ baos //zstream
4298
+ .close();
33814299 out.close();
33824300
3383
- return baos.toByteArray();
4301
+ byte[] bytes = baos.toByteArray();
4302
+
4303
+ System.out.println("save #bytes = " + bytes.length);
4304
+ return bytes;
33844305 } catch (Exception e)
33854306 {
33864307 System.err.println(e);
....@@ -3390,13 +4311,16 @@
33904311
33914312 static public Object Uncompress(byte[] bytes)
33924313 {
3393
- System.out.println("#bytes = " + bytes.length);
4314
+ System.out.println("restore #bytes = " + bytes.length);
33944315 try
33954316 {
33964317 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3397
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3398
- ObjectInputStream in = new ObjectInputStream(istream);
4318
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4319
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
33994320 Object obj = in.readObject();
4321
+
4322
+ bais //istream
4323
+ .close();
34004324 in.close();
34014325
34024326 return obj;
....@@ -3451,39 +4375,97 @@
34514375 return null;
34524376 }
34534377
3454
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
34554378
34564379 public void Save()
34574380 {
4381
+ //Save(true);
4382
+ Replace();
4383
+ SetVersionStates();
4384
+ }
4385
+
4386
+ private boolean Equal(byte[] compress, byte[] name)
4387
+ {
4388
+ if (compress.length != name.length)
4389
+ {
4390
+ return false;
4391
+ }
4392
+
4393
+ for (int i=compress.length; --i>=0;)
4394
+ {
4395
+ if (compress[i] != name[i])
4396
+ return false;
4397
+ }
4398
+
4399
+ return true;
4400
+ }
4401
+
4402
+ void DeleteVersion()
4403
+ {
4404
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4405
+ {
4406
+ copy.versionlist[i] = copy.versionlist[i+1];
4407
+ }
4408
+
4409
+ if (copy.versionlist[copy.versionindex] == null)
4410
+ copy.versionindex -= 1;
4411
+
4412
+ if (copy.versionindex != -1)
4413
+ CopyChanged();
4414
+
4415
+ SetVersionStates();
4416
+ }
4417
+
4418
+ public boolean Save(boolean user)
4419
+ {
34584420 System.err.println("Save");
4421
+ Replace();
34594422
3460
- cRadio tab = GetCurrentTab();
4423
+ //cRadio tab = GetCurrentTab();
34614424
3462
- boolean temp = CameraPane.SWITCH;
3463
- CameraPane.SWITCH = false;
4425
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
34644426
3465
- copy.ExtractBigData(hashtable);
4427
+ boolean thesame = false;
4428
+
4429
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4430
+// {
4431
+// thesame = true;
4432
+// }
34664433
34674434 //EditorFrame.m_MainFrame.requestFocusInWindow();
3468
- tab.graphs[tab.undoindex++] = Compress(copy);
3469
-
3470
- copy.RestoreBigData(hashtable);
3471
-
3472
- CameraPane.SWITCH = temp;
3473
-
3474
- //assert(hashtable.isEmpty());
3475
-
3476
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
4435
+ if (!thesame)
34774436 {
3478
- tab.graphs[i] = null;
4437
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4438
+ {
4439
+ copy.versionlist[i] = copy.versionlist[i-1];
4440
+ }
4441
+
4442
+ //tab.user[tab.versionindex] = user;
4443
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4444
+
4445
+ copy.versionlist[++copy.versionindex] = compress;
4446
+
4447
+ // if (increment)
4448
+ // tab.versionindex++;
34794449 }
34804450
4451
+ //copy.RestoreBigData(versiontable);
4452
+
4453
+ //assert(hashtable.isEmpty());
4454
+
4455
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4456
+// {
4457
+// //tab.user[i] = false;
4458
+// copy.versionlist[i] = null;
4459
+// }
4460
+
4461
+ SetVersionStates();
4462
+
34814463 // test save
34824464 if (false)
34834465 {
34844466 try
34854467 {
3486
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4468
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
34874469 ObjectOutputStream p = new ObjectOutputStream(ostream);
34884470
34894471 p.writeObject(copy);
....@@ -3496,26 +4478,68 @@
34964478 e.printStackTrace();
34974479 }
34984480 }
4481
+
4482
+ return !thesame;
4483
+ }
4484
+
4485
+ boolean flashIt = true;
4486
+
4487
+ void RefreshSelection()
4488
+ {
4489
+ Object3D selection = new Object3D();
4490
+
4491
+ for (int i = 0; i < copy.selection.size(); i++)
4492
+ {
4493
+ Object3D elem = copy.selection.elementAt(i);
4494
+
4495
+ Object3D obj = copy.GetObject(elem.GetUUID());
4496
+
4497
+ if (obj == null)
4498
+ {
4499
+ copy.selection.remove(i--);
4500
+ }
4501
+ else
4502
+ {
4503
+ selection.add(obj);
4504
+ copy.selection.setElementAt(obj, i);
4505
+ }
4506
+ }
4507
+
4508
+ flashIt = false;
4509
+ GetTree().clearSelection();
4510
+ for (int i = 0; i < selection.size(); i++)
4511
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4512
+ flashIt = true;
4513
+
4514
+ //refreshContents(false);
34994515 }
35004516
3501
- void CopyChanged(Object3D obj)
4517
+ void CopyChanged()
35024518 {
4519
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4520
+
4521
+ SetVersionStates();
4522
+
35034523 boolean temp = CameraPane.SWITCH;
35044524 CameraPane.SWITCH = false;
35054525
3506
- copy.ExtractBigData(hashtable);
4526
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
35074527
35084528 copy.clear();
35094529
4530
+ copy.skyboxname = obj.skyboxname;
4531
+ copy.skyboxext = obj.skyboxext;
4532
+
35104533 for (int i=0; i<obj.Size(); i++)
35114534 {
35124535 copy.add(obj.get(i));
35134536 }
35144537
3515
- copy.RestoreBigData(hashtable);
4538
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
35164539
35174540 CameraPane.SWITCH = temp;
35184541
4542
+ RefreshSelection();
35194543 //assert(hashtable.isEmpty());
35204544
35214545 copy.Touch();
....@@ -3536,45 +4560,161 @@
35364560 }
35374561 }
35384562
3539
- refreshContents();
4563
+ refreshContents(true);
35404564 }
35414565
3542
- public void Undo()
4566
+ cButton previousVersionButton;
4567
+ cButton restoreButton;
4568
+ cButton replaceButton;
4569
+ cButton nextVersionButton;
4570
+ cButton saveVersionButton;
4571
+ cButton deleteVersionButton;
4572
+
4573
+ boolean muteSlider;
4574
+
4575
+ int VersionCount()
35434576 {
4577
+ int count = 0;
4578
+
4579
+ for (int i = copy.versionlist.length; --i >= 0;)
4580
+ {
4581
+ if (copy.versionlist[i] != null)
4582
+ count++;
4583
+ }
4584
+
4585
+ return count;
4586
+ }
4587
+
4588
+ public cGridBag versionSliderPane;
4589
+
4590
+ void SetVersionStates()
4591
+ {
4592
+ //if (true)
4593
+ // return;
4594
+
4595
+ //cRadio tab = GetCurrentTab();
4596
+
4597
+ if (copy.versionlist == null)
4598
+ {
4599
+ saveVersionButton.setEnabled(false);
4600
+ restoreButton.setEnabled(false);
4601
+ replaceButton.setEnabled(false);
4602
+ previousVersionButton.setEnabled(false);
4603
+ nextVersionButton.setEnabled(false);
4604
+ deleteVersionButton.setEnabled(false);
4605
+ versionSliderPane.setVisible(false);
4606
+ }
4607
+ else
4608
+ {
4609
+ restoreButton.setEnabled(copy.versionindex != -1);
4610
+ replaceButton.setEnabled(copy.versionindex != -1);
4611
+
4612
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4613
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4614
+
4615
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4616
+ //copy.versionlist[copy.versionindex + 1] != null);
4617
+
4618
+ muteSlider = true;
4619
+ versionSlider.setMinimum(0);
4620
+ versionSlider.setMaximum(VersionCount() - 1);
4621
+ versionSlider.setInteger(copy.versionindex);
4622
+ versionSlider.setEnabled(copy.versionindex != -1);
4623
+ muteSlider = false;
4624
+
4625
+ versionSliderPane.setVisible(true);
4626
+ }
4627
+ }
4628
+
4629
+ public boolean PreviousVersion()
4630
+ {
4631
+ // Option?
4632
+ Replace();
4633
+
35444634 System.err.println("Undo");
35454635
3546
- cRadio tab = GetCurrentTab();
4636
+ //cRadio tab = GetCurrentTab();
35474637
3548
- if (tab.undoindex == 0)
4638
+ if (copy.versionindex == 0)
35494639 {
35504640 java.awt.Toolkit.getDefaultToolkit().beep();
3551
- return;
4641
+ return false;
35524642 }
35534643
3554
- if (tab.graphs[tab.undoindex] == null)
3555
- {
3556
- Save();
3557
- tab.undoindex -= 1;
3558
- }
4644
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4645
+// {
4646
+// if (Save(false))
4647
+// tab.versionindex -= 1;
4648
+// else
4649
+// {
4650
+// if (tab.versionindex <= 0)
4651
+// return false;
4652
+// else
4653
+// tab.versionindex -= 1;
4654
+// }
4655
+// }
35594656
3560
- tab.undoindex -= 1;
4657
+ copy.versionindex -= 1;
35614658
3562
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4659
+ CopyChanged();
4660
+
4661
+ return true;
35634662 }
35644663
3565
- public void Redo()
4664
+ public boolean Restore()
35664665 {
3567
- cRadio tab = GetCurrentTab();
4666
+ System.err.println("Restore");
35684667
3569
- if (tab.graphs[tab.undoindex + 1] == null)
4668
+ //cRadio tab = GetCurrentTab();
4669
+
4670
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4671
+ {
4672
+ java.awt.Toolkit.getDefaultToolkit().beep();
4673
+ return false;
4674
+ }
4675
+
4676
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4677
+ CopyChanged();
4678
+
4679
+ return true;
4680
+ }
4681
+
4682
+ public boolean Replace()
4683
+ {
4684
+ //System.err.println("Replace");
4685
+
4686
+ //cRadio tab = GetCurrentTab();
4687
+
4688
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4689
+ {
4690
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4691
+ return false;
4692
+ }
4693
+
4694
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4695
+
4696
+ return true;
4697
+ }
4698
+
4699
+ public void NextVersion()
4700
+ {
4701
+ // Option?
4702
+ Replace();
4703
+
4704
+ //cRadio tab = GetCurrentTab();
4705
+
4706
+ if (copy.versionlist[copy.versionindex + 1] == null)
35704707 {
35714708 java.awt.Toolkit.getDefaultToolkit().beep();
35724709 return;
35734710 }
35744711
3575
- tab.undoindex += 1;
4712
+ copy.versionindex += 1;
35764713
3577
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4714
+ CopyChanged();
4715
+
4716
+ //if (!tab.user[tab.versionindex])
4717
+ // tab.graphs[tab.versionindex] = null;
35784718 }
35794719
35804720 void ImportGFD()
....@@ -3726,7 +4866,7 @@
37264866 assert false;
37274867 }
37284868
3729
- void EditSelection()
4869
+ void EditSelection(boolean newWindow)
37304870 {
37314871 }
37324872
....@@ -3768,6 +4908,12 @@
37684908 // else
37694909 // applySelf(true);
37704910 // }
4911
+
4912
+ boolean Equal(double a, double b)
4913
+ {
4914
+ return Math.abs(a - b) < 0.001;
4915
+ }
4916
+
37714917 void applySelf0(boolean name)
37724918 {
37734919 if (name)
....@@ -3785,7 +4931,7 @@
37854931 //copy.material = new cMaterial(copy.GetMaterial());
37864932
37874933 current.color = (float) colorField.getFloat();
3788
- current.modulation = (float) modulationField.getFloat();
4934
+ current.modulation = (float) saturationField.getFloat();
37894935 current.metalness = (float) metalnessField.getFloat();
37904936 current.diffuse = (float) diffuseField.getFloat();
37914937 current.specular = (float) specularField.getFloat();
....@@ -3817,29 +4963,52 @@
38174963 {
38184964 cMaterial mat = copy.material;
38194965
3820
- colorField.SetToolTipValue((mat.color));
3821
- modulationField.SetToolTipValue((mat.modulation));
3822
- metalnessField.SetToolTipValue((mat.metalness));
3823
- diffuseField.SetToolTipValue((mat.diffuse));
3824
- specularField.SetToolTipValue((mat.specular));
3825
- shininessField.SetToolTipValue((mat.shininess));
3826
- shiftField.SetToolTipValue((mat.shift));
3827
- ambientField.SetToolTipValue((mat.ambient));
3828
- lightareaField.SetToolTipValue((mat.lightarea));
3829
- diffusenessField.SetToolTipValue((mat.factor));
3830
- velvetField.SetToolTipValue((mat.velvet));
3831
- sheenField.SetToolTipValue((mat.sheen));
3832
- subsurfaceField.SetToolTipValue((mat.subsurface));
3833
- backlitField.SetToolTipValue((mat.bump));
3834
- anisoField.SetToolTipValue((mat.aniso));
3835
- anisoVField.SetToolTipValue((mat.anisoV));
3836
- cameraField.SetToolTipValue((mat.cameralight));
3837
- selfshadowField.SetToolTipValue((mat.diffuseness));
3838
- shadowField.SetToolTipValue((mat.shadow));
3839
- textureField.SetToolTipValue((mat.texture));
3840
- opacityField.SetToolTipValue((mat.opacity));
3841
- fakedepthField.SetToolTipValue((mat.fakedepth));
3842
- shadowbiasField.SetToolTipValue((mat.shadowbias));
4966
+ if (!Equal(colorField.getFloat(), mat.color))
4967
+ colorField.SetToolTipValue((mat.color));
4968
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4969
+ saturationField.SetToolTipValue((mat.modulation));
4970
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4971
+ metalnessField.SetToolTipValue((mat.metalness));
4972
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4973
+ diffuseField.SetToolTipValue((mat.diffuse));
4974
+ if (!Equal(specularField.getFloat(), mat.specular))
4975
+ specularField.SetToolTipValue((mat.specular));
4976
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4977
+ shininessField.SetToolTipValue((mat.shininess));
4978
+ if (!Equal(shiftField.getFloat(), mat.shift))
4979
+ shiftField.SetToolTipValue((mat.shift));
4980
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4981
+ ambientField.SetToolTipValue((mat.ambient));
4982
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4983
+ lightareaField.SetToolTipValue((mat.lightarea));
4984
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4985
+ diffusenessField.SetToolTipValue((mat.factor));
4986
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4987
+ velvetField.SetToolTipValue((mat.velvet));
4988
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4989
+ sheenField.SetToolTipValue((mat.sheen));
4990
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4991
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4992
+ if (!Equal(backlitField.getFloat(), mat.bump))
4993
+ backlitField.SetToolTipValue((mat.bump));
4994
+ if (!Equal(anisoField.getFloat(), mat.aniso))
4995
+ anisoField.SetToolTipValue((mat.aniso));
4996
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
4997
+ anisoVField.SetToolTipValue((mat.anisoV));
4998
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
4999
+ cameraField.SetToolTipValue((mat.cameralight));
5000
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
5001
+ selfshadowField.SetToolTipValue((mat.diffuseness));
5002
+ if (!Equal(shadowField.getFloat(), mat.shadow))
5003
+ shadowField.SetToolTipValue((mat.shadow));
5004
+ if (!Equal(textureField.getFloat(), mat.texture))
5005
+ textureField.SetToolTipValue((mat.texture));
5006
+ if (!Equal(opacityField.getFloat(), mat.opacity))
5007
+ opacityField.SetToolTipValue((mat.opacity));
5008
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
5009
+ fakedepthField.SetToolTipValue((mat.fakedepth));
5010
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
5011
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
38435012 }
38445013
38455014 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -3870,9 +5039,28 @@
38705039 //copy.Touch();
38715040 }
38725041
5042
+ cNumberSlider versionSlider;
5043
+
38735044 public void stateChanged(ChangeEvent e)
38745045 {
3875
- // assert(false);
5046
+ // assert(false);
5047
+ if (e.getSource() == versionSlider)
5048
+ {
5049
+ if (muteSlider)
5050
+ return;
5051
+
5052
+ Replace();
5053
+
5054
+ int version = versionSlider.getInteger();
5055
+
5056
+ if (version != -1 && copy.versionlist[version] != null)
5057
+ {
5058
+ copy.versionindex = version;
5059
+ CopyChanged();
5060
+ }
5061
+
5062
+ return;
5063
+ }
38765064
38775065 if (freezematerial)
38785066 {
....@@ -3908,6 +5096,12 @@
39085096 {
39095097 //System.out.println("stateChanged = " + this);
39105098 materialtouched = true;
5099
+
5100
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
5101
+ {
5102
+ saturationField.setFloat(1);
5103
+ }
5104
+
39115105 applySelf();
39125106 //System.out.println("this = " + this);
39135107 //System.out.println("PARENT = " + parent);
....@@ -4207,6 +5401,7 @@
42075401 {
42085402 if (GetTree() != null)
42095403 {
5404
+ GetTree().revalidate();
42105405 GetTree().repaint();
42115406 }
42125407
....@@ -4215,13 +5410,18 @@
42155410 ctrlPanel.validate(); // ? new
42165411 ctrlPanel.repaint();
42175412 }
5413
+
5414
+ if (previousVersionButton != null && copy.versionlist != null)
5415
+ SetVersionStates();
5416
+
5417
+ cameraView.requestFocusInWindow();
42185418 }
42195419
42205420 static TweenManager tweenManager = new TweenManager();
42215421
42225422 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42235423 {
4224
- if (Globals.SAVEONMAKE)
5424
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42255425 Save();
42265426 //Tween.set(thing, 0).target(1).start(tweenManager);
42275427 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4246,7 +5446,7 @@
42465446 // group = (Composite) group.get(0);
42475447 // }
42485448
4249
- System.out.println("makeSomething of " + thing);
5449
+ //System.out.println("makeSomething of " + thing);
42505450
42515451 /*
42525452 if (deselect && jList != null)
....@@ -4309,6 +5509,12 @@
43095509 {
43105510 ResetModel();
43115511 Select(thing.GetTreePath(), true, false); // unselect... false);
5512
+
5513
+ if (thing.Size() == 0)
5514
+ {
5515
+ //EditSelection(false);
5516
+ }
5517
+
43125518 refreshContents();
43135519 }
43145520
....@@ -4457,7 +5663,9 @@
44575663 readobj.ResetDisplayList();
44585664 } catch (Exception e)
44595665 {
4460
- //e.printStackTrace();
5666
+ if (!e.toString().contains("GZIP"))
5667
+ e.printStackTrace();
5668
+
44615669 try
44625670 {
44635671 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4531,12 +5739,14 @@
45315739
45325740 if (readobj != null)
45335741 {
4534
- if (Globals.SAVEONMAKE)
4535
- Save();
5742
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5743
+ // Save();
45365744 try
45375745 {
45385746 //readobj.deepCopySelf(copy);
45395747 copy.clear(); // june 2014
5748
+ copy.skyboxname = readobj.skyboxname;
5749
+ copy.skyboxext = readobj.skyboxext;
45405750 for (int i = 0; i < readobj.size(); i++)
45415751 {
45425752 Object3D child = readobj.get(i); // reserve(i);
....@@ -4577,6 +5787,7 @@
45775787 }
45785788 } catch (ClassCastException e)
45795789 {
5790
+ e.printStackTrace();
45805791 assert (false);
45815792 Composite c = (Composite) copy;
45825793 c.children.clear();
....@@ -4587,17 +5798,32 @@
45875798 c.addChild(csg);
45885799 }
45895800
5801
+ copy.versionlist = readobj.versionlist;
5802
+ copy.versionindex = readobj.versionindex;
5803
+ copy.versiontable = readobj.versiontable;
5804
+
5805
+ if (copy.versionlist == null)
5806
+ {
5807
+ // Backward compatibility
5808
+ copy.versionlist = new Object3D[100];
5809
+ copy.versionindex = -1;
5810
+
5811
+ //Save(true);
5812
+ }
5813
+
5814
+ //? SetUndoStates();
5815
+
45905816 ResetModel();
45915817 copy.HardTouch(); // recompile?
45925818 refreshContents();
45935819 }
45945820 }
45955821
4596
- void load() // throws ClassNotFoundException
5822
+ void Open() // throws ClassNotFoundException
45975823 {
45985824 if (Grafreed.standAlone)
45995825 {
4600
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5826
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
46015827 browser.show();
46025828 String filename = browser.getFile();
46035829 if (filename != null && filename.length() > 0)
....@@ -4674,6 +5900,8 @@
46745900
46755901 void save()
46765902 {
5903
+ Replace();
5904
+
46775905 if (lastname == null)
46785906 {
46795907 return;
....@@ -4696,6 +5924,7 @@
46965924 //ps.print(buffer.toString());
46975925 } catch (IOException e)
46985926 {
5927
+ e.printStackTrace();
46995928 }
47005929 }
47015930
....@@ -4710,6 +5939,8 @@
47105939 String filename = browser.getFile();
47115940 if (filename != null && filename.length() > 0)
47125941 {
5942
+ if (!filename.endsWith(".gfd"))
5943
+ filename += ".gfd";
47135944 lastname = browser.getDirectory() + filename;
47145945 save();
47155946 }
....@@ -4876,7 +6107,7 @@
48766107 MenuBar menuBar;
48776108 Menu fileMenu;
48786109 MenuItem newItem;
4879
- MenuItem loadItem;
6110
+ MenuItem openItem;
48806111 MenuItem saveItem;
48816112 MenuItem saveAsItem;
48826113 MenuItem exportAsItem;
....@@ -4899,22 +6130,38 @@
48996130 CheckboxMenuItem toggleSwitchItem;
49006131 CheckboxMenuItem toggleRootItem;
49016132 CheckboxMenuItem animationItem;
6133
+ MenuItem archiveItem;
49026134 CheckboxMenuItem toggleHandleItem;
49036135 CheckboxMenuItem togglePaintItem;
49046136 JSplitPane mainPanel;
49056137 JScrollPane scrollpane;
6138
+
49066139 JPanel toolbarPanel;
6140
+
49076141 cGridBag treePanel;
6142
+
49086143 JPanel radioPanel;
49096144 ButtonGroup buttonGroup;
4910
- cGridBag ctrlPanel;
6145
+
6146
+ cGridBag toolboxPanel;
6147
+ cGridBag skyboxPanel;
49116148 cGridBag materialPanel;
6149
+ cGridBag ctrlPanel;
6150
+
49126151 JScrollPane infoPanel;
6152
+
49136153 cGridBag optionsPanel;
6154
+
49146155 JTabbedPane objectPanel;
6156
+ boolean materialFlushed;
6157
+ Object3D latestObject;
6158
+
6159
+ cGridBag transformPanel;
49156160 cGridBag XYZPanel;
6161
+
49166162 JSplitPane gridPanel;
49176163 JSplitPane bigPanel;
6164
+
49186165 cGridBag bigThree;
49196166 cGridBag scenePanel;
49206167 cGridBag centralPanel;
....@@ -4972,7 +6219,7 @@
49726219 JLabel colorLabel;
49736220 cNumberSlider colorField;
49746221 JLabel modulationLabel;
4975
- cNumberSlider modulationField;
6222
+ cNumberSlider saturationField;
49766223 JLabel metalnessLabel;
49776224 cNumberSlider metalnessField;
49786225 JLabel diffuseLabel;
....@@ -5003,6 +6250,7 @@
50036250 cNumberSlider anisoField;
50046251 JLabel anisoVLabel;
50056252 cNumberSlider anisoVField;
6253
+
50066254 JLabel cameraLabel;
50076255 cNumberSlider cameraField;
50086256 JLabel selfshadowLabel;
....@@ -5017,6 +6265,7 @@
50176265 cNumberSlider fakedepthField;
50186266 JLabel shadowbiasLabel;
50196267 cNumberSlider shadowbiasField;
6268
+
50206269 JLabel bumpLabel;
50216270 cNumberSlider bumpField;
50226271 JLabel noiseLabel;
....@@ -5029,7 +6278,7 @@
50296278 cNumberSlider fogField;
50306279 JLabel opacityPowerLabel;
50316280 cNumberSlider opacityPowerField;
5032
- JTree jTree;
6281
+ cTree jTree;
50336282 //ObjectUI parent;
50346283
50356284 cNumberSlider normalpushField;