Normand Briere
2019-08-19 22e8ab6479334206f97b0093f6c5ffd14610cce3
ObjEditor.java
....@@ -34,6 +34,7 @@
3434 iSendInfo
3535 //KeyListener
3636 {
37
+ public cToggleButton pinButton;
3738 boolean timeline;
3839 boolean wasFullScreen;
3940
....@@ -41,64 +42,137 @@
4142 JFrame frame;
4243
4344 static ObjEditor theFrame;
45
+
46
+ public void AllocProjectedVertices(Object3D object)
47
+ {
48
+ assert (object.projectedVertices != null);
49
+
50
+ if (object.projectedVertices.length <= 2)
51
+ {
52
+ // Side effect...
53
+ Object3D.cVector2[] keep = object.projectedVertices;
54
+ object.projectedVertices = new Object3D.cVector2[3];
55
+ for (int i = 0; i < 3; i++)
56
+ {
57
+ if (i < keep.length)
58
+ {
59
+ object.projectedVertices[i] = keep[i];
60
+ } else
61
+ {
62
+ object.projectedVertices[i] = new Object3D.cVector2();
63
+ }
64
+ /*
65
+ if(keep.length == 0)
66
+ object.projectedVertices[0] = new Object3D.cVector2();
67
+ else
68
+ object.projectedVertices[0] = keep[0];
69
+ object.projectedVertices[1] = new Object3D.cVector2();
70
+ */
71
+ }
72
+ }
73
+ }
74
+
75
+ public 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
+ }
4497
4598 cButton GetButton(String name, boolean border)
4699 {
47
- try
48
- {
49
- ImageIcon icon = GetIcon(name);
100
+ ImageIcon icon = GetIcon(name);
101
+ if (icon != null || name.contains("/"))
50102 return new cButton(icon, border);
51
- }
52
- catch (Exception e)
53
- {
103
+ else
54104 return new cButton(name, border);
55
- }
105
+ }
106
+
107
+ cLabel GetLabel(String name, boolean border)
108
+ {
109
+ //ImageIcon icon = GetIcon(name);
110
+ return new cLabel(GetImage(name), border);
56111 }
57112
58113 cToggleButton GetToggleButton(String name, boolean border)
59114 {
60
- try
61
- {
62
- ImageIcon icon = GetIcon(name);
63
- return new cToggleButton(icon, border);
64
- }
65
- catch (Exception e)
66
- {
67
- return new cToggleButton(name, border);
68
- }
115
+ ImageIcon icon = GetIcon(name);
116
+ return new cToggleButton(icon, border);
69117 }
70118
71119 cCheckBox GetCheckBox(String name, boolean border)
72120 {
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
+
73135 try
74136 {
75
- ImageIcon icon = GetIcon(name);
76
- 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;
77156 }
78157 catch (Exception e)
79158 {
80
- return new cCheckBox(name, border);
159
+ //icons.put(name, null);
160
+ return null;
81161 }
82162 }
83
-
84
- private ImageIcon GetIcon(String name) throws IOException
163
+
164
+ BufferedImage GetImage(String name)
85165 {
86
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
-
88
- if (image.getWidth() != 24 && image.getHeight() != 24)
166
+ try
89167 {
90
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
91
- Graphics2D g = resized.createGraphics();
92
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
93
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
94
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
95
- g.dispose();
96
-
97
- image = resized;
168
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
169
+
170
+ return image;
98171 }
99
-
100
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
- return icon;
172
+ catch (Exception e)
173
+ {
174
+ return null;
175
+ }
102176 }
103177
104178 // SCRIPT
....@@ -282,6 +356,14 @@
282356 client = inClient;
283357 copy = client;
284358
359
+// if (copy.versionlist == null)
360
+// {
361
+// copy.versionlist = new Object3D[100];
362
+// copy.versionindex = -1;
363
+//
364
+// callee.Save(true);
365
+// }
366
+
285367 // "this" is not called: SetupUI2(objEditor);
286368 }
287369
....@@ -295,6 +377,14 @@
295377 client = inClient;
296378 copy = client;
297379
380
+ if (copy.versionlist == null)
381
+ {
382
+ copy.versionlist = new Object3D[100];
383
+ copy.versionindex = -1;
384
+
385
+// Save(true);
386
+ }
387
+
298388 SetupUI2(callee.GetEditor());
299389 }
300390
....@@ -316,7 +406,8 @@
316406 //parent = p;
317407
318408 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
319
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
409
+ if (Globals.DEBUG)
410
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
320411 //gd.setFullScreenWindow(this);
321412 //setResizable(false);
322413 //if (!isDisplayable())
....@@ -327,6 +418,14 @@
327418 copy = localCopy;
328419 copy.editWindow = this;
329420
421
+// if (copy.versionlist == null)
422
+// {
423
+// copy.versionlist = new Object3D[100];
424
+// copy.versionindex = -1;
425
+//
426
+// Save(true);
427
+// }
428
+
330429 SetupMenu();
331430
332431 //SetupName(objEditor); // new
....@@ -345,6 +444,9 @@
345444
346445 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347446
447
+ // This is to refresh the UI of the material panel.
448
+ boolean patchMaterial;
449
+
348450 void SetupMenu()
349451 {
350452 frame.setMenuBar(menuBar = new MenuBar());
....@@ -358,8 +460,11 @@
358460 importOBJItem.addActionListener(this);
359461 import3DSItem = menu.add(new MenuItem("3DS file..."));
360462 import3DSItem.addActionListener(this);
463
+ if (Globals.ADVANCED)
464
+ {
361465 importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
362466 importVRMLX3DItem.addActionListener(this);
467
+ }
363468 menu.add("-");
364469 importGFDItem = menu.add(new MenuItem("Grafreed file..."));
365470 importGFDItem.addActionListener(this);
....@@ -394,6 +499,8 @@
394499
395500 ChangeListener changeListener = new ChangeListener()
396501 {
502
+ //String name;
503
+
397504 public void stateChanged(ChangeEvent changeEvent)
398505 {
399506 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -412,18 +519,49 @@
412519 // EditSelection(false);
413520 // }
414521
415
- refreshContents(false); // To refresh Info tab
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();
416553 }
417554 };
418555 objectPanel.addChangeListener(changeListener);
419556
420557 toolbarPanel = new JPanel();
421558 toolbarPanel.setName("Toolbar");
559
+
422560 treePanel = new cGridBag();
423561 treePanel.setName("Tree");
424562
425563 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
564
+ //editPanel.setName("Edit");
427565
428566 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429567
....@@ -431,11 +569,13 @@
431569 editPanel.add(editCommandsPanel);
432570 editPanel.add(ctrlPanel);
433571
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
572
+ toolboxPanel = new cGridBag().setVertical(true);
573
+ //toolboxPanel.setName("Toolbox");
436574
437
- materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
575
+ skyboxPanel = new cGridBag().setVertical(true);
576
+
577
+ materialPanel = new cGridBag().setVertical(false);
578
+ //materialPanel.setName("Material");
439579
440580 /*JTextPane*/
441581 infoarea = createTextPane();
....@@ -443,6 +583,7 @@
443583
444584 infoarea.setEditable(true);
445585 SetText();
586
+
446587 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447588 // infoarea.setOpaque(false);
448589 // //infoarea.setForeground(textcolor);
....@@ -450,7 +591,7 @@
450591 // TEXTAREA infoarea.setWrapStyleWord(true);
451592 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452593 infoPanel.setPreferredSize(new Dimension(1, 1));
453
- infoPanel.setName("Info");
594
+ //infoPanel.setName("Info");
454595 //infoPanel.setLayout(new BorderLayout());
455596 //infoPanel.add(createTextPane());
456597
....@@ -717,6 +858,7 @@
717858 boolean maximized;
718859
719860 cButton fullscreenLayout;
861
+ cButton expandedLayout;
720862
721863 void Minimize()
722864 {
....@@ -756,10 +898,12 @@
756898 cButton minButton;
757899 cButton maxButton;
758900 cButton fullButton;
901
+ cButton collapseButton;
902
+ cButton maximize3DButton;
759903
760904 void ToggleFullScreen()
761905 {
762
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
906
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763907
764908 cameraView.ToggleFullScreen();
765909
....@@ -780,13 +924,13 @@
780924 // X frame.getContentPane().remove(/*"Center",*/bigThree);
781925 // X framePanel.add(bigThree);
782926 // X frame.getContentPane().add(/*"Center",*/framePanel);
783
- framePanel.setDividerLocation(46);
927
+// framePanel.setDividerLocation(46); // icons are 24x24
784928
785929 //frame.setVisible(true);
786
- radio.layout = keepButton;
930
+// radio.layout = keepButton;
787931 //theFrame = null;
788932 keepButton = null;
789
- radio.layout.doClick();
933
+// radio.layout.doClick();
790934
791935 } else
792936 {
....@@ -807,31 +951,53 @@
807951 // X frame.getContentPane().remove(/*"Center",*/framePanel);
808952 // X framePanel.remove(bigThree);
809953 // X frame.getContentPane().add(/*"Center",*/bigThree);
810
- framePanel.setDividerLocation(0);
954
+// framePanel.setDividerLocation(0);
811955
812
- radio.layout = fullscreenLayout;
813
- radio.layout.doClick();
956
+// radio.layout = fullscreenLayout;
957
+// radio.layout.doClick();
814958 //frame.setVisible(true);
815959 }
816960 frame.validate();
961
+
962
+ cameraView.requestFocusInWindow();
817963 }
818964
819
- private byte[] CompressCopy()
965
+ void CollapseToolbar()
966
+ {
967
+ framePanel.setDividerLocation(0);
968
+ //frame.validate();
969
+
970
+ cameraView.requestFocusInWindow();
971
+ }
972
+
973
+ private Object3D Duplicate(Object3D object)
820974 {
821975 boolean temp = CameraPane.SWITCH;
822976 CameraPane.SWITCH = false;
823977
824
- copy.ExtractBigData(versiontable);
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);
825982 // if (copy == client)
826983
827
- byte[] versions[] = copy.versions;
828
- copy.versions = null;
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;
829988
830
- byte[] compress = Compress(copy);
989
+ Object3D parent = object.parent;
990
+ object.parent = null;
831991
832
- copy.versions = versions;
992
+ //byte[] compress = Compress(copy);
993
+ Object3D compress = (Object3D)Grafreed.clone(object);
833994
834
- copy.RestoreBigData(versiontable);
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);
8351001
8361002 CameraPane.SWITCH = temp;
8371003
....@@ -959,6 +1125,7 @@
9591125 {
9601126 SetupMaterial(materialPanel);
9611127 }
1128
+
9621129 //SetupName();
9631130 //SetupViews();
9641131 }
....@@ -968,7 +1135,7 @@
9681135 // NumberSlider vDivsField;
9691136 // JCheckBox endcaps;
9701137 JCheckBox liveCB;
971
- JCheckBox selectCB;
1138
+ JCheckBox selectableCB;
9721139 JCheckBox hideCB;
9731140 JCheckBox link2masterCB;
9741141 JCheckBox markCB;
....@@ -1167,6 +1334,18 @@
11671334
11681335 namePanel = new cGridBag();
11691336
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
+
11701349 nameField = AddText(namePanel, copy.GetName());
11711350 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11721351 oe.ctrlPanel.add(namePanel);
....@@ -1180,13 +1359,16 @@
11801359
11811360 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11821361 liveCB.setToolTipText("Animate object");
1183
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1184
- 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");
11851366 // Return();
1367
+
11861368 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11871369 hideCB.setToolTipText("Hide object");
1188
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1189
- markCB.setToolTipText("As animation target transform");
1370
+
1371
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11901372
11911373 setupPanel2 = new cGridBag().setVertical(false);
11921374
....@@ -1386,22 +1568,9 @@
13861568
13871569 if (cam == null || !(copy.get(0) instanceof cGroup))
13881570 {
1389
- System.out.println("CREATE CAMERAS");
1390
- cams = new cTemplate();
1391
- cams.name = "Cameras";
1392
- copy.insertElementAt(cams, 0);
1393
- //cams.parent = copy;
1394
-
1395
- cam = new Camera(); // LA.newVector(3, 2, 1));
1396
- cams.addChild(cam);
1397
- cam = new Camera(1);
1398
- cams.addChild(cam);
1399
- cam = new Camera(2);
1400
- cams.addChild(cam);
1401
- cam = new Camera(3);
1402
- cams.addChild(cam);
1403
- cam = new Camera(4); // Light
1404
- cams.addChild(cam);
1571
+ if (Globals.DEBUG)
1572
+ System.out.println("CREATE CAMERAS");
1573
+ cams = CreateCameras();
14051574 } else
14061575 {
14071576 cams = (cGroup) copy.get(0);
....@@ -1467,6 +1636,45 @@
14671636 //frontView.object = copy;
14681637 //sideView.object = copy;
14691638
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
+
14701678 XYZPanel = new cGridBag().setVertical(true);
14711679 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
14721680
....@@ -1474,7 +1682,11 @@
14741682 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14751683 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14761684 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1685
+ //XYZPanel.setName("XYZ");
14771686
1687
+ transformPanel.add(resetTransformPanel);
1688
+ transformPanel.add(XYZPanel);
1689
+
14781690 /*
14791691 gridPanel = new JPanel(); //new BorderLayout());
14801692 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1482,12 +1694,12 @@
14821694 gridPanel.add(cameraView);
14831695 gridPanel.add(XYZPanel);
14841696 */
1485
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1486
- gridPanel.setContinuousLayout(true);
1487
- gridPanel.setOneTouchExpandable(true);
1488
- gridPanel.setDividerLocation(1.0);
1489
- gridPanel.setDividerSize(9);
1490
- 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);
14911703
14921704 // aConstraints.weighty = 0;
14931705 //System.out.println("THIS = " + this);
....@@ -1510,18 +1722,34 @@
15101722
15111723 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15121724 //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
+
15131733 objectPanel.add(materialPanel);
1734
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1735
+ objectPanel.setToolTipTextAt(2, "Material");
1736
+
15141737 // JPanel north = new JPanel(new BorderLayout());
15151738 // north.setName("Edit");
15161739 // north.add(ctrlPanel, BorderLayout.NORTH);
15171740 // objectPanel.add(north);
15181741 objectPanel.add(editPanel);
1742
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
1743
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15191744
1520
- //if (Globals.ADVANCED)
1521
- objectPanel.add(infoPanel);
1745
+ objectPanel.add(transformPanel);
1746
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1747
+ objectPanel.setToolTipTextAt(4, "TRS transform");
15221748
1523
- objectPanel.add(toolboxPanel);
1524
-
1749
+ patchMaterial = true;
1750
+ cameraView.patchMaterial = this;
1751
+ objectPanel.setSelectedIndex(2);
1752
+
15251753 /*
15261754 aConstraints.gridx = 0;
15271755 aConstraints.gridwidth = 1;
....@@ -1552,11 +1780,108 @@
15521780
15531781 AddOptions(optionsPanel); //, aConstraints);
15541782
1555
- tabbedPane.add(optionsPanel);
1556
-
15571783 tabbedPane.add(FSPane = new cFileSystemPane(this));
15581784
1785
+ tabbedPane.add(optionsPanel);
1786
+
15591787 scenePanel.add(tabbedPane);
1788
+
1789
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1790
+ creditsPanel.setName("Credits");
1791
+
1792
+ cLabel ogaLabel = new cLabel(" Most 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
+ }
15601885
15611886 /*
15621887 cTree jTree = new cTree(null);
....@@ -1578,13 +1903,13 @@
15781903 jtp.add(tree);
15791904 */
15801905
1581
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1582
- bigPanel.setContinuousLayout(true);
1583
- bigPanel.setOneTouchExpandable(true);
1584
- bigPanel.setDividerLocation(0.8);
1585
- bigPanel.setDividerSize(15);
1586
- bigPanel.setResizeWeight(0.15);
1587
- 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");
15881913
15891914 //bigPanel.setLayout(new BorderLayout());
15901915 //bigPanel.setSize(new Dimension(10,10));
....@@ -1619,7 +1944,7 @@
16191944 bigThree = new cGridBag();
16201945 bigThree.addComponent(scenePanel);
16211946 bigThree.addComponent(centralPanel);
1622
- bigThree.addComponent(XYZPanel);
1947
+ //bigThree.addComponent(XYZPanel);
16231948
16241949 // // SIDE EFFECT!!!
16251950 // aConstraints.gridx = 0;
....@@ -1628,6 +1953,23 @@
16281953 // aConstraints.gridheight = 1;
16291954
16301955 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
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
+
16311973 framePanel.setContinuousLayout(false);
16321974 framePanel.setOneTouchExpandable(false);
16331975 //.setDividerLocation(0.8);
....@@ -1637,7 +1979,7 @@
16371979
16381980 frame.getContentPane().setLayout(new BorderLayout());
16391981 /**/
1640
- JTabbedPane worldPane = new JTabbedPane();
1982
+ //JTabbedPane worldPane = new JTabbedPane();
16411983 //worldPane.add(bigPanel);
16421984 //worldPane.add(worldPanel);
16431985 /**/
....@@ -1651,7 +1993,7 @@
16511993
16521994 cameraView.requestFocusInWindow();
16531995
1654
- gridPanel.setDividerLocation(1.0);
1996
+// gridPanel.setDividerLocation(1.0);
16551997
16561998 frame.validate();
16571999
....@@ -1660,7 +2002,6 @@
16602002 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16612003 frame.addWindowListener(new WindowAdapter()
16622004 {
1663
-
16642005 public void windowClosing(WindowEvent e)
16652006 {
16662007 Close();
....@@ -1683,28 +2024,442 @@
16832024 ctrlPanel.removeAll();
16842025 }
16852026
1686
- void SetupMaterial(cGridBag panel)
2027
+ void SetupMaterial(cGridBag materialpanel)
16872028 {
1688
- /*
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
+ /*
16892444 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16902445 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1691
- */
2446
+ */
16922447
16932448 cGridBag editBar = new cGridBag().setVertical(false);
16942449
1695
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2450
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
16962451 createMaterialButton.setToolTipText("Create material");
16972452
16982453 /*
16992454 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
17002455 */
17012456
1702
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2457
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
17032458 clearMaterialButton.setToolTipText("Clear material");
17042459
17052460 if (Globals.ADVANCED)
17062461 {
1707
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2462
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
17082463 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
17092464 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
17102465 }
....@@ -1722,27 +2477,61 @@
17222477 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17232478
17242479 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);
17252504
17262505 cGridBag color = new cGridBag();
1727
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1728
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1729
- 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
+
17302511 //colorField.preferredWidth = 200;
17312512 colorSection.add(color);
17322513
17332514 cGridBag modulation = new cGridBag();
17342515 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17352516 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1736
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2517
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17372518 colorSection.add(modulation);
17382519
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
+
17392528 cGridBag texture = new cGridBag();
17402529 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17412530 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17422531 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17432532 colorSection.add(texture);
17442533
1745
- panel.add(new JSeparator());
2534
+ panel.add(GetSeparator());
17462535
17472536 panel.add(colorSection);
17482537
....@@ -1798,7 +2587,7 @@
17982587 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17992588 diffuseSection.add(shadowbias);
18002589
1801
- panel.add(new JSeparator());
2590
+ panel.add(GetSeparator());
18022591
18032592 panel.add(diffuseSection);
18042593
....@@ -1861,7 +2650,7 @@
18612650 specularSection.add(anisoV);
18622651
18632652
1864
- panel.add(new JSeparator());
2653
+ panel.add(GetSeparator());
18652654
18662655 panel.add(specularSection);
18672656
....@@ -1886,12 +2675,6 @@
18862675 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18872676 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18882677 colorSection.add(backlit);
1889
-
1890
- cGridBag opacity = new cGridBag();
1891
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1892
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1893
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1894
- colorSection.add(opacity);
18952678
18962679 //panel.add(new JSeparator());
18972680
....@@ -1937,7 +2720,7 @@
19372720 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19382721 textureSection.add(opacityPower);
19392722
1940
- panel.add(new JSeparator());
2723
+ panel.add(GetSeparator());
19412724
19422725 panel.add(textureSection);
19432726
....@@ -2924,7 +3707,7 @@
29243707
29253708 freezematerial = true;
29263709 colorField.setFloat(mat.color);
2927
- modulationField.setFloat(mat.modulation);
3710
+ saturationField.setFloat(mat.modulation);
29283711 metalnessField.setFloat(mat.metalness);
29293712 diffuseField.setFloat(mat.diffuse);
29303713 specularField.setFloat(mat.specular);
....@@ -2986,32 +3769,8 @@
29863769
29873770 if (multiplyToggle != null)
29883771 multiplyToggle.setSelected(mat.multiply);
2989
-
2990
- assert (object.projectedVertices != null);
2991
-
2992
- if (object.projectedVertices.length <= 2)
2993
- {
2994
- // Side effect...
2995
- Object3D.cVector2[] keep = object.projectedVertices;
2996
- object.projectedVertices = new Object3D.cVector2[3];
2997
- for (int i = 0; i < 3; i++)
2998
- {
2999
- if (i < keep.length)
3000
- {
3001
- object.projectedVertices[i] = keep[i];
3002
- } else
3003
- {
3004
- object.projectedVertices[i] = new Object3D.cVector2();
3005
- }
3006
- /*
3007
- if(keep.length == 0)
3008
- object.projectedVertices[0] = new Object3D.cVector2();
3009
- else
3010
- object.projectedVertices[0] = keep[0];
3011
- object.projectedVertices[1] = new Object3D.cVector2();
3012
- */
3013
- }
3014
- }
3772
+
3773
+ AllocProjectedVertices(object);
30153774
30163775 SetMaterial(mat, object.projectedVertices);
30173776 }
....@@ -3131,6 +3890,17 @@
31313890 public void itemStateChanged(ItemEvent event)
31323891 {
31333892 // 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
31343904 if (event.getSource() == propagateToggle)
31353905 {
31363906 propagate ^= true;
....@@ -3235,8 +4005,9 @@
32354005 } else if (event.getSource() == liveCB)
32364006 {
32374007 copy.live ^= true;
4008
+ objEditor.refreshContents(true); // To show item colors
32384009 return;
3239
- } else if (event.getSource() == selectCB)
4010
+ } else if (event.getSource() == selectableCB)
32404011 {
32414012 copy.dontselect ^= true;
32424013 return;
....@@ -3244,7 +4015,7 @@
32444015 {
32454016 copy.hide ^= true;
32464017 copy.Touch(); // display list issue
3247
- objEditor.refreshContents();
4018
+ objEditor.refreshContents(true); // To show item colors
32484019 return;
32494020 } else if (event.getSource() == link2masterCB)
32504021 {
....@@ -3309,7 +4080,7 @@
33094080 //System.out.println("ObjEditor " + event);
33104081 applySelf0(true);
33114082 //parent.applySelf();
3312
- objEditor.refreshContents();
4083
+ // conflicts with requestFocus objEditor.refreshContents();
33134084 } else if (source == resetButton)
33144085 {
33154086 CameraPane.fullreset = true;
....@@ -3489,17 +4260,25 @@
34894260
34904261 void New()
34914262 {
3492
- while (copy.Size() > 1)
4263
+ while (copy.Size() > 0)
34934264 {
3494
- copy.remove(1);
4265
+ copy.remove(0);
34954266 }
34964267
4268
+ copy.selection.clear();
4269
+
4270
+ if (copy == Grafreed.grafreed.universe)
4271
+ {
4272
+ CreateCameras();
4273
+ cameraView.SetCamera(GetCamera(copy, 0));
4274
+ }
34974275 ResetModel();
34984276 objEditor.refreshContents();
34994277 }
35004278
35014279 static public byte[] Compress(Object3D o)
35024280 {
4281
+ // Slower to actually compress.
35034282 try
35044283 {
35054284 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3601,6 +4380,7 @@
36014380 {
36024381 //Save(true);
36034382 Replace();
4383
+ SetVersionStates();
36044384 }
36054385
36064386 private boolean Equal(byte[] compress, byte[] name)
....@@ -3619,31 +4399,50 @@
36194399 return true;
36204400 }
36214401
3622
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
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
+ }
36234417
36244418 public boolean Save(boolean user)
36254419 {
36264420 System.err.println("Save");
4421
+ Replace();
36274422
3628
- cRadio tab = GetCurrentTab();
4423
+ //cRadio tab = GetCurrentTab();
36294424
3630
- byte[] compress = CompressCopy();
4425
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
36314426
36324427 boolean thesame = false;
36334428
3634
- // Quick heuristic using length. Works only when stream is compressed.
3635
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3636
- {
3637
- thesame = true;
3638
- }
4429
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4430
+// {
4431
+// thesame = true;
4432
+// }
36394433
36404434 //EditorFrame.m_MainFrame.requestFocusInWindow();
36414435 if (!thesame)
36424436 {
4437
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4438
+ {
4439
+ copy.versionlist[i] = copy.versionlist[i-1];
4440
+ }
4441
+
36434442 //tab.user[tab.versionindex] = user;
36444443 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36454444
3646
- copy.versions[++copy.versionindex] = compress;
4445
+ copy.versionlist[++copy.versionindex] = compress;
36474446
36484447 // if (increment)
36494448 // tab.versionindex++;
....@@ -3653,13 +4452,13 @@
36534452
36544453 //assert(hashtable.isEmpty());
36554454
3656
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3657
- {
3658
- //tab.user[i] = false;
3659
- copy.versions[i] = null;
3660
- }
4455
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4456
+// {
4457
+// //tab.user[i] = false;
4458
+// copy.versionlist[i] = null;
4459
+// }
36614460
3662
- SetUndoStates();
4461
+ SetVersionStates();
36634462
36644463 // test save
36654464 if (false)
....@@ -3682,27 +4481,65 @@
36824481
36834482 return !thesame;
36844483 }
3685
-
3686
- void CopyChanged(Object3D obj)
4484
+
4485
+ boolean flashIt = true;
4486
+
4487
+ void RefreshSelection()
36874488 {
3688
- SetUndoStates();
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);
4515
+ }
4516
+
4517
+ void CopyChanged()
4518
+ {
4519
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4520
+
4521
+ SetVersionStates();
36894522
36904523 boolean temp = CameraPane.SWITCH;
36914524 CameraPane.SWITCH = false;
36924525
3693
- copy.ExtractBigData(versiontable);
4526
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
36944527
36954528 copy.clear();
36964529
4530
+ copy.skyboxname = obj.skyboxname;
4531
+ copy.skyboxext = obj.skyboxext;
4532
+
36974533 for (int i=0; i<obj.Size(); i++)
36984534 {
36994535 copy.add(obj.get(i));
37004536 }
37014537
3702
- copy.RestoreBigData(versiontable);
4538
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
37034539
37044540 CameraPane.SWITCH = temp;
37054541
4542
+ RefreshSelection();
37064543 //assert(hashtable.isEmpty());
37074544
37084545 copy.Touch();
....@@ -3723,29 +4560,80 @@
37234560 }
37244561 }
37254562
3726
- refreshContents();
4563
+ refreshContents(true);
37274564 }
37284565
3729
- cButton undoButton;
4566
+ cButton previousVersionButton;
37304567 cButton restoreButton;
37314568 cButton replaceButton;
3732
- cButton redoButton;
4569
+ cButton nextVersionButton;
4570
+ cButton saveVersionButton;
4571
+ cButton deleteVersionButton;
37334572
3734
- void SetUndoStates()
4573
+ boolean muteSlider;
4574
+
4575
+ int VersionCount()
37354576 {
3736
- cRadio tab = GetCurrentTab();
4577
+ int count = 0;
37374578
3738
- restoreButton.setEnabled(copy.versionindex != -1);
3739
- replaceButton.setEnabled(copy.versionindex != -1);
3740
- undoButton.setEnabled(copy.versionindex > 0);
3741
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
4579
+ for (int i = copy.versionlist.length; --i >= 0;)
4580
+ {
4581
+ if (copy.versionlist[i] != null)
4582
+ count++;
4583
+ }
4584
+
4585
+ return count;
37424586 }
37434587
3744
- public boolean Undo()
4588
+ public cGridBag versionSliderPane;
4589
+
4590
+ void SetVersionStates()
37454591 {
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
+
37464634 System.err.println("Undo");
37474635
3748
- cRadio tab = GetCurrentTab();
4636
+ //cRadio tab = GetCurrentTab();
37494637
37504638 if (copy.versionindex == 0)
37514639 {
....@@ -3768,7 +4656,7 @@
37684656
37694657 copy.versionindex -= 1;
37704658
3771
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4659
+ CopyChanged();
37724660
37734661 return true;
37744662 }
....@@ -3777,41 +4665,45 @@
37774665 {
37784666 System.err.println("Restore");
37794667
3780
- cRadio tab = GetCurrentTab();
4668
+ //cRadio tab = GetCurrentTab();
37814669
3782
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4670
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
37834671 {
37844672 java.awt.Toolkit.getDefaultToolkit().beep();
37854673 return false;
37864674 }
37874675
3788
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4676
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4677
+ CopyChanged();
37894678
37904679 return true;
37914680 }
37924681
37934682 public boolean Replace()
37944683 {
3795
- System.err.println("Replace");
4684
+ //System.err.println("Replace");
37964685
3797
- cRadio tab = GetCurrentTab();
4686
+ //cRadio tab = GetCurrentTab();
37984687
3799
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4688
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38004689 {
38014690 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38024691 return false;
38034692 }
38044693
3805
- copy.versions[copy.versionindex] = CompressCopy();
4694
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
38064695
38074696 return true;
38084697 }
38094698
3810
- public void Redo()
4699
+ public void NextVersion()
38114700 {
3812
- cRadio tab = GetCurrentTab();
4701
+ // Option?
4702
+ Replace();
38134703
3814
- if (copy.versions[copy.versionindex + 1] == null)
4704
+ //cRadio tab = GetCurrentTab();
4705
+
4706
+ if (copy.versionlist[copy.versionindex + 1] == null)
38154707 {
38164708 java.awt.Toolkit.getDefaultToolkit().beep();
38174709 return;
....@@ -3819,7 +4711,7 @@
38194711
38204712 copy.versionindex += 1;
38214713
3822
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4714
+ CopyChanged();
38234715
38244716 //if (!tab.user[tab.versionindex])
38254717 // tab.graphs[tab.versionindex] = null;
....@@ -4016,6 +4908,12 @@
40164908 // else
40174909 // applySelf(true);
40184910 // }
4911
+
4912
+ boolean Equal(double a, double b)
4913
+ {
4914
+ return Math.abs(a - b) < 0.001;
4915
+ }
4916
+
40194917 void applySelf0(boolean name)
40204918 {
40214919 if (name)
....@@ -4033,7 +4931,7 @@
40334931 //copy.material = new cMaterial(copy.GetMaterial());
40344932
40354933 current.color = (float) colorField.getFloat();
4036
- current.modulation = (float) modulationField.getFloat();
4934
+ current.modulation = (float) saturationField.getFloat();
40374935 current.metalness = (float) metalnessField.getFloat();
40384936 current.diffuse = (float) diffuseField.getFloat();
40394937 current.specular = (float) specularField.getFloat();
....@@ -4065,29 +4963,52 @@
40654963 {
40664964 cMaterial mat = copy.material;
40674965
4068
- colorField.SetToolTipValue((mat.color));
4069
- modulationField.SetToolTipValue((mat.modulation));
4070
- metalnessField.SetToolTipValue((mat.metalness));
4071
- diffuseField.SetToolTipValue((mat.diffuse));
4072
- specularField.SetToolTipValue((mat.specular));
4073
- shininessField.SetToolTipValue((mat.shininess));
4074
- shiftField.SetToolTipValue((mat.shift));
4075
- ambientField.SetToolTipValue((mat.ambient));
4076
- lightareaField.SetToolTipValue((mat.lightarea));
4077
- diffusenessField.SetToolTipValue((mat.factor));
4078
- velvetField.SetToolTipValue((mat.velvet));
4079
- sheenField.SetToolTipValue((mat.sheen));
4080
- subsurfaceField.SetToolTipValue((mat.subsurface));
4081
- backlitField.SetToolTipValue((mat.bump));
4082
- anisoField.SetToolTipValue((mat.aniso));
4083
- anisoVField.SetToolTipValue((mat.anisoV));
4084
- cameraField.SetToolTipValue((mat.cameralight));
4085
- selfshadowField.SetToolTipValue((mat.diffuseness));
4086
- shadowField.SetToolTipValue((mat.shadow));
4087
- textureField.SetToolTipValue((mat.texture));
4088
- opacityField.SetToolTipValue((mat.opacity));
4089
- fakedepthField.SetToolTipValue((mat.fakedepth));
4090
- 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));
40915012 }
40925013
40935014 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -4118,18 +5039,24 @@
41185039 //copy.Touch();
41195040 }
41205041
4121
- cNumberSlider versionField;
5042
+ cNumberSlider versionSlider;
41225043
41235044 public void stateChanged(ChangeEvent e)
41245045 {
4125
- // assert(false);
4126
- if (e.getSource() == versionField)
5046
+ // assert(false);
5047
+ if (e.getSource() == versionSlider)
41275048 {
4128
- int version = versionField.getInteger();
5049
+ if (muteSlider)
5050
+ return;
41295051
4130
- if (copy.versions[version] != null)
5052
+ Replace();
5053
+
5054
+ int version = versionSlider.getInteger();
5055
+
5056
+ if (version != -1 && copy.versionlist[version] != null)
41315057 {
4132
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
5058
+ copy.versionindex = version;
5059
+ CopyChanged();
41335060 }
41345061
41355062 return;
....@@ -4169,6 +5096,12 @@
41695096 {
41705097 //System.out.println("stateChanged = " + this);
41715098 materialtouched = true;
5099
+
5100
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
5101
+ {
5102
+ saturationField.setFloat(1);
5103
+ }
5104
+
41725105 applySelf();
41735106 //System.out.println("this = " + this);
41745107 //System.out.println("PARENT = " + parent);
....@@ -4468,6 +5401,7 @@
44685401 {
44695402 if (GetTree() != null)
44705403 {
5404
+ GetTree().revalidate();
44715405 GetTree().repaint();
44725406 }
44735407
....@@ -4476,6 +5410,11 @@
44765410 ctrlPanel.validate(); // ? new
44775411 ctrlPanel.repaint();
44785412 }
5413
+
5414
+ if (previousVersionButton != null && copy.versionlist != null)
5415
+ SetVersionStates();
5416
+
5417
+ cameraView.requestFocusInWindow();
44795418 }
44805419
44815420 static TweenManager tweenManager = new TweenManager();
....@@ -4507,7 +5446,7 @@
45075446 // group = (Composite) group.get(0);
45085447 // }
45095448
4510
- System.out.println("makeSomething of " + thing);
5449
+ //System.out.println("makeSomething of " + thing);
45115450
45125451 /*
45135452 if (deselect && jList != null)
....@@ -4724,7 +5663,9 @@
47245663 readobj.ResetDisplayList();
47255664 } catch (Exception e)
47265665 {
4727
- //e.printStackTrace();
5666
+ if (!e.toString().contains("GZIP"))
5667
+ e.printStackTrace();
5668
+
47285669 try
47295670 {
47305671 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4804,6 +5745,8 @@
48045745 {
48055746 //readobj.deepCopySelf(copy);
48065747 copy.clear(); // june 2014
5748
+ copy.skyboxname = readobj.skyboxname;
5749
+ copy.skyboxext = readobj.skyboxext;
48075750 for (int i = 0; i < readobj.size(); i++)
48085751 {
48095752 Object3D child = readobj.get(i); // reserve(i);
....@@ -4844,6 +5787,7 @@
48445787 }
48455788 } catch (ClassCastException e)
48465789 {
5790
+ e.printStackTrace();
48475791 assert (false);
48485792 Composite c = (Composite) copy;
48495793 c.children.clear();
....@@ -4854,10 +5798,20 @@
48545798 c.addChild(csg);
48555799 }
48565800
4857
- copy.versions = readobj.versions;
5801
+ copy.versionlist = readobj.versionlist;
48585802 copy.versionindex = readobj.versionindex;
5803
+ copy.versiontable = readobj.versiontable;
48595804
4860
- SetUndoStates();
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();
48615815
48625816 ResetModel();
48635817 copy.HardTouch(); // recompile?
....@@ -4869,7 +5823,7 @@
48695823 {
48705824 if (Grafreed.standAlone)
48715825 {
4872
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5826
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
48735827 browser.show();
48745828 String filename = browser.getFile();
48755829 if (filename != null && filename.length() > 0)
....@@ -4946,6 +5900,8 @@
49465900
49475901 void save()
49485902 {
5903
+ Replace();
5904
+
49495905 if (lastname == null)
49505906 {
49515907 return;
....@@ -4968,6 +5924,7 @@
49685924 //ps.print(buffer.toString());
49695925 } catch (IOException e)
49705926 {
5927
+ e.printStackTrace();
49715928 }
49725929 }
49735930
....@@ -5187,6 +6144,7 @@
51876144 ButtonGroup buttonGroup;
51886145
51896146 cGridBag toolboxPanel;
6147
+ cGridBag skyboxPanel;
51906148 cGridBag materialPanel;
51916149 cGridBag ctrlPanel;
51926150
....@@ -5198,6 +6156,7 @@
51986156 boolean materialFlushed;
51996157 Object3D latestObject;
52006158
6159
+ cGridBag transformPanel;
52016160 cGridBag XYZPanel;
52026161
52036162 JSplitPane gridPanel;
....@@ -5260,7 +6219,7 @@
52606219 JLabel colorLabel;
52616220 cNumberSlider colorField;
52626221 JLabel modulationLabel;
5263
- cNumberSlider modulationField;
6222
+ cNumberSlider saturationField;
52646223 JLabel metalnessLabel;
52656224 cNumberSlider metalnessField;
52666225 JLabel diffuseLabel;
....@@ -5291,6 +6250,7 @@
52916250 cNumberSlider anisoField;
52926251 JLabel anisoVLabel;
52936252 cNumberSlider anisoVField;
6253
+
52946254 JLabel cameraLabel;
52956255 cNumberSlider cameraField;
52966256 JLabel selfshadowLabel;
....@@ -5305,6 +6265,7 @@
53056265 cNumberSlider fakedepthField;
53066266 JLabel shadowbiasLabel;
53076267 cNumberSlider shadowbiasField;
6268
+
53086269 JLabel bumpLabel;
53096270 cNumberSlider bumpField;
53106271 JLabel noiseLabel;