Normand Briere
2019-08-20 537f4ac57ae2b34f0a04fa63874c8ca6534c9a6d
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,143 @@
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;
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;
77162 }
78163 catch (Exception e)
79164 {
80
- return new cCheckBox(name, border);
165
+ //icons.put(name, null);
166
+ return null;
81167 }
82168 }
83
-
84
- private ImageIcon GetIcon(String name) throws IOException
169
+
170
+ BufferedImage GetImage(String name)
85171 {
86
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
-
88
- if (image.getWidth() != 24 && image.getHeight() != 24)
172
+ try
89173 {
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;
174
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
175
+
176
+ return image;
98177 }
99
-
100
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
- return icon;
178
+ catch (Exception e)
179
+ {
180
+ return null;
181
+ }
102182 }
103183
104184 // SCRIPT
....@@ -282,6 +362,14 @@
282362 client = inClient;
283363 copy = client;
284364
365
+// if (copy.versionlist == null)
366
+// {
367
+// copy.versionlist = new Object3D[100];
368
+// copy.versionindex = -1;
369
+//
370
+// callee.Save(true);
371
+// }
372
+
285373 // "this" is not called: SetupUI2(objEditor);
286374 }
287375
....@@ -295,6 +383,14 @@
295383 client = inClient;
296384 copy = client;
297385
386
+ if (copy.versionlist == null)
387
+ {
388
+ copy.versionlist = new Object3D[100];
389
+ copy.versionindex = -1;
390
+
391
+// Save(true);
392
+ }
393
+
298394 SetupUI2(callee.GetEditor());
299395 }
300396
....@@ -309,14 +405,15 @@
309405 //localCopy.parent = null;
310406
311407 frame = new JFrame();
312
- frame.setUndecorated(true);
408
+ frame.setUndecorated(false);
313409 objEditor = this;
314410 this.callee = callee;
315411
316412 //parent = p;
317413
318414 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
319
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
415
+ if (Globals.DEBUG)
416
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
320417 //gd.setFullScreenWindow(this);
321418 //setResizable(false);
322419 //if (!isDisplayable())
....@@ -327,6 +424,14 @@
327424 copy = localCopy;
328425 copy.editWindow = this;
329426
427
+// if (copy.versionlist == null)
428
+// {
429
+// copy.versionlist = new Object3D[100];
430
+// copy.versionindex = -1;
431
+//
432
+// Save(true);
433
+// }
434
+
330435 SetupMenu();
331436
332437 //SetupName(objEditor); // new
....@@ -345,12 +450,15 @@
345450
346451 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347452
453
+ // This is to refresh the UI of the material panel.
454
+ boolean patchMaterial;
455
+
348456 void SetupMenu()
349457 {
350458 frame.setMenuBar(menuBar = new MenuBar());
351459 menuBar.add(fileMenu = new Menu("File"));
352460 fileMenu.add(newItem = new MenuItem("New"));
353
- fileMenu.add(loadItem = new MenuItem("Open..."));
461
+ fileMenu.add(openItem = new MenuItem("Open..."));
354462
355463 //oe.menuBar.add(menu = new Menu("Include"));
356464 Menu menu = new Menu("Import");
....@@ -358,8 +466,11 @@
358466 importOBJItem.addActionListener(this);
359467 import3DSItem = menu.add(new MenuItem("3DS file..."));
360468 import3DSItem.addActionListener(this);
469
+ if (Globals.ADVANCED)
470
+ {
361471 importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
362472 importVRMLX3DItem.addActionListener(this);
473
+ }
363474 menu.add("-");
364475 importGFDItem = menu.add(new MenuItem("Grafreed file..."));
365476 importGFDItem.addActionListener(this);
....@@ -382,7 +493,7 @@
382493 }
383494
384495 newItem.addActionListener(this);
385
- loadItem.addActionListener(this);
496
+ openItem.addActionListener(this);
386497 saveItem.addActionListener(this);
387498 saveAsItem.addActionListener(this);
388499 exportAsItem.addActionListener(this);
....@@ -394,6 +505,8 @@
394505
395506 ChangeListener changeListener = new ChangeListener()
396507 {
508
+ //String name;
509
+
397510 public void stateChanged(ChangeEvent changeEvent)
398511 {
399512 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -412,18 +525,49 @@
412525 // EditSelection(false);
413526 // }
414527
415
- refreshContents(false); // To refresh Info tab
528
+// if (objectPanel.getSelectedIndex() == 4)
529
+// {
530
+// name = copy.skyboxname;
531
+//
532
+// if (name == null)
533
+// {
534
+// name = "";
535
+// }
536
+//
537
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
538
+// copy.skyboxext = "jpg";
539
+// }
540
+// else
541
+// {
542
+// if (name != null)
543
+// {
544
+// if (name.equals(""))
545
+// {
546
+// copy.skyboxname = null;
547
+// copy.skyboxext = null;
548
+// }
549
+// else
550
+// {
551
+// copy.skyboxname = name;
552
+// }
553
+// }
554
+// }
555
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
556
+
557
+// refreshContents(false); // To refresh Info tab
558
+ cameraView.repaint();
416559 }
417560 };
418561 objectPanel.addChangeListener(changeListener);
419562
420563 toolbarPanel = new JPanel();
421564 toolbarPanel.setName("Toolbar");
565
+
422566 treePanel = new cGridBag();
423567 treePanel.setName("Tree");
424568
425569 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
570
+ //editPanel.setName("Edit");
427571
428572 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429573
....@@ -431,11 +575,13 @@
431575 editPanel.add(editCommandsPanel);
432576 editPanel.add(ctrlPanel);
433577
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
578
+ toolboxPanel = new cGridBag().setVertical(true);
579
+ //toolboxPanel.setName("Toolbox");
436580
437
- materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
581
+ skyboxPanel = new cGridBag().setVertical(true);
582
+
583
+ materialPanel = new cGridBag().setVertical(false);
584
+ //materialPanel.setName("Material");
439585
440586 /*JTextPane*/
441587 infoarea = createTextPane();
....@@ -443,14 +589,15 @@
443589
444590 infoarea.setEditable(true);
445591 SetText();
592
+
446593 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447594 // infoarea.setOpaque(false);
448595 // //infoarea.setForeground(textcolor);
449596 // TEXTAREA infoarea.setLineWrap(true);
450597 // TEXTAREA infoarea.setWrapStyleWord(true);
451598 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452
- //infoPanel.setPreferredSize(new Dimension(50, 200));
453
- infoPanel.setName("Info");
599
+ infoPanel.setPreferredSize(new Dimension(1, 1));
600
+ //infoPanel.setName("Info");
454601 //infoPanel.setLayout(new BorderLayout());
455602 //infoPanel.add(createTextPane());
456603
....@@ -699,8 +846,8 @@
699846 }
700847 }
701848
702
-static GraphicsDevice device = GraphicsEnvironment
703
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
849
+//static GraphicsDevice device = GraphicsEnvironment
850
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
704851
705852 Rectangle keeprect;
706853 cRadio radio;
....@@ -717,6 +864,7 @@
717864 boolean maximized;
718865
719866 cButton fullscreenLayout;
867
+ cButton expandedLayout;
720868
721869 void Minimize()
722870 {
....@@ -741,10 +889,11 @@
741889 else
742890 {
743891 keeprect = frame.getBounds();
744
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
745
- Dimension rect2 = frame.getToolkit().getScreenSize();
746
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
892
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
893
+// Dimension rect2 = frame.getToolkit().getScreenSize();
894
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
747895 // frame.setState(Frame.MAXIMIZED_BOTH);
896
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
748897 }
749898
750899 maximized ^= true;
....@@ -755,15 +904,22 @@
755904 cButton minButton;
756905 cButton maxButton;
757906 cButton fullButton;
907
+ cButton collapseButton;
908
+ cButton maximize3DButton;
758909
759910 void ToggleFullScreen()
760911 {
912
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
913
+
761914 cameraView.ToggleFullScreen();
762915
763916 if (!CameraPane.FULLSCREEN)
764917 {
765918 device.setFullScreenWindow(null);
919
+ frame.dispose();
920
+ frame.setUndecorated(false);
766921 frame.validate();
922
+ frame.setVisible(true);
767923
768924 //frame.setVisible(false);
769925 // frame.removeNotify();
....@@ -774,13 +930,13 @@
774930 // X frame.getContentPane().remove(/*"Center",*/bigThree);
775931 // X framePanel.add(bigThree);
776932 // X frame.getContentPane().add(/*"Center",*/framePanel);
777
- framePanel.setDividerLocation(1);
933
+// framePanel.setDividerLocation(46); // icons are 24x24
778934
779935 //frame.setVisible(true);
780
- radio.layout = keepButton;
936
+// radio.layout = keepButton;
781937 //theFrame = null;
782938 keepButton = null;
783
- radio.layout.doClick();
939
+// radio.layout.doClick();
784940
785941 } else
786942 {
....@@ -789,22 +945,70 @@
789945 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
790946 // frame.getToolkit().getScreenSize().height);
791947 //frame.setVisible(false);
948
+
949
+ frame.dispose();
950
+ frame.setUndecorated(true);
792951 device.setFullScreenWindow(frame);
793952 frame.validate();
953
+ frame.setVisible(true);
794954 // frame.removeNotify();
795955 // frame.setUndecorated(true);
796956 // frame.addNotify();
797957 // X frame.getContentPane().remove(/*"Center",*/framePanel);
798958 // X framePanel.remove(bigThree);
799959 // X frame.getContentPane().add(/*"Center",*/bigThree);
800
- framePanel.setDividerLocation(0);
960
+// framePanel.setDividerLocation(0);
801961
802
- radio.layout = fullscreenLayout;
803
- radio.layout.doClick();
962
+// radio.layout = fullscreenLayout;
963
+// radio.layout.doClick();
804964 //frame.setVisible(true);
805965 }
806966 frame.validate();
967
+
968
+ cameraView.requestFocusInWindow();
807969 }
970
+
971
+ void CollapseToolbar()
972
+ {
973
+ framePanel.setDividerLocation(0);
974
+ //frame.validate();
975
+
976
+ cameraView.requestFocusInWindow();
977
+ }
978
+
979
+ private Object3D Duplicate(Object3D object)
980
+ {
981
+ boolean temp = CameraPane.SWITCH;
982
+ CameraPane.SWITCH = false;
983
+
984
+ if (Grafreed.grafreed.universe.versiontable == null)
985
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
986
+
987
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
988
+ // if (copy == client)
989
+
990
+ Object3D versions[] = object.versionlist;
991
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
992
+ object.versionlist = null;
993
+ object.versiontable = null;
994
+
995
+ Object3D parent = object.parent;
996
+ object.parent = null;
997
+
998
+ //byte[] compress = Compress(copy);
999
+ Object3D compress = (Object3D)Grafreed.clone(object);
1000
+
1001
+ object.parent = parent;
1002
+
1003
+ object.versionlist = versions;
1004
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
1005
+
1006
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
1007
+
1008
+ CameraPane.SWITCH = temp;
1009
+
1010
+ return compress;
1011
+ }
8081012
8091013 private JTextPane createTextPane()
8101014 {
....@@ -927,6 +1131,7 @@
9271131 {
9281132 SetupMaterial(materialPanel);
9291133 }
1134
+
9301135 //SetupName();
9311136 //SetupViews();
9321137 }
....@@ -936,7 +1141,7 @@
9361141 // NumberSlider vDivsField;
9371142 // JCheckBox endcaps;
9381143 JCheckBox liveCB;
939
- JCheckBox selectCB;
1144
+ JCheckBox selectableCB;
9401145 JCheckBox hideCB;
9411146 JCheckBox link2masterCB;
9421147 JCheckBox markCB;
....@@ -1135,6 +1340,18 @@
11351340
11361341 namePanel = new cGridBag();
11371342
1343
+ //if (copy.pinned)
1344
+ {
1345
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
1346
+ pinButton.setSelected(copy.pinned);
1347
+ cGridBag t = new cGridBag();
1348
+ t.preferredWidth = 2;
1349
+ t.add(pinButton);
1350
+ namePanel.add(t);
1351
+
1352
+ pinButton.addItemListener(this);
1353
+ }
1354
+
11381355 nameField = AddText(namePanel, copy.GetName());
11391356 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11401357 oe.ctrlPanel.add(namePanel);
....@@ -1148,13 +1365,16 @@
11481365
11491366 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11501367 liveCB.setToolTipText("Animate object");
1151
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1152
- selectCB.setToolTipText("Make object selectable");
1368
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1369
+ markCB.setToolTipText("Set target transform");
1370
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1371
+ selectableCB.setToolTipText("Make object selectable");
11531372 // Return();
1373
+
11541374 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11551375 hideCB.setToolTipText("Hide object");
1156
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1157
- markCB.setToolTipText("As animation target transform");
1376
+
1377
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11581378
11591379 setupPanel2 = new cGridBag().setVertical(false);
11601380
....@@ -1164,10 +1384,11 @@
11641384 randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11651385 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11661386
1387
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1388
+ link2masterCB.setToolTipText("Attach to support");
1389
+
11671390 if (Globals.ADVANCED)
11681391 {
1169
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1170
- link2masterCB.setToolTipText("Attach to support");
11711392 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11721393 speedupCB.setToolTipText("Option motion capture");
11731394 }
....@@ -1353,22 +1574,9 @@
13531574
13541575 if (cam == null || !(copy.get(0) instanceof cGroup))
13551576 {
1356
- System.out.println("CREATE CAMERAS");
1357
- cams = new cTemplate();
1358
- cams.name = "Cameras";
1359
- copy.insertElementAt(cams, 0);
1360
- //cams.parent = copy;
1361
-
1362
- cam = new Camera(); // LA.newVector(3, 2, 1));
1363
- cams.addChild(cam);
1364
- cam = new Camera(1);
1365
- cams.addChild(cam);
1366
- cam = new Camera(2);
1367
- cams.addChild(cam);
1368
- cam = new Camera(3);
1369
- cams.addChild(cam);
1370
- cam = new Camera(4); // Light
1371
- cams.addChild(cam);
1577
+ if (Globals.DEBUG)
1578
+ System.out.println("CREATE CAMERAS");
1579
+ cams = CreateCameras();
13721580 } else
13731581 {
13741582 cams = (cGroup) copy.get(0);
....@@ -1434,6 +1642,45 @@
14341642 //frontView.object = copy;
14351643 //sideView.object = copy;
14361644
1645
+ transformPanel = new cGridBag().setVertical(true);
1646
+
1647
+ cGridBag resetTransformPanel = new cGridBag();
1648
+
1649
+ resetTransformPanel.preferredHeight = 2;
1650
+
1651
+ cButton resetTransform = GetButton("Reset all", !Globals.NIMBUSLAF);
1652
+ resetTransform.setToolTipText("Reset Translation, Rotation and Scale");
1653
+ resetTransform.addMouseListener(new MouseAdapter()
1654
+ {
1655
+ public void mouseClicked(MouseEvent e)
1656
+ {
1657
+ ResetTransform();
1658
+ }
1659
+ });
1660
+ resetTransformPanel.add(resetTransform);
1661
+
1662
+ resetTransform = GetButton("T only", !Globals.NIMBUSLAF);
1663
+ resetTransform.setToolTipText("Reset Translation only");
1664
+ resetTransform.addMouseListener(new MouseAdapter()
1665
+ {
1666
+ public void mouseClicked(MouseEvent e)
1667
+ {
1668
+ ResetTransform(1);
1669
+ }
1670
+ });
1671
+ resetTransformPanel.add(resetTransform);
1672
+
1673
+ resetTransform = GetButton("RS only", !Globals.NIMBUSLAF);
1674
+ resetTransform.setToolTipText("Reset Rotation and Scale only");
1675
+ resetTransform.addMouseListener(new MouseAdapter()
1676
+ {
1677
+ public void mouseClicked(MouseEvent e)
1678
+ {
1679
+ ResetTransform(2);
1680
+ }
1681
+ });
1682
+ resetTransformPanel.add(resetTransform);
1683
+
14371684 XYZPanel = new cGridBag().setVertical(true);
14381685 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
14391686
....@@ -1441,7 +1688,11 @@
14411688 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14421689 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14431690 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1691
+ //XYZPanel.setName("XYZ");
14441692
1693
+ transformPanel.add(resetTransformPanel);
1694
+ transformPanel.add(XYZPanel);
1695
+
14451696 /*
14461697 gridPanel = new JPanel(); //new BorderLayout());
14471698 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1449,12 +1700,12 @@
14491700 gridPanel.add(cameraView);
14501701 gridPanel.add(XYZPanel);
14511702 */
1452
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1453
- gridPanel.setContinuousLayout(true);
1454
- gridPanel.setOneTouchExpandable(true);
1455
- gridPanel.setDividerLocation(1.0);
1456
- gridPanel.setDividerSize(9);
1457
- gridPanel.setResizeWeight(0.85);
1703
+// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1704
+// gridPanel.setContinuousLayout(true);
1705
+// gridPanel.setOneTouchExpandable(true);
1706
+// gridPanel.setDividerLocation(1.0);
1707
+// gridPanel.setDividerSize(9);
1708
+// gridPanel.setResizeWeight(0.85);
14581709
14591710 // aConstraints.weighty = 0;
14601711 //System.out.println("THIS = " + this);
....@@ -1477,15 +1728,34 @@
14771728
14781729 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14791730 //tmp.setName("Edit");
1731
+ objectPanel.add(skyboxPanel);
1732
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1733
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1734
+
1735
+ objectPanel.add(toolboxPanel);
1736
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1737
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1738
+
14801739 objectPanel.add(materialPanel);
1740
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1741
+ objectPanel.setToolTipTextAt(2, "Material");
1742
+
14811743 // JPanel north = new JPanel(new BorderLayout());
14821744 // north.setName("Edit");
14831745 // north.add(ctrlPanel, BorderLayout.NORTH);
14841746 // objectPanel.add(north);
14851747 objectPanel.add(editPanel);
1486
- objectPanel.add(infoPanel);
1487
- objectPanel.add(toolboxPanel);
1488
-
1748
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
1749
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1750
+
1751
+ objectPanel.add(transformPanel);
1752
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1753
+ objectPanel.setToolTipTextAt(4, "TRS transform");
1754
+
1755
+ patchMaterial = true;
1756
+ cameraView.patchMaterial = this;
1757
+ objectPanel.setSelectedIndex(2);
1758
+
14891759 /*
14901760 aConstraints.gridx = 0;
14911761 aConstraints.gridwidth = 1;
....@@ -1516,11 +1786,108 @@
15161786
15171787 AddOptions(optionsPanel); //, aConstraints);
15181788
1519
- tabbedPane.add(optionsPanel);
1520
-
15211789 tabbedPane.add(FSPane = new cFileSystemPane(this));
15221790
1791
+ tabbedPane.add(optionsPanel);
1792
+
15231793 scenePanel.add(tabbedPane);
1794
+
1795
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1796
+ creditsPanel.setName("Credits");
1797
+
1798
+ cLabel ogaLabel = new cLabel(" Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1799
+ creditsPanel.add(ogaLabel);
1800
+
1801
+ cButton creditButton;
1802
+ creditsPanel.add(creditButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1803
+ creditButton.setToolTipText("https://opengameart.org");
1804
+
1805
+ creditButton.addMouseListener(new MouseAdapter()
1806
+ {
1807
+ public void mouseClicked(MouseEvent e)
1808
+ {
1809
+ try
1810
+ {
1811
+ Desktop.getDesktop().browse(new java.net.URI("https://opengameart.org/"));
1812
+ } catch (Exception e1)
1813
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1814
+ {
1815
+ e1.printStackTrace();
1816
+ }
1817
+ }
1818
+ });
1819
+
1820
+ ogaLabel = new cLabel(" Download 3D models! (.3ds and .obj only)", !Globals.NIMBUSLAF);
1821
+ creditsPanel.add(ogaLabel);
1822
+
1823
+ creditsPanel.add(creditButton = GetButton("icons/3delicious.png", !Globals.NIMBUSLAF));
1824
+ creditButton.setToolTipText("https://3delicious.net");
1825
+
1826
+ creditButton.addMouseListener(new MouseAdapter()
1827
+ {
1828
+ public void mouseClicked(MouseEvent e)
1829
+ {
1830
+ try
1831
+ {
1832
+ Desktop.getDesktop().browse(new java.net.URI("https://3delicious.net"));
1833
+ } catch (Exception e1)
1834
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1835
+ {
1836
+ e1.printStackTrace();
1837
+ }
1838
+ }
1839
+ });
1840
+
1841
+ creditsPanel.add(creditButton = GetButton("icons/archive3d.png", !Globals.NIMBUSLAF));
1842
+ creditButton.setToolTipText("https://archive3d.net");
1843
+
1844
+ creditButton.addMouseListener(new MouseAdapter()
1845
+ {
1846
+ public void mouseClicked(MouseEvent e)
1847
+ {
1848
+ try
1849
+ {
1850
+ Desktop.getDesktop().browse(new java.net.URI("https://archive3d.net"));
1851
+ } catch (Exception e1)
1852
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1853
+ {
1854
+ e1.printStackTrace();
1855
+ }
1856
+ }
1857
+ });
1858
+
1859
+ creditsPanel.add(creditButton = GetButton("icons/turbosquid.png", !Globals.NIMBUSLAF));
1860
+ creditButton.setToolTipText("https://turbosquid.com");
1861
+
1862
+ creditButton.addMouseListener(new MouseAdapter()
1863
+ {
1864
+ public void mouseClicked(MouseEvent e)
1865
+ {
1866
+ try
1867
+ {
1868
+ Desktop.getDesktop().browse(new java.net.URI("https://www.turbosquid.com/Search/3D-Models/free"));
1869
+ } catch (Exception e1)
1870
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1871
+ {
1872
+ e1.printStackTrace();
1873
+ }
1874
+ }
1875
+ });
1876
+
1877
+ for (int i=6; --i>=0;)
1878
+ {
1879
+ creditsPanel.add(new cGridBag());
1880
+ }
1881
+
1882
+ tabbedPane.add(creditsPanel);
1883
+ tabbedPane.setToolTipTextAt(3, "Credits");
1884
+
1885
+ if (Globals.ADVANCED)
1886
+ {
1887
+ tabbedPane.add(infoPanel);
1888
+ tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1889
+ tabbedPane.setToolTipTextAt(4, "Information");
1890
+ }
15241891
15251892 /*
15261893 cTree jTree = new cTree(null);
....@@ -1542,13 +1909,13 @@
15421909 jtp.add(tree);
15431910 */
15441911
1545
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1546
- bigPanel.setContinuousLayout(true);
1547
- bigPanel.setOneTouchExpandable(true);
1548
- bigPanel.setDividerLocation(0.8);
1549
- bigPanel.setDividerSize(15);
1550
- bigPanel.setResizeWeight(0.15);
1551
- bigPanel.setName("Scene");
1912
+// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1913
+// bigPanel.setContinuousLayout(true);
1914
+// bigPanel.setOneTouchExpandable(true);
1915
+// bigPanel.setDividerLocation(0.8);
1916
+// bigPanel.setDividerSize(15);
1917
+// bigPanel.setResizeWeight(0.15);
1918
+// bigPanel.setName("Scene");
15521919
15531920 //bigPanel.setLayout(new BorderLayout());
15541921 //bigPanel.setSize(new Dimension(10,10));
....@@ -1583,7 +1950,7 @@
15831950 bigThree = new cGridBag();
15841951 bigThree.addComponent(scenePanel);
15851952 bigThree.addComponent(centralPanel);
1586
- bigThree.addComponent(XYZPanel);
1953
+ //bigThree.addComponent(XYZPanel);
15871954
15881955 // // SIDE EFFECT!!!
15891956 // aConstraints.gridx = 0;
....@@ -1592,16 +1959,33 @@
15921959 // aConstraints.gridheight = 1;
15931960
15941961 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1595
- framePanel.setContinuousLayout(true);
1596
- framePanel.setOneTouchExpandable(true);
1597
- framePanel.setDividerLocation(0.8);
1962
+
1963
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1964
+ new java.beans.PropertyChangeListener()
1965
+ {
1966
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1967
+ {
1968
+ if ((Integer)pce.getOldValue() == 1)
1969
+ {
1970
+ if (radio.layout != expandedLayout)
1971
+ {
1972
+ radio.layout = expandedLayout;
1973
+ radio.layout.doClick();
1974
+ }
1975
+ }
1976
+ }
1977
+ });
1978
+
1979
+ framePanel.setContinuousLayout(false);
1980
+ framePanel.setOneTouchExpandable(false);
1981
+ //.setDividerLocation(0.8);
15981982 //framePanel.setDividerSize(15);
15991983 //framePanel.setResizeWeight(0.15);
16001984 framePanel.setName("Frame");
16011985
16021986 frame.getContentPane().setLayout(new BorderLayout());
16031987 /**/
1604
- JTabbedPane worldPane = new JTabbedPane();
1988
+ //JTabbedPane worldPane = new JTabbedPane();
16051989 //worldPane.add(bigPanel);
16061990 //worldPane.add(worldPanel);
16071991 /**/
....@@ -1613,17 +1997,17 @@
16131997
16141998 frame.setSize(1280, 860);
16151999
1616
- frame.validate();
1617
- frame.setVisible(true);
1618
-
16192000 cameraView.requestFocusInWindow();
16202001
1621
- gridPanel.setDividerLocation(1.0);
2002
+// gridPanel.setDividerLocation(1.0);
2003
+
2004
+ frame.validate();
2005
+
2006
+ frame.setVisible(true);
16222007
16232008 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16242009 frame.addWindowListener(new WindowAdapter()
16252010 {
1626
-
16272011 public void windowClosing(WindowEvent e)
16282012 {
16292013 Close();
....@@ -1646,28 +2030,442 @@
16462030 ctrlPanel.removeAll();
16472031 }
16482032
1649
- void SetupMaterial(cGridBag panel)
2033
+ void SetupMaterial(cGridBag materialpanel)
16502034 {
1651
- /*
2035
+ cGridBag presetpanel = new cGridBag().setVertical(true);
2036
+
2037
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
2038
+ skin.setToolTipText("Skin");
2039
+ skin.addMouseListener(new MouseAdapter()
2040
+ {
2041
+ public void mouseClicked(MouseEvent e)
2042
+ {
2043
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
2044
+ cMaterial material = object.material;
2045
+
2046
+ // Skin
2047
+ colorField.setFloat(material.color);
2048
+ float saturation = material.modulation;
2049
+
2050
+ if (!cameraView.Skinshader)
2051
+ {
2052
+ saturation /= 1.5;
2053
+ }
2054
+
2055
+ saturationField.setFloat(saturation);
2056
+
2057
+ subsurfaceField.setFloat(material.subsurface);
2058
+ selfshadowField.setFloat(material.diffuseness);
2059
+ diffusenessField.setFloat(material.factor);
2060
+ shininessField.setFloat(material.shininess);
2061
+ shadowbiasField.setFloat(material.shadowbias);
2062
+ diffuseField.setFloat(material.diffuse);
2063
+ specularField.setFloat(material.specular);
2064
+
2065
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2066
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2067
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2068
+
2069
+ materialtouched = true;
2070
+ applySelf();
2071
+ }
2072
+ });
2073
+ presetpanel.add(skin);
2074
+
2075
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
2076
+ lambert.setToolTipText("Diffuse");
2077
+ lambert.addMouseListener(new MouseAdapter()
2078
+ {
2079
+ public void mouseClicked(MouseEvent e)
2080
+ {
2081
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
2082
+ cMaterial material = object.material;
2083
+
2084
+ diffusenessField.setFloat(material.factor);
2085
+ selfshadowField.setFloat(material.diffuseness);
2086
+
2087
+ materialtouched = true;
2088
+ applySelf();
2089
+ }
2090
+ });
2091
+ presetpanel.add(lambert);
2092
+
2093
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
2094
+ diffuse2.setToolTipText("Diffuse2");
2095
+ diffuse2.addMouseListener(new MouseAdapter()
2096
+ {
2097
+ public void mouseClicked(MouseEvent e)
2098
+ {
2099
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
2100
+ cMaterial material = object.material;
2101
+
2102
+ diffusenessField.setFloat(material.factor);
2103
+ selfshadowField.setFloat(material.diffuseness);
2104
+
2105
+ materialtouched = true;
2106
+ applySelf();
2107
+ }
2108
+ });
2109
+ presetpanel.add(diffuse2);
2110
+
2111
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
2112
+ diffusemoon.setToolTipText("Moon");
2113
+ diffusemoon.addMouseListener(new MouseAdapter()
2114
+ {
2115
+ public void mouseClicked(MouseEvent e)
2116
+ {
2117
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
2118
+ cMaterial material = object.material;
2119
+
2120
+ diffusenessField.setFloat(material.factor);
2121
+ selfshadowField.setFloat(material.diffuseness);
2122
+
2123
+ materialtouched = true;
2124
+ applySelf();
2125
+ }
2126
+ });
2127
+ presetpanel.add(diffusemoon);
2128
+
2129
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
2130
+ diffusemoon2.setToolTipText("Moon2");
2131
+ diffusemoon2.addMouseListener(new MouseAdapter()
2132
+ {
2133
+ public void mouseClicked(MouseEvent e)
2134
+ {
2135
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
2136
+ cMaterial material = object.material;
2137
+
2138
+ diffusenessField.setFloat(material.factor);
2139
+ selfshadowField.setFloat(material.diffuseness);
2140
+
2141
+ materialtouched = true;
2142
+ applySelf();
2143
+ }
2144
+ });
2145
+ presetpanel.add(diffusemoon2);
2146
+
2147
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
2148
+ diffusemoon3.setToolTipText("Moon3");
2149
+ diffusemoon3.addMouseListener(new MouseAdapter()
2150
+ {
2151
+ public void mouseClicked(MouseEvent e)
2152
+ {
2153
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2154
+ cMaterial material = object.material;
2155
+
2156
+ diffusenessField.setFloat(material.factor);
2157
+ selfshadowField.setFloat(material.diffuseness);
2158
+
2159
+ materialtouched = true;
2160
+ applySelf();
2161
+ }
2162
+ });
2163
+ presetpanel.add(diffusemoon3);
2164
+
2165
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
2166
+ diffusesheen.setToolTipText("Sheen");
2167
+ diffusesheen.addMouseListener(new MouseAdapter()
2168
+ {
2169
+ public void mouseClicked(MouseEvent e)
2170
+ {
2171
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2172
+ cMaterial material = object.material;
2173
+
2174
+ sheenField.setFloat(material.sheen);
2175
+
2176
+ materialtouched = true;
2177
+ applySelf();
2178
+ }
2179
+ });
2180
+ presetpanel.add(diffusesheen);
2181
+
2182
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
2183
+ rough.setToolTipText("Rough metal");
2184
+ rough.addMouseListener(new MouseAdapter()
2185
+ {
2186
+ public void mouseClicked(MouseEvent e)
2187
+ {
2188
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2189
+ cMaterial material = object.material;
2190
+
2191
+ shininessField.setFloat(material.shininess);
2192
+ velvetField.setFloat(material.velvet);
2193
+
2194
+ materialtouched = true;
2195
+ applySelf();
2196
+ }
2197
+ });
2198
+ presetpanel.add(rough);
2199
+
2200
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
2201
+ rough2.setToolTipText("Medium metal");
2202
+ rough2.addMouseListener(new MouseAdapter()
2203
+ {
2204
+ public void mouseClicked(MouseEvent e)
2205
+ {
2206
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2207
+ cMaterial material = object.material;
2208
+
2209
+ shininessField.setFloat(material.shininess);
2210
+ lightareaField.setFloat(material.lightarea);
2211
+
2212
+ materialtouched = true;
2213
+ applySelf();
2214
+ }
2215
+ });
2216
+ presetpanel.add(rough2);
2217
+
2218
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
2219
+ shini0.setToolTipText("Shiny");
2220
+ shini0.addMouseListener(new MouseAdapter()
2221
+ {
2222
+ public void mouseClicked(MouseEvent e)
2223
+ {
2224
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2225
+ cMaterial material = object.material;
2226
+
2227
+ shininessField.setFloat(material.shininess);
2228
+ lightareaField.setFloat(material.lightarea);
2229
+
2230
+ materialtouched = true;
2231
+ applySelf();
2232
+ }
2233
+ });
2234
+ presetpanel.add(shini0);
2235
+
2236
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
2237
+ shini1.setToolTipText("Shiny2");
2238
+ shini1.addMouseListener(new MouseAdapter()
2239
+ {
2240
+ public void mouseClicked(MouseEvent e)
2241
+ {
2242
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2243
+ cMaterial material = object.material;
2244
+
2245
+ shininessField.setFloat(material.shininess);
2246
+ lightareaField.setFloat(material.lightarea);
2247
+
2248
+ materialtouched = true;
2249
+ applySelf();
2250
+ }
2251
+ });
2252
+ presetpanel.add(shini1);
2253
+
2254
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
2255
+ shini2.setToolTipText("Shiny3");
2256
+ shini2.addMouseListener(new MouseAdapter()
2257
+ {
2258
+ public void mouseClicked(MouseEvent e)
2259
+ {
2260
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2261
+ cMaterial material = object.material;
2262
+
2263
+ shininessField.setFloat(material.shininess);
2264
+ lightareaField.setFloat(material.lightarea);
2265
+
2266
+ materialtouched = true;
2267
+ applySelf();
2268
+ }
2269
+ });
2270
+ presetpanel.add(shini2);
2271
+
2272
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
2273
+ aniso.setToolTipText("AnisoU");
2274
+ aniso.addMouseListener(new MouseAdapter()
2275
+ {
2276
+ public void mouseClicked(MouseEvent e)
2277
+ {
2278
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2279
+ cMaterial material = object.material;
2280
+
2281
+ anisoField.setFloat(material.aniso);
2282
+ anisoVField.setFloat(material.anisoV);
2283
+
2284
+ materialtouched = true;
2285
+ applySelf();
2286
+ }
2287
+ });
2288
+ presetpanel.add(aniso);
2289
+
2290
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
2291
+ aniso2.setToolTipText("AnisoV");
2292
+ aniso2.addMouseListener(new MouseAdapter()
2293
+ {
2294
+ public void mouseClicked(MouseEvent e)
2295
+ {
2296
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2297
+ cMaterial material = object.material;
2298
+
2299
+ anisoField.setFloat(material.aniso);
2300
+ anisoVField.setFloat(material.anisoV);
2301
+
2302
+ materialtouched = true;
2303
+ applySelf();
2304
+ }
2305
+ });
2306
+ presetpanel.add(aniso2);
2307
+
2308
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
2309
+ aniso3.setToolTipText("AnisoUV");
2310
+ aniso3.addMouseListener(new MouseAdapter()
2311
+ {
2312
+ public void mouseClicked(MouseEvent e)
2313
+ {
2314
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2315
+ cMaterial material = object.material;
2316
+
2317
+ anisoField.setFloat(material.aniso);
2318
+ anisoVField.setFloat(material.anisoV);
2319
+
2320
+ materialtouched = true;
2321
+ applySelf();
2322
+ }
2323
+ });
2324
+ presetpanel.add(aniso3);
2325
+
2326
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
2327
+ velvet0.setToolTipText("Velvet");
2328
+ velvet0.addMouseListener(new MouseAdapter()
2329
+ {
2330
+ public void mouseClicked(MouseEvent e)
2331
+ {
2332
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2333
+ cMaterial material = object.material;
2334
+
2335
+ diffusenessField.setFloat(material.factor);
2336
+ selfshadowField.setFloat(material.diffuseness);
2337
+ sheenField.setFloat(material.sheen);
2338
+ shininessField.setFloat(material.shininess);
2339
+ velvetField.setFloat(material.velvet);
2340
+ shiftField.setFloat(material.shift);
2341
+
2342
+ materialtouched = true;
2343
+ applySelf();
2344
+ }
2345
+ });
2346
+ presetpanel.add(velvet0);
2347
+
2348
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
2349
+ bump0.setToolTipText("Bump texture");
2350
+ bump0.addMouseListener(new MouseAdapter()
2351
+ {
2352
+ public void mouseClicked(MouseEvent e)
2353
+ {
2354
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2355
+ cMaterial material = object.material;
2356
+
2357
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2358
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2359
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2360
+
2361
+ materialtouched = true;
2362
+ applySelf();
2363
+ }
2364
+ });
2365
+ presetpanel.add(bump0);
2366
+
2367
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
2368
+ borderShader.setToolTipText("Border fade");
2369
+ borderShader.addMouseListener(new MouseAdapter()
2370
+ {
2371
+ public void mouseClicked(MouseEvent e)
2372
+ {
2373
+ borderfadeField.setFloat(0.5);
2374
+ opacityField.setFloat(0.75);
2375
+
2376
+ materialtouched = true;
2377
+ applySelf();
2378
+ }
2379
+ });
2380
+ presetpanel.add(borderShader);
2381
+
2382
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
2383
+ halo.setToolTipText("Halo");
2384
+ halo.addMouseListener(new MouseAdapter()
2385
+ {
2386
+ public void mouseClicked(MouseEvent e)
2387
+ {
2388
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2389
+ cMaterial material = object.material;
2390
+
2391
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2392
+
2393
+ materialtouched = true;
2394
+ applySelf();
2395
+ }
2396
+ });
2397
+ presetpanel.add(halo);
2398
+
2399
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
2400
+ candle.setToolTipText("Candle");
2401
+ candle.addMouseListener(new MouseAdapter()
2402
+ {
2403
+ public void mouseClicked(MouseEvent e)
2404
+ {
2405
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2406
+ cMaterial material = object.material;
2407
+
2408
+ subsurfaceField.setFloat(material.subsurface);
2409
+ shadowbiasField.setFloat(material.shadowbias);
2410
+ ambientField.setFloat(material.ambient);
2411
+ specularField.setFloat(material.specular);
2412
+ lightareaField.setFloat(material.lightarea);
2413
+ shininessField.setFloat(material.shininess);
2414
+
2415
+ materialtouched = true;
2416
+ applySelf();
2417
+ }
2418
+ });
2419
+ presetpanel.add(candle);
2420
+
2421
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
2422
+ shadowShader.setToolTipText("Shadow");
2423
+ shadowShader.addMouseListener(new MouseAdapter()
2424
+ {
2425
+ public void mouseClicked(MouseEvent e)
2426
+ {
2427
+ diffuseField.setFloat(0.001);
2428
+ ambientField.setFloat(0.001);
2429
+ cameraField.setFloat(0.001);
2430
+ specularField.setFloat(0.001);
2431
+ fakedepthField.setFloat(0.001);
2432
+ opacityField.setFloat(0.6);
2433
+
2434
+ materialtouched = true;
2435
+ applySelf();
2436
+ }
2437
+ });
2438
+ presetpanel.add(shadowShader);
2439
+
2440
+ cGridBag panel = new cGridBag().setVertical(true);
2441
+
2442
+ presetpanel.preferredWidth = 1;
2443
+
2444
+ materialpanel.add(presetpanel);
2445
+ materialpanel.add(panel);
2446
+
2447
+ panel.preferredWidth = 8;
2448
+
2449
+ /*
16522450 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16532451 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1654
- */
2452
+ */
16552453
16562454 cGridBag editBar = new cGridBag().setVertical(false);
16572455
1658
- editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2456
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
16592457 createMaterialButton.setToolTipText("Create material");
16602458
16612459 /*
16622460 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
16632461 */
16642462
1665
- editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2463
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
16662464 clearMaterialButton.setToolTipText("Clear material");
16672465
16682466 if (Globals.ADVANCED)
16692467 {
1670
- editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2468
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
16712469 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
16722470 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
16732471 }
....@@ -1685,27 +2483,61 @@
16852483 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16862484
16872485 cGridBag colorSection = new cGridBag().setVertical(true);
2486
+
2487
+ cGridBag huepanel = new cGridBag();
2488
+ cGridBag huelabel = new cGridBag();
2489
+ cLabel hue = GetLabel("icons/hue.png", false);
2490
+ hue.fit = true;
2491
+
2492
+ hue.addMouseListener(new MouseAdapter()
2493
+ {
2494
+ public void mousePressed(MouseEvent e)
2495
+ {
2496
+ int x = e.getX();
2497
+
2498
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2499
+ }
2500
+ });
2501
+
2502
+ huelabel.add(hue);
2503
+ huelabel.preferredWidth = 20;
2504
+ huepanel.add(new cGridBag()); // Label
2505
+ huepanel.add(huelabel); // Field/slider
2506
+
2507
+ huepanel.preferredHeight = 7;
2508
+
2509
+ colorSection.add(huepanel);
16882510
16892511 cGridBag color = new cGridBag();
1690
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1691
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1692
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2512
+
2513
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2514
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2515
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2516
+
16932517 //colorField.preferredWidth = 200;
16942518 colorSection.add(color);
16952519
16962520 cGridBag modulation = new cGridBag();
16972521 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16982522 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1699
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2523
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17002524 colorSection.add(modulation);
17012525
2526
+ cGridBag opacity = new cGridBag();
2527
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2528
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2529
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2530
+ colorSection.add(opacity);
2531
+
2532
+ colorSection.add(GetSeparator());
2533
+
17022534 cGridBag texture = new cGridBag();
17032535 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17042536 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17052537 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17062538 colorSection.add(texture);
17072539
1708
- panel.add(new JSeparator());
2540
+ panel.add(GetSeparator());
17092541
17102542 panel.add(colorSection);
17112543
....@@ -1761,7 +2593,7 @@
17612593 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17622594 diffuseSection.add(shadowbias);
17632595
1764
- panel.add(new JSeparator());
2596
+ panel.add(GetSeparator());
17652597
17662598 panel.add(diffuseSection);
17672599
....@@ -1824,7 +2656,7 @@
18242656 specularSection.add(anisoV);
18252657
18262658
1827
- panel.add(new JSeparator());
2659
+ panel.add(GetSeparator());
18282660
18292661 panel.add(specularSection);
18302662
....@@ -1849,12 +2681,6 @@
18492681 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18502682 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18512683 colorSection.add(backlit);
1852
-
1853
- cGridBag opacity = new cGridBag();
1854
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1855
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1856
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1857
- colorSection.add(opacity);
18582684
18592685 //panel.add(new JSeparator());
18602686
....@@ -1900,7 +2726,7 @@
19002726 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19012727 textureSection.add(opacityPower);
19022728
1903
- panel.add(new JSeparator());
2729
+ panel.add(GetSeparator());
19042730
19052731 panel.add(textureSection);
19062732
....@@ -1965,8 +2791,9 @@
19652791 // 3D models
19662792 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19672793 {
1968
- lastConverter = new com.jmex.model.converters.MaxToJme();
1969
- LoadFile(filename, lastConverter);
2794
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2795
+ //LoadFile(filename, lastConverter);
2796
+ LoadObjFile(filename); // New 3ds loader
19702797 continue;
19712798 }
19722799 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2692,6 +3519,7 @@
26923519 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26933520 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26943521 }
3522
+
26953523 //cJME.count++;
26963524 //cJME.count %= 12;
26973525 if (gc)
....@@ -2875,6 +3703,7 @@
28753703 }
28763704 }
28773705 }
3706
+
28783707 cFileSystemPane FSPane;
28793708
28803709 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2884,7 +3713,7 @@
28843713
28853714 freezematerial = true;
28863715 colorField.setFloat(mat.color);
2887
- modulationField.setFloat(mat.modulation);
3716
+ saturationField.setFloat(mat.modulation);
28883717 metalnessField.setFloat(mat.metalness);
28893718 diffuseField.setFloat(mat.diffuse);
28903719 specularField.setFloat(mat.specular);
....@@ -2928,6 +3757,7 @@
29283757 }
29293758 }
29303759 }
3760
+
29313761 freezematerial = false;
29323762 }
29333763
....@@ -2945,32 +3775,8 @@
29453775
29463776 if (multiplyToggle != null)
29473777 multiplyToggle.setSelected(mat.multiply);
2948
-
2949
- assert (object.projectedVertices != null);
2950
-
2951
- if (object.projectedVertices.length <= 2)
2952
- {
2953
- // Side effect...
2954
- Object3D.cVector2[] keep = object.projectedVertices;
2955
- object.projectedVertices = new Object3D.cVector2[3];
2956
- for (int i = 0; i < 3; i++)
2957
- {
2958
- if (i < keep.length)
2959
- {
2960
- object.projectedVertices[i] = keep[i];
2961
- } else
2962
- {
2963
- object.projectedVertices[i] = new Object3D.cVector2();
2964
- }
2965
- /*
2966
- if(keep.length == 0)
2967
- object.projectedVertices[0] = new Object3D.cVector2();
2968
- else
2969
- object.projectedVertices[0] = keep[0];
2970
- object.projectedVertices[1] = new Object3D.cVector2();
2971
- */
2972
- }
2973
- }
3778
+
3779
+ AllocProjectedVertices(object);
29743780
29753781 SetMaterial(mat, object.projectedVertices);
29763782 }
....@@ -3090,6 +3896,17 @@
30903896 public void itemStateChanged(ItemEvent event)
30913897 {
30923898 // System.out.println("Propagate = " + propagate);
3899
+ if (event.getSource() == pinButton)
3900
+ {
3901
+ copy.pinned ^= true;
3902
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3903
+ {
3904
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3905
+ copy.CloseUI();
3906
+ //copy.editWindow.refreshContents();
3907
+ }
3908
+ }
3909
+ else
30933910 if (event.getSource() == propagateToggle)
30943911 {
30953912 propagate ^= true;
....@@ -3194,8 +4011,9 @@
31944011 } else if (event.getSource() == liveCB)
31954012 {
31964013 copy.live ^= true;
4014
+ objEditor.refreshContents(true); // To show item colors
31974015 return;
3198
- } else if (event.getSource() == selectCB)
4016
+ } else if (event.getSource() == selectableCB)
31994017 {
32004018 copy.dontselect ^= true;
32014019 return;
....@@ -3203,7 +4021,7 @@
32034021 {
32044022 copy.hide ^= true;
32054023 copy.Touch(); // display list issue
3206
- objEditor.refreshContents();
4024
+ objEditor.refreshContents(true); // To show item colors
32074025 return;
32084026 } else if (event.getSource() == link2masterCB)
32094027 {
....@@ -3268,7 +4086,7 @@
32684086 //System.out.println("ObjEditor " + event);
32694087 applySelf0(true);
32704088 //parent.applySelf();
3271
- objEditor.refreshContents();
4089
+ // conflicts with requestFocus objEditor.refreshContents();
32724090 } else if (source == resetButton)
32734091 {
32744092 CameraPane.fullreset = true;
....@@ -3380,9 +4198,9 @@
33804198 {
33814199 Close();
33824200 //return true;
3383
- } else if (source == loadItem)
4201
+ } else if (source == openItem)
33844202 {
3385
- load();
4203
+ Open();
33864204 //return true;
33874205 } else if (source == newItem)
33884206 {
....@@ -3407,6 +4225,10 @@
34074225 {
34084226 generatePOV();
34094227 //return true;
4228
+ } else if (event.getSource() == archiveItem)
4229
+ {
4230
+ cTools.Archive(frame);
4231
+ return;
34104232 } else if (source == zBufferItem)
34114233 {
34124234 try
....@@ -3444,22 +4266,30 @@
34444266
34454267 void New()
34464268 {
3447
- while (copy.Size() > 1)
4269
+ while (copy.Size() > 0)
34484270 {
3449
- copy.remove(1);
4271
+ copy.remove(0);
34504272 }
34514273
4274
+ copy.selection.clear();
4275
+
4276
+ if (copy == Grafreed.grafreed.universe)
4277
+ {
4278
+ CreateCameras();
4279
+ cameraView.SetCamera(GetCamera(copy, 0));
4280
+ }
34524281 ResetModel();
34534282 objEditor.refreshContents();
34544283 }
34554284
34564285 static public byte[] Compress(Object3D o)
34574286 {
4287
+ // Slower to actually compress.
34584288 try
34594289 {
34604290 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3461
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3462
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4291
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4292
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34634293
34644294 Object3D parent = o.parent;
34654295 o.parent = null;
....@@ -3470,10 +4300,14 @@
34704300
34714301 out.flush();
34724302
3473
- zstream.close();
4303
+ baos //zstream
4304
+ .close();
34744305 out.close();
34754306
3476
- return baos.toByteArray();
4307
+ byte[] bytes = baos.toByteArray();
4308
+
4309
+ System.out.println("save #bytes = " + bytes.length);
4310
+ return bytes;
34774311 } catch (Exception e)
34784312 {
34794313 System.err.println(e);
....@@ -3483,13 +4317,16 @@
34834317
34844318 static public Object Uncompress(byte[] bytes)
34854319 {
3486
- System.out.println("#bytes = " + bytes.length);
4320
+ System.out.println("restore #bytes = " + bytes.length);
34874321 try
34884322 {
34894323 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3490
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3491
- ObjectInputStream in = new ObjectInputStream(istream);
4324
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4325
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34924326 Object obj = in.readObject();
4327
+
4328
+ bais //istream
4329
+ .close();
34934330 in.close();
34944331
34954332 return obj;
....@@ -3544,43 +4381,97 @@
35444381 return null;
35454382 }
35464383
3547
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35484384
35494385 public void Save()
35504386 {
4387
+ //Save(true);
4388
+ Replace();
4389
+ SetVersionStates();
4390
+ }
4391
+
4392
+ private boolean Equal(byte[] compress, byte[] name)
4393
+ {
4394
+ if (compress.length != name.length)
4395
+ {
4396
+ return false;
4397
+ }
4398
+
4399
+ for (int i=compress.length; --i>=0;)
4400
+ {
4401
+ if (compress[i] != name[i])
4402
+ return false;
4403
+ }
4404
+
4405
+ return true;
4406
+ }
4407
+
4408
+ void DeleteVersion()
4409
+ {
4410
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4411
+ {
4412
+ copy.versionlist[i] = copy.versionlist[i+1];
4413
+ }
4414
+
4415
+ if (copy.versionlist[copy.versionindex] == null)
4416
+ copy.versionindex -= 1;
4417
+
4418
+ if (copy.versionindex != -1)
4419
+ CopyChanged();
4420
+
4421
+ SetVersionStates();
4422
+ }
4423
+
4424
+ public boolean Save(boolean user)
4425
+ {
35514426 System.err.println("Save");
4427
+ Replace();
35524428
3553
- cRadio tab = GetCurrentTab();
4429
+ //cRadio tab = GetCurrentTab();
35544430
3555
- boolean temp = CameraPane.SWITCH;
3556
- CameraPane.SWITCH = false;
4431
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
35574432
3558
- copy.ExtractBigData(hashtable);
4433
+ boolean thesame = false;
35594434
3560
- byte[] compress = Compress(copy);
4435
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4436
+// {
4437
+// thesame = true;
4438
+// }
35614439
35624440 //EditorFrame.m_MainFrame.requestFocusInWindow();
3563
- tab.graphs[tab.undoindex++] = compress;
3564
-
3565
- copy.RestoreBigData(hashtable);
3566
-
3567
- CameraPane.SWITCH = temp;
3568
-
3569
- //assert(hashtable.isEmpty());
3570
-
3571
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
4441
+ if (!thesame)
35724442 {
3573
- tab.graphs[i] = null;
4443
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4444
+ {
4445
+ copy.versionlist[i] = copy.versionlist[i-1];
4446
+ }
4447
+
4448
+ //tab.user[tab.versionindex] = user;
4449
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4450
+
4451
+ copy.versionlist[++copy.versionindex] = compress;
4452
+
4453
+ // if (increment)
4454
+ // tab.versionindex++;
35744455 }
35754456
3576
- SetUndoStates();
4457
+ //copy.RestoreBigData(versiontable);
4458
+
4459
+ //assert(hashtable.isEmpty());
4460
+
4461
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4462
+// {
4463
+// //tab.user[i] = false;
4464
+// copy.versionlist[i] = null;
4465
+// }
4466
+
4467
+ SetVersionStates();
35774468
35784469 // test save
35794470 if (false)
35804471 {
35814472 try
35824473 {
3583
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4474
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35844475 ObjectOutputStream p = new ObjectOutputStream(ostream);
35854476
35864477 p.writeObject(copy);
....@@ -3593,28 +4484,68 @@
35934484 e.printStackTrace();
35944485 }
35954486 }
4487
+
4488
+ return !thesame;
4489
+ }
4490
+
4491
+ boolean flashIt = true;
4492
+
4493
+ void RefreshSelection()
4494
+ {
4495
+ Object3D selection = new Object3D();
4496
+
4497
+ for (int i = 0; i < copy.selection.size(); i++)
4498
+ {
4499
+ Object3D elem = copy.selection.elementAt(i);
4500
+
4501
+ Object3D obj = copy.GetObject(elem.GetUUID());
4502
+
4503
+ if (obj == null)
4504
+ {
4505
+ copy.selection.remove(i--);
4506
+ }
4507
+ else
4508
+ {
4509
+ selection.add(obj);
4510
+ copy.selection.setElementAt(obj, i);
4511
+ }
4512
+ }
4513
+
4514
+ flashIt = false;
4515
+ GetTree().clearSelection();
4516
+ for (int i = 0; i < selection.size(); i++)
4517
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4518
+ flashIt = true;
4519
+
4520
+ //refreshContents(false);
35964521 }
35974522
3598
- void CopyChanged(Object3D obj)
4523
+ void CopyChanged()
35994524 {
3600
- SetUndoStates();
4525
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4526
+
4527
+ SetVersionStates();
36014528
36024529 boolean temp = CameraPane.SWITCH;
36034530 CameraPane.SWITCH = false;
36044531
3605
- copy.ExtractBigData(hashtable);
4532
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
36064533
36074534 copy.clear();
36084535
4536
+ copy.skyboxname = obj.skyboxname;
4537
+ copy.skyboxext = obj.skyboxext;
4538
+
36094539 for (int i=0; i<obj.Size(); i++)
36104540 {
36114541 copy.add(obj.get(i));
36124542 }
36134543
3614
- copy.RestoreBigData(hashtable);
4544
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
36154545
36164546 CameraPane.SWITCH = temp;
36174547
4548
+ RefreshSelection();
36184549 //assert(hashtable.isEmpty());
36194550
36204551 copy.Touch();
....@@ -3635,56 +4566,161 @@
36354566 }
36364567 }
36374568
3638
- refreshContents();
4569
+ refreshContents(true);
36394570 }
36404571
3641
- cButton undoButton;
3642
- cButton redoButton;
4572
+ cButton previousVersionButton;
4573
+ cButton restoreButton;
4574
+ cButton replaceButton;
4575
+ cButton nextVersionButton;
4576
+ cButton saveVersionButton;
4577
+ cButton deleteVersionButton;
36434578
3644
- void SetUndoStates()
4579
+ boolean muteSlider;
4580
+
4581
+ int VersionCount()
36454582 {
3646
- cRadio tab = GetCurrentTab();
4583
+ int count = 0;
36474584
3648
- undoButton.setEnabled(tab.undoindex > 0);
3649
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
4585
+ for (int i = copy.versionlist.length; --i >= 0;)
4586
+ {
4587
+ if (copy.versionlist[i] != null)
4588
+ count++;
4589
+ }
4590
+
4591
+ return count;
36504592 }
36514593
3652
- public void Undo()
4594
+ public cGridBag versionSliderPane;
4595
+
4596
+ void SetVersionStates()
36534597 {
4598
+ //if (true)
4599
+ // return;
4600
+
4601
+ //cRadio tab = GetCurrentTab();
4602
+
4603
+ if (copy.versionlist == null)
4604
+ {
4605
+ saveVersionButton.setEnabled(false);
4606
+ restoreButton.setEnabled(false);
4607
+ replaceButton.setEnabled(false);
4608
+ previousVersionButton.setEnabled(false);
4609
+ nextVersionButton.setEnabled(false);
4610
+ deleteVersionButton.setEnabled(false);
4611
+ versionSliderPane.setVisible(false);
4612
+ }
4613
+ else
4614
+ {
4615
+ restoreButton.setEnabled(copy.versionindex != -1);
4616
+ replaceButton.setEnabled(copy.versionindex != -1);
4617
+
4618
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4619
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4620
+
4621
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4622
+ //copy.versionlist[copy.versionindex + 1] != null);
4623
+
4624
+ muteSlider = true;
4625
+ versionSlider.setMinimum(0);
4626
+ versionSlider.setMaximum(VersionCount() - 1);
4627
+ versionSlider.setInteger(copy.versionindex);
4628
+ versionSlider.setEnabled(copy.versionindex != -1);
4629
+ muteSlider = false;
4630
+
4631
+ versionSliderPane.setVisible(true);
4632
+ }
4633
+ }
4634
+
4635
+ public boolean PreviousVersion()
4636
+ {
4637
+ // Option?
4638
+ Replace();
4639
+
36544640 System.err.println("Undo");
36554641
3656
- cRadio tab = GetCurrentTab();
4642
+ //cRadio tab = GetCurrentTab();
36574643
3658
- if (tab.undoindex == 0)
4644
+ if (copy.versionindex == 0)
36594645 {
36604646 java.awt.Toolkit.getDefaultToolkit().beep();
3661
- return;
4647
+ return false;
36624648 }
36634649
3664
- if (tab.graphs[tab.undoindex] == null)
3665
- {
3666
- Save();
3667
- tab.undoindex -= 1;
3668
- }
4650
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4651
+// {
4652
+// if (Save(false))
4653
+// tab.versionindex -= 1;
4654
+// else
4655
+// {
4656
+// if (tab.versionindex <= 0)
4657
+// return false;
4658
+// else
4659
+// tab.versionindex -= 1;
4660
+// }
4661
+// }
36694662
3670
- tab.undoindex -= 1;
4663
+ copy.versionindex -= 1;
36714664
3672
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4665
+ CopyChanged();
4666
+
4667
+ return true;
36734668 }
36744669
3675
- public void Redo()
4670
+ public boolean Restore()
36764671 {
3677
- cRadio tab = GetCurrentTab();
4672
+ System.err.println("Restore");
36784673
3679
- if (tab.graphs[tab.undoindex + 1] == null)
4674
+ //cRadio tab = GetCurrentTab();
4675
+
4676
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4677
+ {
4678
+ java.awt.Toolkit.getDefaultToolkit().beep();
4679
+ return false;
4680
+ }
4681
+
4682
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4683
+ CopyChanged();
4684
+
4685
+ return true;
4686
+ }
4687
+
4688
+ public boolean Replace()
4689
+ {
4690
+ //System.err.println("Replace");
4691
+
4692
+ //cRadio tab = GetCurrentTab();
4693
+
4694
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4695
+ {
4696
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4697
+ return false;
4698
+ }
4699
+
4700
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4701
+
4702
+ return true;
4703
+ }
4704
+
4705
+ public void NextVersion()
4706
+ {
4707
+ // Option?
4708
+ Replace();
4709
+
4710
+ //cRadio tab = GetCurrentTab();
4711
+
4712
+ if (copy.versionlist[copy.versionindex + 1] == null)
36804713 {
36814714 java.awt.Toolkit.getDefaultToolkit().beep();
36824715 return;
36834716 }
36844717
3685
- tab.undoindex += 1;
4718
+ copy.versionindex += 1;
36864719
3687
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4720
+ CopyChanged();
4721
+
4722
+ //if (!tab.user[tab.versionindex])
4723
+ // tab.graphs[tab.versionindex] = null;
36884724 }
36894725
36904726 void ImportGFD()
....@@ -3878,6 +4914,12 @@
38784914 // else
38794915 // applySelf(true);
38804916 // }
4917
+
4918
+ boolean Equal(double a, double b)
4919
+ {
4920
+ return Math.abs(a - b) < 0.001;
4921
+ }
4922
+
38814923 void applySelf0(boolean name)
38824924 {
38834925 if (name)
....@@ -3895,7 +4937,7 @@
38954937 //copy.material = new cMaterial(copy.GetMaterial());
38964938
38974939 current.color = (float) colorField.getFloat();
3898
- current.modulation = (float) modulationField.getFloat();
4940
+ current.modulation = (float) saturationField.getFloat();
38994941 current.metalness = (float) metalnessField.getFloat();
39004942 current.diffuse = (float) diffuseField.getFloat();
39014943 current.specular = (float) specularField.getFloat();
....@@ -3927,29 +4969,52 @@
39274969 {
39284970 cMaterial mat = copy.material;
39294971
3930
- colorField.SetToolTipValue((mat.color));
3931
- modulationField.SetToolTipValue((mat.modulation));
3932
- metalnessField.SetToolTipValue((mat.metalness));
3933
- diffuseField.SetToolTipValue((mat.diffuse));
3934
- specularField.SetToolTipValue((mat.specular));
3935
- shininessField.SetToolTipValue((mat.shininess));
3936
- shiftField.SetToolTipValue((mat.shift));
3937
- ambientField.SetToolTipValue((mat.ambient));
3938
- lightareaField.SetToolTipValue((mat.lightarea));
3939
- diffusenessField.SetToolTipValue((mat.factor));
3940
- velvetField.SetToolTipValue((mat.velvet));
3941
- sheenField.SetToolTipValue((mat.sheen));
3942
- subsurfaceField.SetToolTipValue((mat.subsurface));
3943
- backlitField.SetToolTipValue((mat.bump));
3944
- anisoField.SetToolTipValue((mat.aniso));
3945
- anisoVField.SetToolTipValue((mat.anisoV));
3946
- cameraField.SetToolTipValue((mat.cameralight));
3947
- selfshadowField.SetToolTipValue((mat.diffuseness));
3948
- shadowField.SetToolTipValue((mat.shadow));
3949
- textureField.SetToolTipValue((mat.texture));
3950
- opacityField.SetToolTipValue((mat.opacity));
3951
- fakedepthField.SetToolTipValue((mat.fakedepth));
3952
- shadowbiasField.SetToolTipValue((mat.shadowbias));
4972
+ if (!Equal(colorField.getFloat(), mat.color))
4973
+ colorField.SetToolTipValue((mat.color));
4974
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4975
+ saturationField.SetToolTipValue((mat.modulation));
4976
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4977
+ metalnessField.SetToolTipValue((mat.metalness));
4978
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4979
+ diffuseField.SetToolTipValue((mat.diffuse));
4980
+ if (!Equal(specularField.getFloat(), mat.specular))
4981
+ specularField.SetToolTipValue((mat.specular));
4982
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4983
+ shininessField.SetToolTipValue((mat.shininess));
4984
+ if (!Equal(shiftField.getFloat(), mat.shift))
4985
+ shiftField.SetToolTipValue((mat.shift));
4986
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4987
+ ambientField.SetToolTipValue((mat.ambient));
4988
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4989
+ lightareaField.SetToolTipValue((mat.lightarea));
4990
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4991
+ diffusenessField.SetToolTipValue((mat.factor));
4992
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4993
+ velvetField.SetToolTipValue((mat.velvet));
4994
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4995
+ sheenField.SetToolTipValue((mat.sheen));
4996
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4997
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4998
+ if (!Equal(backlitField.getFloat(), mat.bump))
4999
+ backlitField.SetToolTipValue((mat.bump));
5000
+ if (!Equal(anisoField.getFloat(), mat.aniso))
5001
+ anisoField.SetToolTipValue((mat.aniso));
5002
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
5003
+ anisoVField.SetToolTipValue((mat.anisoV));
5004
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
5005
+ cameraField.SetToolTipValue((mat.cameralight));
5006
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
5007
+ selfshadowField.SetToolTipValue((mat.diffuseness));
5008
+ if (!Equal(shadowField.getFloat(), mat.shadow))
5009
+ shadowField.SetToolTipValue((mat.shadow));
5010
+ if (!Equal(textureField.getFloat(), mat.texture))
5011
+ textureField.SetToolTipValue((mat.texture));
5012
+ if (!Equal(opacityField.getFloat(), mat.opacity))
5013
+ opacityField.SetToolTipValue((mat.opacity));
5014
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
5015
+ fakedepthField.SetToolTipValue((mat.fakedepth));
5016
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
5017
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
39535018 }
39545019
39555020 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -3980,9 +5045,28 @@
39805045 //copy.Touch();
39815046 }
39825047
5048
+ cNumberSlider versionSlider;
5049
+
39835050 public void stateChanged(ChangeEvent e)
39845051 {
3985
- // assert(false);
5052
+ // assert(false);
5053
+ if (e.getSource() == versionSlider)
5054
+ {
5055
+ if (muteSlider)
5056
+ return;
5057
+
5058
+ Replace();
5059
+
5060
+ int version = versionSlider.getInteger();
5061
+
5062
+ if (version != -1 && copy.versionlist[version] != null)
5063
+ {
5064
+ copy.versionindex = version;
5065
+ CopyChanged();
5066
+ }
5067
+
5068
+ return;
5069
+ }
39865070
39875071 if (freezematerial)
39885072 {
....@@ -4018,6 +5102,12 @@
40185102 {
40195103 //System.out.println("stateChanged = " + this);
40205104 materialtouched = true;
5105
+
5106
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
5107
+ {
5108
+ saturationField.setFloat(1);
5109
+ }
5110
+
40215111 applySelf();
40225112 //System.out.println("this = " + this);
40235113 //System.out.println("PARENT = " + parent);
....@@ -4317,6 +5407,7 @@
43175407 {
43185408 if (GetTree() != null)
43195409 {
5410
+ GetTree().revalidate();
43205411 GetTree().repaint();
43215412 }
43225413
....@@ -4325,13 +5416,18 @@
43255416 ctrlPanel.validate(); // ? new
43265417 ctrlPanel.repaint();
43275418 }
5419
+
5420
+ if (previousVersionButton != null && copy.versionlist != null)
5421
+ SetVersionStates();
5422
+
5423
+ cameraView.requestFocusInWindow();
43285424 }
43295425
43305426 static TweenManager tweenManager = new TweenManager();
43315427
43325428 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43335429 {
4334
- if (Globals.SAVEONMAKE) // && resetmodel)
5430
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43355431 Save();
43365432 //Tween.set(thing, 0).target(1).start(tweenManager);
43375433 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4356,7 +5452,7 @@
43565452 // group = (Composite) group.get(0);
43575453 // }
43585454
4359
- System.out.println("makeSomething of " + thing);
5455
+ //System.out.println("makeSomething of " + thing);
43605456
43615457 /*
43625458 if (deselect && jList != null)
....@@ -4573,7 +5669,9 @@
45735669 readobj.ResetDisplayList();
45745670 } catch (Exception e)
45755671 {
4576
- //e.printStackTrace();
5672
+ if (!e.toString().contains("GZIP"))
5673
+ e.printStackTrace();
5674
+
45775675 try
45785676 {
45795677 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4647,12 +5745,14 @@
46475745
46485746 if (readobj != null)
46495747 {
4650
- if (Globals.SAVEONMAKE)
4651
- Save();
5748
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5749
+ // Save();
46525750 try
46535751 {
46545752 //readobj.deepCopySelf(copy);
46555753 copy.clear(); // june 2014
5754
+ copy.skyboxname = readobj.skyboxname;
5755
+ copy.skyboxext = readobj.skyboxext;
46565756 for (int i = 0; i < readobj.size(); i++)
46575757 {
46585758 Object3D child = readobj.get(i); // reserve(i);
....@@ -4693,6 +5793,7 @@
46935793 }
46945794 } catch (ClassCastException e)
46955795 {
5796
+ e.printStackTrace();
46965797 assert (false);
46975798 Composite c = (Composite) copy;
46985799 c.children.clear();
....@@ -4703,17 +5804,32 @@
47035804 c.addChild(csg);
47045805 }
47055806
5807
+ copy.versionlist = readobj.versionlist;
5808
+ copy.versionindex = readobj.versionindex;
5809
+ copy.versiontable = readobj.versiontable;
5810
+
5811
+ if (copy.versionlist == null)
5812
+ {
5813
+ // Backward compatibility
5814
+ copy.versionlist = new Object3D[100];
5815
+ copy.versionindex = -1;
5816
+
5817
+ //Save(true);
5818
+ }
5819
+
5820
+ //? SetUndoStates();
5821
+
47065822 ResetModel();
47075823 copy.HardTouch(); // recompile?
47085824 refreshContents();
47095825 }
47105826 }
47115827
4712
- void load() // throws ClassNotFoundException
5828
+ void Open() // throws ClassNotFoundException
47135829 {
47145830 if (Grafreed.standAlone)
47155831 {
4716
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5832
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
47175833 browser.show();
47185834 String filename = browser.getFile();
47195835 if (filename != null && filename.length() > 0)
....@@ -4790,6 +5906,8 @@
47905906
47915907 void save()
47925908 {
5909
+ Replace();
5910
+
47935911 if (lastname == null)
47945912 {
47955913 return;
....@@ -4812,6 +5930,7 @@
48125930 //ps.print(buffer.toString());
48135931 } catch (IOException e)
48145932 {
5933
+ e.printStackTrace();
48155934 }
48165935 }
48175936
....@@ -4994,7 +6113,7 @@
49946113 MenuBar menuBar;
49956114 Menu fileMenu;
49966115 MenuItem newItem;
4997
- MenuItem loadItem;
6116
+ MenuItem openItem;
49986117 MenuItem saveItem;
49996118 MenuItem saveAsItem;
50006119 MenuItem exportAsItem;
....@@ -5017,6 +6136,7 @@
50176136 CheckboxMenuItem toggleSwitchItem;
50186137 CheckboxMenuItem toggleRootItem;
50196138 CheckboxMenuItem animationItem;
6139
+ MenuItem archiveItem;
50206140 CheckboxMenuItem toggleHandleItem;
50216141 CheckboxMenuItem togglePaintItem;
50226142 JSplitPane mainPanel;
....@@ -5030,6 +6150,7 @@
50306150 ButtonGroup buttonGroup;
50316151
50326152 cGridBag toolboxPanel;
6153
+ cGridBag skyboxPanel;
50336154 cGridBag materialPanel;
50346155 cGridBag ctrlPanel;
50356156
....@@ -5041,6 +6162,7 @@
50416162 boolean materialFlushed;
50426163 Object3D latestObject;
50436164
6165
+ cGridBag transformPanel;
50446166 cGridBag XYZPanel;
50456167
50466168 JSplitPane gridPanel;
....@@ -5103,7 +6225,7 @@
51036225 JLabel colorLabel;
51046226 cNumberSlider colorField;
51056227 JLabel modulationLabel;
5106
- cNumberSlider modulationField;
6228
+ cNumberSlider saturationField;
51076229 JLabel metalnessLabel;
51086230 cNumberSlider metalnessField;
51096231 JLabel diffuseLabel;
....@@ -5134,6 +6256,7 @@
51346256 cNumberSlider anisoField;
51356257 JLabel anisoVLabel;
51366258 cNumberSlider anisoVField;
6259
+
51376260 JLabel cameraLabel;
51386261 cNumberSlider cameraField;
51396262 JLabel selfshadowLabel;
....@@ -5148,6 +6271,7 @@
51486271 cNumberSlider fakedepthField;
51496272 JLabel shadowbiasLabel;
51506273 cNumberSlider shadowbiasField;
6274
+
51516275 JLabel bumpLabel;
51526276 cNumberSlider bumpField;
51536277 JLabel noiseLabel;