Normand Briere
2019-08-12 b1d79b74514041a059b454a9f6fc3970773c0cb8
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -30,11 +34,87 @@
3034 iSendInfo
3135 //KeyListener
3236 {
37
+ public cToggleButton pinButton;
3338 boolean timeline;
3439 boolean wasFullScreen;
3540
3641 GroupEditor callee;
3742 JFrame frame;
43
+
44
+ static ObjEditor theFrame;
45
+
46
+ public cGridBag GetSeparator()
47
+ {
48
+ cGridBag separator = new cGridBag();
49
+ separator.add(new JSeparator());
50
+ separator.preferredHeight = 5;
51
+ return separator;
52
+ }
53
+
54
+ cButton GetButton(String name, boolean border)
55
+ {
56
+ ImageIcon icon = GetIcon(name);
57
+ return new cButton(icon, border);
58
+ }
59
+
60
+ cLabel GetLabel(String name, boolean border)
61
+ {
62
+ //ImageIcon icon = GetIcon(name);
63
+ return new cLabel(GetImage(name), border);
64
+ }
65
+
66
+ cToggleButton GetToggleButton(String name, boolean border)
67
+ {
68
+ ImageIcon icon = GetIcon(name);
69
+ return new cToggleButton(icon, border);
70
+ }
71
+
72
+ cCheckBox GetCheckBox(String name, boolean border)
73
+ {
74
+ ImageIcon icon = GetIcon(name);
75
+ return new cCheckBox(icon, border);
76
+ }
77
+
78
+ ImageIcon GetIcon(String name)
79
+ {
80
+ try
81
+ {
82
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
83
+
84
+// if (image.getWidth() > 48 && image.getHeight() > 48)
85
+// {
86
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
87
+// Graphics2D g = resized.createGraphics();
88
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
89
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
90
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
91
+// g.dispose();
92
+//
93
+// image = resized;
94
+// }
95
+
96
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
97
+ return icon;
98
+ }
99
+ catch (Exception e)
100
+ {
101
+ return null;
102
+ }
103
+ }
104
+
105
+ BufferedImage GetImage(String name)
106
+ {
107
+ try
108
+ {
109
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
110
+
111
+ return image;
112
+ }
113
+ catch (Exception e)
114
+ {
115
+ return null;
116
+ }
117
+ }
38118
39119 // SCRIPT
40120
....@@ -143,7 +223,9 @@
143223 //nameField.removeActionListener(this);
144224 // objEditor.ctrlPanel.remove(nameField);
145225
146
- if (!GroupEditor.allparams)
226
+ objEditor.ctrlPanel.remove(namePanel);
227
+
228
+ if (!allparams)
147229 return;
148230
149231 // objEditor.ctrlPanel.remove(liveCB);
....@@ -165,9 +247,9 @@
165247 // objEditor.ctrlPanel.remove(fasterButton);
166248 // objEditor.ctrlPanel.remove(remarkButton);
167249
168
- objEditor.ctrlPanel.remove(namePanel);
169250 objEditor.ctrlPanel.remove(setupPanel);
170
- objEditor.ctrlPanel.remove(commandsPanel);
251
+ objEditor.ctrlPanel.remove(setupPanel2);
252
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
171253 objEditor.ctrlPanel.remove(pushPanel);
172254 //objEditor.ctrlPanel.remove(fillPanel);
173255
....@@ -215,6 +297,12 @@
215297 client = inClient;
216298 copy = client;
217299
300
+ if (copy.versionlist == null)
301
+ {
302
+ copy.versionlist = new Object3D[100];
303
+ copy.versionindex = -1;
304
+ }
305
+
218306 // "this" is not called: SetupUI2(objEditor);
219307 }
220308
....@@ -228,6 +316,12 @@
228316 client = inClient;
229317 copy = client;
230318
319
+ if (copy.versionlist == null)
320
+ {
321
+ copy.versionlist = new Object3D[100];
322
+ copy.versionindex = -1;
323
+ }
324
+
231325 SetupUI2(callee.GetEditor());
232326 }
233327
....@@ -242,6 +336,7 @@
242336 //localCopy.parent = null;
243337
244338 frame = new JFrame();
339
+ frame.setUndecorated(false);
245340 objEditor = this;
246341 this.callee = callee;
247342
....@@ -259,6 +354,12 @@
259354 copy = localCopy;
260355 copy.editWindow = this;
261356
357
+ if (copy.versionlist == null)
358
+ {
359
+// copy.versions = new byte[100][];
360
+// copy.versionindex = -1;
361
+ }
362
+
262363 SetupMenu();
263364
264365 //SetupName(objEditor); // new
....@@ -272,28 +373,49 @@
272373 return frame.action(event, obj);
273374 }
274375
376
+ // Cannot work without static
377
+ static boolean allparams = true;
378
+
379
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
380
+
275381 void SetupMenu()
276382 {
277383 frame.setMenuBar(menuBar = new MenuBar());
278
- menuBar.add(windowMenu = new Menu("File"));
279
- windowMenu.add(loadItem = new MenuItem("Load..."));
280
- windowMenu.add("-");
281
- windowMenu.add(saveItem = new MenuItem("Save"));
282
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
384
+ menuBar.add(fileMenu = new Menu("File"));
385
+ fileMenu.add(newItem = new MenuItem("New"));
386
+ fileMenu.add(openItem = new MenuItem("Open..."));
387
+
388
+ //oe.menuBar.add(menu = new Menu("Include"));
389
+ Menu menu = new Menu("Import");
390
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
391
+ importOBJItem.addActionListener(this);
392
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
393
+ import3DSItem.addActionListener(this);
394
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
395
+ importVRMLX3DItem.addActionListener(this);
396
+ menu.add("-");
397
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
398
+ importGFDItem.addActionListener(this);
399
+ fileMenu.add(menu);
400
+ fileMenu.add("-");
401
+
402
+ fileMenu.add(saveItem = new MenuItem("Save"));
403
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
283404 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
284
- windowMenu.add("-");
285
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
286
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
287
- windowMenu.add("-");
405
+ fileMenu.add("-");
406
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
407
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
408
+ fileMenu.add("-");
288409 if (client.parent != null)
289410 {
290
- windowMenu.add(closeItem = new MenuItem("Close"));
411
+ fileMenu.add(closeItem = new MenuItem("Close"));
291412 } else
292413 {
293
- windowMenu.add(closeItem = new MenuItem("Exit"));
414
+ fileMenu.add(closeItem = new MenuItem("Exit"));
294415 }
295416
296
- loadItem.addActionListener(this);
417
+ newItem.addActionListener(this);
418
+ openItem.addActionListener(this);
297419 saveItem.addActionListener(this);
298420 saveAsItem.addActionListener(this);
299421 exportAsItem.addActionListener(this);
....@@ -301,84 +423,71 @@
301423 //povItem.addActionListener(this);
302424 closeItem.addActionListener(this);
303425
304
- menuBar.add(cameraMenu = new Menu("View"));
305
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
306
- //zBufferItem.addActionListener(this);
307
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
308
- //normalLensItem.addActionListener(this);
309
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
310
- revertCameraItem.addActionListener(this);
311
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
312
- toggleTimelineItem.addItemListener(this);
313
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
314
- toggleFullScreenItem.addItemListener(this);
315
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
316
- cameraMenu.add("-");
317
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
318
- toggleTextureItem.addItemListener(this);
319
- toggleTextureItem.setState(CameraPane.textureon);
320
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
321
- toggleLiveItem.addItemListener(this);
322
- toggleLiveItem.setState(Globals.isLIVE());
323
- cameraMenu.add(stepItem = new MenuItem("Step"));
324
- stepItem.addActionListener(this);
325
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
326
-// toggleDLItem.addItemListener(this);
327
-// toggleDLItem.setState(false);
328
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
329
- toggleRenderItem.addItemListener(this);
330
- toggleRenderItem.setState(!CameraPane.frozen);
331
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
332
- toggleDebugItem.addItemListener(this);
333
- toggleDebugItem.setState(CameraPane.DEBUG);
334
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
335
- toggleFrustumItem.addItemListener(this);
336
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
337
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
338
- toggleFootContactItem.addItemListener(this);
339
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
340
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
341
- toggleRandomItem.addItemListener(this);
342
- toggleRandomItem.setState(CameraPane.RANDOM);
343
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
344
- toggleHandleItem.addItemListener(this);
345
- toggleHandleItem.setState(CameraPane.HANDLES);
346
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
347
- togglePaintItem.addItemListener(this);
348
- togglePaintItem.setState(CameraPane.PAINTMODE);
349
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
350
-// toggleRootItem.addItemListener(this);
351
-// toggleRootItem.setState(false);
352
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
353
-// animationItem.addItemListener(this);
354
-// animationItem.setState(CameraPane.ANIMATION);
355
- cameraMenu.add("-");
356
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
357
- editCameraItem.addActionListener(this);
358
-
359426 objectPanel = new JTabbedPane();
427
+
428
+ ChangeListener changeListener = new ChangeListener()
429
+ {
430
+ public void stateChanged(ChangeEvent changeEvent)
431
+ {
432
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
433
+// {
434
+// if (latestObject != null)
435
+// {
436
+// refreshContents(true);
437
+// SetMaterial(latestObject);
438
+// }
439
+//
440
+// materialFlushed = true;
441
+// }
442
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
443
+// {
444
+// if (listUI.size() == 0)
445
+// EditSelection(false);
446
+// }
447
+
448
+ refreshContents(false); // To refresh Info tab
449
+ }
450
+ };
451
+ objectPanel.addChangeListener(changeListener);
452
+
360453 toolbarPanel = new JPanel();
361454 toolbarPanel.setName("Toolbar");
455
+
362456 treePanel = new cGridBag();
363457 treePanel.setName("Tree");
458
+
459
+ editPanel = new cGridBag().setVertical(true);
460
+ //editPanel.setName("Edit");
461
+
364462 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
365
- ctrlPanel.setName("Edit");
366
- materialPanel = new cGridBag().setVertical(true);
367
- materialPanel.setName("Material");
463
+
464
+ editCommandsPanel = new cGridBag();
465
+ editPanel.add(editCommandsPanel);
466
+ editPanel.add(ctrlPanel);
467
+
468
+ toolboxPanel = new cGridBag().setVertical(true);
469
+ //toolboxPanel.setName("Toolbox");
470
+
471
+ skyboxPanel = new cGridBag().setVertical(true);
472
+
473
+ materialPanel = new cGridBag().setVertical(false);
474
+ //materialPanel.setName("Material");
475
+
368476 /*JTextPane*/
369477 infoarea = createTextPane();
370478 doc = infoarea.getStyledDocument();
371479
372480 infoarea.setEditable(true);
373481 SetText();
482
+
374483 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
375484 // infoarea.setOpaque(false);
376485 // //infoarea.setForeground(textcolor);
377486 // TEXTAREA infoarea.setLineWrap(true);
378487 // TEXTAREA infoarea.setWrapStyleWord(true);
379488 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
380
- infoPanel.setPreferredSize(new Dimension(50, 200));
381
- infoPanel.setName("Info");
489
+ infoPanel.setPreferredSize(new Dimension(1, 1));
490
+ //infoPanel.setName("Info");
382491 //infoPanel.setLayout(new BorderLayout());
383492 //infoPanel.add(createTextPane());
384493
....@@ -389,7 +498,14 @@
389498 mainPanel.setDividerSize(9);
390499 mainPanel.setDividerLocation(0.5); //1.0);
391500 mainPanel.setResizeWeight(0.5);
392
-
501
+
502
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
503
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
504
+ divider.setDividerSize(15);
505
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
506
+
507
+ mainPanel.setUI(new BasicSplitPaneUI());
508
+
393509 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
394510 //mainPanel.setLayout(new GridBagLayout());
395511 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -457,10 +573,10 @@
457573 e.printStackTrace();
458574 }
459575
460
- String selection = infoarea.getText();
461
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
462
- java.awt.datatransfer.Clipboard clipboard =
463
- Toolkit.getDefaultToolkit().getSystemClipboard();
576
+// String selection = infoarea.getText();
577
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
578
+// java.awt.datatransfer.Clipboard clipboard =
579
+// Toolkit.getDefaultToolkit().getSystemClipboard();
464580 //clipboard.setContents(data, data);
465581 }
466582
....@@ -483,13 +599,13 @@
483599 //SendInfo("Name:", "bold");
484600 if (sel.GetTextures() != null || debug)
485601 {
486
- si.SendInfo(sel.toString(), "bold");
602
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
487603 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
488604 if (sel.Size() > 0)
489605 {
490606 si.SendInfo("#children = " + sel.Size(), "regular");
491607 }
492
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
608
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
493609 if (debug)
494610 {
495611 try
....@@ -531,7 +647,7 @@
531647 }
532648 if (sel.support != null)
533649 {
534
- si.SendInfo(" support: " + sel.support, "regular");
650
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
535651 }
536652 if (sel.scriptnode != null)
537653 {
....@@ -620,21 +736,158 @@
620736 }
621737 }
622738
739
+//static GraphicsDevice device = GraphicsEnvironment
740
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
741
+
742
+ Rectangle keeprect;
743
+ cRadio radio;
744
+
745
+cButton keepButton;
746
+ cButton twoButton; // Full 3D
747
+ cButton sixButton;
748
+ cButton threeButton;
749
+ cButton sevenButton;
750
+ cButton fourButton; // full panel
751
+ cButton oneButton; // full XYZ
752
+ //cButton currentLayout;
753
+
754
+ boolean maximized;
755
+
756
+ cButton fullscreenLayout;
757
+ cButton expandedLayout;
758
+
759
+ void Minimize()
760
+ {
761
+ frame.setState(Frame.ICONIFIED);
762
+ frame.validate();
763
+ }
764
+
765
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
766
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
767
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
768
+ void Maximize()
769
+ {
770
+ if (CameraPane.FULLSCREEN)
771
+ {
772
+ ToggleFullScreen();
773
+ }
774
+
775
+ if (maximized)
776
+ {
777
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
778
+ }
779
+ else
780
+ {
781
+ keeprect = frame.getBounds();
782
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
783
+// Dimension rect2 = frame.getToolkit().getScreenSize();
784
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
785
+// frame.setState(Frame.MAXIMIZED_BOTH);
786
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
787
+ }
788
+
789
+ maximized ^= true;
790
+
791
+ frame.validate();
792
+ }
793
+
794
+ cButton minButton;
795
+ cButton maxButton;
796
+ cButton fullButton;
797
+ cButton collapseButton;
798
+ cButton maximize3DButton;
799
+
623800 void ToggleFullScreen()
624801 {
625
- if (CameraPane.FULLSCREEN)
802
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
803
+
804
+ cameraView.ToggleFullScreen();
805
+
806
+ if (!CameraPane.FULLSCREEN)
626807 {
627
- frame.getContentPane().remove(/*"Center",*/bigThree);
628
- framePanel.add(bigThree);
629
- frame.getContentPane().add(/*"Center",*/framePanel);
808
+ device.setFullScreenWindow(null);
809
+ frame.dispose();
810
+ frame.setUndecorated(false);
811
+ frame.validate();
812
+ frame.setVisible(true);
813
+
814
+ //frame.setVisible(false);
815
+// frame.removeNotify();
816
+// frame.setUndecorated(false);
817
+// frame.addNotify();
818
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
819
+
820
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
821
+// X framePanel.add(bigThree);
822
+// X frame.getContentPane().add(/*"Center",*/framePanel);
823
+// framePanel.setDividerLocation(46); // icons are 24x24
824
+
825
+ //frame.setVisible(true);
826
+// radio.layout = keepButton;
827
+ //theFrame = null;
828
+ keepButton = null;
829
+// radio.layout.doClick();
830
+
630831 } else
631832 {
632
- frame.getContentPane().remove(/*"Center",*/framePanel);
633
- framePanel.remove(bigThree);
634
- frame.getContentPane().add(/*"Center",*/bigThree);
833
+ keepButton = radio.layout;
834
+ //keeprect = frame.getBounds();
835
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
836
+// frame.getToolkit().getScreenSize().height);
837
+ //frame.setVisible(false);
838
+
839
+ frame.dispose();
840
+ frame.setUndecorated(true);
841
+ device.setFullScreenWindow(frame);
842
+ frame.validate();
843
+ frame.setVisible(true);
844
+// frame.removeNotify();
845
+// frame.setUndecorated(true);
846
+// frame.addNotify();
847
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
848
+// X framePanel.remove(bigThree);
849
+// X frame.getContentPane().add(/*"Center",*/bigThree);
850
+// framePanel.setDividerLocation(0);
851
+
852
+// radio.layout = fullscreenLayout;
853
+// radio.layout.doClick();
854
+ //frame.setVisible(true);
635855 }
636
- cameraView.ToggleFullScreen();
856
+ frame.validate();
857
+
858
+ cameraView.requestFocusInWindow();
637859 }
860
+
861
+ void CollapseToolbar()
862
+ {
863
+ framePanel.setDividerLocation(0);
864
+ //frame.validate();
865
+
866
+ cameraView.requestFocusInWindow();
867
+ }
868
+
869
+ private Object3D Duplicate(Object3D object)
870
+ {
871
+ boolean temp = CameraPane.SWITCH;
872
+ CameraPane.SWITCH = false;
873
+
874
+ object.ExtractBigData(versiontable);
875
+ // if (copy == client)
876
+
877
+ Object3D versions[] = object.versionlist;
878
+ object.versionlist = null;
879
+
880
+ //byte[] compress = Compress(copy);
881
+ Object3D compress = (Object3D)Grafreed.clone(object);
882
+
883
+ object.versionlist = versions;
884
+
885
+ object.RestoreBigData(versiontable);
886
+
887
+ CameraPane.SWITCH = temp;
888
+
889
+ return compress;
890
+ }
638891
639892 private JTextPane createTextPane()
640893 {
....@@ -734,7 +987,7 @@
734987 protected static ImageIcon createImageIcon(String path,
735988 String description)
736989 {
737
- java.net.URL imgURL = GrafreeD.class.getResource(path);
990
+ java.net.URL imgURL = Grafreed.class.getResource(path);
738991 if (imgURL != null)
739992 {
740993 return new ImageIcon(imgURL, description);
....@@ -757,6 +1010,7 @@
7571010 {
7581011 SetupMaterial(materialPanel);
7591012 }
1013
+
7601014 //SetupName();
7611015 //SetupViews();
7621016 }
....@@ -766,6 +1020,7 @@
7661020 // NumberSlider vDivsField;
7671021 // JCheckBox endcaps;
7681022 JCheckBox liveCB;
1023
+ JCheckBox selectableCB;
7691024 JCheckBox hideCB;
7701025 JCheckBox link2masterCB;
7711026 JCheckBox markCB;
....@@ -773,7 +1028,12 @@
7731028 JCheckBox speedupCB;
7741029 JCheckBox rewindCB;
7751030 JCheckBox flipVCB;
1031
+
1032
+ cCheckBox toggleTextureCB;
1033
+ cCheckBox toggleSwitchCB;
1034
+
7761035 JComboBox texresMenu;
1036
+
7771037 JButton resetButton;
7781038 JButton stepButton;
7791039 JButton stepAllButton;
....@@ -782,9 +1042,13 @@
7821042 JButton fasterButton;
7831043 JButton remarkButton;
7841044
1045
+ cGridBag editPanel;
1046
+ cGridBag editCommandsPanel;
1047
+
7851048 cGridBag namePanel;
7861049 cGridBag setupPanel;
787
- cGridBag commandsPanel;
1050
+ cGridBag setupPanel2;
1051
+ cGridBag objectCommandsPanel;
7881052 cGridBag pushPanel;
7891053 cGridBag fillPanel;
7901054
....@@ -951,52 +1215,88 @@
9511215
9521216 void SetupUI2(ObjEditor oe)
9531217 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
9581218 //SetupName(oe);
9591219
9601220 namePanel = new cGridBag();
9611221
1222
+ //if (copy.pinned)
1223
+ {
1224
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1225
+ pinButton.setSelected(copy.pinned);
1226
+ cGridBag t = new cGridBag();
1227
+ t.preferredWidth = 2;
1228
+ t.add(pinButton);
1229
+ namePanel.add(t);
1230
+
1231
+ pinButton.addItemListener(this);
1232
+ }
1233
+
9621234 nameField = AddText(namePanel, copy.GetName());
963
- namePanel.add(nameField);
1235
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9641236 oe.ctrlPanel.add(namePanel);
9651237
9661238 oe.ctrlPanel.Return();
9671239
968
- if (!GroupEditor.allparams)
1240
+ if (!allparams)
9691241 return;
9701242
9711243 setupPanel = new cGridBag().setVertical(false);
9721244
9731245 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
974
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
975
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1246
+ liveCB.setToolTipText("Animate object");
1247
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1248
+ selectableCB.setToolTipText("Make object selectable");
9761249 // Return();
1250
+
1251
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1252
+ hideCB.setToolTipText("Hide object");
9771253 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
978
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
979
- randomCB = AddCheckBox(setupPanel, "Rand", copy.random);
1254
+ markCB.setToolTipText("As animation target transform");
1255
+
1256
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1257
+
1258
+ setupPanel2 = new cGridBag().setVertical(false);
1259
+
1260
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1261
+ rewindCB.setToolTipText("Rewind animation");
1262
+
1263
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1264
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9801265
1266
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1267
+ link2masterCB.setToolTipText("Attach to support");
1268
+
1269
+ if (Globals.ADVANCED)
1270
+ {
1271
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1272
+ speedupCB.setToolTipText("Option motion capture");
1273
+ }
1274
+
9811275 oe.ctrlPanel.add(setupPanel);
9821276 oe.ctrlPanel.Return();
1277
+ oe.ctrlPanel.add(setupPanel2);
1278
+ oe.ctrlPanel.Return();
9831279
984
- commandsPanel = new cGridBag().setVertical(false);
1280
+ objectCommandsPanel = new cGridBag().setVertical(false);
9851281
986
- resetButton = AddButton(commandsPanel, "Reset");
987
- stepButton = AddButton(commandsPanel, "Step");
1282
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1283
+ resetButton.setToolTipText("Jump to frame zero");
1284
+ stepButton = AddButton(objectCommandsPanel, "Step");
1285
+ stepButton.setToolTipText("Step one frame");
9881286 // resetAllButton = AddButton(oe, "Reset All");
9891287 // stepAllButton = AddButton(oe, "Step All");
990
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
9911288 // Return();
992
- slowerButton = AddButton(commandsPanel, "Slow");
993
- fasterButton = AddButton(commandsPanel, "Fast");
994
- remarkButton = AddButton(commandsPanel, "Remark");
1289
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1290
+ slowerButton.setToolTipText("Decrease animation speed");
1291
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1292
+ fasterButton.setToolTipText("Increase animation speed");
1293
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1294
+ remarkButton.setToolTipText("Set the current transform as the target");
9951295
996
- oe.ctrlPanel.add(commandsPanel);
1296
+ oe.ctrlPanel.add(objectCommandsPanel);
9971297 oe.ctrlPanel.Return();
9981298
999
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1299
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
10001300 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
10011301 //Return();
10021302
....@@ -1199,8 +1499,11 @@
11991499 //worldPanel.setName("World");
12001500 centralPanel = new cGridBag();
12011501 centralPanel.preferredWidth = 20;
1202
- timelinePanel = new JPanel(new BorderLayout());
1203
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1502
+
1503
+ if (Globals.ADVANCED)
1504
+ {
1505
+ timelinePanel = new JPanel(new BorderLayout());
1506
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
12041507
12051508 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
12061509 cameraPanel.setContinuousLayout(true);
....@@ -1209,7 +1512,10 @@
12091512 // cameraPanel.setDividerSize(9);
12101513 cameraPanel.setResizeWeight(1.0);
12111514
1515
+ }
1516
+
12121517 centralPanel.add(cameraView);
1518
+ centralPanel.setFocusable(true);
12131519 //frame.setJMenuBar(timelineMenubar);
12141520 //centralPanel.add(timelinePanel);
12151521
....@@ -1235,6 +1541,7 @@
12351541 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12361542 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12371543 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1544
+ //XYZPanel.setName("XYZ");
12381545
12391546 /*
12401547 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1272,13 +1579,29 @@
12721579 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12731580 //tmp.setName("Edit");
12741581 objectPanel.add(materialPanel);
1582
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1583
+ objectPanel.setToolTipTextAt(0, "Material");
1584
+
1585
+ objectPanel.add(toolboxPanel);
1586
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1587
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1588
+
1589
+ objectPanel.add(skyboxPanel);
1590
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1591
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1592
+
12751593 // JPanel north = new JPanel(new BorderLayout());
12761594 // north.setName("Edit");
12771595 // north.add(ctrlPanel, BorderLayout.NORTH);
12781596 // objectPanel.add(north);
1279
- objectPanel.add(ctrlPanel);
1280
- objectPanel.add(infoPanel);
1281
-
1597
+ objectPanel.add(editPanel);
1598
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1599
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1600
+
1601
+ objectPanel.add(XYZPanel);
1602
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1603
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1604
+
12821605 /*
12831606 aConstraints.gridx = 0;
12841607 aConstraints.gridwidth = 1;
....@@ -1286,7 +1609,7 @@
12861609 aConstraints.gridy += 1;
12871610 aConstraints.gridwidth = 1;
12881611 mainPanel.add(objectPanel, aConstraints);
1289
- */
1612
+ */
12901613
12911614 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12921615 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1298,14 +1621,12 @@
12981621 scrollpane.addMouseWheelListener(this); // Default not fast enough
12991622
13001623 /*JTabbedPane*/ scenePanel = new cGridBag();
1301
- scenePanel.preferredWidth = 7;
1624
+ scenePanel.preferredWidth = 5;
13021625
13031626 JTabbedPane tabbedPane = new JTabbedPane();
13041627 tabbedPane.add(scrollpane);
13051628
1306
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1307
-
1308
- optionsPanel = new cGridBag().setVertical(true);
1629
+ optionsPanel = new cGridBag().setVertical(false);
13091630
13101631 optionsPanel.setName("Options");
13111632
....@@ -1313,8 +1634,15 @@
13131634
13141635 tabbedPane.add(optionsPanel);
13151636
1637
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1638
+
13161639 scenePanel.add(tabbedPane);
13171640
1641
+ //if (Globals.ADVANCED)
1642
+ tabbedPane.add(infoPanel);
1643
+ tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1644
+ tabbedPane.setToolTipTextAt(3, "Information");
1645
+
13181646 /*
13191647 cTree jTree = new cTree(null);
13201648 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1376,7 +1704,7 @@
13761704 bigThree = new cGridBag();
13771705 bigThree.addComponent(scenePanel);
13781706 bigThree.addComponent(centralPanel);
1379
- bigThree.addComponent(XYZPanel);
1707
+ //bigThree.addComponent(XYZPanel);
13801708
13811709 // // SIDE EFFECT!!!
13821710 // aConstraints.gridx = 0;
....@@ -1385,9 +1713,26 @@
13851713 // aConstraints.gridheight = 1;
13861714
13871715 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1388
- framePanel.setContinuousLayout(true);
1389
- framePanel.setOneTouchExpandable(true);
1390
- framePanel.setDividerLocation(0.8);
1716
+
1717
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1718
+ new java.beans.PropertyChangeListener()
1719
+ {
1720
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1721
+ {
1722
+ if ((Integer)pce.getOldValue() == 1)
1723
+ {
1724
+ if (radio.layout != expandedLayout)
1725
+ {
1726
+ radio.layout = expandedLayout;
1727
+ radio.layout.doClick();
1728
+ }
1729
+ }
1730
+ }
1731
+ });
1732
+
1733
+ framePanel.setContinuousLayout(false);
1734
+ framePanel.setOneTouchExpandable(false);
1735
+ //.setDividerLocation(0.8);
13911736 //framePanel.setDividerSize(15);
13921737 //framePanel.setResizeWeight(0.15);
13931738 framePanel.setName("Frame");
....@@ -1404,15 +1749,19 @@
14041749
14051750 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14061751
1407
- frame.setSize(1024, 768);
1408
- frame.show();
1409
-
1752
+ frame.setSize(1280, 860);
1753
+
1754
+ cameraView.requestFocusInWindow();
1755
+
14101756 gridPanel.setDividerLocation(1.0);
1757
+
1758
+ frame.validate();
1759
+
1760
+ frame.setVisible(true);
14111761
14121762 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14131763 frame.addWindowListener(new WindowAdapter()
14141764 {
1415
-
14161765 public void windowClosing(WindowEvent e)
14171766 {
14181767 Close();
....@@ -1435,28 +1784,422 @@
14351784 ctrlPanel.removeAll();
14361785 }
14371786
1438
- void SetupMaterial(cGridBag panel)
1787
+ void SetupMaterial(cGridBag materialpanel)
14391788 {
1440
- /*
1789
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1790
+
1791
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1792
+ skin.setToolTipText("Skin");
1793
+ skin.addMouseListener(new MouseAdapter()
1794
+ {
1795
+ public void mouseClicked(MouseEvent e)
1796
+ {
1797
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1798
+ cMaterial material = object.material;
1799
+
1800
+ // Skin
1801
+ colorField.setFloat(material.color);
1802
+ saturationField.setFloat(material.modulation);
1803
+ subsurfaceField.setFloat(material.subsurface);
1804
+ selfshadowField.setFloat(material.diffuseness);
1805
+ diffusenessField.setFloat(material.factor);
1806
+ shininessField.setFloat(material.shininess);
1807
+ shadowbiasField.setFloat(material.shadowbias);
1808
+ diffuseField.setFloat(material.diffuse);
1809
+ specularField.setFloat(material.specular);
1810
+
1811
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1812
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1813
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1814
+
1815
+ materialtouched = true;
1816
+ applySelf();
1817
+ }
1818
+ });
1819
+ presetpanel.add(skin);
1820
+
1821
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1822
+ lambert.setToolTipText("Diffuse");
1823
+ lambert.addMouseListener(new MouseAdapter()
1824
+ {
1825
+ public void mouseClicked(MouseEvent e)
1826
+ {
1827
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1828
+ cMaterial material = object.material;
1829
+
1830
+ diffusenessField.setFloat(material.factor);
1831
+ selfshadowField.setFloat(material.diffuseness);
1832
+
1833
+ materialtouched = true;
1834
+ applySelf();
1835
+ }
1836
+ });
1837
+ presetpanel.add(lambert);
1838
+
1839
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1840
+ diffuse2.setToolTipText("Diffuse2");
1841
+ diffuse2.addMouseListener(new MouseAdapter()
1842
+ {
1843
+ public void mouseClicked(MouseEvent e)
1844
+ {
1845
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1846
+ cMaterial material = object.material;
1847
+
1848
+ diffusenessField.setFloat(material.factor);
1849
+ selfshadowField.setFloat(material.diffuseness);
1850
+
1851
+ materialtouched = true;
1852
+ applySelf();
1853
+ }
1854
+ });
1855
+ presetpanel.add(diffuse2);
1856
+
1857
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1858
+ diffusemoon.setToolTipText("Moon");
1859
+ diffusemoon.addMouseListener(new MouseAdapter()
1860
+ {
1861
+ public void mouseClicked(MouseEvent e)
1862
+ {
1863
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1864
+ cMaterial material = object.material;
1865
+
1866
+ diffusenessField.setFloat(material.factor);
1867
+ selfshadowField.setFloat(material.diffuseness);
1868
+
1869
+ materialtouched = true;
1870
+ applySelf();
1871
+ }
1872
+ });
1873
+ presetpanel.add(diffusemoon);
1874
+
1875
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1876
+ diffusemoon2.setToolTipText("Moon2");
1877
+ diffusemoon2.addMouseListener(new MouseAdapter()
1878
+ {
1879
+ public void mouseClicked(MouseEvent e)
1880
+ {
1881
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1882
+ cMaterial material = object.material;
1883
+
1884
+ diffusenessField.setFloat(material.factor);
1885
+ selfshadowField.setFloat(material.diffuseness);
1886
+
1887
+ materialtouched = true;
1888
+ applySelf();
1889
+ }
1890
+ });
1891
+ presetpanel.add(diffusemoon2);
1892
+
1893
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1894
+ diffusemoon3.setToolTipText("Moon3");
1895
+ diffusemoon3.addMouseListener(new MouseAdapter()
1896
+ {
1897
+ public void mouseClicked(MouseEvent e)
1898
+ {
1899
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1900
+ cMaterial material = object.material;
1901
+
1902
+ diffusenessField.setFloat(material.factor);
1903
+ selfshadowField.setFloat(material.diffuseness);
1904
+
1905
+ materialtouched = true;
1906
+ applySelf();
1907
+ }
1908
+ });
1909
+ presetpanel.add(diffusemoon3);
1910
+
1911
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1912
+ diffusesheen.setToolTipText("Sheen");
1913
+ diffusesheen.addMouseListener(new MouseAdapter()
1914
+ {
1915
+ public void mouseClicked(MouseEvent e)
1916
+ {
1917
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1918
+ cMaterial material = object.material;
1919
+
1920
+ sheenField.setFloat(material.sheen);
1921
+
1922
+ materialtouched = true;
1923
+ applySelf();
1924
+ }
1925
+ });
1926
+ presetpanel.add(diffusesheen);
1927
+
1928
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1929
+ rough.setToolTipText("Rough metal");
1930
+ rough.addMouseListener(new MouseAdapter()
1931
+ {
1932
+ public void mouseClicked(MouseEvent e)
1933
+ {
1934
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1935
+ cMaterial material = object.material;
1936
+
1937
+ shininessField.setFloat(material.shininess);
1938
+ velvetField.setFloat(material.velvet);
1939
+
1940
+ materialtouched = true;
1941
+ applySelf();
1942
+ }
1943
+ });
1944
+ presetpanel.add(rough);
1945
+
1946
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
1947
+ rough2.setToolTipText("Medium metal");
1948
+ rough2.addMouseListener(new MouseAdapter()
1949
+ {
1950
+ public void mouseClicked(MouseEvent e)
1951
+ {
1952
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
1953
+ cMaterial material = object.material;
1954
+
1955
+ shininessField.setFloat(material.shininess);
1956
+ lightareaField.setFloat(material.lightarea);
1957
+
1958
+ materialtouched = true;
1959
+ applySelf();
1960
+ }
1961
+ });
1962
+ presetpanel.add(rough2);
1963
+
1964
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
1965
+ shini0.setToolTipText("Shiny");
1966
+ shini0.addMouseListener(new MouseAdapter()
1967
+ {
1968
+ public void mouseClicked(MouseEvent e)
1969
+ {
1970
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
1971
+ cMaterial material = object.material;
1972
+
1973
+ shininessField.setFloat(material.shininess);
1974
+ lightareaField.setFloat(material.lightarea);
1975
+
1976
+ materialtouched = true;
1977
+ applySelf();
1978
+ }
1979
+ });
1980
+ presetpanel.add(shini0);
1981
+
1982
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
1983
+ shini1.setToolTipText("Shiny2");
1984
+ shini1.addMouseListener(new MouseAdapter()
1985
+ {
1986
+ public void mouseClicked(MouseEvent e)
1987
+ {
1988
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
1989
+ cMaterial material = object.material;
1990
+
1991
+ shininessField.setFloat(material.shininess);
1992
+ lightareaField.setFloat(material.lightarea);
1993
+
1994
+ materialtouched = true;
1995
+ applySelf();
1996
+ }
1997
+ });
1998
+ presetpanel.add(shini1);
1999
+
2000
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2001
+ shini2.setToolTipText("Shiny3");
2002
+ shini2.addMouseListener(new MouseAdapter()
2003
+ {
2004
+ public void mouseClicked(MouseEvent e)
2005
+ {
2006
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2007
+ cMaterial material = object.material;
2008
+
2009
+ shininessField.setFloat(material.shininess);
2010
+ lightareaField.setFloat(material.lightarea);
2011
+
2012
+ materialtouched = true;
2013
+ applySelf();
2014
+ }
2015
+ });
2016
+ presetpanel.add(shini2);
2017
+
2018
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2019
+ aniso.setToolTipText("AnisoU");
2020
+ aniso.addMouseListener(new MouseAdapter()
2021
+ {
2022
+ public void mouseClicked(MouseEvent e)
2023
+ {
2024
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2025
+ cMaterial material = object.material;
2026
+
2027
+ anisoField.setFloat(material.aniso);
2028
+ anisoVField.setFloat(material.anisoV);
2029
+
2030
+ materialtouched = true;
2031
+ applySelf();
2032
+ }
2033
+ });
2034
+ presetpanel.add(aniso);
2035
+
2036
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2037
+ aniso2.setToolTipText("AnisoV");
2038
+ aniso2.addMouseListener(new MouseAdapter()
2039
+ {
2040
+ public void mouseClicked(MouseEvent e)
2041
+ {
2042
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2043
+ cMaterial material = object.material;
2044
+
2045
+ anisoField.setFloat(material.aniso);
2046
+ anisoVField.setFloat(material.anisoV);
2047
+
2048
+ materialtouched = true;
2049
+ applySelf();
2050
+ }
2051
+ });
2052
+ presetpanel.add(aniso2);
2053
+
2054
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2055
+ aniso3.setToolTipText("AnisoUV");
2056
+ aniso3.addMouseListener(new MouseAdapter()
2057
+ {
2058
+ public void mouseClicked(MouseEvent e)
2059
+ {
2060
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2061
+ cMaterial material = object.material;
2062
+
2063
+ anisoField.setFloat(material.aniso);
2064
+ anisoVField.setFloat(material.anisoV);
2065
+
2066
+ materialtouched = true;
2067
+ applySelf();
2068
+ }
2069
+ });
2070
+ presetpanel.add(aniso3);
2071
+
2072
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2073
+ velvet0.setToolTipText("Velvet");
2074
+ velvet0.addMouseListener(new MouseAdapter()
2075
+ {
2076
+ public void mouseClicked(MouseEvent e)
2077
+ {
2078
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2079
+ cMaterial material = object.material;
2080
+
2081
+ diffusenessField.setFloat(material.factor);
2082
+ selfshadowField.setFloat(material.diffuseness);
2083
+ sheenField.setFloat(material.sheen);
2084
+ shininessField.setFloat(material.shininess);
2085
+ velvetField.setFloat(material.velvet);
2086
+ shiftField.setFloat(material.shift);
2087
+
2088
+ materialtouched = true;
2089
+ applySelf();
2090
+ }
2091
+ });
2092
+ presetpanel.add(velvet0);
2093
+
2094
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2095
+ bump0.setToolTipText("Bump texture");
2096
+ bump0.addMouseListener(new MouseAdapter()
2097
+ {
2098
+ public void mouseClicked(MouseEvent e)
2099
+ {
2100
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2101
+ cMaterial material = object.material;
2102
+
2103
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2104
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2105
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2106
+
2107
+ materialtouched = true;
2108
+ applySelf();
2109
+ }
2110
+ });
2111
+ presetpanel.add(bump0);
2112
+
2113
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2114
+ halo.setToolTipText("Halo");
2115
+ halo.addMouseListener(new MouseAdapter()
2116
+ {
2117
+ public void mouseClicked(MouseEvent e)
2118
+ {
2119
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2120
+ cMaterial material = object.material;
2121
+
2122
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2123
+
2124
+ materialtouched = true;
2125
+ applySelf();
2126
+ }
2127
+ });
2128
+ presetpanel.add(halo);
2129
+
2130
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2131
+ candle.setToolTipText("Candle");
2132
+ candle.addMouseListener(new MouseAdapter()
2133
+ {
2134
+ public void mouseClicked(MouseEvent e)
2135
+ {
2136
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2137
+ cMaterial material = object.material;
2138
+
2139
+ subsurfaceField.setFloat(material.subsurface);
2140
+ shadowbiasField.setFloat(material.shadowbias);
2141
+ ambientField.setFloat(material.ambient);
2142
+ specularField.setFloat(material.specular);
2143
+ lightareaField.setFloat(material.lightarea);
2144
+ shininessField.setFloat(material.shininess);
2145
+
2146
+ materialtouched = true;
2147
+ applySelf();
2148
+ }
2149
+ });
2150
+ presetpanel.add(candle);
2151
+
2152
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2153
+ shadowShader.setToolTipText("Shadow");
2154
+ shadowShader.addMouseListener(new MouseAdapter()
2155
+ {
2156
+ public void mouseClicked(MouseEvent e)
2157
+ {
2158
+ diffuseField.setFloat(0.001);
2159
+ ambientField.setFloat(0.001);
2160
+ cameraField.setFloat(0.001);
2161
+ specularField.setFloat(0.001);
2162
+ fakedepthField.setFloat(0.001);
2163
+ opacityField.setFloat(0.6);
2164
+
2165
+ materialtouched = true;
2166
+ applySelf();
2167
+ }
2168
+ });
2169
+ presetpanel.add(shadowShader);
2170
+
2171
+ cGridBag panel = new cGridBag().setVertical(true);
2172
+
2173
+ presetpanel.preferredWidth = 1;
2174
+
2175
+ materialpanel.add(presetpanel);
2176
+ materialpanel.add(panel);
2177
+
2178
+ panel.preferredWidth = 8;
2179
+
2180
+ /*
14412181 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14422182 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1443
- */
2183
+ */
14442184
14452185 cGridBag editBar = new cGridBag().setVertical(false);
14462186
1447
- editBar.add(createMaterialButton = new cButton("Create", !GrafreeD.NIMBUSLAF)); // , aConstraints);
2187
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
14482188 createMaterialButton.setToolTipText("Create material");
14492189
14502190 /*
14512191 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14522192 */
14532193
1454
- editBar.add(clearMaterialButton = new cButton("Clear", !GrafreeD.NIMBUSLAF)); // , aConstraints);
2194
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
14552195 clearMaterialButton.setToolTipText("Clear material");
14562196
1457
- editBar.add(resetSlidersButton = new cButton("Reset", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1458
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1459
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
2197
+ if (Globals.ADVANCED)
2198
+ {
2199
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2200
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
2201
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
2202
+ }
14602203
14612204 editBar.preferredHeight = 15;
14622205
....@@ -1471,45 +2214,50 @@
14712214 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14722215
14732216 cGridBag colorSection = new cGridBag().setVertical(true);
2217
+
2218
+ cGridBag huepanel = new cGridBag();
2219
+ cGridBag huelabel = new cGridBag();
2220
+ skin = GetLabel("icons/hue.png", false);
2221
+ skin.fit = true;
2222
+ huelabel.add(skin);
2223
+ huelabel.preferredWidth = 20;
2224
+ huepanel.add(new cGridBag()); // Label
2225
+ huepanel.add(huelabel); // Field/slider
2226
+
2227
+ huepanel.preferredHeight = 7;
2228
+
2229
+ colorSection.add(huepanel);
14742230
14752231 cGridBag color = new cGridBag();
1476
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1477
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1478
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2232
+
2233
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2234
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2235
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2236
+
14792237 //colorField.preferredWidth = 200;
14802238 colorSection.add(color);
14812239
14822240 cGridBag modulation = new cGridBag();
14832241 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14842242 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1485
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2243
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14862244 colorSection.add(modulation);
14872245
2246
+ cGridBag opacity = new cGridBag();
2247
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2248
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2249
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2250
+ colorSection.add(opacity);
2251
+
2252
+ colorSection.add(GetSeparator());
2253
+
14882254 cGridBag texture = new cGridBag();
14892255 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14902256 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14912257 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14922258 colorSection.add(texture);
14932259
1494
- cGridBag anisoU = new cGridBag();
1495
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1496
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1497
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1498
- colorSection.add(anisoU);
1499
-
1500
- cGridBag anisoV = new cGridBag();
1501
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1502
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1503
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1504
- colorSection.add(anisoV);
1505
-
1506
- cGridBag shadowbias = new cGridBag();
1507
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1508
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1509
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1510
- colorSection.add(shadowbias);
1511
-
1512
- panel.add(new JSeparator());
2260
+ panel.add(GetSeparator());
15132261
15142262 panel.add(colorSection);
15152263
....@@ -1559,7 +2307,13 @@
15592307 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15602308 diffuseSection.add(fakedepth);
15612309
1562
- panel.add(new JSeparator());
2310
+ cGridBag shadowbias = new cGridBag();
2311
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2312
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2313
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2314
+ diffuseSection.add(shadowbias);
2315
+
2316
+ panel.add(GetSeparator());
15632317
15642318 panel.add(diffuseSection);
15652319
....@@ -1609,42 +2363,48 @@
16092363 // aConstraints.gridy += 1;
16102364 // aConstraints.gridwidth = 1;
16112365
2366
+ cGridBag anisoU = new cGridBag();
2367
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2368
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2369
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2370
+ specularSection.add(anisoU);
16122371
1613
- panel.add(new JSeparator());
2372
+ cGridBag anisoV = new cGridBag();
2373
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2374
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2375
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2376
+ specularSection.add(anisoV);
2377
+
2378
+
2379
+ panel.add(GetSeparator());
16142380
16152381 panel.add(specularSection);
16162382
16172383 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16182384
1619
- cGridBag globalSection = new cGridBag().setVertical(true);
2385
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16202386
16212387 cGridBag camera = new cGridBag();
16222388 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16232389 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16242390 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1625
- globalSection.add(camera);
2391
+ colorSection.add(camera);
16262392
16272393 cGridBag ambient = new cGridBag();
16282394 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16292395 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16302396 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1631
- globalSection.add(ambient);
2397
+ colorSection.add(ambient);
16322398
16332399 cGridBag backlit = new cGridBag();
16342400 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16352401 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16362402 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1637
- globalSection.add(backlit);
2403
+ colorSection.add(backlit);
16382404
1639
- cGridBag opacity = new cGridBag();
1640
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1641
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1642
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1643
- globalSection.add(opacity);
1644
-
1645
- panel.add(new JSeparator());
2405
+ //panel.add(new JSeparator());
16462406
1647
- panel.add(globalSection);
2407
+ //panel.add(globalSection);
16482408
16492409 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16502410
....@@ -1686,7 +2446,7 @@
16862446 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16872447 textureSection.add(opacityPower);
16882448
1689
- panel.add(new JSeparator());
2449
+ panel.add(GetSeparator());
16902450
16912451 panel.add(textureSection);
16922452
....@@ -1725,12 +2485,15 @@
17252485 opacityPowerField.addChangeListener(this);
17262486 /**/
17272487
1728
- resetSlidersButton.addActionListener(this);
17292488 clearMaterialButton.addActionListener(this);
17302489 createMaterialButton.addActionListener(this);
1731
-
1732
- propagateToggle.addItemListener(this);
1733
- multiplyToggle.addItemListener(this);
2490
+
2491
+ if (Globals.ADVANCED)
2492
+ {
2493
+ resetSlidersButton.addActionListener(this);
2494
+ propagateToggle.addItemListener(this);
2495
+ multiplyToggle.addItemListener(this);
2496
+ }
17342497 }
17352498
17362499 void DropFile(java.io.File[] files, boolean textures)
....@@ -1748,8 +2511,9 @@
17482511 // 3D models
17492512 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17502513 {
1751
- lastConverter = new com.jmex.model.converters.MaxToJme();
1752
- LoadFile(filename, lastConverter);
2514
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2515
+ //LoadFile(filename, lastConverter);
2516
+ LoadObjFile(filename); // New 3ds loader
17532517 continue;
17542518 }
17552519 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1901,7 +2665,7 @@
19012665
19022666 //? flashIt = false;
19032667 CameraPane pane = (CameraPane) cameraView;
1904
- pane.clickStart(location.x, location.y, 0);
2668
+ pane.clickStart(location.x, location.y, 0, 0);
19052669 pane.clickEnd(location.x, location.y, 0, true);
19062670
19072671 if (group.selection.size() == 1)
....@@ -1950,6 +2714,7 @@
19502714 e2.printStackTrace();
19512715 }
19522716 }
2717
+
19532718 LoadJMEThread loadThread;
19542719
19552720 class LoadJMEThread extends Thread
....@@ -2007,6 +2772,7 @@
20072772 //LoadFile0(filename, converter);
20082773 }
20092774 }
2775
+
20102776 LoadOBJThread loadObjThread;
20112777
20122778 class LoadOBJThread extends Thread
....@@ -2085,19 +2851,19 @@
20852851
20862852 void LoadObjFile(String fullname)
20872853 {
2088
- /*
2854
+ System.out.println("Loading " + fullname);
2855
+ /**/
20892856 //lastFilename = fullname;
20902857 if(loadObjThread == null)
20912858 {
2092
- loadObjThread = new LoadOBJThread();
2093
- loadObjThread.start();
2859
+ loadObjThread = new LoadOBJThread();
2860
+ loadObjThread.start();
20942861 }
20952862
20962863 loadObjThread.add(fullname);
2097
- */
2864
+ /**/
20982865
2099
- System.out.println("Loading " + fullname);
2100
- makeSomething(new FileObject(fullname, true), true);
2866
+ //makeSomething(new FileObject(fullname, true), true);
21012867 }
21022868
21032869 void LoadGFDFile(String fullname)
....@@ -2358,11 +3124,11 @@
23583124
23593125 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23603126 {
2361
- if (GrafreeD.standAlone)
3127
+ if (Grafreed.standAlone)
23623128 {
23633129 /**/
23643130 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2365
- browser.show();
3131
+ browser.setVisible(true);
23663132 String filename = browser.getFile();
23673133 if (filename != null && filename.length() > 0)
23683134 {
....@@ -2473,6 +3239,7 @@
24733239 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24743240 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24753241 }
3242
+
24763243 //cJME.count++;
24773244 //cJME.count %= 12;
24783245 if (gc)
....@@ -2656,6 +3423,7 @@
26563423 }
26573424 }
26583425 }
3426
+
26593427 cFileSystemPane FSPane;
26603428
26613429 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2665,7 +3433,7 @@
26653433
26663434 freezematerial = true;
26673435 colorField.setFloat(mat.color);
2668
- modulationField.setFloat(mat.modulation);
3436
+ saturationField.setFloat(mat.modulation);
26693437 metalnessField.setFloat(mat.metalness);
26703438 diffuseField.setFloat(mat.diffuse);
26713439 specularField.setFloat(mat.specular);
....@@ -2709,11 +3477,14 @@
27093477 }
27103478 }
27113479 }
3480
+
27123481 freezematerial = false;
27133482 }
27143483
27153484 void SetMaterial(Object3D object)
27163485 {
3486
+ latestObject = object;
3487
+
27173488 cMaterial mat = object.material;
27183489
27193490 if (mat == null)
....@@ -2722,7 +3493,8 @@
27223493 return;
27233494 }
27243495
2725
- multiplyToggle.setSelected(mat.multiply);
3496
+ if (multiplyToggle != null)
3497
+ multiplyToggle.setSelected(mat.multiply);
27263498
27273499 assert (object.projectedVertices != null);
27283500
....@@ -2824,12 +3596,17 @@
28243596 // }
28253597
28263598 /**/
2827
- if (deselect)
3599
+ if (deselect || child == null)
28283600 {
28293601 //group.deselectAll();
28303602 //freeze = true;
28313603 GetTree().clearSelection();
28323604 //freeze = false;
3605
+
3606
+ if (child == null)
3607
+ {
3608
+ return;
3609
+ }
28333610 }
28343611
28353612 //group.addSelectee(child);
....@@ -2863,6 +3640,17 @@
28633640 public void itemStateChanged(ItemEvent event)
28643641 {
28653642 // System.out.println("Propagate = " + propagate);
3643
+ if (event.getSource() == pinButton)
3644
+ {
3645
+ copy.pinned ^= true;
3646
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3647
+ {
3648
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3649
+ copy.CloseUI();
3650
+ //copy.editWindow.refreshContents();
3651
+ }
3652
+ }
3653
+ else
28663654 if (event.getSource() == propagateToggle)
28673655 {
28683656 propagate ^= true;
....@@ -2898,7 +3686,7 @@
28983686 cameraView.ToggleDL();
28993687 cameraView.repaint();
29003688 return;
2901
- } else if (event.getSource() == toggleTextureItem)
3689
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29023690 {
29033691 cameraView.ToggleTexture();
29043692 // june 2013 copy.HardTouch();
....@@ -2937,9 +3725,9 @@
29373725 frame.validate();
29383726
29393727 return;
2940
- } else if (event.getSource() == toggleRandomItem)
3728
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29413729 {
2942
- cameraView.ToggleRandom();
3730
+ cameraView.ToggleSwitch();
29433731 cameraView.repaint();
29443732 return;
29453733 } else if (event.getSource() == toggleHandleItem)
....@@ -2967,12 +3755,17 @@
29673755 } else if (event.getSource() == liveCB)
29683756 {
29693757 copy.live ^= true;
3758
+ objEditor.refreshContents(true); // To show item colors
3759
+ return;
3760
+ } else if (event.getSource() == selectableCB)
3761
+ {
3762
+ copy.dontselect ^= true;
29703763 return;
29713764 } else if (event.getSource() == hideCB)
29723765 {
29733766 copy.hide ^= true;
29743767 copy.Touch(); // display list issue
2975
- objEditor.refreshContents();
3768
+ objEditor.refreshContents(true); // To show item colors
29763769 return;
29773770 } else if (event.getSource() == link2masterCB)
29783771 {
....@@ -2982,6 +3775,7 @@
29823775 if (event.getSource() == randomCB)
29833776 {
29843777 copy.random ^= true;
3778
+ objEditor.refreshContents();
29853779 return;
29863780 }
29873781 if (event.getSource() == speedupCB)
....@@ -3005,8 +3799,9 @@
30053799
30063800 public void actionPerformed(ActionEvent event)
30073801 {
3802
+ Object source = event.getSource();
30083803 // SCRIPT DIALOG
3009
- if (event.getSource() == okbutton)
3804
+ if (source == okbutton)
30103805 {
30113806 textpanel.setVisible(false);
30123807 textpanel.remove(textarea);
....@@ -3018,7 +3813,7 @@
30183813 textarea = null;
30193814 textpanel = null;
30203815 }
3021
- if (event.getSource() == cancelbutton)
3816
+ if (source == cancelbutton)
30223817 {
30233818 textpanel.setVisible(false);
30243819 textpanel.remove(textarea);
....@@ -3030,50 +3825,50 @@
30303825 //applySelf();
30313826 //client.refreshEditWindow();
30323827 //refreshContents();
3033
- if (event.getSource() == nameField)
3828
+ if (source == nameField)
30343829 {
30353830 //System.out.println("ObjEditor " + event);
30363831 applySelf0(true);
30373832 //parent.applySelf();
30383833 objEditor.refreshContents();
3039
- } else if (event.getSource() == resetButton)
3834
+ } else if (source == resetButton)
30403835 {
30413836 CameraPane.fullreset = true;
30423837 copy.Reset(); // ResetMeshes();
30433838 copy.Touch();
30443839 objEditor.refreshContents();
3045
- } else if (event.getSource() == stepItem)
3840
+ } else if (source == stepItem)
30463841 {
30473842 //cameraView.ONESTEP = true;
30483843 Globals.ONESTEP = true;
30493844 cameraView.repaint();
30503845 return;
3051
- } else if (event.getSource() == stepButton)
3846
+ } else if (source == stepButton)
30523847 {
30533848 copy.Step();
30543849 copy.Touch();
30553850 objEditor.refreshContents();
3056
- } else if (event.getSource() == slowerButton)
3851
+ } else if (source == slowerButton)
30573852 {
30583853 copy.Slower();
30593854 copy.Touch();
30603855 objEditor.refreshContents();
3061
- } else if (event.getSource() == fasterButton)
3856
+ } else if (source == fasterButton)
30623857 {
30633858 copy.Faster();
30643859 copy.Touch();
30653860 objEditor.refreshContents();
3066
- } else if (event.getSource() == remarkButton)
3861
+ } else if (source == remarkButton)
30673862 {
30683863 copy.Remark();
30693864 copy.Touch();
30703865 objEditor.refreshContents();
3071
- } else if (event.getSource() == stepAllButton)
3866
+ } else if (source == stepAllButton)
30723867 {
30733868 copy.StepAll();
30743869 copy.Touch();
30753870 objEditor.refreshContents();
3076
- } else if (event.getSource() == resetAllButton)
3871
+ } else if (source == resetAllButton)
30773872 {
30783873 //CameraPane.fullreset = true;
30793874 copy.ResetAll(); // ResetMeshes();
....@@ -3106,53 +3901,79 @@
31063901 // Close();
31073902 // }
31083903 // else
3109
- if (event.getSource() == resetSlidersButton)
3904
+ if (source == resetSlidersButton)
31103905 {
31113906 ResetSliders();
3112
- } else if (event.getSource() == clearMaterialButton)
3907
+ } else if (source == clearMaterialButton)
31133908 {
31143909 ClearMaterial();
3115
- } else if (event.getSource() == createMaterialButton)
3910
+ } else if (source == createMaterialButton)
31163911 {
31173912 CreateMaterial();
3118
- } else if (event.getSource() == clearPanelButton)
3913
+ } else if (source == clearPanelButton)
31193914 {
31203915 copy.ClearUI();
31213916 refreshContents(true);
3122
- } /*
3123
- }
3124
-
3125
- public boolean action(Event event, Object arg)
3126
- {
3127
- */ else if (event.getSource() == closeItem)
3917
+ } else if (source == importGFDItem)
3918
+ {
3919
+ ImportGFD();
3920
+ } else
3921
+ if (source == importVRMLX3DItem)
3922
+ {
3923
+ ImportVRMLX3D();
3924
+ } else
3925
+ if (source == import3DSItem)
3926
+ {
3927
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3928
+ } else
3929
+ if (source == importOBJItem)
3930
+ {
3931
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3932
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3933
+ browser.setVisible(true);
3934
+ String filename = browser.getFile();
3935
+ if (filename != null && filename.length() > 0)
3936
+ {
3937
+ String fullname = browser.getDirectory() + filename;
3938
+ makeSomething(ReadOBJ(fullname), true);
3939
+ }
3940
+ } else
3941
+ if (source == closeItem)
31283942 {
31293943 Close();
31303944 //return true;
3131
- } else if (event.getSource() == loadItem)
3945
+ } else if (source == openItem)
31323946 {
3133
- load();
3947
+ Open();
31343948 //return true;
3135
- } else if (event.getSource() == saveItem)
3949
+ } else if (source == newItem)
3950
+ {
3951
+ New();
3952
+ } else if (source == saveItem)
31363953 {
31373954 save();
31383955 //return true;
3139
- } else if (event.getSource() == saveAsItem)
3956
+ } else if (source == saveAsItem)
31403957 {
31413958 saveAs();
31423959 //return true;
3143
- } else if (event.getSource() == reexportItem)
3960
+ } else if (source == reexportItem)
31443961 {
31453962 reexport();
31463963 //return true;
3147
- } else if (event.getSource() == exportAsItem)
3964
+ } else if (source == exportAsItem)
31483965 {
31493966 export();
31503967 //return true;
3151
- } else if (event.getSource() == povItem)
3968
+ } else if (source == povItem)
31523969 {
31533970 generatePOV();
31543971 //return true;
3155
- } else if (event.getSource() == zBufferItem)
3972
+ } else if (event.getSource() == archiveItem)
3973
+ {
3974
+ cTools.Archive(frame);
3975
+ return;
3976
+ } else if (source == zBufferItem)
31563977 {
31573978 try
31583979 {
....@@ -3174,21 +3995,8 @@
31743995 cameraView.repaint();
31753996 //return true;
31763997 }
3177
- */ else if (event.getSource() == editCameraItem)
3178
- {
3179
- cameraView.ProtectCamera();
3180
- cameraView.repaint();
3181
- return;
3182
- } else if (event.getSource() == revertCameraItem)
3183
- {
3184
- cameraView.RevertCamera();
3185
- cameraView.repaint();
3186
- return;
3187
-// } else if (event.getSource() == textureButton)
3188
-// {
3189
-// return; // true;
3190
- } else // combos...
3191
- if (event.getSource() == texresMenu)
3998
+ */ else // combos...
3999
+ if (source == texresMenu)
31924000 {
31934001 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31944002 copy.texres = texresMenu.getSelectedIndex();
....@@ -3200,6 +4008,466 @@
32004008 }
32014009 }
32024010
4011
+ void New()
4012
+ {
4013
+ while (copy.Size() > 1)
4014
+ {
4015
+ copy.remove(1);
4016
+ }
4017
+
4018
+ ResetModel();
4019
+ objEditor.refreshContents();
4020
+ }
4021
+
4022
+ static public byte[] Compress(Object3D o)
4023
+ {
4024
+ // Slower to actually compress.
4025
+ try
4026
+ {
4027
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4028
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4029
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
4030
+
4031
+ Object3D parent = o.parent;
4032
+ o.parent = null;
4033
+
4034
+ out.writeObject(o);
4035
+
4036
+ o.parent = parent;
4037
+
4038
+ out.flush();
4039
+
4040
+ baos //zstream
4041
+ .close();
4042
+ out.close();
4043
+
4044
+ byte[] bytes = baos.toByteArray();
4045
+
4046
+ System.out.println("save #bytes = " + bytes.length);
4047
+ return bytes;
4048
+ } catch (Exception e)
4049
+ {
4050
+ System.err.println(e);
4051
+ return null;
4052
+ }
4053
+ }
4054
+
4055
+ static public Object Uncompress(byte[] bytes)
4056
+ {
4057
+ System.out.println("restore #bytes = " + bytes.length);
4058
+ try
4059
+ {
4060
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4061
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4062
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
4063
+ Object obj = in.readObject();
4064
+
4065
+ bais //istream
4066
+ .close();
4067
+ in.close();
4068
+
4069
+ return obj;
4070
+ } catch (Exception e)
4071
+ {
4072
+ System.err.println(e);
4073
+ return null;
4074
+ }
4075
+ }
4076
+
4077
+ static public Object clone(Object o)
4078
+ {
4079
+ try
4080
+ {
4081
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4082
+ ObjectOutputStream out = new ObjectOutputStream(baos);
4083
+
4084
+ out.writeObject(o);
4085
+
4086
+ out.flush();
4087
+ out.close();
4088
+
4089
+ byte[] bytes = baos.toByteArray();
4090
+
4091
+ System.out.println("clone = " + bytes.length);
4092
+
4093
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4094
+ ObjectInputStream in = new ObjectInputStream(bais);
4095
+ Object obj = in.readObject();
4096
+ in.close();
4097
+
4098
+ return obj;
4099
+ } catch (Exception e)
4100
+ {
4101
+ System.err.println(e);
4102
+ return null;
4103
+ }
4104
+ }
4105
+
4106
+ cRadio GetCurrentTab()
4107
+ {
4108
+ cRadio ab;
4109
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4110
+ {
4111
+ ab = (cRadio)e.nextElement();
4112
+ if(ab.GetObject() == copy)
4113
+ {
4114
+ return ab;
4115
+ }
4116
+ }
4117
+
4118
+ return null;
4119
+ }
4120
+
4121
+
4122
+ public void Save()
4123
+ {
4124
+ //Save(true);
4125
+ Replace();
4126
+ SetUndoStates();
4127
+ }
4128
+
4129
+ private boolean Equal(byte[] compress, byte[] name)
4130
+ {
4131
+ if (compress.length != name.length)
4132
+ {
4133
+ return false;
4134
+ }
4135
+
4136
+ for (int i=compress.length; --i>=0;)
4137
+ {
4138
+ if (compress[i] != name[i])
4139
+ return false;
4140
+ }
4141
+
4142
+ return true;
4143
+ }
4144
+
4145
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4146
+
4147
+ void DeleteVersion()
4148
+ {
4149
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4150
+ {
4151
+ copy.versionlist[i] = copy.versionlist[i+1];
4152
+ }
4153
+
4154
+ CopyChanged();
4155
+
4156
+ SetUndoStates();
4157
+ }
4158
+
4159
+ public boolean Save(boolean user)
4160
+ {
4161
+ System.err.println("Save");
4162
+ Replace();
4163
+
4164
+ cRadio tab = GetCurrentTab();
4165
+
4166
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
4167
+
4168
+ boolean thesame = false;
4169
+
4170
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4171
+// {
4172
+// thesame = true;
4173
+// }
4174
+
4175
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
4176
+ if (!thesame)
4177
+ {
4178
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4179
+ {
4180
+ copy.versionlist[i] = copy.versionlist[i-1];
4181
+ }
4182
+
4183
+ //tab.user[tab.versionindex] = user;
4184
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4185
+
4186
+ copy.versionlist[++copy.versionindex] = compress;
4187
+
4188
+ // if (increment)
4189
+ // tab.versionindex++;
4190
+ }
4191
+
4192
+ //copy.RestoreBigData(versiontable);
4193
+
4194
+ //assert(hashtable.isEmpty());
4195
+
4196
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4197
+// {
4198
+// //tab.user[i] = false;
4199
+// copy.versionlist[i] = null;
4200
+// }
4201
+
4202
+ SetUndoStates();
4203
+
4204
+ // test save
4205
+ if (false)
4206
+ {
4207
+ try
4208
+ {
4209
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
4210
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
4211
+
4212
+ p.writeObject(copy);
4213
+
4214
+ p.flush();
4215
+
4216
+ ostream.close();
4217
+ } catch (Exception e)
4218
+ {
4219
+ e.printStackTrace();
4220
+ }
4221
+ }
4222
+
4223
+ return !thesame;
4224
+ }
4225
+
4226
+ boolean flashIt = true;
4227
+
4228
+ void RefreshSelection()
4229
+ {
4230
+ Object3D selection = new Object3D();
4231
+
4232
+ for (int i = 0; i < copy.selection.size(); i++)
4233
+ {
4234
+ Object3D elem = copy.selection.elementAt(i);
4235
+
4236
+ Object3D obj = copy.GetObject(elem.GetUUID());
4237
+
4238
+ if (obj == null)
4239
+ {
4240
+ copy.selection.remove(i--);
4241
+ }
4242
+ else
4243
+ {
4244
+ selection.add(obj);
4245
+ copy.selection.setElementAt(obj, i);
4246
+ }
4247
+ }
4248
+
4249
+ flashIt = false;
4250
+ GetTree().clearSelection();
4251
+ for (int i = 0; i < selection.size(); i++)
4252
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4253
+ flashIt = true;
4254
+
4255
+ //refreshContents(false);
4256
+ }
4257
+
4258
+ void CopyChanged()
4259
+ {
4260
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4261
+
4262
+ SetUndoStates();
4263
+
4264
+ boolean temp = CameraPane.SWITCH;
4265
+ CameraPane.SWITCH = false;
4266
+
4267
+ copy.ExtractBigData(versiontable);
4268
+
4269
+ copy.clear();
4270
+
4271
+ copy.skyboxname = obj.skyboxname;
4272
+ copy.skyboxext = obj.skyboxext;
4273
+
4274
+ for (int i=0; i<obj.Size(); i++)
4275
+ {
4276
+ copy.add(obj.get(i));
4277
+ }
4278
+
4279
+ copy.RestoreBigData(versiontable);
4280
+
4281
+ CameraPane.SWITCH = temp;
4282
+
4283
+ RefreshSelection();
4284
+ //assert(hashtable.isEmpty());
4285
+
4286
+ copy.Touch();
4287
+
4288
+ ResetModel();
4289
+ copy.HardTouch(); // recompile?
4290
+
4291
+ cRadio ab;
4292
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4293
+ {
4294
+ ab = (cRadio)e.nextElement();
4295
+ Object3D test = copy.GetObject(ab.object.GetUUID());
4296
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
4297
+ if (test != null)
4298
+ {
4299
+ test.editWindow = ab.object.editWindow;
4300
+ ab.object = test;
4301
+ }
4302
+ }
4303
+
4304
+ refreshContents(true);
4305
+ }
4306
+
4307
+ cButton previousVersionButton;
4308
+ cButton restoreButton;
4309
+ cButton replaceButton;
4310
+ cButton nextVersionButton;
4311
+ cButton saveVersionButton;
4312
+ cButton deleteVersionButton;
4313
+
4314
+ boolean muteSlider;
4315
+
4316
+ int VersionCount()
4317
+ {
4318
+ int count = 0;
4319
+
4320
+ for (int i = copy.versionlist.length; --i >= 0;)
4321
+ {
4322
+ if (copy.versionlist[i] != null)
4323
+ count++;
4324
+ }
4325
+
4326
+ return count;
4327
+ }
4328
+
4329
+ void SetUndoStates()
4330
+ {
4331
+ cRadio tab = GetCurrentTab();
4332
+
4333
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
4334
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
4335
+
4336
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4337
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4338
+
4339
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4340
+ copy.versionlist[copy.versionindex + 1] != null);
4341
+
4342
+ muteSlider = true;
4343
+ versionSlider.setMaximum(VersionCount() - 1);
4344
+ versionSlider.setInteger(copy.versionindex);
4345
+ muteSlider = false;
4346
+ }
4347
+
4348
+ public boolean PreviousVersion()
4349
+ {
4350
+ // Option?
4351
+ Replace();
4352
+
4353
+ System.err.println("Undo");
4354
+
4355
+ cRadio tab = GetCurrentTab();
4356
+
4357
+ if (copy.versionindex == 0)
4358
+ {
4359
+ java.awt.Toolkit.getDefaultToolkit().beep();
4360
+ return false;
4361
+ }
4362
+
4363
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4364
+// {
4365
+// if (Save(false))
4366
+// tab.versionindex -= 1;
4367
+// else
4368
+// {
4369
+// if (tab.versionindex <= 0)
4370
+// return false;
4371
+// else
4372
+// tab.versionindex -= 1;
4373
+// }
4374
+// }
4375
+
4376
+ copy.versionindex -= 1;
4377
+
4378
+ CopyChanged();
4379
+
4380
+ return true;
4381
+ }
4382
+
4383
+ public boolean Restore()
4384
+ {
4385
+ System.err.println("Restore");
4386
+
4387
+ cRadio tab = GetCurrentTab();
4388
+
4389
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4390
+ {
4391
+ java.awt.Toolkit.getDefaultToolkit().beep();
4392
+ return false;
4393
+ }
4394
+
4395
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4396
+ CopyChanged();
4397
+
4398
+ return true;
4399
+ }
4400
+
4401
+ public boolean Replace()
4402
+ {
4403
+ System.err.println("Replace");
4404
+
4405
+ cRadio tab = GetCurrentTab();
4406
+
4407
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4408
+ {
4409
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4410
+ return false;
4411
+ }
4412
+
4413
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4414
+
4415
+ return true;
4416
+ }
4417
+
4418
+ public void NextVersion()
4419
+ {
4420
+ // Option?
4421
+ Replace();
4422
+
4423
+ cRadio tab = GetCurrentTab();
4424
+
4425
+ if (copy.versionlist[copy.versionindex + 1] == null)
4426
+ {
4427
+ java.awt.Toolkit.getDefaultToolkit().beep();
4428
+ return;
4429
+ }
4430
+
4431
+ copy.versionindex += 1;
4432
+
4433
+ CopyChanged();
4434
+
4435
+ //if (!tab.user[tab.versionindex])
4436
+ // tab.graphs[tab.versionindex] = null;
4437
+ }
4438
+
4439
+ void ImportGFD()
4440
+ {
4441
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
4442
+ browser.show();
4443
+ String filename = browser.getFile();
4444
+ if (filename != null && filename.length() > 0)
4445
+ {
4446
+ String fullname = browser.getDirectory() + filename;
4447
+
4448
+ //Object3D readobj =
4449
+ objEditor.ReadGFD(fullname, objEditor);
4450
+ //makeSomething(readobj);
4451
+ }
4452
+ }
4453
+
4454
+ void ImportVRMLX3D()
4455
+ {
4456
+ if (Grafreed.standAlone)
4457
+ {
4458
+ /**/
4459
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
4460
+ browser.show();
4461
+ String filename = browser.getFile();
4462
+ if (filename != null && filename.length() > 0)
4463
+ {
4464
+ String fullname = browser.getDirectory() + filename;
4465
+ LoadVRMLX3D(fullname);
4466
+ }
4467
+ /**/
4468
+ }
4469
+ }
4470
+
32034471 void ToggleAnimation()
32044472 {
32054473 if (!Globals.ANIMATION)
....@@ -3215,8 +4483,8 @@
32154483
32164484 Globals.ANIMATION ^= true;
32174485
3218
- GrafreeD.wav.cursor = 0;
3219
- GrafreeD.wav.loop = 0;
4486
+ Grafreed.wav.cursor = 0;
4487
+ Grafreed.wav.loop = 0;
32204488 }
32214489 } else
32224490 {
....@@ -3237,7 +4505,6 @@
32374505 callee.refreshContents();
32384506 } else
32394507 {
3240
- new Exception().printStackTrace();
32414508 System.exit(0);
32424509 }
32434510 }
....@@ -3267,7 +4534,7 @@
32674534 void CreateMaterial()
32684535 {
32694536 //copy.ClearMaterial(); // PATCH
3270
- copy.CreateMaterialS(multiplyToggle.isSelected());
4537
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32714538 if (copy.selection.size() > 0)
32724539 //SetMaterial(copy);
32734540 {
....@@ -3318,7 +4585,7 @@
33184585 assert false;
33194586 }
33204587
3321
- void EditSelection()
4588
+ void EditSelection(boolean newWindow)
33224589 {
33234590 }
33244591
....@@ -3326,11 +4593,11 @@
33264593 {
33274594 copy.ResetBlockLoop(); // temporary problem
33284595
3329
- boolean random = CameraPane.RANDOM;
3330
- CameraPane.RANDOM = false; // parse everything
4596
+ boolean random = CameraPane.SWITCH;
4597
+ CameraPane.SWITCH = false; // parse everything
33314598 copy.ResetDisplayList();
33324599 copy.HardTouch();
3333
- CameraPane.RANDOM = random;
4600
+ CameraPane.SWITCH = random;
33344601 }
33354602
33364603 // public void applySelf()
....@@ -3377,7 +4644,7 @@
33774644 //copy.material = new cMaterial(copy.GetMaterial());
33784645
33794646 current.color = (float) colorField.getFloat();
3380
- current.modulation = (float) modulationField.getFloat();
4647
+ current.modulation = (float) saturationField.getFloat();
33814648 current.metalness = (float) metalnessField.getFloat();
33824649 current.diffuse = (float) diffuseField.getFloat();
33834650 current.specular = (float) specularField.getFloat();
....@@ -3404,6 +4671,36 @@
34044671 {
34054672 //System.out.println("Propagate = " + propagate);
34064673 copy.UpdateMaterial(anchor, current, propagate);
4674
+
4675
+ if (copy.material != null)
4676
+ {
4677
+ cMaterial mat = copy.material;
4678
+
4679
+ colorField.SetToolTipValue((mat.color));
4680
+ saturationField.SetToolTipValue((mat.modulation));
4681
+ metalnessField.SetToolTipValue((mat.metalness));
4682
+ diffuseField.SetToolTipValue((mat.diffuse));
4683
+ specularField.SetToolTipValue((mat.specular));
4684
+ shininessField.SetToolTipValue((mat.shininess));
4685
+ shiftField.SetToolTipValue((mat.shift));
4686
+ ambientField.SetToolTipValue((mat.ambient));
4687
+ lightareaField.SetToolTipValue((mat.lightarea));
4688
+ diffusenessField.SetToolTipValue((mat.factor));
4689
+ velvetField.SetToolTipValue((mat.velvet));
4690
+ sheenField.SetToolTipValue((mat.sheen));
4691
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4692
+ backlitField.SetToolTipValue((mat.bump));
4693
+ anisoField.SetToolTipValue((mat.aniso));
4694
+ anisoVField.SetToolTipValue((mat.anisoV));
4695
+ cameraField.SetToolTipValue((mat.cameralight));
4696
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4697
+ shadowField.SetToolTipValue((mat.shadow));
4698
+ textureField.SetToolTipValue((mat.texture));
4699
+ opacityField.SetToolTipValue((mat.opacity));
4700
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4701
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
4702
+ }
4703
+
34074704 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34084705 {
34094706 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3432,9 +4729,26 @@
34324729 //copy.Touch();
34334730 }
34344731
4732
+ cNumberSlider versionSlider;
4733
+
34354734 public void stateChanged(ChangeEvent e)
34364735 {
34374736 // assert(false);
4737
+ if (e.getSource() == versionSlider)
4738
+ {
4739
+ if (muteSlider)
4740
+ return;
4741
+
4742
+ int version = versionSlider.getInteger();
4743
+
4744
+ if (copy.versionlist[version] != null)
4745
+ {
4746
+ copy.versionindex = version;
4747
+ CopyChanged();
4748
+ }
4749
+
4750
+ return;
4751
+ }
34384752
34394753 if (freezematerial)
34404754 {
....@@ -3470,6 +4784,12 @@
34704784 {
34714785 //System.out.println("stateChanged = " + this);
34724786 materialtouched = true;
4787
+
4788
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4789
+ {
4790
+ saturationField.setFloat(1);
4791
+ }
4792
+
34734793 applySelf();
34744794 //System.out.println("this = " + this);
34754795 //System.out.println("PARENT = " + parent);
....@@ -3519,7 +4839,7 @@
35194839 }
35204840
35214841 if (normalpushField != null)
3522
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4842
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35234843 }
35244844
35254845 void SnapObject()
....@@ -3769,6 +5089,7 @@
37695089 {
37705090 if (GetTree() != null)
37715091 {
5092
+ GetTree().revalidate();
37725093 GetTree().repaint();
37735094 }
37745095
....@@ -3777,12 +5098,17 @@
37775098 ctrlPanel.validate(); // ? new
37785099 ctrlPanel.repaint();
37795100 }
5101
+
5102
+ if (previousVersionButton != null && copy.versionlist != null)
5103
+ SetUndoStates();
37805104 }
37815105
37825106 static TweenManager tweenManager = new TweenManager();
37835107
37845108 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37855109 {
5110
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5111
+ Save();
37865112 //Tween.set(thing, 0).target(1).start(tweenManager);
37875113 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37885114 // if (thing instanceof GenericJointDemo)
....@@ -3869,6 +5195,12 @@
38695195 {
38705196 ResetModel();
38715197 Select(thing.GetTreePath(), true, false); // unselect... false);
5198
+
5199
+ if (thing.Size() == 0)
5200
+ {
5201
+ //EditSelection(false);
5202
+ }
5203
+
38725204 refreshContents();
38735205 }
38745206
....@@ -3986,6 +5318,7 @@
39865318 }
39875319 }
39885320 }
5321
+
39895322 LoadGFDThread loadGFDThread;
39905323
39915324 void ReadGFD(String fullname, iCallBack cb)
....@@ -4005,8 +5338,10 @@
40055338
40065339 try
40075340 {
5341
+ // Try compressed version first.
40085342 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4009
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5343
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
5344
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40105345
40115346 readobj = (Object3D) p.readObject();
40125347 istream.close();
....@@ -4014,7 +5349,22 @@
40145349 readobj.ResetDisplayList();
40155350 } catch (Exception e)
40165351 {
4017
- e.printStackTrace();
5352
+ if (!e.toString().contains("GZIP"))
5353
+ e.printStackTrace();
5354
+
5355
+ try
5356
+ {
5357
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
5358
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5359
+
5360
+ readobj = (Object3D) p.readObject();
5361
+ istream.close();
5362
+
5363
+ readobj.ResetDisplayList();
5364
+ } catch (Exception e2)
5365
+ {
5366
+ e2.printStackTrace();
5367
+ }
40185368 }
40195369 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40205370 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4060,6 +5410,12 @@
40605410
40615411 void LoadIt(Object obj)
40625412 {
5413
+ if (obj == null)
5414
+ {
5415
+ // Invalid file
5416
+ return;
5417
+ }
5418
+
40635419 System.out.println("Loaded " + obj);
40645420 //new Exception().printStackTrace();
40655421 Object3D readobj = (Object3D) obj;
....@@ -4069,10 +5425,14 @@
40695425
40705426 if (readobj != null)
40715427 {
5428
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5429
+ // Save();
40725430 try
40735431 {
40745432 //readobj.deepCopySelf(copy);
40755433 copy.clear(); // june 2014
5434
+ copy.skyboxname = readobj.skyboxname;
5435
+ copy.skyboxext = readobj.skyboxext;
40765436 for (int i = 0; i < readobj.size(); i++)
40775437 {
40785438 Object3D child = readobj.get(i); // reserve(i);
....@@ -4113,6 +5473,7 @@
41135473 }
41145474 } catch (ClassCastException e)
41155475 {
5476
+ e.printStackTrace();
41165477 assert (false);
41175478 Composite c = (Composite) copy;
41185479 c.children.clear();
....@@ -4123,17 +5484,28 @@
41235484 c.addChild(csg);
41245485 }
41255486
5487
+ copy.versionlist = readobj.versionlist;
5488
+ copy.versionindex = readobj.versionindex;
5489
+
5490
+ if (copy.versionlist == null)
5491
+ {
5492
+ copy.versionlist = new Object3D[100];
5493
+ copy.versionindex = -1;
5494
+ }
5495
+
5496
+ //? SetUndoStates();
5497
+
41265498 ResetModel();
41275499 copy.HardTouch(); // recompile?
41285500 refreshContents();
41295501 }
41305502 }
41315503
4132
- void load() // throws ClassNotFoundException
5504
+ void Open() // throws ClassNotFoundException
41335505 {
4134
- if (GrafreeD.standAlone)
5506
+ if (Grafreed.standAlone)
41355507 {
4136
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5508
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
41375509 browser.show();
41385510 String filename = browser.getFile();
41395511 if (filename != null && filename.length() > 0)
....@@ -4218,11 +5590,13 @@
42185590 try
42195591 {
42205592 FileOutputStream ostream = new FileOutputStream(lastname);
4221
- ObjectOutputStream p = new ObjectOutputStream(ostream);
5593
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5594
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42225595
42235596 p.writeObject(copy);
42245597 p.flush();
42255598
5599
+ zstream.close();
42265600 ostream.close();
42275601
42285602 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4230,19 +5604,23 @@
42305604 //ps.print(buffer.toString());
42315605 } catch (IOException e)
42325606 {
5607
+ e.printStackTrace();
42335608 }
42345609 }
5610
+
42355611 String lastname;
42365612
42375613 void saveAs()
42385614 {
4239
- if (GrafreeD.standAlone)
5615
+ if (Grafreed.standAlone)
42405616 {
42415617 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42425618 browser.setVisible(true);
42435619 String filename = browser.getFile();
42445620 if (filename != null && filename.length() > 0)
42455621 {
5622
+ if (!filename.endsWith(".gfd"))
5623
+ filename += ".gfd";
42465624 lastname = browser.getDirectory() + filename;
42475625 save();
42485626 }
....@@ -4341,13 +5719,13 @@
43415719 try
43425720 {
43435721 FileOutputStream ostream = new FileOutputStream(filename);
4344
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4345
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
5722
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5723
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43465724
43475725 Object3D objectparent = obj.parent;
43485726 obj.parent = null;
43495727
4350
- Object3D object = (Object3D) GrafreeD.clone(obj);
5728
+ Object3D object = (Object3D) Grafreed.clone(obj);
43515729
43525730 obj.parent = objectparent;
43535731
....@@ -4359,8 +5737,8 @@
43595737 p.writeObject(object);
43605738 p.flush();
43615739
5740
+ zstream.close();
43625741 ostream.close();
4363
- // zstream.close();
43645742
43655743 // group.selection.get(0).parent = parent;
43665744 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4381,7 +5759,7 @@
43815759 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43825760 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43835761 copy.generatePOV(buffer);
4384
- if (GrafreeD.standAlone)
5762
+ if (Grafreed.standAlone)
43855763 {
43865764 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43875765 browser.show();
....@@ -4407,19 +5785,18 @@
44075785 Object3D client;
44085786 Object3D copy;
44095787 MenuBar menuBar;
4410
- Menu windowMenu;
4411
- MenuItem loadItem;
5788
+ Menu fileMenu;
5789
+ MenuItem newItem;
5790
+ MenuItem openItem;
44125791 MenuItem saveItem;
44135792 MenuItem saveAsItem;
44145793 MenuItem exportAsItem;
44155794 MenuItem reexportItem;
44165795 MenuItem povItem;
44175796 MenuItem closeItem;
4418
- Menu cameraMenu;
5797
+
44195798 CheckboxMenuItem zBufferItem;
44205799 //MenuItem normalLensItem;
4421
- MenuItem editCameraItem;
4422
- MenuItem revertCameraItem;
44235800 MenuItem stepItem;
44245801 CheckboxMenuItem toggleLiveItem;
44255802 CheckboxMenuItem toggleFullScreenItem;
....@@ -4430,25 +5807,40 @@
44305807 CheckboxMenuItem toggleFootContactItem;
44315808 CheckboxMenuItem toggleDLItem;
44325809 CheckboxMenuItem toggleTextureItem;
4433
- CheckboxMenuItem toggleRandomItem;
5810
+ CheckboxMenuItem toggleSwitchItem;
44345811 CheckboxMenuItem toggleRootItem;
44355812 CheckboxMenuItem animationItem;
5813
+ MenuItem archiveItem;
44365814 CheckboxMenuItem toggleHandleItem;
44375815 CheckboxMenuItem togglePaintItem;
44385816 JSplitPane mainPanel;
44395817 JScrollPane scrollpane;
5818
+
44405819 JPanel toolbarPanel;
5820
+
44415821 cGridBag treePanel;
5822
+
44425823 JPanel radioPanel;
44435824 ButtonGroup buttonGroup;
4444
- cGridBag ctrlPanel;
5825
+
5826
+ cGridBag toolboxPanel;
5827
+ cGridBag skyboxPanel;
44455828 cGridBag materialPanel;
5829
+ cGridBag ctrlPanel;
5830
+
44465831 JScrollPane infoPanel;
5832
+
44475833 cGridBag optionsPanel;
5834
+
44485835 JTabbedPane objectPanel;
5836
+ boolean materialFlushed;
5837
+ Object3D latestObject;
5838
+
44495839 cGridBag XYZPanel;
5840
+
44505841 JSplitPane gridPanel;
44515842 JSplitPane bigPanel;
5843
+
44525844 cGridBag bigThree;
44535845 cGridBag scenePanel;
44545846 cGridBag centralPanel;
....@@ -4506,7 +5898,7 @@
45065898 JLabel colorLabel;
45075899 cNumberSlider colorField;
45085900 JLabel modulationLabel;
4509
- cNumberSlider modulationField;
5901
+ cNumberSlider saturationField;
45105902 JLabel metalnessLabel;
45115903 cNumberSlider metalnessField;
45125904 JLabel diffuseLabel;
....@@ -4537,6 +5929,7 @@
45375929 cNumberSlider anisoField;
45385930 JLabel anisoVLabel;
45395931 cNumberSlider anisoVField;
5932
+
45405933 JLabel cameraLabel;
45415934 cNumberSlider cameraField;
45425935 JLabel selfshadowLabel;
....@@ -4551,6 +5944,7 @@
45515944 cNumberSlider fakedepthField;
45525945 JLabel shadowbiasLabel;
45535946 cNumberSlider shadowbiasField;
5947
+
45545948 JLabel bumpLabel;
45555949 cNumberSlider bumpField;
45565950 JLabel noiseLabel;
....@@ -4563,8 +5957,13 @@
45635957 cNumberSlider fogField;
45645958 JLabel opacityPowerLabel;
45655959 cNumberSlider opacityPowerField;
4566
- JTree jTree;
5960
+ cTree jTree;
45675961 //ObjectUI parent;
45685962
45695963 cNumberSlider normalpushField;
5964
+
5965
+ private MenuItem importGFDItem;
5966
+ private MenuItem importVRMLX3DItem;
5967
+ private MenuItem import3DSItem;
5968
+ private MenuItem importOBJItem;
45705969 }