Normand Briere
2019-08-22 0c7b833be7d86598a6813cd1c6db0ca9e1b17966
ObjEditor.java
....@@ -15,6 +15,9 @@
1515 //import javax.swing.plaf.ColorUIResource;
1616 //import javax.swing.plaf.metal.DefaultMetalTheme;
1717
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1821 //import javax.media.opengl.GLCanvas;
1922
2023 import //weka.core.
....@@ -31,6 +34,7 @@
3134 iSendInfo
3235 //KeyListener
3336 {
37
+ public cToggleButton pinButton;
3438 boolean timeline;
3539 boolean wasFullScreen;
3640
....@@ -38,64 +42,143 @@
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);
53111 }
54112
55113 cToggleButton GetToggleButton(String name, boolean border)
56114 {
57
- try
58
- {
59
- ImageIcon icon = GetIcon(name);
60
- return new cToggleButton(icon, border);
61
- }
62
- catch (Exception e)
63
- {
64
- return new cToggleButton(name, border);
65
- }
115
+ ImageIcon icon = GetIcon(name);
116
+ return new cToggleButton(icon, border);
66117 }
67118
68119 cCheckBox GetCheckBox(String name, boolean border)
69120 {
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
+
70135 try
71136 {
72
- ImageIcon icon = GetIcon(name);
73
- return new cCheckBox(icon, border);
137
+ BufferedImage image;
138
+
139
+ if (name.endsWith("jpg"))
140
+ // Much faster!
141
+ image = new sun.awt.image.codec.JPEGImageDecoderImpl(ObjEditor.class.getClassLoader().getResourceAsStream(name)).decodeAsBufferedImage();
142
+ else
143
+ image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
144
+
145
+// if (image.getWidth() > 48 && image.getHeight() > 48)
146
+// {
147
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
148
+// Graphics2D g = resized.createGraphics();
149
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
150
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
151
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
152
+// g.dispose();
153
+//
154
+// image = resized;
155
+// }
156
+
157
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
158
+
159
+ icons.put(name, icon);
160
+
161
+ return icon;
74162 }
75163 catch (Exception e)
76164 {
77
- return new cCheckBox(name, border);
165
+ //icons.put(name, null);
166
+ return null;
78167 }
79168 }
80
-
81
- private ImageIcon GetIcon(String name) throws IOException
169
+
170
+ BufferedImage GetImage(String name)
82171 {
83
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
-
85
- if (image.getWidth() != 24 && image.getHeight() != 24)
172
+ try
86173 {
87
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
88
- Graphics2D g = resized.createGraphics();
89
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
90
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
92
- g.dispose();
93
-
94
- image = resized;
174
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
175
+
176
+ return image;
95177 }
96
-
97
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
- return icon;
178
+ catch (Exception e)
179
+ {
180
+ return null;
181
+ }
99182 }
100183
101184 // SCRIPT
....@@ -279,6 +362,14 @@
279362 client = inClient;
280363 copy = client;
281364
365
+// if (copy.versionlist == null)
366
+// {
367
+// copy.versionlist = new Object3D[100];
368
+// copy.versionindex = -1;
369
+//
370
+// callee.Save(true);
371
+// }
372
+
282373 // "this" is not called: SetupUI2(objEditor);
283374 }
284375
....@@ -306,14 +397,15 @@
306397 //localCopy.parent = null;
307398
308399 frame = new JFrame();
309
- frame.setUndecorated(true);
400
+ frame.setUndecorated(false);
310401 objEditor = this;
311402 this.callee = callee;
312403
313404 //parent = p;
314405
315406 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
316
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
407
+ if (Globals.DEBUG)
408
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
317409 //gd.setFullScreenWindow(this);
318410 //setResizable(false);
319411 //if (!isDisplayable())
....@@ -324,6 +416,14 @@
324416 copy = localCopy;
325417 copy.editWindow = this;
326418
419
+// if (copy.versionlist == null)
420
+// {
421
+// copy.versionlist = new Object3D[100];
422
+// copy.versionindex = -1;
423
+//
424
+// Save(true);
425
+// }
426
+
327427 SetupMenu();
328428
329429 //SetupName(objEditor); // new
....@@ -342,12 +442,15 @@
342442
343443 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
344444
445
+ // This is to refresh the UI of the material panel.
446
+ boolean patchMaterial;
447
+
345448 void SetupMenu()
346449 {
347450 frame.setMenuBar(menuBar = new MenuBar());
348451 menuBar.add(fileMenu = new Menu("File"));
349452 fileMenu.add(newItem = new MenuItem("New"));
350
- fileMenu.add(loadItem = new MenuItem("Open..."));
453
+ fileMenu.add(openItem = new MenuItem("Open..."));
351454
352455 //oe.menuBar.add(menu = new Menu("Include"));
353456 Menu menu = new Menu("Import");
....@@ -355,8 +458,11 @@
355458 importOBJItem.addActionListener(this);
356459 import3DSItem = menu.add(new MenuItem("3DS file..."));
357460 import3DSItem.addActionListener(this);
461
+ if (Globals.ADVANCED)
462
+ {
358463 importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
359464 importVRMLX3DItem.addActionListener(this);
465
+ }
360466 menu.add("-");
361467 importGFDItem = menu.add(new MenuItem("Grafreed file..."));
362468 importGFDItem.addActionListener(this);
....@@ -379,7 +485,7 @@
379485 }
380486
381487 newItem.addActionListener(this);
382
- loadItem.addActionListener(this);
488
+ openItem.addActionListener(this);
383489 saveItem.addActionListener(this);
384490 saveAsItem.addActionListener(this);
385491 exportAsItem.addActionListener(this);
....@@ -391,6 +497,8 @@
391497
392498 ChangeListener changeListener = new ChangeListener()
393499 {
500
+ //String name;
501
+
394502 public void stateChanged(ChangeEvent changeEvent)
395503 {
396504 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -409,18 +517,49 @@
409517 // EditSelection(false);
410518 // }
411519
412
- refreshContents(false); // To refresh Info tab
520
+// if (objectPanel.getSelectedIndex() == 4)
521
+// {
522
+// name = copy.skyboxname;
523
+//
524
+// if (name == null)
525
+// {
526
+// name = "";
527
+// }
528
+//
529
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
530
+// copy.skyboxext = "jpg";
531
+// }
532
+// else
533
+// {
534
+// if (name != null)
535
+// {
536
+// if (name.equals(""))
537
+// {
538
+// copy.skyboxname = null;
539
+// copy.skyboxext = null;
540
+// }
541
+// else
542
+// {
543
+// copy.skyboxname = name;
544
+// }
545
+// }
546
+// }
547
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
548
+
549
+// refreshContents(false); // To refresh Info tab
550
+ cameraView.repaint();
413551 }
414552 };
415553 objectPanel.addChangeListener(changeListener);
416554
417555 toolbarPanel = new JPanel();
418556 toolbarPanel.setName("Toolbar");
557
+
419558 treePanel = new cGridBag();
420559 treePanel.setName("Tree");
421560
422561 editPanel = new cGridBag().setVertical(true);
423
- editPanel.setName("Edit");
562
+ //editPanel.setName("Edit");
424563
425564 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
426565
....@@ -428,11 +567,13 @@
428567 editPanel.add(editCommandsPanel);
429568 editPanel.add(ctrlPanel);
430569
431
- toolboxPanel = new cGridBag().setVertical(false);
432
- toolboxPanel.setName("Toolbox");
570
+ toolboxPanel = new cGridBag().setVertical(true);
571
+ //toolboxPanel.setName("Toolbox");
433572
434
- materialPanel = new cGridBag().setVertical(true);
435
- materialPanel.setName("Material");
573
+ skyboxPanel = new cGridBag().setVertical(true);
574
+
575
+ materialPanel = new cGridBag().setVertical(false);
576
+ //materialPanel.setName("Material");
436577
437578 /*JTextPane*/
438579 infoarea = createTextPane();
....@@ -440,14 +581,15 @@
440581
441582 infoarea.setEditable(true);
442583 SetText();
584
+
443585 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
444586 // infoarea.setOpaque(false);
445587 // //infoarea.setForeground(textcolor);
446588 // TEXTAREA infoarea.setLineWrap(true);
447589 // TEXTAREA infoarea.setWrapStyleWord(true);
448590 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
449
- infoPanel.setPreferredSize(new Dimension(50, 200));
450
- infoPanel.setName("Info");
591
+ infoPanel.setPreferredSize(new Dimension(1, 1));
592
+ //infoPanel.setName("Info");
451593 //infoPanel.setLayout(new BorderLayout());
452594 //infoPanel.add(createTextPane());
453595
....@@ -458,7 +600,14 @@
458600 mainPanel.setDividerSize(9);
459601 mainPanel.setDividerLocation(0.5); //1.0);
460602 mainPanel.setResizeWeight(0.5);
461
-
603
+
604
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
605
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
606
+ divider.setDividerSize(15);
607
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
608
+
609
+ mainPanel.setUI(new BasicSplitPaneUI());
610
+
462611 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
463612 //mainPanel.setLayout(new GridBagLayout());
464613 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -689,8 +838,8 @@
689838 }
690839 }
691840
692
-static GraphicsDevice device = GraphicsEnvironment
693
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
841
+//static GraphicsDevice device = GraphicsEnvironment
842
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
694843
695844 Rectangle keeprect;
696845 cRadio radio;
....@@ -707,14 +856,24 @@
707856 boolean maximized;
708857
709858 cButton fullscreenLayout;
859
+ cButton expandedLayout;
710860
711861 void Minimize()
712862 {
713863 frame.setState(Frame.ICONIFIED);
864
+ frame.validate();
714865 }
715866
867
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
868
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
869
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
716870 void Maximize()
717871 {
872
+ if (CameraPane.FULLSCREEN)
873
+ {
874
+ ToggleFullScreen();
875
+ }
876
+
718877 if (maximized)
719878 {
720879 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -722,22 +881,38 @@
722881 else
723882 {
724883 keeprect = frame.getBounds();
725
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
726
- Dimension rect2 = frame.getToolkit().getScreenSize();
727
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
884
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
885
+// Dimension rect2 = frame.getToolkit().getScreenSize();
886
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
728887 // frame.setState(Frame.MAXIMIZED_BOTH);
888
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
729889 }
730890
731891 maximized ^= true;
892
+
893
+ frame.validate();
732894 }
895
+
896
+ cButton minButton;
897
+ cButton maxButton;
898
+ cButton fullButton;
899
+ cButton collapseButton;
900
+ cButton maximize3DButton;
733901
734902 void ToggleFullScreen()
735903 {
904
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
905
+
736906 cameraView.ToggleFullScreen();
737907
738908 if (!CameraPane.FULLSCREEN)
739909 {
740910 device.setFullScreenWindow(null);
911
+ frame.dispose();
912
+ frame.setUndecorated(false);
913
+ frame.validate();
914
+ frame.setVisible(true);
915
+
741916 //frame.setVisible(false);
742917 // frame.removeNotify();
743918 // frame.setUndecorated(false);
....@@ -747,13 +922,13 @@
747922 // X frame.getContentPane().remove(/*"Center",*/bigThree);
748923 // X framePanel.add(bigThree);
749924 // X frame.getContentPane().add(/*"Center",*/framePanel);
750
- framePanel.setDividerLocation(1);
925
+// framePanel.setDividerLocation(46); // icons are 24x24
751926
752927 //frame.setVisible(true);
753
- radio.layout = keepButton;
928
+// radio.layout = keepButton;
754929 //theFrame = null;
755930 keepButton = null;
756
- radio.layout.doClick();
931
+// radio.layout.doClick();
757932
758933 } else
759934 {
....@@ -762,20 +937,70 @@
762937 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
763938 // frame.getToolkit().getScreenSize().height);
764939 //frame.setVisible(false);
940
+
941
+ frame.dispose();
942
+ frame.setUndecorated(true);
765943 device.setFullScreenWindow(frame);
944
+ frame.validate();
945
+ frame.setVisible(true);
766946 // frame.removeNotify();
767947 // frame.setUndecorated(true);
768948 // frame.addNotify();
769949 // X frame.getContentPane().remove(/*"Center",*/framePanel);
770950 // X framePanel.remove(bigThree);
771951 // X frame.getContentPane().add(/*"Center",*/bigThree);
772
- framePanel.setDividerLocation(0);
952
+// framePanel.setDividerLocation(0);
773953
774
- radio.layout = fullscreenLayout;
775
- radio.layout.doClick();
954
+// radio.layout = fullscreenLayout;
955
+// radio.layout.doClick();
776956 //frame.setVisible(true);
777957 }
958
+ frame.validate();
959
+
960
+ cameraView.requestFocusInWindow();
778961 }
962
+
963
+ void CollapseToolbar()
964
+ {
965
+ framePanel.setDividerLocation(0);
966
+ //frame.validate();
967
+
968
+ cameraView.requestFocusInWindow();
969
+ }
970
+
971
+ private Object3D Duplicate(Object3D object)
972
+ {
973
+ boolean temp = CameraPane.SWITCH;
974
+ CameraPane.SWITCH = false;
975
+
976
+ if (Grafreed.grafreed.universe.versiontable == null)
977
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
978
+
979
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
980
+ // if (copy == client)
981
+
982
+ Object3D versions[] = object.versionlist;
983
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
984
+ object.versionlist = null;
985
+ object.versiontable = null;
986
+
987
+ Object3D parent = object.parent;
988
+ object.parent = null;
989
+
990
+ //byte[] compress = Compress(copy);
991
+ Object3D compress = (Object3D)Grafreed.clone(object);
992
+
993
+ object.parent = parent;
994
+
995
+ object.versionlist = versions;
996
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
997
+
998
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
999
+
1000
+ CameraPane.SWITCH = temp;
1001
+
1002
+ return compress;
1003
+ }
7791004
7801005 private JTextPane createTextPane()
7811006 {
....@@ -898,6 +1123,7 @@
8981123 {
8991124 SetupMaterial(materialPanel);
9001125 }
1126
+
9011127 //SetupName();
9021128 //SetupViews();
9031129 }
....@@ -907,7 +1133,7 @@
9071133 // NumberSlider vDivsField;
9081134 // JCheckBox endcaps;
9091135 JCheckBox liveCB;
910
- JCheckBox selectCB;
1136
+ JCheckBox selectableCB;
9111137 JCheckBox hideCB;
9121138 JCheckBox link2masterCB;
9131139 JCheckBox markCB;
....@@ -1106,8 +1332,20 @@
11061332
11071333 namePanel = new cGridBag();
11081334
1335
+ //if (copy.pinned)
1336
+ {
1337
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
1338
+ pinButton.setSelected(copy.pinned);
1339
+ cGridBag t = new cGridBag();
1340
+ t.preferredWidth = 2;
1341
+ t.add(pinButton);
1342
+ namePanel.add(t);
1343
+
1344
+ pinButton.addItemListener(this);
1345
+ }
1346
+
11091347 nameField = AddText(namePanel, copy.GetName());
1110
- namePanel.add(nameField);
1348
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11111349 oe.ctrlPanel.add(namePanel);
11121350
11131351 oe.ctrlPanel.Return();
....@@ -1119,26 +1357,30 @@
11191357
11201358 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11211359 liveCB.setToolTipText("Animate object");
1122
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1123
- selectCB.setToolTipText("Make object selectable");
1360
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1361
+ markCB.setToolTipText("Set target transform");
1362
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1363
+ selectableCB.setToolTipText("Make object selectable");
11241364 // Return();
1365
+
11251366 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11261367 hideCB.setToolTipText("Hide object");
1127
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1128
- markCB.setToolTipText("Set the animation target transform");
1368
+
1369
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11291370
11301371 setupPanel2 = new cGridBag().setVertical(false);
11311372
11321373 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11331374 rewindCB.setToolTipText("Rewind animation");
11341375
1135
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1136
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1376
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1377
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11371378
1379
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1380
+ link2masterCB.setToolTipText("Attach to support");
1381
+
11381382 if (Globals.ADVANCED)
11391383 {
1140
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1141
- link2masterCB.setToolTipText("Attach to support");
11421384 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11431385 speedupCB.setToolTipText("Option motion capture");
11441386 }
....@@ -1324,22 +1566,9 @@
13241566
13251567 if (cam == null || !(copy.get(0) instanceof cGroup))
13261568 {
1327
- System.out.println("CREATE CAMERAS");
1328
- cams = new cTemplate();
1329
- cams.name = "Cameras";
1330
- copy.insertElementAt(cams, 0);
1331
- //cams.parent = copy;
1332
-
1333
- cam = new Camera(); // LA.newVector(3, 2, 1));
1334
- cams.addChild(cam);
1335
- cam = new Camera(1);
1336
- cams.addChild(cam);
1337
- cam = new Camera(2);
1338
- cams.addChild(cam);
1339
- cam = new Camera(3);
1340
- cams.addChild(cam);
1341
- cam = new Camera(4); // Light
1342
- cams.addChild(cam);
1569
+ if (Globals.DEBUG)
1570
+ System.out.println("CREATE CAMERAS");
1571
+ cams = CreateCameras();
13431572 } else
13441573 {
13451574 cams = (cGroup) copy.get(0);
....@@ -1405,6 +1634,45 @@
14051634 //frontView.object = copy;
14061635 //sideView.object = copy;
14071636
1637
+ transformPanel = new cGridBag().setVertical(true);
1638
+
1639
+ cGridBag resetTransformPanel = new cGridBag();
1640
+
1641
+ resetTransformPanel.preferredHeight = 2;
1642
+
1643
+ cButton resetTransform = GetButton("Reset all", !Globals.NIMBUSLAF);
1644
+ resetTransform.setToolTipText("Reset Translation, Rotation and Scale");
1645
+ resetTransform.addMouseListener(new MouseAdapter()
1646
+ {
1647
+ public void mouseClicked(MouseEvent e)
1648
+ {
1649
+ ResetTransform();
1650
+ }
1651
+ });
1652
+ resetTransformPanel.add(resetTransform);
1653
+
1654
+ resetTransform = GetButton("T only", !Globals.NIMBUSLAF);
1655
+ resetTransform.setToolTipText("Reset Translation only");
1656
+ resetTransform.addMouseListener(new MouseAdapter()
1657
+ {
1658
+ public void mouseClicked(MouseEvent e)
1659
+ {
1660
+ ResetTransform(1);
1661
+ }
1662
+ });
1663
+ resetTransformPanel.add(resetTransform);
1664
+
1665
+ resetTransform = GetButton("RS only", !Globals.NIMBUSLAF);
1666
+ resetTransform.setToolTipText("Reset Rotation and Scale only");
1667
+ resetTransform.addMouseListener(new MouseAdapter()
1668
+ {
1669
+ public void mouseClicked(MouseEvent e)
1670
+ {
1671
+ ResetTransform(2);
1672
+ }
1673
+ });
1674
+ resetTransformPanel.add(resetTransform);
1675
+
14081676 XYZPanel = new cGridBag().setVertical(true);
14091677 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
14101678
....@@ -1412,7 +1680,11 @@
14121680 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14131681 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14141682 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1683
+ //XYZPanel.setName("XYZ");
14151684
1685
+ transformPanel.add(resetTransformPanel);
1686
+ transformPanel.add(XYZPanel);
1687
+
14161688 /*
14171689 gridPanel = new JPanel(); //new BorderLayout());
14181690 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1420,12 +1692,12 @@
14201692 gridPanel.add(cameraView);
14211693 gridPanel.add(XYZPanel);
14221694 */
1423
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1424
- gridPanel.setContinuousLayout(true);
1425
- gridPanel.setOneTouchExpandable(true);
1426
- gridPanel.setDividerLocation(1.0);
1427
- gridPanel.setDividerSize(9);
1428
- gridPanel.setResizeWeight(0.85);
1695
+// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1696
+// gridPanel.setContinuousLayout(true);
1697
+// gridPanel.setOneTouchExpandable(true);
1698
+// gridPanel.setDividerLocation(1.0);
1699
+// gridPanel.setDividerSize(9);
1700
+// gridPanel.setResizeWeight(0.85);
14291701
14301702 // aConstraints.weighty = 0;
14311703 //System.out.println("THIS = " + this);
....@@ -1448,15 +1720,34 @@
14481720
14491721 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14501722 //tmp.setName("Edit");
1723
+ objectPanel.add(skyboxPanel);
1724
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1725
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1726
+
1727
+ objectPanel.add(toolboxPanel);
1728
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1729
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1730
+
14511731 objectPanel.add(materialPanel);
1732
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1733
+ objectPanel.setToolTipTextAt(2, "Material");
1734
+
14521735 // JPanel north = new JPanel(new BorderLayout());
14531736 // north.setName("Edit");
14541737 // north.add(ctrlPanel, BorderLayout.NORTH);
14551738 // objectPanel.add(north);
14561739 objectPanel.add(editPanel);
1457
- objectPanel.add(infoPanel);
1458
- objectPanel.add(toolboxPanel);
1459
-
1740
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
1741
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1742
+
1743
+ objectPanel.add(transformPanel);
1744
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1745
+ objectPanel.setToolTipTextAt(4, "TRS transform");
1746
+
1747
+ patchMaterial = true;
1748
+ cameraView.patchMaterial = this;
1749
+ objectPanel.setSelectedIndex(2);
1750
+
14601751 /*
14611752 aConstraints.gridx = 0;
14621753 aConstraints.gridwidth = 1;
....@@ -1487,11 +1778,108 @@
14871778
14881779 AddOptions(optionsPanel); //, aConstraints);
14891780
1490
- tabbedPane.add(optionsPanel);
1491
-
14921781 tabbedPane.add(FSPane = new cFileSystemPane(this));
14931782
1783
+ tabbedPane.add(optionsPanel);
1784
+
14941785 scenePanel.add(tabbedPane);
1786
+
1787
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1788
+ creditsPanel.setName("Credits");
1789
+
1790
+ cLabel ogaLabel = new cLabel(" Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1791
+ creditsPanel.add(ogaLabel);
1792
+
1793
+ cButton creditButton;
1794
+ creditsPanel.add(creditButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1795
+ creditButton.setToolTipText("https://opengameart.org");
1796
+
1797
+ creditButton.addMouseListener(new MouseAdapter()
1798
+ {
1799
+ public void mouseClicked(MouseEvent e)
1800
+ {
1801
+ try
1802
+ {
1803
+ Desktop.getDesktop().browse(new java.net.URI("https://opengameart.org/"));
1804
+ } catch (Exception e1)
1805
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1806
+ {
1807
+ e1.printStackTrace();
1808
+ }
1809
+ }
1810
+ });
1811
+
1812
+ ogaLabel = new cLabel(" Download 3D models! (.3ds and .obj only)", !Globals.NIMBUSLAF);
1813
+ creditsPanel.add(ogaLabel);
1814
+
1815
+ creditsPanel.add(creditButton = GetButton("icons/3delicious.png", !Globals.NIMBUSLAF));
1816
+ creditButton.setToolTipText("https://3delicious.net");
1817
+
1818
+ creditButton.addMouseListener(new MouseAdapter()
1819
+ {
1820
+ public void mouseClicked(MouseEvent e)
1821
+ {
1822
+ try
1823
+ {
1824
+ Desktop.getDesktop().browse(new java.net.URI("https://3delicious.net"));
1825
+ } catch (Exception e1)
1826
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1827
+ {
1828
+ e1.printStackTrace();
1829
+ }
1830
+ }
1831
+ });
1832
+
1833
+ creditsPanel.add(creditButton = GetButton("icons/archive3d.png", !Globals.NIMBUSLAF));
1834
+ creditButton.setToolTipText("https://archive3d.net");
1835
+
1836
+ creditButton.addMouseListener(new MouseAdapter()
1837
+ {
1838
+ public void mouseClicked(MouseEvent e)
1839
+ {
1840
+ try
1841
+ {
1842
+ Desktop.getDesktop().browse(new java.net.URI("https://archive3d.net"));
1843
+ } catch (Exception e1)
1844
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1845
+ {
1846
+ e1.printStackTrace();
1847
+ }
1848
+ }
1849
+ });
1850
+
1851
+ creditsPanel.add(creditButton = GetButton("icons/turbosquid.png", !Globals.NIMBUSLAF));
1852
+ creditButton.setToolTipText("https://turbosquid.com");
1853
+
1854
+ creditButton.addMouseListener(new MouseAdapter()
1855
+ {
1856
+ public void mouseClicked(MouseEvent e)
1857
+ {
1858
+ try
1859
+ {
1860
+ Desktop.getDesktop().browse(new java.net.URI("https://www.turbosquid.com/Search/3D-Models/free"));
1861
+ } catch (Exception e1)
1862
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1863
+ {
1864
+ e1.printStackTrace();
1865
+ }
1866
+ }
1867
+ });
1868
+
1869
+ for (int i=6; --i>=0;)
1870
+ {
1871
+ creditsPanel.add(new cGridBag());
1872
+ }
1873
+
1874
+ tabbedPane.add(creditsPanel);
1875
+ tabbedPane.setToolTipTextAt(3, "Credits");
1876
+
1877
+ if (Globals.ADVANCED)
1878
+ {
1879
+ objectPanel.add(infoPanel);
1880
+ objectPanel.setIconAt(5, GetIcon("icons/info.png"));
1881
+ objectPanel.setToolTipTextAt(4, "Information");
1882
+ }
14951883
14961884 /*
14971885 cTree jTree = new cTree(null);
....@@ -1513,13 +1901,13 @@
15131901 jtp.add(tree);
15141902 */
15151903
1516
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1517
- bigPanel.setContinuousLayout(true);
1518
- bigPanel.setOneTouchExpandable(true);
1519
- bigPanel.setDividerLocation(0.8);
1520
- bigPanel.setDividerSize(15);
1521
- bigPanel.setResizeWeight(0.15);
1522
- bigPanel.setName("Scene");
1904
+// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1905
+// bigPanel.setContinuousLayout(true);
1906
+// bigPanel.setOneTouchExpandable(true);
1907
+// bigPanel.setDividerLocation(0.8);
1908
+// bigPanel.setDividerSize(15);
1909
+// bigPanel.setResizeWeight(0.15);
1910
+// bigPanel.setName("Scene");
15231911
15241912 //bigPanel.setLayout(new BorderLayout());
15251913 //bigPanel.setSize(new Dimension(10,10));
....@@ -1554,7 +1942,7 @@
15541942 bigThree = new cGridBag();
15551943 bigThree.addComponent(scenePanel);
15561944 bigThree.addComponent(centralPanel);
1557
- bigThree.addComponent(XYZPanel);
1945
+ //bigThree.addComponent(XYZPanel);
15581946
15591947 // // SIDE EFFECT!!!
15601948 // aConstraints.gridx = 0;
....@@ -1563,16 +1951,33 @@
15631951 // aConstraints.gridheight = 1;
15641952
15651953 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1566
- framePanel.setContinuousLayout(true);
1567
- framePanel.setOneTouchExpandable(true);
1568
- framePanel.setDividerLocation(0.8);
1954
+
1955
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1956
+ new java.beans.PropertyChangeListener()
1957
+ {
1958
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1959
+ {
1960
+ if ((Integer)pce.getOldValue() == 1)
1961
+ {
1962
+ if (radio.layout != expandedLayout)
1963
+ {
1964
+ radio.layout = expandedLayout;
1965
+ radio.layout.doClick();
1966
+ }
1967
+ }
1968
+ }
1969
+ });
1970
+
1971
+ framePanel.setContinuousLayout(false);
1972
+ framePanel.setOneTouchExpandable(false);
1973
+ //.setDividerLocation(0.8);
15691974 //framePanel.setDividerSize(15);
15701975 //framePanel.setResizeWeight(0.15);
15711976 framePanel.setName("Frame");
15721977
15731978 frame.getContentPane().setLayout(new BorderLayout());
15741979 /**/
1575
- JTabbedPane worldPane = new JTabbedPane();
1980
+ //JTabbedPane worldPane = new JTabbedPane();
15761981 //worldPane.add(bigPanel);
15771982 //worldPane.add(worldPanel);
15781983 /**/
....@@ -1584,17 +1989,17 @@
15841989
15851990 frame.setSize(1280, 860);
15861991
1587
- frame.validate();
1588
- frame.setVisible(true);
1589
-
15901992 cameraView.requestFocusInWindow();
15911993
1592
- gridPanel.setDividerLocation(1.0);
1994
+// gridPanel.setDividerLocation(1.0);
1995
+
1996
+ frame.validate();
1997
+
1998
+ frame.setVisible(true);
15931999
15942000 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15952001 frame.addWindowListener(new WindowAdapter()
15962002 {
1597
-
15982003 public void windowClosing(WindowEvent e)
15992004 {
16002005 Close();
....@@ -1617,28 +2022,484 @@
16172022 ctrlPanel.removeAll();
16182023 }
16192024
1620
- void SetupMaterial(cGridBag panel)
2025
+ void SetupMaterial(cGridBag materialpanel)
16212026 {
1622
- /*
2027
+ cGridBag presetpanel = new cGridBag().setVertical(true);
2028
+
2029
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
2030
+ skin.setToolTipText("Skin");
2031
+ skin.addMouseListener(new MouseAdapter()
2032
+ {
2033
+ public void mouseClicked(MouseEvent e)
2034
+ {
2035
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
2036
+ cMaterial material = object.material;
2037
+
2038
+ // Skin
2039
+ colorField.setFloat(material.color);
2040
+ float saturation = material.modulation;
2041
+
2042
+ if (!cameraView.Skinshader)
2043
+ {
2044
+ saturation /= 1.5;
2045
+ }
2046
+
2047
+ saturationField.setFloat(saturation);
2048
+
2049
+ subsurfaceField.setFloat(material.subsurface);
2050
+ selfshadowField.setFloat(material.diffuseness);
2051
+ diffusenessField.setFloat(material.factor);
2052
+ shininessField.setFloat(material.shininess);
2053
+ shadowbiasField.setFloat(material.shadowbias);
2054
+ diffuseField.setFloat(material.diffuse);
2055
+ specularField.setFloat(material.specular);
2056
+
2057
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2058
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2059
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2060
+
2061
+ materialtouched = true;
2062
+ applySelf();
2063
+ }
2064
+ });
2065
+ presetpanel.add(skin);
2066
+
2067
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
2068
+ lambert.setToolTipText("Diffuse");
2069
+ lambert.addMouseListener(new MouseAdapter()
2070
+ {
2071
+ public void mouseClicked(MouseEvent e)
2072
+ {
2073
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
2074
+ cMaterial material = object.material;
2075
+
2076
+ diffusenessField.setFloat(material.factor);
2077
+ selfshadowField.setFloat(material.diffuseness);
2078
+
2079
+ materialtouched = true;
2080
+ applySelf();
2081
+ }
2082
+ });
2083
+ presetpanel.add(lambert);
2084
+
2085
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
2086
+ diffuse2.setToolTipText("Diffuse2");
2087
+ diffuse2.addMouseListener(new MouseAdapter()
2088
+ {
2089
+ public void mouseClicked(MouseEvent e)
2090
+ {
2091
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
2092
+ cMaterial material = object.material;
2093
+
2094
+ diffusenessField.setFloat(material.factor);
2095
+ selfshadowField.setFloat(material.diffuseness);
2096
+
2097
+ materialtouched = true;
2098
+ applySelf();
2099
+ }
2100
+ });
2101
+ presetpanel.add(diffuse2);
2102
+
2103
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
2104
+ diffusemoon.setToolTipText("Moon");
2105
+ diffusemoon.addMouseListener(new MouseAdapter()
2106
+ {
2107
+ public void mouseClicked(MouseEvent e)
2108
+ {
2109
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
2110
+ cMaterial material = object.material;
2111
+
2112
+ diffusenessField.setFloat(material.factor);
2113
+ selfshadowField.setFloat(material.diffuseness);
2114
+
2115
+ materialtouched = true;
2116
+ applySelf();
2117
+ }
2118
+ });
2119
+ presetpanel.add(diffusemoon);
2120
+
2121
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
2122
+ diffusemoon2.setToolTipText("Moon2");
2123
+ diffusemoon2.addMouseListener(new MouseAdapter()
2124
+ {
2125
+ public void mouseClicked(MouseEvent e)
2126
+ {
2127
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
2128
+ cMaterial material = object.material;
2129
+
2130
+ diffusenessField.setFloat(material.factor);
2131
+ selfshadowField.setFloat(material.diffuseness);
2132
+
2133
+ materialtouched = true;
2134
+ applySelf();
2135
+ }
2136
+ });
2137
+ presetpanel.add(diffusemoon2);
2138
+
2139
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
2140
+ diffusemoon3.setToolTipText("Moon3");
2141
+ diffusemoon3.addMouseListener(new MouseAdapter()
2142
+ {
2143
+ public void mouseClicked(MouseEvent e)
2144
+ {
2145
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2146
+ cMaterial material = object.material;
2147
+
2148
+ diffusenessField.setFloat(material.factor);
2149
+ selfshadowField.setFloat(material.diffuseness);
2150
+
2151
+ materialtouched = true;
2152
+ applySelf();
2153
+ }
2154
+ });
2155
+ presetpanel.add(diffusemoon3);
2156
+
2157
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
2158
+ diffusesheen.setToolTipText("Sheen");
2159
+ diffusesheen.addMouseListener(new MouseAdapter()
2160
+ {
2161
+ public void mouseClicked(MouseEvent e)
2162
+ {
2163
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2164
+ cMaterial material = object.material;
2165
+
2166
+ sheenField.setFloat(material.sheen);
2167
+
2168
+ materialtouched = true;
2169
+ applySelf();
2170
+ }
2171
+ });
2172
+ presetpanel.add(diffusesheen);
2173
+
2174
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
2175
+ rough.setToolTipText("Rough metal");
2176
+ rough.addMouseListener(new MouseAdapter()
2177
+ {
2178
+ public void mouseClicked(MouseEvent e)
2179
+ {
2180
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2181
+ cMaterial material = object.material;
2182
+
2183
+ shininessField.setFloat(material.shininess);
2184
+ velvetField.setFloat(material.velvet);
2185
+
2186
+ materialtouched = true;
2187
+ applySelf();
2188
+ }
2189
+ });
2190
+ presetpanel.add(rough);
2191
+
2192
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
2193
+ rough2.setToolTipText("Medium metal");
2194
+ rough2.addMouseListener(new MouseAdapter()
2195
+ {
2196
+ public void mouseClicked(MouseEvent e)
2197
+ {
2198
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2199
+ cMaterial material = object.material;
2200
+
2201
+ shininessField.setFloat(material.shininess);
2202
+ lightareaField.setFloat(material.lightarea);
2203
+
2204
+ materialtouched = true;
2205
+ applySelf();
2206
+ }
2207
+ });
2208
+ presetpanel.add(rough2);
2209
+
2210
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
2211
+ shini0.setToolTipText("Shiny");
2212
+ shini0.addMouseListener(new MouseAdapter()
2213
+ {
2214
+ public void mouseClicked(MouseEvent e)
2215
+ {
2216
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2217
+ cMaterial material = object.material;
2218
+
2219
+ shininessField.setFloat(material.shininess);
2220
+ lightareaField.setFloat(material.lightarea);
2221
+
2222
+ materialtouched = true;
2223
+ applySelf();
2224
+ }
2225
+ });
2226
+ presetpanel.add(shini0);
2227
+
2228
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
2229
+ shini1.setToolTipText("Shiny2");
2230
+ shini1.addMouseListener(new MouseAdapter()
2231
+ {
2232
+ public void mouseClicked(MouseEvent e)
2233
+ {
2234
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2235
+ cMaterial material = object.material;
2236
+
2237
+ shininessField.setFloat(material.shininess);
2238
+ lightareaField.setFloat(material.lightarea);
2239
+
2240
+ materialtouched = true;
2241
+ applySelf();
2242
+ }
2243
+ });
2244
+ presetpanel.add(shini1);
2245
+
2246
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
2247
+ shini2.setToolTipText("Shiny3");
2248
+ shini2.addMouseListener(new MouseAdapter()
2249
+ {
2250
+ public void mouseClicked(MouseEvent e)
2251
+ {
2252
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2253
+ cMaterial material = object.material;
2254
+
2255
+ shininessField.setFloat(material.shininess);
2256
+ lightareaField.setFloat(material.lightarea);
2257
+
2258
+ materialtouched = true;
2259
+ applySelf();
2260
+ }
2261
+ });
2262
+ presetpanel.add(shini2);
2263
+
2264
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
2265
+ aniso.setToolTipText("AnisoU");
2266
+ aniso.addMouseListener(new MouseAdapter()
2267
+ {
2268
+ public void mouseClicked(MouseEvent e)
2269
+ {
2270
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2271
+ cMaterial material = object.material;
2272
+
2273
+ anisoField.setFloat(material.aniso);
2274
+ anisoVField.setFloat(material.anisoV);
2275
+
2276
+ materialtouched = true;
2277
+ applySelf();
2278
+ }
2279
+ });
2280
+ presetpanel.add(aniso);
2281
+
2282
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
2283
+ aniso2.setToolTipText("AnisoV");
2284
+ aniso2.addMouseListener(new MouseAdapter()
2285
+ {
2286
+ public void mouseClicked(MouseEvent e)
2287
+ {
2288
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2289
+ cMaterial material = object.material;
2290
+
2291
+ anisoField.setFloat(material.aniso);
2292
+ anisoVField.setFloat(material.anisoV);
2293
+
2294
+ materialtouched = true;
2295
+ applySelf();
2296
+ }
2297
+ });
2298
+ presetpanel.add(aniso2);
2299
+
2300
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
2301
+ aniso3.setToolTipText("AnisoUV");
2302
+ aniso3.addMouseListener(new MouseAdapter()
2303
+ {
2304
+ public void mouseClicked(MouseEvent e)
2305
+ {
2306
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2307
+ cMaterial material = object.material;
2308
+
2309
+ anisoField.setFloat(material.aniso);
2310
+ anisoVField.setFloat(material.anisoV);
2311
+
2312
+ materialtouched = true;
2313
+ applySelf();
2314
+ }
2315
+ });
2316
+ presetpanel.add(aniso3);
2317
+
2318
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
2319
+ velvet0.setToolTipText("Velvet");
2320
+ velvet0.addMouseListener(new MouseAdapter()
2321
+ {
2322
+ public void mouseClicked(MouseEvent e)
2323
+ {
2324
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2325
+ cMaterial material = object.material;
2326
+
2327
+ diffusenessField.setFloat(material.factor);
2328
+ selfshadowField.setFloat(material.diffuseness);
2329
+ sheenField.setFloat(material.sheen);
2330
+ shininessField.setFloat(material.shininess);
2331
+ velvetField.setFloat(material.velvet);
2332
+ shiftField.setFloat(material.shift);
2333
+
2334
+ materialtouched = true;
2335
+ applySelf();
2336
+ }
2337
+ });
2338
+ presetpanel.add(velvet0);
2339
+
2340
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
2341
+ bump0.setToolTipText("Bump texture");
2342
+ bump0.addMouseListener(new MouseAdapter()
2343
+ {
2344
+ public void mouseClicked(MouseEvent e)
2345
+ {
2346
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2347
+ cMaterial material = object.material;
2348
+
2349
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2350
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2351
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2352
+
2353
+ materialtouched = true;
2354
+ applySelf();
2355
+ }
2356
+ });
2357
+ presetpanel.add(bump0);
2358
+
2359
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
2360
+ borderShader.setToolTipText("Border fade");
2361
+ borderShader.addMouseListener(new MouseAdapter()
2362
+ {
2363
+ public void mouseClicked(MouseEvent e)
2364
+ {
2365
+ borderfadeField.setFloat(0.4);
2366
+ opacityField.setFloat(0.75);
2367
+
2368
+ materialtouched = true;
2369
+ applySelf();
2370
+ }
2371
+ });
2372
+ presetpanel.add(borderShader);
2373
+
2374
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
2375
+ halo.setToolTipText("Halo");
2376
+ halo.addMouseListener(new MouseAdapter()
2377
+ {
2378
+ public void mouseClicked(MouseEvent e)
2379
+ {
2380
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2381
+ cMaterial material = object.material;
2382
+
2383
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2384
+
2385
+ materialtouched = true;
2386
+ applySelf();
2387
+ }
2388
+ });
2389
+ presetpanel.add(halo);
2390
+
2391
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
2392
+ candle.setToolTipText("Candle");
2393
+ candle.addMouseListener(new MouseAdapter()
2394
+ {
2395
+ public void mouseClicked(MouseEvent e)
2396
+ {
2397
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2398
+ cMaterial material = object.material;
2399
+
2400
+ subsurfaceField.setFloat(material.subsurface);
2401
+ shadowbiasField.setFloat(material.shadowbias);
2402
+ ambientField.setFloat(material.ambient);
2403
+ specularField.setFloat(material.specular);
2404
+ lightareaField.setFloat(material.lightarea);
2405
+ shininessField.setFloat(material.shininess);
2406
+
2407
+ materialtouched = true;
2408
+ applySelf();
2409
+ }
2410
+ });
2411
+ presetpanel.add(candle);
2412
+
2413
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
2414
+ shadowShader.setToolTipText("Shadow");
2415
+ shadowShader.addMouseListener(new MouseAdapter()
2416
+ {
2417
+ public void mouseClicked(MouseEvent e)
2418
+ {
2419
+ diffuseField.setFloat(0.001);
2420
+ ambientField.setFloat(0.001);
2421
+ cameraField.setFloat(0.001);
2422
+ specularField.setFloat(0.001);
2423
+ fakedepthField.setFloat(0.001);
2424
+ opacityField.setFloat(0.6);
2425
+
2426
+ materialtouched = true;
2427
+ applySelf();
2428
+ }
2429
+ });
2430
+ presetpanel.add(shadowShader);
2431
+
2432
+ cLabel para0 = GetLabel("icons/shadericons/parallax0.png", !Globals.NIMBUSLAF);
2433
+ para0.setToolTipText("No parallax");
2434
+ para0.addMouseListener(new MouseAdapter()
2435
+ {
2436
+ public void mouseClicked(MouseEvent e)
2437
+ {
2438
+ parallaxField.setFloat(0.125);
2439
+
2440
+ materialtouched = true;
2441
+ applySelf();
2442
+ }
2443
+ });
2444
+ presetpanel.add(para0);
2445
+
2446
+ cLabel para1 = GetLabel("icons/shadericons/parallax1.png", !Globals.NIMBUSLAF);
2447
+ para1.setToolTipText("With parallax");
2448
+ para1.addMouseListener(new MouseAdapter()
2449
+ {
2450
+ public void mouseClicked(MouseEvent e)
2451
+ {
2452
+ parallaxField.setFloat(0.13);
2453
+
2454
+ materialtouched = true;
2455
+ applySelf();
2456
+ }
2457
+ });
2458
+ presetpanel.add(para1);
2459
+
2460
+ cLabel para2 = GetLabel("icons/shadericons/parallax2.png", !Globals.NIMBUSLAF);
2461
+ para2.setToolTipText("Reset parallax");
2462
+ para2.addMouseListener(new MouseAdapter()
2463
+ {
2464
+ public void mouseClicked(MouseEvent e)
2465
+ {
2466
+ parallaxField.setFloat(0.14);
2467
+
2468
+ materialtouched = true;
2469
+ applySelf();
2470
+ }
2471
+ });
2472
+ presetpanel.add(para2);
2473
+
2474
+ cGridBag panel = new cGridBag().setVertical(true);
2475
+
2476
+ presetpanel.preferredWidth = 1;
2477
+
2478
+ materialpanel.add(presetpanel);
2479
+ materialpanel.add(panel);
2480
+
2481
+ panel.preferredWidth = 8;
2482
+
2483
+ /*
16232484 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16242485 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1625
- */
2486
+ */
16262487
16272488 cGridBag editBar = new cGridBag().setVertical(false);
16282489
1629
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2490
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
16302491 createMaterialButton.setToolTipText("Create material");
16312492
16322493 /*
16332494 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
16342495 */
16352496
1636
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2497
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
16372498 clearMaterialButton.setToolTipText("Clear material");
16382499
16392500 if (Globals.ADVANCED)
16402501 {
1641
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2502
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
16422503 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
16432504 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
16442505 }
....@@ -1656,45 +2517,61 @@
16562517 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16572518
16582519 cGridBag colorSection = new cGridBag().setVertical(true);
2520
+
2521
+ cGridBag huepanel = new cGridBag();
2522
+ cGridBag huelabel = new cGridBag();
2523
+ cLabel hue = GetLabel("icons/hue.png", false);
2524
+ hue.fit = true;
2525
+
2526
+ hue.addMouseListener(new MouseAdapter()
2527
+ {
2528
+ public void mousePressed(MouseEvent e)
2529
+ {
2530
+ int x = e.getX();
2531
+
2532
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2533
+ }
2534
+ });
2535
+
2536
+ huelabel.add(hue);
2537
+ huelabel.preferredWidth = 20;
2538
+ huepanel.add(new cGridBag()); // Label
2539
+ huepanel.add(huelabel); // Field/slider
2540
+
2541
+ huepanel.preferredHeight = 7;
2542
+
2543
+ colorSection.add(huepanel);
16592544
16602545 cGridBag color = new cGridBag();
1661
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1662
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1663
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2546
+
2547
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2548
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2549
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2550
+
16642551 //colorField.preferredWidth = 200;
16652552 colorSection.add(color);
16662553
16672554 cGridBag modulation = new cGridBag();
16682555 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16692556 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1670
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2557
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16712558 colorSection.add(modulation);
16722559
2560
+ cGridBag opacity = new cGridBag();
2561
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2562
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2563
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2564
+ colorSection.add(opacity);
2565
+
2566
+ colorSection.add(GetSeparator());
2567
+
16732568 cGridBag texture = new cGridBag();
16742569 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16752570 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16762571 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16772572 colorSection.add(texture);
16782573
1679
- cGridBag anisoU = new cGridBag();
1680
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1681
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1682
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1683
- colorSection.add(anisoU);
1684
-
1685
- cGridBag anisoV = new cGridBag();
1686
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1687
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1688
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1689
- colorSection.add(anisoV);
1690
-
1691
- cGridBag shadowbias = new cGridBag();
1692
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1693
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1694
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1695
- colorSection.add(shadowbias);
1696
-
1697
- panel.add(new JSeparator());
2574
+ panel.add(GetSeparator());
16982575
16992576 panel.add(colorSection);
17002577
....@@ -1744,7 +2621,13 @@
17442621 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17452622 diffuseSection.add(fakedepth);
17462623
1747
- panel.add(new JSeparator());
2624
+ cGridBag shadowbias = new cGridBag();
2625
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2626
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2627
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2628
+ diffuseSection.add(shadowbias);
2629
+
2630
+ panel.add(GetSeparator());
17482631
17492632 panel.add(diffuseSection);
17502633
....@@ -1794,42 +2677,54 @@
17942677 // aConstraints.gridy += 1;
17952678 // aConstraints.gridwidth = 1;
17962679
2680
+ cGridBag anisoU = new cGridBag();
2681
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2682
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2683
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2684
+ specularSection.add(anisoU);
17972685
1798
- panel.add(new JSeparator());
2686
+ cGridBag anisoV = new cGridBag();
2687
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2688
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2689
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2690
+ specularSection.add(anisoV);
2691
+
2692
+
2693
+ panel.add(GetSeparator());
17992694
18002695 panel.add(specularSection);
18012696
18022697 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18032698
1804
- cGridBag globalSection = new cGridBag().setVertical(true);
2699
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18052700
18062701 cGridBag camera = new cGridBag();
18072702 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18082703 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18092704 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1810
- globalSection.add(camera);
2705
+ colorSection.add(camera);
18112706
18122707 cGridBag ambient = new cGridBag();
18132708 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18142709 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18152710 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1816
- globalSection.add(ambient);
2711
+ colorSection.add(ambient);
18172712
18182713 cGridBag backlit = new cGridBag();
18192714 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18202715 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18212716 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1822
- globalSection.add(backlit);
2717
+ colorSection.add(backlit);
18232718
1824
- cGridBag opacity = new cGridBag();
1825
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1826
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1827
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1828
- globalSection.add(opacity);
1829
-
1830
- panel.add(new JSeparator());
2719
+ cGridBag parallax = new cGridBag();
2720
+ parallax.add(parallaxLabel = new JLabel("Parallax")); // , aConstraints);
2721
+ parallaxLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2722
+ parallax.add(parallaxField = new cNumberSlider(this, 0.001, 0.25, -0.125)); // , aConstraints);
2723
+ colorSection.add(parallax);
18312724
1832
- panel.add(globalSection);
2725
+ //panel.add(new JSeparator());
2726
+
2727
+ //panel.add(globalSection);
18332728
18342729 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18352730
....@@ -1871,7 +2766,7 @@
18712766 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18722767 textureSection.add(opacityPower);
18732768
1874
- panel.add(new JSeparator());
2769
+ panel.add(GetSeparator());
18752770
18762771 panel.add(textureSection);
18772772
....@@ -1936,8 +2831,9 @@
19362831 // 3D models
19372832 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19382833 {
1939
- lastConverter = new com.jmex.model.converters.MaxToJme();
1940
- LoadFile(filename, lastConverter);
2834
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2835
+ //LoadFile(filename, lastConverter);
2836
+ LoadObjFile(filename); // New 3ds loader
19412837 continue;
19422838 }
19432839 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2663,6 +3559,7 @@
26633559 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26643560 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26653561 }
3562
+
26663563 //cJME.count++;
26673564 //cJME.count %= 12;
26683565 if (gc)
....@@ -2846,6 +3743,7 @@
28463743 }
28473744 }
28483745 }
3746
+
28493747 cFileSystemPane FSPane;
28503748
28513749 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2855,7 +3753,7 @@
28553753
28563754 freezematerial = true;
28573755 colorField.setFloat(mat.color);
2858
- modulationField.setFloat(mat.modulation);
3756
+ saturationField.setFloat(mat.modulation);
28593757 metalnessField.setFloat(mat.metalness);
28603758 diffuseField.setFloat(mat.diffuse);
28613759 specularField.setFloat(mat.specular);
....@@ -2875,6 +3773,7 @@
28753773 shadowField.setFloat(mat.shadow);
28763774 textureField.setFloat(mat.texture);
28773775 opacityField.setFloat(mat.opacity);
3776
+ parallaxField.setFloat(mat.parallax + 0.125f);
28783777 fakedepthField.setFloat(mat.fakedepth);
28793778 shadowbiasField.setFloat(mat.shadowbias);
28803779 bumpField.setInteger(1); // dec 2013
....@@ -2899,6 +3798,7 @@
28993798 }
29003799 }
29013800 }
3801
+
29023802 freezematerial = false;
29033803 }
29043804
....@@ -2916,32 +3816,8 @@
29163816
29173817 if (multiplyToggle != null)
29183818 multiplyToggle.setSelected(mat.multiply);
2919
-
2920
- assert (object.projectedVertices != null);
2921
-
2922
- if (object.projectedVertices.length <= 2)
2923
- {
2924
- // Side effect...
2925
- Object3D.cVector2[] keep = object.projectedVertices;
2926
- object.projectedVertices = new Object3D.cVector2[3];
2927
- for (int i = 0; i < 3; i++)
2928
- {
2929
- if (i < keep.length)
2930
- {
2931
- object.projectedVertices[i] = keep[i];
2932
- } else
2933
- {
2934
- object.projectedVertices[i] = new Object3D.cVector2();
2935
- }
2936
- /*
2937
- if(keep.length == 0)
2938
- object.projectedVertices[0] = new Object3D.cVector2();
2939
- else
2940
- object.projectedVertices[0] = keep[0];
2941
- object.projectedVertices[1] = new Object3D.cVector2();
2942
- */
2943
- }
2944
- }
3819
+
3820
+ AllocProjectedVertices(object);
29453821
29463822 SetMaterial(mat, object.projectedVertices);
29473823 }
....@@ -3017,12 +3893,17 @@
30173893 // }
30183894
30193895 /**/
3020
- if (deselect)
3896
+ if (deselect || child == null)
30213897 {
30223898 //group.deselectAll();
30233899 //freeze = true;
30243900 GetTree().clearSelection();
30253901 //freeze = false;
3902
+
3903
+ if (child == null)
3904
+ {
3905
+ return;
3906
+ }
30263907 }
30273908
30283909 //group.addSelectee(child);
....@@ -3056,6 +3937,17 @@
30563937 public void itemStateChanged(ItemEvent event)
30573938 {
30583939 // System.out.println("Propagate = " + propagate);
3940
+ if (event.getSource() == pinButton)
3941
+ {
3942
+ copy.pinned ^= true;
3943
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3944
+ {
3945
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3946
+ copy.CloseUI();
3947
+ //copy.editWindow.refreshContents();
3948
+ }
3949
+ }
3950
+ else
30593951 if (event.getSource() == propagateToggle)
30603952 {
30613953 propagate ^= true;
....@@ -3160,8 +4052,9 @@
31604052 } else if (event.getSource() == liveCB)
31614053 {
31624054 copy.live ^= true;
4055
+ objEditor.refreshContents(true); // To show item colors
31634056 return;
3164
- } else if (event.getSource() == selectCB)
4057
+ } else if (event.getSource() == selectableCB)
31654058 {
31664059 copy.dontselect ^= true;
31674060 return;
....@@ -3169,7 +4062,7 @@
31694062 {
31704063 copy.hide ^= true;
31714064 copy.Touch(); // display list issue
3172
- objEditor.refreshContents();
4065
+ objEditor.refreshContents(true); // To show item colors
31734066 return;
31744067 } else if (event.getSource() == link2masterCB)
31754068 {
....@@ -3234,7 +4127,7 @@
32344127 //System.out.println("ObjEditor " + event);
32354128 applySelf0(true);
32364129 //parent.applySelf();
3237
- objEditor.refreshContents();
4130
+ // conflicts with requestFocus objEditor.refreshContents();
32384131 } else if (source == resetButton)
32394132 {
32404133 CameraPane.fullreset = true;
....@@ -3346,9 +4239,9 @@
33464239 {
33474240 Close();
33484241 //return true;
3349
- } else if (source == loadItem)
4242
+ } else if (source == openItem)
33504243 {
3351
- load();
4244
+ Open();
33524245 //return true;
33534246 } else if (source == newItem)
33544247 {
....@@ -3373,6 +4266,10 @@
33734266 {
33744267 generatePOV();
33754268 //return true;
4269
+ } else if (event.getSource() == archiveItem)
4270
+ {
4271
+ cTools.Archive(frame);
4272
+ return;
33764273 } else if (source == zBufferItem)
33774274 {
33784275 try
....@@ -3410,22 +4307,30 @@
34104307
34114308 void New()
34124309 {
3413
- while (copy.Size() > 1)
4310
+ while (copy.Size() > 0)
34144311 {
3415
- copy.remove(1);
4312
+ copy.remove(0);
34164313 }
34174314
4315
+ copy.selection.clear();
4316
+
4317
+ if (copy == Grafreed.grafreed.universe)
4318
+ {
4319
+ CreateCameras();
4320
+ cameraView.SetCamera(GetCamera(copy, 0));
4321
+ }
34184322 ResetModel();
34194323 objEditor.refreshContents();
34204324 }
34214325
34224326 static public byte[] Compress(Object3D o)
34234327 {
4328
+ // Slower to actually compress.
34244329 try
34254330 {
34264331 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3427
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3428
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4332
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4333
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34294334
34304335 Object3D parent = o.parent;
34314336 o.parent = null;
....@@ -3436,10 +4341,14 @@
34364341
34374342 out.flush();
34384343
3439
- zstream.close();
4344
+ baos //zstream
4345
+ .close();
34404346 out.close();
34414347
3442
- return baos.toByteArray();
4348
+ byte[] bytes = baos.toByteArray();
4349
+
4350
+ System.out.println("save #bytes = " + bytes.length);
4351
+ return bytes;
34434352 } catch (Exception e)
34444353 {
34454354 System.err.println(e);
....@@ -3449,13 +4358,16 @@
34494358
34504359 static public Object Uncompress(byte[] bytes)
34514360 {
3452
- System.out.println("#bytes = " + bytes.length);
4361
+ System.out.println("restore #bytes = " + bytes.length);
34534362 try
34544363 {
34554364 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3456
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3457
- ObjectInputStream in = new ObjectInputStream(istream);
4365
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4366
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34584367 Object obj = in.readObject();
4368
+
4369
+ bais //istream
4370
+ .close();
34594371 in.close();
34604372
34614373 return obj;
....@@ -3510,41 +4422,101 @@
35104422 return null;
35114423 }
35124424
3513
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35144425
35154426 public void Save()
35164427 {
4428
+ //Save(true);
4429
+ Replace();
4430
+ SetVersionStates();
4431
+ }
4432
+
4433
+ private boolean Equal(byte[] compress, byte[] name)
4434
+ {
4435
+ if (compress.length != name.length)
4436
+ {
4437
+ return false;
4438
+ }
4439
+
4440
+ for (int i=compress.length; --i>=0;)
4441
+ {
4442
+ if (compress[i] != name[i])
4443
+ return false;
4444
+ }
4445
+
4446
+ return true;
4447
+ }
4448
+
4449
+ void DeleteVersion()
4450
+ {
4451
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4452
+ {
4453
+ copy.versionlist[i] = copy.versionlist[i+1];
4454
+ }
4455
+
4456
+ if (copy.versionlist[copy.versionindex] == null)
4457
+ copy.versionindex -= 1;
4458
+
4459
+ if (copy.versionindex != -1)
4460
+ CopyChanged();
4461
+
4462
+ SetVersionStates();
4463
+ }
4464
+
4465
+ public boolean Save(boolean user)
4466
+ {
35174467 System.err.println("Save");
4468
+ Replace();
35184469
3519
- cRadio tab = GetCurrentTab();
4470
+ if (copy.versionlist == null)
4471
+ {
4472
+ copy.versionlist = new Object3D[100];
4473
+ copy.versionindex = -1;
4474
+ }
35204475
3521
- boolean temp = CameraPane.SWITCH;
3522
- CameraPane.SWITCH = false;
4476
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
35234477
3524
- copy.ExtractBigData(hashtable);
4478
+ boolean thesame = false;
4479
+
4480
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4481
+// {
4482
+// thesame = true;
4483
+// }
35254484
35264485 //EditorFrame.m_MainFrame.requestFocusInWindow();
3527
- tab.graphs[tab.undoindex++] = Compress(copy);
3528
-
3529
- copy.RestoreBigData(hashtable);
3530
-
3531
- CameraPane.SWITCH = temp;
3532
-
3533
- //assert(hashtable.isEmpty());
3534
-
3535
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
4486
+ if (!thesame)
35364487 {
3537
- tab.graphs[i] = null;
4488
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4489
+ {
4490
+ copy.versionlist[i] = copy.versionlist[i-1];
4491
+ }
4492
+
4493
+ //tab.user[tab.versionindex] = user;
4494
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4495
+
4496
+ copy.versionlist[++copy.versionindex] = compress;
4497
+
4498
+ // if (increment)
4499
+ // tab.versionindex++;
35384500 }
35394501
3540
- SetUndoStates();
4502
+ //copy.RestoreBigData(versiontable);
4503
+
4504
+ //assert(hashtable.isEmpty());
4505
+
4506
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4507
+// {
4508
+// //tab.user[i] = false;
4509
+// copy.versionlist[i] = null;
4510
+// }
4511
+
4512
+ SetVersionStates();
35414513
35424514 // test save
35434515 if (false)
35444516 {
35454517 try
35464518 {
3547
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4519
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35484520 ObjectOutputStream p = new ObjectOutputStream(ostream);
35494521
35504522 p.writeObject(copy);
....@@ -3557,28 +4529,68 @@
35574529 e.printStackTrace();
35584530 }
35594531 }
4532
+
4533
+ return !thesame;
4534
+ }
4535
+
4536
+ boolean flashIt = true;
4537
+
4538
+ void RefreshSelection()
4539
+ {
4540
+ Object3D selection = new Object3D();
4541
+
4542
+ for (int i = 0; i < copy.selection.size(); i++)
4543
+ {
4544
+ Object3D elem = copy.selection.elementAt(i);
4545
+
4546
+ Object3D obj = copy.GetObject(elem.GetUUID());
4547
+
4548
+ if (obj == null)
4549
+ {
4550
+ copy.selection.remove(i--);
4551
+ }
4552
+ else
4553
+ {
4554
+ selection.add(obj);
4555
+ copy.selection.setElementAt(obj, i);
4556
+ }
4557
+ }
4558
+
4559
+ flashIt = false;
4560
+ GetTree().clearSelection();
4561
+ for (int i = 0; i < selection.size(); i++)
4562
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4563
+ flashIt = true;
4564
+
4565
+ //refreshContents(false);
35604566 }
35614567
3562
- void CopyChanged(Object3D obj)
4568
+ void CopyChanged()
35634569 {
3564
- SetUndoStates();
4570
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4571
+
4572
+ SetVersionStates();
35654573
35664574 boolean temp = CameraPane.SWITCH;
35674575 CameraPane.SWITCH = false;
35684576
3569
- copy.ExtractBigData(hashtable);
4577
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
35704578
35714579 copy.clear();
35724580
4581
+ copy.skyboxname = obj.skyboxname;
4582
+ copy.skyboxext = obj.skyboxext;
4583
+
35734584 for (int i=0; i<obj.Size(); i++)
35744585 {
35754586 copy.add(obj.get(i));
35764587 }
35774588
3578
- copy.RestoreBigData(hashtable);
4589
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
35794590
35804591 CameraPane.SWITCH = temp;
35814592
4593
+ RefreshSelection();
35824594 //assert(hashtable.isEmpty());
35834595
35844596 copy.Touch();
....@@ -3599,56 +4611,161 @@
35994611 }
36004612 }
36014613
3602
- refreshContents();
4614
+ refreshContents(true);
36034615 }
36044616
3605
- cButton undoButton;
3606
- cButton redoButton;
4617
+ cButton previousVersionButton;
4618
+ cButton restoreButton;
4619
+ cButton replaceButton;
4620
+ cButton nextVersionButton;
4621
+ cButton saveVersionButton;
4622
+ cButton deleteVersionButton;
36074623
3608
- void SetUndoStates()
4624
+ boolean muteSlider;
4625
+
4626
+ int VersionCount()
36094627 {
3610
- cRadio tab = GetCurrentTab();
4628
+ int count = 0;
36114629
3612
- undoButton.setEnabled(tab.undoindex > 0);
3613
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
4630
+ for (int i = copy.versionlist.length; --i >= 0;)
4631
+ {
4632
+ if (copy.versionlist[i] != null)
4633
+ count++;
4634
+ }
4635
+
4636
+ return count;
36144637 }
36154638
3616
- public void Undo()
4639
+ public cGridBag versionSliderPane;
4640
+
4641
+ void SetVersionStates()
36174642 {
4643
+ //if (true)
4644
+ // return;
4645
+
4646
+ //cRadio tab = GetCurrentTab();
4647
+
4648
+ if (copy.versionindex == -2)
4649
+ {
4650
+ saveVersionButton.setEnabled(false);
4651
+ restoreButton.setEnabled(false);
4652
+ replaceButton.setEnabled(false);
4653
+ previousVersionButton.setEnabled(false);
4654
+ nextVersionButton.setEnabled(false);
4655
+ deleteVersionButton.setEnabled(false);
4656
+ versionSliderPane.setVisible(false);
4657
+ }
4658
+ else
4659
+ {
4660
+ restoreButton.setEnabled(copy.versionindex != -1);
4661
+ replaceButton.setEnabled(copy.versionindex != -1);
4662
+
4663
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4664
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4665
+
4666
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4667
+ //copy.versionlist[copy.versionindex + 1] != null);
4668
+
4669
+ muteSlider = true;
4670
+ versionSlider.setMinimum(0);
4671
+ versionSlider.setMaximum(VersionCount() - 1);
4672
+ versionSlider.setInteger(copy.versionindex);
4673
+ versionSlider.setEnabled(copy.versionindex != -1);
4674
+ muteSlider = false;
4675
+
4676
+ versionSliderPane.setVisible(true);
4677
+ }
4678
+ }
4679
+
4680
+ public boolean PreviousVersion()
4681
+ {
4682
+ // Option?
4683
+ Replace();
4684
+
36184685 System.err.println("Undo");
36194686
3620
- cRadio tab = GetCurrentTab();
4687
+ //cRadio tab = GetCurrentTab();
36214688
3622
- if (tab.undoindex == 0)
4689
+ if (copy.versionindex == 0)
36234690 {
36244691 java.awt.Toolkit.getDefaultToolkit().beep();
3625
- return;
4692
+ return false;
36264693 }
36274694
3628
- if (tab.graphs[tab.undoindex] == null)
3629
- {
3630
- Save();
3631
- tab.undoindex -= 1;
3632
- }
4695
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4696
+// {
4697
+// if (Save(false))
4698
+// tab.versionindex -= 1;
4699
+// else
4700
+// {
4701
+// if (tab.versionindex <= 0)
4702
+// return false;
4703
+// else
4704
+// tab.versionindex -= 1;
4705
+// }
4706
+// }
36334707
3634
- tab.undoindex -= 1;
4708
+ copy.versionindex -= 1;
36354709
3636
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4710
+ CopyChanged();
4711
+
4712
+ return true;
36374713 }
36384714
3639
- public void Redo()
4715
+ public boolean Restore()
36404716 {
3641
- cRadio tab = GetCurrentTab();
4717
+ System.err.println("Restore");
36424718
3643
- if (tab.graphs[tab.undoindex + 1] == null)
4719
+ //cRadio tab = GetCurrentTab();
4720
+
4721
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4722
+ {
4723
+ java.awt.Toolkit.getDefaultToolkit().beep();
4724
+ return false;
4725
+ }
4726
+
4727
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4728
+ CopyChanged();
4729
+
4730
+ return true;
4731
+ }
4732
+
4733
+ public boolean Replace()
4734
+ {
4735
+ //System.err.println("Replace");
4736
+
4737
+ //cRadio tab = GetCurrentTab();
4738
+
4739
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4740
+ {
4741
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4742
+ return false;
4743
+ }
4744
+
4745
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4746
+
4747
+ return true;
4748
+ }
4749
+
4750
+ public void NextVersion()
4751
+ {
4752
+ // Option?
4753
+ Replace();
4754
+
4755
+ //cRadio tab = GetCurrentTab();
4756
+
4757
+ if (copy.versionlist[copy.versionindex + 1] == null)
36444758 {
36454759 java.awt.Toolkit.getDefaultToolkit().beep();
36464760 return;
36474761 }
36484762
3649
- tab.undoindex += 1;
4763
+ copy.versionindex += 1;
36504764
3651
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4765
+ CopyChanged();
4766
+
4767
+ //if (!tab.user[tab.versionindex])
4768
+ // tab.graphs[tab.versionindex] = null;
36524769 }
36534770
36544771 void ImportGFD()
....@@ -3842,6 +4959,12 @@
38424959 // else
38434960 // applySelf(true);
38444961 // }
4962
+
4963
+ boolean Equal(double a, double b)
4964
+ {
4965
+ return Math.abs(a - b) < 0.001;
4966
+ }
4967
+
38454968 void applySelf0(boolean name)
38464969 {
38474970 if (name)
....@@ -3859,7 +4982,7 @@
38594982 //copy.material = new cMaterial(copy.GetMaterial());
38604983
38614984 current.color = (float) colorField.getFloat();
3862
- current.modulation = (float) modulationField.getFloat();
4985
+ current.modulation = (float) saturationField.getFloat();
38634986 current.metalness = (float) metalnessField.getFloat();
38644987 current.diffuse = (float) diffuseField.getFloat();
38654988 current.specular = (float) specularField.getFloat();
....@@ -3879,6 +5002,7 @@
38795002 current.shadow = (float) shadowField.getFloat();
38805003 current.texture = (float) textureField.getFloat();
38815004 current.opacity = (float) opacityField.getFloat();
5005
+ current.parallax = (float) parallaxField.getFloat() - 0.125f;
38825006 current.fakedepth = (float) fakedepthField.getFloat();
38835007 current.shadowbias = (float) shadowbiasField.getFloat();
38845008
....@@ -3891,29 +5015,54 @@
38915015 {
38925016 cMaterial mat = copy.material;
38935017
3894
- colorField.SetToolTipValue((mat.color));
3895
- modulationField.SetToolTipValue((mat.modulation));
3896
- metalnessField.SetToolTipValue((mat.metalness));
3897
- diffuseField.SetToolTipValue((mat.diffuse));
3898
- specularField.SetToolTipValue((mat.specular));
3899
- shininessField.SetToolTipValue((mat.shininess));
3900
- shiftField.SetToolTipValue((mat.shift));
3901
- ambientField.SetToolTipValue((mat.ambient));
3902
- lightareaField.SetToolTipValue((mat.lightarea));
3903
- diffusenessField.SetToolTipValue((mat.factor));
3904
- velvetField.SetToolTipValue((mat.velvet));
3905
- sheenField.SetToolTipValue((mat.sheen));
3906
- subsurfaceField.SetToolTipValue((mat.subsurface));
3907
- backlitField.SetToolTipValue((mat.bump));
3908
- anisoField.SetToolTipValue((mat.aniso));
3909
- anisoVField.SetToolTipValue((mat.anisoV));
3910
- cameraField.SetToolTipValue((mat.cameralight));
3911
- selfshadowField.SetToolTipValue((mat.diffuseness));
3912
- shadowField.SetToolTipValue((mat.shadow));
3913
- textureField.SetToolTipValue((mat.texture));
3914
- opacityField.SetToolTipValue((mat.opacity));
3915
- fakedepthField.SetToolTipValue((mat.fakedepth));
3916
- shadowbiasField.SetToolTipValue((mat.shadowbias));
5018
+ if (!Equal(colorField.getFloat(), mat.color))
5019
+ colorField.SetToolTipValue((mat.color));
5020
+ if (!Equal(saturationField.getFloat(), mat.modulation))
5021
+ saturationField.SetToolTipValue((mat.modulation));
5022
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
5023
+ metalnessField.SetToolTipValue((mat.metalness));
5024
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
5025
+ diffuseField.SetToolTipValue((mat.diffuse));
5026
+ if (!Equal(specularField.getFloat(), mat.specular))
5027
+ specularField.SetToolTipValue((mat.specular));
5028
+ if (!Equal(shininessField.getFloat(), mat.shininess))
5029
+ shininessField.SetToolTipValue((mat.shininess));
5030
+ if (!Equal(shiftField.getFloat(), mat.shift))
5031
+ shiftField.SetToolTipValue((mat.shift));
5032
+ if (!Equal(ambientField.getFloat(), mat.ambient))
5033
+ ambientField.SetToolTipValue((mat.ambient));
5034
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
5035
+ lightareaField.SetToolTipValue((mat.lightarea));
5036
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
5037
+ diffusenessField.SetToolTipValue((mat.factor));
5038
+ if (!Equal(velvetField.getFloat(), mat.velvet))
5039
+ velvetField.SetToolTipValue((mat.velvet));
5040
+ if (!Equal(sheenField.getFloat(), mat.sheen))
5041
+ sheenField.SetToolTipValue((mat.sheen));
5042
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
5043
+ subsurfaceField.SetToolTipValue((mat.subsurface));
5044
+ if (!Equal(backlitField.getFloat(), mat.bump))
5045
+ backlitField.SetToolTipValue((mat.bump));
5046
+ if (!Equal(anisoField.getFloat(), mat.aniso))
5047
+ anisoField.SetToolTipValue((mat.aniso));
5048
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
5049
+ anisoVField.SetToolTipValue((mat.anisoV));
5050
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
5051
+ cameraField.SetToolTipValue((mat.cameralight));
5052
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
5053
+ selfshadowField.SetToolTipValue((mat.diffuseness));
5054
+ if (!Equal(shadowField.getFloat(), mat.shadow))
5055
+ shadowField.SetToolTipValue((mat.shadow));
5056
+ if (!Equal(textureField.getFloat(), mat.texture))
5057
+ textureField.SetToolTipValue((mat.texture));
5058
+ if (!Equal(opacityField.getFloat(), mat.opacity))
5059
+ opacityField.SetToolTipValue((mat.opacity));
5060
+ //if (!Equal(parallaxField.getFloat(), mat.parallax))
5061
+ parallaxField.SetToolTipValue((mat.parallax));
5062
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
5063
+ fakedepthField.SetToolTipValue((mat.fakedepth));
5064
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
5065
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
39175066 }
39185067
39195068 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -3944,9 +5093,28 @@
39445093 //copy.Touch();
39455094 }
39465095
5096
+ cNumberSlider versionSlider;
5097
+
39475098 public void stateChanged(ChangeEvent e)
39485099 {
3949
- // assert(false);
5100
+ // assert(false);
5101
+ if (e.getSource() == versionSlider)
5102
+ {
5103
+ if (muteSlider)
5104
+ return;
5105
+
5106
+ Replace();
5107
+
5108
+ int version = versionSlider.getInteger();
5109
+
5110
+ if (version != -1 && copy.versionlist[version] != null)
5111
+ {
5112
+ copy.versionindex = version;
5113
+ CopyChanged();
5114
+ }
5115
+
5116
+ return;
5117
+ }
39505118
39515119 if (freezematerial)
39525120 {
....@@ -3982,6 +5150,12 @@
39825150 {
39835151 //System.out.println("stateChanged = " + this);
39845152 materialtouched = true;
5153
+
5154
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
5155
+ {
5156
+ saturationField.setFloat(1);
5157
+ }
5158
+
39855159 applySelf();
39865160 //System.out.println("this = " + this);
39875161 //System.out.println("PARENT = " + parent);
....@@ -4281,6 +5455,7 @@
42815455 {
42825456 if (GetTree() != null)
42835457 {
5458
+ GetTree().revalidate();
42845459 GetTree().repaint();
42855460 }
42865461
....@@ -4289,13 +5464,18 @@
42895464 ctrlPanel.validate(); // ? new
42905465 ctrlPanel.repaint();
42915466 }
5467
+
5468
+ if (previousVersionButton != null && copy.versionlist != null)
5469
+ SetVersionStates();
5470
+
5471
+ cameraView.requestFocusInWindow();
42925472 }
42935473
42945474 static TweenManager tweenManager = new TweenManager();
42955475
42965476 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42975477 {
4298
- if (Globals.SAVEONMAKE) // && resetmodel)
5478
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42995479 Save();
43005480 //Tween.set(thing, 0).target(1).start(tweenManager);
43015481 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4320,7 +5500,7 @@
43205500 // group = (Composite) group.get(0);
43215501 // }
43225502
4323
- System.out.println("makeSomething of " + thing);
5503
+ //System.out.println("makeSomething of " + thing);
43245504
43255505 /*
43265506 if (deselect && jList != null)
....@@ -4537,7 +5717,9 @@
45375717 readobj.ResetDisplayList();
45385718 } catch (Exception e)
45395719 {
4540
- //e.printStackTrace();
5720
+ if (!e.toString().contains("GZIP"))
5721
+ e.printStackTrace();
5722
+
45415723 try
45425724 {
45435725 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4611,12 +5793,14 @@
46115793
46125794 if (readobj != null)
46135795 {
4614
- if (Globals.SAVEONMAKE)
4615
- Save();
5796
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5797
+ // Save();
46165798 try
46175799 {
46185800 //readobj.deepCopySelf(copy);
46195801 copy.clear(); // june 2014
5802
+ copy.skyboxname = readobj.skyboxname;
5803
+ copy.skyboxext = readobj.skyboxext;
46205804 for (int i = 0; i < readobj.size(); i++)
46215805 {
46225806 Object3D child = readobj.get(i); // reserve(i);
....@@ -4657,6 +5841,7 @@
46575841 }
46585842 } catch (ClassCastException e)
46595843 {
5844
+ e.printStackTrace();
46605845 assert (false);
46615846 Composite c = (Composite) copy;
46625847 c.children.clear();
....@@ -4667,17 +5852,32 @@
46675852 c.addChild(csg);
46685853 }
46695854
5855
+ copy.versionlist = readobj.versionlist;
5856
+ copy.versionindex = readobj.versionindex;
5857
+ copy.versiontable = readobj.versiontable;
5858
+
5859
+ if (copy.versionlist == null)
5860
+ {
5861
+ // Backward compatibility
5862
+ copy.versionlist = new Object3D[100];
5863
+ copy.versionindex = -1;
5864
+
5865
+ //Save(true);
5866
+ }
5867
+
5868
+ //? SetUndoStates();
5869
+
46705870 ResetModel();
46715871 copy.HardTouch(); // recompile?
46725872 refreshContents();
46735873 }
46745874 }
46755875
4676
- void load() // throws ClassNotFoundException
5876
+ void Open() // throws ClassNotFoundException
46775877 {
46785878 if (Grafreed.standAlone)
46795879 {
4680
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5880
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
46815881 browser.show();
46825882 String filename = browser.getFile();
46835883 if (filename != null && filename.length() > 0)
....@@ -4754,6 +5954,8 @@
47545954
47555955 void save()
47565956 {
5957
+ Replace();
5958
+
47575959 if (lastname == null)
47585960 {
47595961 return;
....@@ -4776,6 +5978,7 @@
47765978 //ps.print(buffer.toString());
47775979 } catch (IOException e)
47785980 {
5981
+ e.printStackTrace();
47795982 }
47805983 }
47815984
....@@ -4958,7 +6161,7 @@
49586161 MenuBar menuBar;
49596162 Menu fileMenu;
49606163 MenuItem newItem;
4961
- MenuItem loadItem;
6164
+ MenuItem openItem;
49626165 MenuItem saveItem;
49636166 MenuItem saveAsItem;
49646167 MenuItem exportAsItem;
....@@ -4981,6 +6184,7 @@
49816184 CheckboxMenuItem toggleSwitchItem;
49826185 CheckboxMenuItem toggleRootItem;
49836186 CheckboxMenuItem animationItem;
6187
+ MenuItem archiveItem;
49846188 CheckboxMenuItem toggleHandleItem;
49856189 CheckboxMenuItem togglePaintItem;
49866190 JSplitPane mainPanel;
....@@ -4994,6 +6198,7 @@
49946198 ButtonGroup buttonGroup;
49956199
49966200 cGridBag toolboxPanel;
6201
+ cGridBag skyboxPanel;
49976202 cGridBag materialPanel;
49986203 cGridBag ctrlPanel;
49996204
....@@ -5005,6 +6210,7 @@
50056210 boolean materialFlushed;
50066211 Object3D latestObject;
50076212
6213
+ cGridBag transformPanel;
50086214 cGridBag XYZPanel;
50096215
50106216 JSplitPane gridPanel;
....@@ -5067,7 +6273,7 @@
50676273 JLabel colorLabel;
50686274 cNumberSlider colorField;
50696275 JLabel modulationLabel;
5070
- cNumberSlider modulationField;
6276
+ cNumberSlider saturationField;
50716277 JLabel metalnessLabel;
50726278 cNumberSlider metalnessField;
50736279 JLabel diffuseLabel;
....@@ -5098,6 +6304,7 @@
50986304 cNumberSlider anisoField;
50996305 JLabel anisoVLabel;
51006306 cNumberSlider anisoVField;
6307
+
51016308 JLabel cameraLabel;
51026309 cNumberSlider cameraField;
51036310 JLabel selfshadowLabel;
....@@ -5108,10 +6315,13 @@
51086315 cNumberSlider textureField;
51096316 JLabel opacityLabel;
51106317 cNumberSlider opacityField;
6318
+ JLabel parallaxLabel;
6319
+ cNumberSlider parallaxField;
51116320 JLabel fakedepthLabel;
51126321 cNumberSlider fakedepthField;
51136322 JLabel shadowbiasLabel;
51146323 cNumberSlider shadowbiasField;
6324
+
51156325 JLabel bumpLabel;
51166326 cNumberSlider bumpField;
51176327 JLabel noiseLabel;