Normand Briere
2019-08-12 8f1afe25ea8fc8801aab66331c32a50859a758c2
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,14 @@
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
+// callee.Save(true);
306
+// }
307
+
218308 // "this" is not called: SetupUI2(objEditor);
219309 }
220310
....@@ -228,6 +318,14 @@
228318 client = inClient;
229319 copy = client;
230320
321
+ if (copy.versionlist == null)
322
+ {
323
+ copy.versionlist = new Object3D[100];
324
+ copy.versionindex = -1;
325
+
326
+// Save(true);
327
+ }
328
+
231329 SetupUI2(callee.GetEditor());
232330 }
233331
....@@ -242,6 +340,7 @@
242340 //localCopy.parent = null;
243341
244342 frame = new JFrame();
343
+ frame.setUndecorated(false);
245344 objEditor = this;
246345 this.callee = callee;
247346
....@@ -259,6 +358,14 @@
259358 copy = localCopy;
260359 copy.editWindow = this;
261360
361
+// if (copy.versionlist == null)
362
+// {
363
+// copy.versionlist = new Object3D[100];
364
+// copy.versionindex = -1;
365
+//
366
+// Save(true);
367
+// }
368
+
262369 SetupMenu();
263370
264371 //SetupName(objEditor); // new
....@@ -272,28 +379,49 @@
272379 return frame.action(event, obj);
273380 }
274381
382
+ // Cannot work without static
383
+ static boolean allparams = true;
384
+
385
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
386
+
275387 void SetupMenu()
276388 {
277389 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..."));
390
+ menuBar.add(fileMenu = new Menu("File"));
391
+ fileMenu.add(newItem = new MenuItem("New"));
392
+ fileMenu.add(openItem = new MenuItem("Open..."));
393
+
394
+ //oe.menuBar.add(menu = new Menu("Include"));
395
+ Menu menu = new Menu("Import");
396
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
397
+ importOBJItem.addActionListener(this);
398
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
399
+ import3DSItem.addActionListener(this);
400
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
401
+ importVRMLX3DItem.addActionListener(this);
402
+ menu.add("-");
403
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
404
+ importGFDItem.addActionListener(this);
405
+ fileMenu.add(menu);
406
+ fileMenu.add("-");
407
+
408
+ fileMenu.add(saveItem = new MenuItem("Save"));
409
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
283410 //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("-");
411
+ fileMenu.add("-");
412
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
413
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
414
+ fileMenu.add("-");
288415 if (client.parent != null)
289416 {
290
- windowMenu.add(closeItem = new MenuItem("Close"));
417
+ fileMenu.add(closeItem = new MenuItem("Close"));
291418 } else
292419 {
293
- windowMenu.add(closeItem = new MenuItem("Exit"));
420
+ fileMenu.add(closeItem = new MenuItem("Exit"));
294421 }
295422
296
- loadItem.addActionListener(this);
423
+ newItem.addActionListener(this);
424
+ openItem.addActionListener(this);
297425 saveItem.addActionListener(this);
298426 saveAsItem.addActionListener(this);
299427 exportAsItem.addActionListener(this);
....@@ -301,84 +429,71 @@
301429 //povItem.addActionListener(this);
302430 closeItem.addActionListener(this);
303431
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
-
359432 objectPanel = new JTabbedPane();
433
+
434
+ ChangeListener changeListener = new ChangeListener()
435
+ {
436
+ public void stateChanged(ChangeEvent changeEvent)
437
+ {
438
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
439
+// {
440
+// if (latestObject != null)
441
+// {
442
+// refreshContents(true);
443
+// SetMaterial(latestObject);
444
+// }
445
+//
446
+// materialFlushed = true;
447
+// }
448
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
449
+// {
450
+// if (listUI.size() == 0)
451
+// EditSelection(false);
452
+// }
453
+
454
+// refreshContents(false); // To refresh Info tab
455
+ }
456
+ };
457
+ objectPanel.addChangeListener(changeListener);
458
+
360459 toolbarPanel = new JPanel();
361460 toolbarPanel.setName("Toolbar");
461
+
362462 treePanel = new cGridBag();
363463 treePanel.setName("Tree");
464
+
465
+ editPanel = new cGridBag().setVertical(true);
466
+ //editPanel.setName("Edit");
467
+
364468 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
365
- ctrlPanel.setName("Edit");
366
- materialPanel = new cGridBag().setVertical(true);
367
- materialPanel.setName("Material");
469
+
470
+ editCommandsPanel = new cGridBag();
471
+ editPanel.add(editCommandsPanel);
472
+ editPanel.add(ctrlPanel);
473
+
474
+ toolboxPanel = new cGridBag().setVertical(true);
475
+ //toolboxPanel.setName("Toolbox");
476
+
477
+ skyboxPanel = new cGridBag().setVertical(true);
478
+
479
+ materialPanel = new cGridBag().setVertical(false);
480
+ //materialPanel.setName("Material");
481
+
368482 /*JTextPane*/
369483 infoarea = createTextPane();
370484 doc = infoarea.getStyledDocument();
371485
372486 infoarea.setEditable(true);
373487 SetText();
488
+
374489 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
375490 // infoarea.setOpaque(false);
376491 // //infoarea.setForeground(textcolor);
377492 // TEXTAREA infoarea.setLineWrap(true);
378493 // TEXTAREA infoarea.setWrapStyleWord(true);
379494 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");
495
+ infoPanel.setPreferredSize(new Dimension(1, 1));
496
+ //infoPanel.setName("Info");
382497 //infoPanel.setLayout(new BorderLayout());
383498 //infoPanel.add(createTextPane());
384499
....@@ -389,7 +504,14 @@
389504 mainPanel.setDividerSize(9);
390505 mainPanel.setDividerLocation(0.5); //1.0);
391506 mainPanel.setResizeWeight(0.5);
392
-
507
+
508
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
509
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
510
+ divider.setDividerSize(15);
511
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
512
+
513
+ mainPanel.setUI(new BasicSplitPaneUI());
514
+
393515 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
394516 //mainPanel.setLayout(new GridBagLayout());
395517 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -457,10 +579,10 @@
457579 e.printStackTrace();
458580 }
459581
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();
582
+// String selection = infoarea.getText();
583
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
584
+// java.awt.datatransfer.Clipboard clipboard =
585
+// Toolkit.getDefaultToolkit().getSystemClipboard();
464586 //clipboard.setContents(data, data);
465587 }
466588
....@@ -483,13 +605,13 @@
483605 //SendInfo("Name:", "bold");
484606 if (sel.GetTextures() != null || debug)
485607 {
486
- si.SendInfo(sel.toString(), "bold");
608
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
487609 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
488610 if (sel.Size() > 0)
489611 {
490612 si.SendInfo("#children = " + sel.Size(), "regular");
491613 }
492
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
614
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
493615 if (debug)
494616 {
495617 try
....@@ -531,7 +653,7 @@
531653 }
532654 if (sel.support != null)
533655 {
534
- si.SendInfo(" support: " + sel.support, "regular");
656
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
535657 }
536658 if (sel.scriptnode != null)
537659 {
....@@ -620,21 +742,158 @@
620742 }
621743 }
622744
745
+//static GraphicsDevice device = GraphicsEnvironment
746
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
747
+
748
+ Rectangle keeprect;
749
+ cRadio radio;
750
+
751
+cButton keepButton;
752
+ cButton twoButton; // Full 3D
753
+ cButton sixButton;
754
+ cButton threeButton;
755
+ cButton sevenButton;
756
+ cButton fourButton; // full panel
757
+ cButton oneButton; // full XYZ
758
+ //cButton currentLayout;
759
+
760
+ boolean maximized;
761
+
762
+ cButton fullscreenLayout;
763
+ cButton expandedLayout;
764
+
765
+ void Minimize()
766
+ {
767
+ frame.setState(Frame.ICONIFIED);
768
+ frame.validate();
769
+ }
770
+
771
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
772
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
773
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
774
+ void Maximize()
775
+ {
776
+ if (CameraPane.FULLSCREEN)
777
+ {
778
+ ToggleFullScreen();
779
+ }
780
+
781
+ if (maximized)
782
+ {
783
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
784
+ }
785
+ else
786
+ {
787
+ keeprect = frame.getBounds();
788
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
789
+// Dimension rect2 = frame.getToolkit().getScreenSize();
790
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
791
+// frame.setState(Frame.MAXIMIZED_BOTH);
792
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
793
+ }
794
+
795
+ maximized ^= true;
796
+
797
+ frame.validate();
798
+ }
799
+
800
+ cButton minButton;
801
+ cButton maxButton;
802
+ cButton fullButton;
803
+ cButton collapseButton;
804
+ cButton maximize3DButton;
805
+
623806 void ToggleFullScreen()
624807 {
625
- if (CameraPane.FULLSCREEN)
808
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
809
+
810
+ cameraView.ToggleFullScreen();
811
+
812
+ if (!CameraPane.FULLSCREEN)
626813 {
627
- frame.getContentPane().remove(/*"Center",*/bigThree);
628
- framePanel.add(bigThree);
629
- frame.getContentPane().add(/*"Center",*/framePanel);
814
+ device.setFullScreenWindow(null);
815
+ frame.dispose();
816
+ frame.setUndecorated(false);
817
+ frame.validate();
818
+ frame.setVisible(true);
819
+
820
+ //frame.setVisible(false);
821
+// frame.removeNotify();
822
+// frame.setUndecorated(false);
823
+// frame.addNotify();
824
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
825
+
826
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
827
+// X framePanel.add(bigThree);
828
+// X frame.getContentPane().add(/*"Center",*/framePanel);
829
+// framePanel.setDividerLocation(46); // icons are 24x24
830
+
831
+ //frame.setVisible(true);
832
+// radio.layout = keepButton;
833
+ //theFrame = null;
834
+ keepButton = null;
835
+// radio.layout.doClick();
836
+
630837 } else
631838 {
632
- frame.getContentPane().remove(/*"Center",*/framePanel);
633
- framePanel.remove(bigThree);
634
- frame.getContentPane().add(/*"Center",*/bigThree);
839
+ keepButton = radio.layout;
840
+ //keeprect = frame.getBounds();
841
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
842
+// frame.getToolkit().getScreenSize().height);
843
+ //frame.setVisible(false);
844
+
845
+ frame.dispose();
846
+ frame.setUndecorated(true);
847
+ device.setFullScreenWindow(frame);
848
+ frame.validate();
849
+ frame.setVisible(true);
850
+// frame.removeNotify();
851
+// frame.setUndecorated(true);
852
+// frame.addNotify();
853
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
854
+// X framePanel.remove(bigThree);
855
+// X frame.getContentPane().add(/*"Center",*/bigThree);
856
+// framePanel.setDividerLocation(0);
857
+
858
+// radio.layout = fullscreenLayout;
859
+// radio.layout.doClick();
860
+ //frame.setVisible(true);
635861 }
636
- cameraView.ToggleFullScreen();
862
+ frame.validate();
863
+
864
+ cameraView.requestFocusInWindow();
637865 }
866
+
867
+ void CollapseToolbar()
868
+ {
869
+ framePanel.setDividerLocation(0);
870
+ //frame.validate();
871
+
872
+ cameraView.requestFocusInWindow();
873
+ }
874
+
875
+ private Object3D Duplicate(Object3D object)
876
+ {
877
+ boolean temp = CameraPane.SWITCH;
878
+ CameraPane.SWITCH = false;
879
+
880
+ object.ExtractBigData(versiontable);
881
+ // if (copy == client)
882
+
883
+ Object3D versions[] = object.versionlist;
884
+ object.versionlist = null;
885
+
886
+ //byte[] compress = Compress(copy);
887
+ Object3D compress = (Object3D)Grafreed.clone(object);
888
+
889
+ object.versionlist = versions;
890
+
891
+ object.RestoreBigData(versiontable);
892
+
893
+ CameraPane.SWITCH = temp;
894
+
895
+ return compress;
896
+ }
638897
639898 private JTextPane createTextPane()
640899 {
....@@ -734,7 +993,7 @@
734993 protected static ImageIcon createImageIcon(String path,
735994 String description)
736995 {
737
- java.net.URL imgURL = GrafreeD.class.getResource(path);
996
+ java.net.URL imgURL = Grafreed.class.getResource(path);
738997 if (imgURL != null)
739998 {
740999 return new ImageIcon(imgURL, description);
....@@ -757,6 +1016,7 @@
7571016 {
7581017 SetupMaterial(materialPanel);
7591018 }
1019
+
7601020 //SetupName();
7611021 //SetupViews();
7621022 }
....@@ -766,6 +1026,7 @@
7661026 // NumberSlider vDivsField;
7671027 // JCheckBox endcaps;
7681028 JCheckBox liveCB;
1029
+ JCheckBox selectableCB;
7691030 JCheckBox hideCB;
7701031 JCheckBox link2masterCB;
7711032 JCheckBox markCB;
....@@ -773,7 +1034,12 @@
7731034 JCheckBox speedupCB;
7741035 JCheckBox rewindCB;
7751036 JCheckBox flipVCB;
1037
+
1038
+ cCheckBox toggleTextureCB;
1039
+ cCheckBox toggleSwitchCB;
1040
+
7761041 JComboBox texresMenu;
1042
+
7771043 JButton resetButton;
7781044 JButton stepButton;
7791045 JButton stepAllButton;
....@@ -782,9 +1048,13 @@
7821048 JButton fasterButton;
7831049 JButton remarkButton;
7841050
1051
+ cGridBag editPanel;
1052
+ cGridBag editCommandsPanel;
1053
+
7851054 cGridBag namePanel;
7861055 cGridBag setupPanel;
787
- cGridBag commandsPanel;
1056
+ cGridBag setupPanel2;
1057
+ cGridBag objectCommandsPanel;
7881058 cGridBag pushPanel;
7891059 cGridBag fillPanel;
7901060
....@@ -951,52 +1221,88 @@
9511221
9521222 void SetupUI2(ObjEditor oe)
9531223 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
9581224 //SetupName(oe);
9591225
9601226 namePanel = new cGridBag();
9611227
1228
+ //if (copy.pinned)
1229
+ {
1230
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1231
+ pinButton.setSelected(copy.pinned);
1232
+ cGridBag t = new cGridBag();
1233
+ t.preferredWidth = 2;
1234
+ t.add(pinButton);
1235
+ namePanel.add(t);
1236
+
1237
+ pinButton.addItemListener(this);
1238
+ }
1239
+
9621240 nameField = AddText(namePanel, copy.GetName());
963
- namePanel.add(nameField);
1241
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9641242 oe.ctrlPanel.add(namePanel);
9651243
9661244 oe.ctrlPanel.Return();
9671245
968
- if (!GroupEditor.allparams)
1246
+ if (!allparams)
9691247 return;
9701248
9711249 setupPanel = new cGridBag().setVertical(false);
9721250
9731251 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
974
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
975
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1252
+ liveCB.setToolTipText("Animate object");
1253
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1254
+ selectableCB.setToolTipText("Make object selectable");
9761255 // Return();
1256
+
1257
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1258
+ hideCB.setToolTipText("Hide object");
9771259 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
978
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
979
- randomCB = AddCheckBox(setupPanel, "Rand", copy.random);
1260
+ markCB.setToolTipText("As animation target transform");
1261
+
1262
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1263
+
1264
+ setupPanel2 = new cGridBag().setVertical(false);
1265
+
1266
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1267
+ rewindCB.setToolTipText("Rewind animation");
1268
+
1269
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1270
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9801271
1272
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1273
+ link2masterCB.setToolTipText("Attach to support");
1274
+
1275
+ if (Globals.ADVANCED)
1276
+ {
1277
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1278
+ speedupCB.setToolTipText("Option motion capture");
1279
+ }
1280
+
9811281 oe.ctrlPanel.add(setupPanel);
9821282 oe.ctrlPanel.Return();
1283
+ oe.ctrlPanel.add(setupPanel2);
1284
+ oe.ctrlPanel.Return();
9831285
984
- commandsPanel = new cGridBag().setVertical(false);
1286
+ objectCommandsPanel = new cGridBag().setVertical(false);
9851287
986
- resetButton = AddButton(commandsPanel, "Reset");
987
- stepButton = AddButton(commandsPanel, "Step");
1288
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1289
+ resetButton.setToolTipText("Jump to frame zero");
1290
+ stepButton = AddButton(objectCommandsPanel, "Step");
1291
+ stepButton.setToolTipText("Step one frame");
9881292 // resetAllButton = AddButton(oe, "Reset All");
9891293 // stepAllButton = AddButton(oe, "Step All");
990
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
9911294 // Return();
992
- slowerButton = AddButton(commandsPanel, "Slow");
993
- fasterButton = AddButton(commandsPanel, "Fast");
994
- remarkButton = AddButton(commandsPanel, "Remark");
1295
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1296
+ slowerButton.setToolTipText("Decrease animation speed");
1297
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1298
+ fasterButton.setToolTipText("Increase animation speed");
1299
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1300
+ remarkButton.setToolTipText("Set the current transform as the target");
9951301
996
- oe.ctrlPanel.add(commandsPanel);
1302
+ oe.ctrlPanel.add(objectCommandsPanel);
9971303 oe.ctrlPanel.Return();
9981304
999
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1305
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
10001306 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
10011307 //Return();
10021308
....@@ -1199,8 +1505,11 @@
11991505 //worldPanel.setName("World");
12001506 centralPanel = new cGridBag();
12011507 centralPanel.preferredWidth = 20;
1202
- timelinePanel = new JPanel(new BorderLayout());
1203
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1508
+
1509
+ if (Globals.ADVANCED)
1510
+ {
1511
+ timelinePanel = new JPanel(new BorderLayout());
1512
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
12041513
12051514 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
12061515 cameraPanel.setContinuousLayout(true);
....@@ -1209,7 +1518,10 @@
12091518 // cameraPanel.setDividerSize(9);
12101519 cameraPanel.setResizeWeight(1.0);
12111520
1521
+ }
1522
+
12121523 centralPanel.add(cameraView);
1524
+ centralPanel.setFocusable(true);
12131525 //frame.setJMenuBar(timelineMenubar);
12141526 //centralPanel.add(timelinePanel);
12151527
....@@ -1235,6 +1547,7 @@
12351547 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12361548 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12371549 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1550
+ //XYZPanel.setName("XYZ");
12381551
12391552 /*
12401553 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1272,13 +1585,29 @@
12721585 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12731586 //tmp.setName("Edit");
12741587 objectPanel.add(materialPanel);
1588
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1589
+ objectPanel.setToolTipTextAt(0, "Material");
1590
+
1591
+ objectPanel.add(toolboxPanel);
1592
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1593
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1594
+
1595
+ objectPanel.add(skyboxPanel);
1596
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1597
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1598
+
12751599 // JPanel north = new JPanel(new BorderLayout());
12761600 // north.setName("Edit");
12771601 // north.add(ctrlPanel, BorderLayout.NORTH);
12781602 // objectPanel.add(north);
1279
- objectPanel.add(ctrlPanel);
1280
- objectPanel.add(infoPanel);
1281
-
1603
+ objectPanel.add(editPanel);
1604
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1605
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1606
+
1607
+ objectPanel.add(XYZPanel);
1608
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1609
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1610
+
12821611 /*
12831612 aConstraints.gridx = 0;
12841613 aConstraints.gridwidth = 1;
....@@ -1286,7 +1615,7 @@
12861615 aConstraints.gridy += 1;
12871616 aConstraints.gridwidth = 1;
12881617 mainPanel.add(objectPanel, aConstraints);
1289
- */
1618
+ */
12901619
12911620 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12921621 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1298,14 +1627,12 @@
12981627 scrollpane.addMouseWheelListener(this); // Default not fast enough
12991628
13001629 /*JTabbedPane*/ scenePanel = new cGridBag();
1301
- scenePanel.preferredWidth = 7;
1630
+ scenePanel.preferredWidth = 5;
13021631
13031632 JTabbedPane tabbedPane = new JTabbedPane();
13041633 tabbedPane.add(scrollpane);
13051634
1306
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1307
-
1308
- optionsPanel = new cGridBag().setVertical(true);
1635
+ optionsPanel = new cGridBag().setVertical(false);
13091636
13101637 optionsPanel.setName("Options");
13111638
....@@ -1313,8 +1640,15 @@
13131640
13141641 tabbedPane.add(optionsPanel);
13151642
1643
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1644
+
13161645 scenePanel.add(tabbedPane);
13171646
1647
+ //if (Globals.ADVANCED)
1648
+ tabbedPane.add(infoPanel);
1649
+ tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1650
+ tabbedPane.setToolTipTextAt(3, "Information");
1651
+
13181652 /*
13191653 cTree jTree = new cTree(null);
13201654 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1376,7 +1710,7 @@
13761710 bigThree = new cGridBag();
13771711 bigThree.addComponent(scenePanel);
13781712 bigThree.addComponent(centralPanel);
1379
- bigThree.addComponent(XYZPanel);
1713
+ //bigThree.addComponent(XYZPanel);
13801714
13811715 // // SIDE EFFECT!!!
13821716 // aConstraints.gridx = 0;
....@@ -1385,9 +1719,26 @@
13851719 // aConstraints.gridheight = 1;
13861720
13871721 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1388
- framePanel.setContinuousLayout(true);
1389
- framePanel.setOneTouchExpandable(true);
1390
- framePanel.setDividerLocation(0.8);
1722
+
1723
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1724
+ new java.beans.PropertyChangeListener()
1725
+ {
1726
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1727
+ {
1728
+ if ((Integer)pce.getOldValue() == 1)
1729
+ {
1730
+ if (radio.layout != expandedLayout)
1731
+ {
1732
+ radio.layout = expandedLayout;
1733
+ radio.layout.doClick();
1734
+ }
1735
+ }
1736
+ }
1737
+ });
1738
+
1739
+ framePanel.setContinuousLayout(false);
1740
+ framePanel.setOneTouchExpandable(false);
1741
+ //.setDividerLocation(0.8);
13911742 //framePanel.setDividerSize(15);
13921743 //framePanel.setResizeWeight(0.15);
13931744 framePanel.setName("Frame");
....@@ -1404,15 +1755,19 @@
14041755
14051756 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14061757
1407
- frame.setSize(1024, 768);
1408
- frame.show();
1409
-
1758
+ frame.setSize(1280, 860);
1759
+
1760
+ cameraView.requestFocusInWindow();
1761
+
14101762 gridPanel.setDividerLocation(1.0);
1763
+
1764
+ frame.validate();
1765
+
1766
+ frame.setVisible(true);
14111767
14121768 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14131769 frame.addWindowListener(new WindowAdapter()
14141770 {
1415
-
14161771 public void windowClosing(WindowEvent e)
14171772 {
14181773 Close();
....@@ -1435,28 +1790,422 @@
14351790 ctrlPanel.removeAll();
14361791 }
14371792
1438
- void SetupMaterial(cGridBag panel)
1793
+ void SetupMaterial(cGridBag materialpanel)
14391794 {
1440
- /*
1795
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1796
+
1797
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1798
+ skin.setToolTipText("Skin");
1799
+ skin.addMouseListener(new MouseAdapter()
1800
+ {
1801
+ public void mouseClicked(MouseEvent e)
1802
+ {
1803
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1804
+ cMaterial material = object.material;
1805
+
1806
+ // Skin
1807
+ colorField.setFloat(material.color);
1808
+ saturationField.setFloat(material.modulation);
1809
+ subsurfaceField.setFloat(material.subsurface);
1810
+ selfshadowField.setFloat(material.diffuseness);
1811
+ diffusenessField.setFloat(material.factor);
1812
+ shininessField.setFloat(material.shininess);
1813
+ shadowbiasField.setFloat(material.shadowbias);
1814
+ diffuseField.setFloat(material.diffuse);
1815
+ specularField.setFloat(material.specular);
1816
+
1817
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1818
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1819
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1820
+
1821
+ materialtouched = true;
1822
+ applySelf();
1823
+ }
1824
+ });
1825
+ presetpanel.add(skin);
1826
+
1827
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1828
+ lambert.setToolTipText("Diffuse");
1829
+ lambert.addMouseListener(new MouseAdapter()
1830
+ {
1831
+ public void mouseClicked(MouseEvent e)
1832
+ {
1833
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1834
+ cMaterial material = object.material;
1835
+
1836
+ diffusenessField.setFloat(material.factor);
1837
+ selfshadowField.setFloat(material.diffuseness);
1838
+
1839
+ materialtouched = true;
1840
+ applySelf();
1841
+ }
1842
+ });
1843
+ presetpanel.add(lambert);
1844
+
1845
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1846
+ diffuse2.setToolTipText("Diffuse2");
1847
+ diffuse2.addMouseListener(new MouseAdapter()
1848
+ {
1849
+ public void mouseClicked(MouseEvent e)
1850
+ {
1851
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1852
+ cMaterial material = object.material;
1853
+
1854
+ diffusenessField.setFloat(material.factor);
1855
+ selfshadowField.setFloat(material.diffuseness);
1856
+
1857
+ materialtouched = true;
1858
+ applySelf();
1859
+ }
1860
+ });
1861
+ presetpanel.add(diffuse2);
1862
+
1863
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1864
+ diffusemoon.setToolTipText("Moon");
1865
+ diffusemoon.addMouseListener(new MouseAdapter()
1866
+ {
1867
+ public void mouseClicked(MouseEvent e)
1868
+ {
1869
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1870
+ cMaterial material = object.material;
1871
+
1872
+ diffusenessField.setFloat(material.factor);
1873
+ selfshadowField.setFloat(material.diffuseness);
1874
+
1875
+ materialtouched = true;
1876
+ applySelf();
1877
+ }
1878
+ });
1879
+ presetpanel.add(diffusemoon);
1880
+
1881
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1882
+ diffusemoon2.setToolTipText("Moon2");
1883
+ diffusemoon2.addMouseListener(new MouseAdapter()
1884
+ {
1885
+ public void mouseClicked(MouseEvent e)
1886
+ {
1887
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1888
+ cMaterial material = object.material;
1889
+
1890
+ diffusenessField.setFloat(material.factor);
1891
+ selfshadowField.setFloat(material.diffuseness);
1892
+
1893
+ materialtouched = true;
1894
+ applySelf();
1895
+ }
1896
+ });
1897
+ presetpanel.add(diffusemoon2);
1898
+
1899
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1900
+ diffusemoon3.setToolTipText("Moon3");
1901
+ diffusemoon3.addMouseListener(new MouseAdapter()
1902
+ {
1903
+ public void mouseClicked(MouseEvent e)
1904
+ {
1905
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1906
+ cMaterial material = object.material;
1907
+
1908
+ diffusenessField.setFloat(material.factor);
1909
+ selfshadowField.setFloat(material.diffuseness);
1910
+
1911
+ materialtouched = true;
1912
+ applySelf();
1913
+ }
1914
+ });
1915
+ presetpanel.add(diffusemoon3);
1916
+
1917
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1918
+ diffusesheen.setToolTipText("Sheen");
1919
+ diffusesheen.addMouseListener(new MouseAdapter()
1920
+ {
1921
+ public void mouseClicked(MouseEvent e)
1922
+ {
1923
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1924
+ cMaterial material = object.material;
1925
+
1926
+ sheenField.setFloat(material.sheen);
1927
+
1928
+ materialtouched = true;
1929
+ applySelf();
1930
+ }
1931
+ });
1932
+ presetpanel.add(diffusesheen);
1933
+
1934
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1935
+ rough.setToolTipText("Rough metal");
1936
+ rough.addMouseListener(new MouseAdapter()
1937
+ {
1938
+ public void mouseClicked(MouseEvent e)
1939
+ {
1940
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1941
+ cMaterial material = object.material;
1942
+
1943
+ shininessField.setFloat(material.shininess);
1944
+ velvetField.setFloat(material.velvet);
1945
+
1946
+ materialtouched = true;
1947
+ applySelf();
1948
+ }
1949
+ });
1950
+ presetpanel.add(rough);
1951
+
1952
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
1953
+ rough2.setToolTipText("Medium metal");
1954
+ rough2.addMouseListener(new MouseAdapter()
1955
+ {
1956
+ public void mouseClicked(MouseEvent e)
1957
+ {
1958
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
1959
+ cMaterial material = object.material;
1960
+
1961
+ shininessField.setFloat(material.shininess);
1962
+ lightareaField.setFloat(material.lightarea);
1963
+
1964
+ materialtouched = true;
1965
+ applySelf();
1966
+ }
1967
+ });
1968
+ presetpanel.add(rough2);
1969
+
1970
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
1971
+ shini0.setToolTipText("Shiny");
1972
+ shini0.addMouseListener(new MouseAdapter()
1973
+ {
1974
+ public void mouseClicked(MouseEvent e)
1975
+ {
1976
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
1977
+ cMaterial material = object.material;
1978
+
1979
+ shininessField.setFloat(material.shininess);
1980
+ lightareaField.setFloat(material.lightarea);
1981
+
1982
+ materialtouched = true;
1983
+ applySelf();
1984
+ }
1985
+ });
1986
+ presetpanel.add(shini0);
1987
+
1988
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
1989
+ shini1.setToolTipText("Shiny2");
1990
+ shini1.addMouseListener(new MouseAdapter()
1991
+ {
1992
+ public void mouseClicked(MouseEvent e)
1993
+ {
1994
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
1995
+ cMaterial material = object.material;
1996
+
1997
+ shininessField.setFloat(material.shininess);
1998
+ lightareaField.setFloat(material.lightarea);
1999
+
2000
+ materialtouched = true;
2001
+ applySelf();
2002
+ }
2003
+ });
2004
+ presetpanel.add(shini1);
2005
+
2006
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2007
+ shini2.setToolTipText("Shiny3");
2008
+ shini2.addMouseListener(new MouseAdapter()
2009
+ {
2010
+ public void mouseClicked(MouseEvent e)
2011
+ {
2012
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2013
+ cMaterial material = object.material;
2014
+
2015
+ shininessField.setFloat(material.shininess);
2016
+ lightareaField.setFloat(material.lightarea);
2017
+
2018
+ materialtouched = true;
2019
+ applySelf();
2020
+ }
2021
+ });
2022
+ presetpanel.add(shini2);
2023
+
2024
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2025
+ aniso.setToolTipText("AnisoU");
2026
+ aniso.addMouseListener(new MouseAdapter()
2027
+ {
2028
+ public void mouseClicked(MouseEvent e)
2029
+ {
2030
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2031
+ cMaterial material = object.material;
2032
+
2033
+ anisoField.setFloat(material.aniso);
2034
+ anisoVField.setFloat(material.anisoV);
2035
+
2036
+ materialtouched = true;
2037
+ applySelf();
2038
+ }
2039
+ });
2040
+ presetpanel.add(aniso);
2041
+
2042
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2043
+ aniso2.setToolTipText("AnisoV");
2044
+ aniso2.addMouseListener(new MouseAdapter()
2045
+ {
2046
+ public void mouseClicked(MouseEvent e)
2047
+ {
2048
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2049
+ cMaterial material = object.material;
2050
+
2051
+ anisoField.setFloat(material.aniso);
2052
+ anisoVField.setFloat(material.anisoV);
2053
+
2054
+ materialtouched = true;
2055
+ applySelf();
2056
+ }
2057
+ });
2058
+ presetpanel.add(aniso2);
2059
+
2060
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2061
+ aniso3.setToolTipText("AnisoUV");
2062
+ aniso3.addMouseListener(new MouseAdapter()
2063
+ {
2064
+ public void mouseClicked(MouseEvent e)
2065
+ {
2066
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2067
+ cMaterial material = object.material;
2068
+
2069
+ anisoField.setFloat(material.aniso);
2070
+ anisoVField.setFloat(material.anisoV);
2071
+
2072
+ materialtouched = true;
2073
+ applySelf();
2074
+ }
2075
+ });
2076
+ presetpanel.add(aniso3);
2077
+
2078
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2079
+ velvet0.setToolTipText("Velvet");
2080
+ velvet0.addMouseListener(new MouseAdapter()
2081
+ {
2082
+ public void mouseClicked(MouseEvent e)
2083
+ {
2084
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2085
+ cMaterial material = object.material;
2086
+
2087
+ diffusenessField.setFloat(material.factor);
2088
+ selfshadowField.setFloat(material.diffuseness);
2089
+ sheenField.setFloat(material.sheen);
2090
+ shininessField.setFloat(material.shininess);
2091
+ velvetField.setFloat(material.velvet);
2092
+ shiftField.setFloat(material.shift);
2093
+
2094
+ materialtouched = true;
2095
+ applySelf();
2096
+ }
2097
+ });
2098
+ presetpanel.add(velvet0);
2099
+
2100
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2101
+ bump0.setToolTipText("Bump texture");
2102
+ bump0.addMouseListener(new MouseAdapter()
2103
+ {
2104
+ public void mouseClicked(MouseEvent e)
2105
+ {
2106
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2107
+ cMaterial material = object.material;
2108
+
2109
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2110
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2111
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2112
+
2113
+ materialtouched = true;
2114
+ applySelf();
2115
+ }
2116
+ });
2117
+ presetpanel.add(bump0);
2118
+
2119
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2120
+ halo.setToolTipText("Halo");
2121
+ halo.addMouseListener(new MouseAdapter()
2122
+ {
2123
+ public void mouseClicked(MouseEvent e)
2124
+ {
2125
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2126
+ cMaterial material = object.material;
2127
+
2128
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2129
+
2130
+ materialtouched = true;
2131
+ applySelf();
2132
+ }
2133
+ });
2134
+ presetpanel.add(halo);
2135
+
2136
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2137
+ candle.setToolTipText("Candle");
2138
+ candle.addMouseListener(new MouseAdapter()
2139
+ {
2140
+ public void mouseClicked(MouseEvent e)
2141
+ {
2142
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2143
+ cMaterial material = object.material;
2144
+
2145
+ subsurfaceField.setFloat(material.subsurface);
2146
+ shadowbiasField.setFloat(material.shadowbias);
2147
+ ambientField.setFloat(material.ambient);
2148
+ specularField.setFloat(material.specular);
2149
+ lightareaField.setFloat(material.lightarea);
2150
+ shininessField.setFloat(material.shininess);
2151
+
2152
+ materialtouched = true;
2153
+ applySelf();
2154
+ }
2155
+ });
2156
+ presetpanel.add(candle);
2157
+
2158
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2159
+ shadowShader.setToolTipText("Shadow");
2160
+ shadowShader.addMouseListener(new MouseAdapter()
2161
+ {
2162
+ public void mouseClicked(MouseEvent e)
2163
+ {
2164
+ diffuseField.setFloat(0.001);
2165
+ ambientField.setFloat(0.001);
2166
+ cameraField.setFloat(0.001);
2167
+ specularField.setFloat(0.001);
2168
+ fakedepthField.setFloat(0.001);
2169
+ opacityField.setFloat(0.6);
2170
+
2171
+ materialtouched = true;
2172
+ applySelf();
2173
+ }
2174
+ });
2175
+ presetpanel.add(shadowShader);
2176
+
2177
+ cGridBag panel = new cGridBag().setVertical(true);
2178
+
2179
+ presetpanel.preferredWidth = 1;
2180
+
2181
+ materialpanel.add(presetpanel);
2182
+ materialpanel.add(panel);
2183
+
2184
+ panel.preferredWidth = 8;
2185
+
2186
+ /*
14412187 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14422188 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1443
- */
2189
+ */
14442190
14452191 cGridBag editBar = new cGridBag().setVertical(false);
14462192
1447
- editBar.add(createMaterialButton = new cButton("Create", !GrafreeD.NIMBUSLAF)); // , aConstraints);
2193
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
14482194 createMaterialButton.setToolTipText("Create material");
14492195
14502196 /*
14512197 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14522198 */
14532199
1454
- editBar.add(clearMaterialButton = new cButton("Clear", !GrafreeD.NIMBUSLAF)); // , aConstraints);
2200
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
14552201 clearMaterialButton.setToolTipText("Clear material");
14562202
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);
2203
+ if (Globals.ADVANCED)
2204
+ {
2205
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2206
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
2207
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
2208
+ }
14602209
14612210 editBar.preferredHeight = 15;
14622211
....@@ -1471,45 +2220,50 @@
14712220 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14722221
14732222 cGridBag colorSection = new cGridBag().setVertical(true);
2223
+
2224
+ cGridBag huepanel = new cGridBag();
2225
+ cGridBag huelabel = new cGridBag();
2226
+ skin = GetLabel("icons/hue.png", false);
2227
+ skin.fit = true;
2228
+ huelabel.add(skin);
2229
+ huelabel.preferredWidth = 20;
2230
+ huepanel.add(new cGridBag()); // Label
2231
+ huepanel.add(huelabel); // Field/slider
2232
+
2233
+ huepanel.preferredHeight = 7;
2234
+
2235
+ colorSection.add(huepanel);
14742236
14752237 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);
2238
+
2239
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2240
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2241
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2242
+
14792243 //colorField.preferredWidth = 200;
14802244 colorSection.add(color);
14812245
14822246 cGridBag modulation = new cGridBag();
14832247 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14842248 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1485
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2249
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14862250 colorSection.add(modulation);
14872251
2252
+ cGridBag opacity = new cGridBag();
2253
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2254
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2255
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2256
+ colorSection.add(opacity);
2257
+
2258
+ colorSection.add(GetSeparator());
2259
+
14882260 cGridBag texture = new cGridBag();
14892261 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14902262 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14912263 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14922264 colorSection.add(texture);
14932265
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());
2266
+ panel.add(GetSeparator());
15132267
15142268 panel.add(colorSection);
15152269
....@@ -1559,7 +2313,13 @@
15592313 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15602314 diffuseSection.add(fakedepth);
15612315
1562
- panel.add(new JSeparator());
2316
+ cGridBag shadowbias = new cGridBag();
2317
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2318
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2319
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2320
+ diffuseSection.add(shadowbias);
2321
+
2322
+ panel.add(GetSeparator());
15632323
15642324 panel.add(diffuseSection);
15652325
....@@ -1609,42 +2369,48 @@
16092369 // aConstraints.gridy += 1;
16102370 // aConstraints.gridwidth = 1;
16112371
2372
+ cGridBag anisoU = new cGridBag();
2373
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2374
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2375
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2376
+ specularSection.add(anisoU);
16122377
1613
- panel.add(new JSeparator());
2378
+ cGridBag anisoV = new cGridBag();
2379
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2380
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2381
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2382
+ specularSection.add(anisoV);
2383
+
2384
+
2385
+ panel.add(GetSeparator());
16142386
16152387 panel.add(specularSection);
16162388
16172389 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16182390
1619
- cGridBag globalSection = new cGridBag().setVertical(true);
2391
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16202392
16212393 cGridBag camera = new cGridBag();
16222394 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16232395 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16242396 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1625
- globalSection.add(camera);
2397
+ colorSection.add(camera);
16262398
16272399 cGridBag ambient = new cGridBag();
16282400 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16292401 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16302402 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1631
- globalSection.add(ambient);
2403
+ colorSection.add(ambient);
16322404
16332405 cGridBag backlit = new cGridBag();
16342406 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16352407 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16362408 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1637
- globalSection.add(backlit);
2409
+ colorSection.add(backlit);
16382410
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());
2411
+ //panel.add(new JSeparator());
16462412
1647
- panel.add(globalSection);
2413
+ //panel.add(globalSection);
16482414
16492415 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16502416
....@@ -1686,7 +2452,7 @@
16862452 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16872453 textureSection.add(opacityPower);
16882454
1689
- panel.add(new JSeparator());
2455
+ panel.add(GetSeparator());
16902456
16912457 panel.add(textureSection);
16922458
....@@ -1725,12 +2491,15 @@
17252491 opacityPowerField.addChangeListener(this);
17262492 /**/
17272493
1728
- resetSlidersButton.addActionListener(this);
17292494 clearMaterialButton.addActionListener(this);
17302495 createMaterialButton.addActionListener(this);
1731
-
1732
- propagateToggle.addItemListener(this);
1733
- multiplyToggle.addItemListener(this);
2496
+
2497
+ if (Globals.ADVANCED)
2498
+ {
2499
+ resetSlidersButton.addActionListener(this);
2500
+ propagateToggle.addItemListener(this);
2501
+ multiplyToggle.addItemListener(this);
2502
+ }
17342503 }
17352504
17362505 void DropFile(java.io.File[] files, boolean textures)
....@@ -1748,8 +2517,9 @@
17482517 // 3D models
17492518 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17502519 {
1751
- lastConverter = new com.jmex.model.converters.MaxToJme();
1752
- LoadFile(filename, lastConverter);
2520
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2521
+ //LoadFile(filename, lastConverter);
2522
+ LoadObjFile(filename); // New 3ds loader
17532523 continue;
17542524 }
17552525 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1901,7 +2671,7 @@
19012671
19022672 //? flashIt = false;
19032673 CameraPane pane = (CameraPane) cameraView;
1904
- pane.clickStart(location.x, location.y, 0);
2674
+ pane.clickStart(location.x, location.y, 0, 0);
19052675 pane.clickEnd(location.x, location.y, 0, true);
19062676
19072677 if (group.selection.size() == 1)
....@@ -1950,6 +2720,7 @@
19502720 e2.printStackTrace();
19512721 }
19522722 }
2723
+
19532724 LoadJMEThread loadThread;
19542725
19552726 class LoadJMEThread extends Thread
....@@ -2007,6 +2778,7 @@
20072778 //LoadFile0(filename, converter);
20082779 }
20092780 }
2781
+
20102782 LoadOBJThread loadObjThread;
20112783
20122784 class LoadOBJThread extends Thread
....@@ -2085,19 +2857,19 @@
20852857
20862858 void LoadObjFile(String fullname)
20872859 {
2088
- /*
2860
+ System.out.println("Loading " + fullname);
2861
+ /**/
20892862 //lastFilename = fullname;
20902863 if(loadObjThread == null)
20912864 {
2092
- loadObjThread = new LoadOBJThread();
2093
- loadObjThread.start();
2865
+ loadObjThread = new LoadOBJThread();
2866
+ loadObjThread.start();
20942867 }
20952868
20962869 loadObjThread.add(fullname);
2097
- */
2870
+ /**/
20982871
2099
- System.out.println("Loading " + fullname);
2100
- makeSomething(new FileObject(fullname, true), true);
2872
+ //makeSomething(new FileObject(fullname, true), true);
21012873 }
21022874
21032875 void LoadGFDFile(String fullname)
....@@ -2358,11 +3130,11 @@
23583130
23593131 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23603132 {
2361
- if (GrafreeD.standAlone)
3133
+ if (Grafreed.standAlone)
23623134 {
23633135 /**/
23643136 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2365
- browser.show();
3137
+ browser.setVisible(true);
23663138 String filename = browser.getFile();
23673139 if (filename != null && filename.length() > 0)
23683140 {
....@@ -2473,6 +3245,7 @@
24733245 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24743246 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24753247 }
3248
+
24763249 //cJME.count++;
24773250 //cJME.count %= 12;
24783251 if (gc)
....@@ -2656,6 +3429,7 @@
26563429 }
26573430 }
26583431 }
3432
+
26593433 cFileSystemPane FSPane;
26603434
26613435 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2665,7 +3439,7 @@
26653439
26663440 freezematerial = true;
26673441 colorField.setFloat(mat.color);
2668
- modulationField.setFloat(mat.modulation);
3442
+ saturationField.setFloat(mat.modulation);
26693443 metalnessField.setFloat(mat.metalness);
26703444 diffuseField.setFloat(mat.diffuse);
26713445 specularField.setFloat(mat.specular);
....@@ -2709,11 +3483,14 @@
27093483 }
27103484 }
27113485 }
3486
+
27123487 freezematerial = false;
27133488 }
27143489
27153490 void SetMaterial(Object3D object)
27163491 {
3492
+ latestObject = object;
3493
+
27173494 cMaterial mat = object.material;
27183495
27193496 if (mat == null)
....@@ -2722,7 +3499,8 @@
27223499 return;
27233500 }
27243501
2725
- multiplyToggle.setSelected(mat.multiply);
3502
+ if (multiplyToggle != null)
3503
+ multiplyToggle.setSelected(mat.multiply);
27263504
27273505 assert (object.projectedVertices != null);
27283506
....@@ -2824,12 +3602,17 @@
28243602 // }
28253603
28263604 /**/
2827
- if (deselect)
3605
+ if (deselect || child == null)
28283606 {
28293607 //group.deselectAll();
28303608 //freeze = true;
28313609 GetTree().clearSelection();
28323610 //freeze = false;
3611
+
3612
+ if (child == null)
3613
+ {
3614
+ return;
3615
+ }
28333616 }
28343617
28353618 //group.addSelectee(child);
....@@ -2863,6 +3646,17 @@
28633646 public void itemStateChanged(ItemEvent event)
28643647 {
28653648 // System.out.println("Propagate = " + propagate);
3649
+ if (event.getSource() == pinButton)
3650
+ {
3651
+ copy.pinned ^= true;
3652
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3653
+ {
3654
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3655
+ copy.CloseUI();
3656
+ //copy.editWindow.refreshContents();
3657
+ }
3658
+ }
3659
+ else
28663660 if (event.getSource() == propagateToggle)
28673661 {
28683662 propagate ^= true;
....@@ -2898,7 +3692,7 @@
28983692 cameraView.ToggleDL();
28993693 cameraView.repaint();
29003694 return;
2901
- } else if (event.getSource() == toggleTextureItem)
3695
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29023696 {
29033697 cameraView.ToggleTexture();
29043698 // june 2013 copy.HardTouch();
....@@ -2937,9 +3731,9 @@
29373731 frame.validate();
29383732
29393733 return;
2940
- } else if (event.getSource() == toggleRandomItem)
3734
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29413735 {
2942
- cameraView.ToggleRandom();
3736
+ cameraView.ToggleSwitch();
29433737 cameraView.repaint();
29443738 return;
29453739 } else if (event.getSource() == toggleHandleItem)
....@@ -2967,12 +3761,17 @@
29673761 } else if (event.getSource() == liveCB)
29683762 {
29693763 copy.live ^= true;
3764
+ objEditor.refreshContents(true); // To show item colors
3765
+ return;
3766
+ } else if (event.getSource() == selectableCB)
3767
+ {
3768
+ copy.dontselect ^= true;
29703769 return;
29713770 } else if (event.getSource() == hideCB)
29723771 {
29733772 copy.hide ^= true;
29743773 copy.Touch(); // display list issue
2975
- objEditor.refreshContents();
3774
+ objEditor.refreshContents(true); // To show item colors
29763775 return;
29773776 } else if (event.getSource() == link2masterCB)
29783777 {
....@@ -2982,6 +3781,7 @@
29823781 if (event.getSource() == randomCB)
29833782 {
29843783 copy.random ^= true;
3784
+ objEditor.refreshContents();
29853785 return;
29863786 }
29873787 if (event.getSource() == speedupCB)
....@@ -3005,8 +3805,9 @@
30053805
30063806 public void actionPerformed(ActionEvent event)
30073807 {
3808
+ Object source = event.getSource();
30083809 // SCRIPT DIALOG
3009
- if (event.getSource() == okbutton)
3810
+ if (source == okbutton)
30103811 {
30113812 textpanel.setVisible(false);
30123813 textpanel.remove(textarea);
....@@ -3018,7 +3819,7 @@
30183819 textarea = null;
30193820 textpanel = null;
30203821 }
3021
- if (event.getSource() == cancelbutton)
3822
+ if (source == cancelbutton)
30223823 {
30233824 textpanel.setVisible(false);
30243825 textpanel.remove(textarea);
....@@ -3030,50 +3831,50 @@
30303831 //applySelf();
30313832 //client.refreshEditWindow();
30323833 //refreshContents();
3033
- if (event.getSource() == nameField)
3834
+ if (source == nameField)
30343835 {
30353836 //System.out.println("ObjEditor " + event);
30363837 applySelf0(true);
30373838 //parent.applySelf();
30383839 objEditor.refreshContents();
3039
- } else if (event.getSource() == resetButton)
3840
+ } else if (source == resetButton)
30403841 {
30413842 CameraPane.fullreset = true;
30423843 copy.Reset(); // ResetMeshes();
30433844 copy.Touch();
30443845 objEditor.refreshContents();
3045
- } else if (event.getSource() == stepItem)
3846
+ } else if (source == stepItem)
30463847 {
30473848 //cameraView.ONESTEP = true;
30483849 Globals.ONESTEP = true;
30493850 cameraView.repaint();
30503851 return;
3051
- } else if (event.getSource() == stepButton)
3852
+ } else if (source == stepButton)
30523853 {
30533854 copy.Step();
30543855 copy.Touch();
30553856 objEditor.refreshContents();
3056
- } else if (event.getSource() == slowerButton)
3857
+ } else if (source == slowerButton)
30573858 {
30583859 copy.Slower();
30593860 copy.Touch();
30603861 objEditor.refreshContents();
3061
- } else if (event.getSource() == fasterButton)
3862
+ } else if (source == fasterButton)
30623863 {
30633864 copy.Faster();
30643865 copy.Touch();
30653866 objEditor.refreshContents();
3066
- } else if (event.getSource() == remarkButton)
3867
+ } else if (source == remarkButton)
30673868 {
30683869 copy.Remark();
30693870 copy.Touch();
30703871 objEditor.refreshContents();
3071
- } else if (event.getSource() == stepAllButton)
3872
+ } else if (source == stepAllButton)
30723873 {
30733874 copy.StepAll();
30743875 copy.Touch();
30753876 objEditor.refreshContents();
3076
- } else if (event.getSource() == resetAllButton)
3877
+ } else if (source == resetAllButton)
30773878 {
30783879 //CameraPane.fullreset = true;
30793880 copy.ResetAll(); // ResetMeshes();
....@@ -3106,53 +3907,79 @@
31063907 // Close();
31073908 // }
31083909 // else
3109
- if (event.getSource() == resetSlidersButton)
3910
+ if (source == resetSlidersButton)
31103911 {
31113912 ResetSliders();
3112
- } else if (event.getSource() == clearMaterialButton)
3913
+ } else if (source == clearMaterialButton)
31133914 {
31143915 ClearMaterial();
3115
- } else if (event.getSource() == createMaterialButton)
3916
+ } else if (source == createMaterialButton)
31163917 {
31173918 CreateMaterial();
3118
- } else if (event.getSource() == clearPanelButton)
3919
+ } else if (source == clearPanelButton)
31193920 {
31203921 copy.ClearUI();
31213922 refreshContents(true);
3122
- } /*
3123
- }
3124
-
3125
- public boolean action(Event event, Object arg)
3126
- {
3127
- */ else if (event.getSource() == closeItem)
3923
+ } else if (source == importGFDItem)
3924
+ {
3925
+ ImportGFD();
3926
+ } else
3927
+ if (source == importVRMLX3DItem)
3928
+ {
3929
+ ImportVRMLX3D();
3930
+ } else
3931
+ if (source == import3DSItem)
3932
+ {
3933
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3934
+ } else
3935
+ if (source == importOBJItem)
3936
+ {
3937
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3938
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3939
+ browser.setVisible(true);
3940
+ String filename = browser.getFile();
3941
+ if (filename != null && filename.length() > 0)
3942
+ {
3943
+ String fullname = browser.getDirectory() + filename;
3944
+ makeSomething(ReadOBJ(fullname), true);
3945
+ }
3946
+ } else
3947
+ if (source == closeItem)
31283948 {
31293949 Close();
31303950 //return true;
3131
- } else if (event.getSource() == loadItem)
3951
+ } else if (source == openItem)
31323952 {
3133
- load();
3953
+ Open();
31343954 //return true;
3135
- } else if (event.getSource() == saveItem)
3955
+ } else if (source == newItem)
3956
+ {
3957
+ New();
3958
+ } else if (source == saveItem)
31363959 {
31373960 save();
31383961 //return true;
3139
- } else if (event.getSource() == saveAsItem)
3962
+ } else if (source == saveAsItem)
31403963 {
31413964 saveAs();
31423965 //return true;
3143
- } else if (event.getSource() == reexportItem)
3966
+ } else if (source == reexportItem)
31443967 {
31453968 reexport();
31463969 //return true;
3147
- } else if (event.getSource() == exportAsItem)
3970
+ } else if (source == exportAsItem)
31483971 {
31493972 export();
31503973 //return true;
3151
- } else if (event.getSource() == povItem)
3974
+ } else if (source == povItem)
31523975 {
31533976 generatePOV();
31543977 //return true;
3155
- } else if (event.getSource() == zBufferItem)
3978
+ } else if (event.getSource() == archiveItem)
3979
+ {
3980
+ cTools.Archive(frame);
3981
+ return;
3982
+ } else if (source == zBufferItem)
31563983 {
31573984 try
31583985 {
....@@ -3174,21 +4001,8 @@
31744001 cameraView.repaint();
31754002 //return true;
31764003 }
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)
4004
+ */ else // combos...
4005
+ if (source == texresMenu)
31924006 {
31934007 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31944008 copy.texres = texresMenu.getSelectedIndex();
....@@ -3200,12 +4014,477 @@
32004014 }
32014015 }
32024016
4017
+ void New()
4018
+ {
4019
+ while (copy.Size() > 1)
4020
+ {
4021
+ copy.remove(1);
4022
+ }
4023
+
4024
+ ResetModel();
4025
+ objEditor.refreshContents();
4026
+ }
4027
+
4028
+ static public byte[] Compress(Object3D o)
4029
+ {
4030
+ // Slower to actually compress.
4031
+ try
4032
+ {
4033
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4034
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4035
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
4036
+
4037
+ Object3D parent = o.parent;
4038
+ o.parent = null;
4039
+
4040
+ out.writeObject(o);
4041
+
4042
+ o.parent = parent;
4043
+
4044
+ out.flush();
4045
+
4046
+ baos //zstream
4047
+ .close();
4048
+ out.close();
4049
+
4050
+ byte[] bytes = baos.toByteArray();
4051
+
4052
+ System.out.println("save #bytes = " + bytes.length);
4053
+ return bytes;
4054
+ } catch (Exception e)
4055
+ {
4056
+ System.err.println(e);
4057
+ return null;
4058
+ }
4059
+ }
4060
+
4061
+ static public Object Uncompress(byte[] bytes)
4062
+ {
4063
+ System.out.println("restore #bytes = " + bytes.length);
4064
+ try
4065
+ {
4066
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4067
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4068
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
4069
+ Object obj = in.readObject();
4070
+
4071
+ bais //istream
4072
+ .close();
4073
+ in.close();
4074
+
4075
+ return obj;
4076
+ } catch (Exception e)
4077
+ {
4078
+ System.err.println(e);
4079
+ return null;
4080
+ }
4081
+ }
4082
+
4083
+ static public Object clone(Object o)
4084
+ {
4085
+ try
4086
+ {
4087
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4088
+ ObjectOutputStream out = new ObjectOutputStream(baos);
4089
+
4090
+ out.writeObject(o);
4091
+
4092
+ out.flush();
4093
+ out.close();
4094
+
4095
+ byte[] bytes = baos.toByteArray();
4096
+
4097
+ System.out.println("clone = " + bytes.length);
4098
+
4099
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4100
+ ObjectInputStream in = new ObjectInputStream(bais);
4101
+ Object obj = in.readObject();
4102
+ in.close();
4103
+
4104
+ return obj;
4105
+ } catch (Exception e)
4106
+ {
4107
+ System.err.println(e);
4108
+ return null;
4109
+ }
4110
+ }
4111
+
4112
+ cRadio GetCurrentTab()
4113
+ {
4114
+ cRadio ab;
4115
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4116
+ {
4117
+ ab = (cRadio)e.nextElement();
4118
+ if(ab.GetObject() == copy)
4119
+ {
4120
+ return ab;
4121
+ }
4122
+ }
4123
+
4124
+ return null;
4125
+ }
4126
+
4127
+
4128
+ public void Save()
4129
+ {
4130
+ //Save(true);
4131
+ Replace();
4132
+ SetUndoStates();
4133
+ }
4134
+
4135
+ private boolean Equal(byte[] compress, byte[] name)
4136
+ {
4137
+ if (compress.length != name.length)
4138
+ {
4139
+ return false;
4140
+ }
4141
+
4142
+ for (int i=compress.length; --i>=0;)
4143
+ {
4144
+ if (compress[i] != name[i])
4145
+ return false;
4146
+ }
4147
+
4148
+ return true;
4149
+ }
4150
+
4151
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4152
+
4153
+ void DeleteVersion()
4154
+ {
4155
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4156
+ {
4157
+ copy.versionlist[i] = copy.versionlist[i+1];
4158
+ }
4159
+
4160
+ CopyChanged();
4161
+
4162
+ SetUndoStates();
4163
+ }
4164
+
4165
+ public boolean Save(boolean user)
4166
+ {
4167
+ System.err.println("Save");
4168
+ Replace();
4169
+
4170
+ //cRadio tab = GetCurrentTab();
4171
+
4172
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
4173
+
4174
+ boolean thesame = false;
4175
+
4176
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4177
+// {
4178
+// thesame = true;
4179
+// }
4180
+
4181
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
4182
+ if (!thesame)
4183
+ {
4184
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4185
+ {
4186
+ copy.versionlist[i] = copy.versionlist[i-1];
4187
+ }
4188
+
4189
+ //tab.user[tab.versionindex] = user;
4190
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4191
+
4192
+ copy.versionlist[++copy.versionindex] = compress;
4193
+
4194
+ // if (increment)
4195
+ // tab.versionindex++;
4196
+ }
4197
+
4198
+ //copy.RestoreBigData(versiontable);
4199
+
4200
+ //assert(hashtable.isEmpty());
4201
+
4202
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4203
+// {
4204
+// //tab.user[i] = false;
4205
+// copy.versionlist[i] = null;
4206
+// }
4207
+
4208
+ SetUndoStates();
4209
+
4210
+ // test save
4211
+ if (false)
4212
+ {
4213
+ try
4214
+ {
4215
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
4216
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
4217
+
4218
+ p.writeObject(copy);
4219
+
4220
+ p.flush();
4221
+
4222
+ ostream.close();
4223
+ } catch (Exception e)
4224
+ {
4225
+ e.printStackTrace();
4226
+ }
4227
+ }
4228
+
4229
+ return !thesame;
4230
+ }
4231
+
4232
+ boolean flashIt = true;
4233
+
4234
+ void RefreshSelection()
4235
+ {
4236
+ Object3D selection = new Object3D();
4237
+
4238
+ for (int i = 0; i < copy.selection.size(); i++)
4239
+ {
4240
+ Object3D elem = copy.selection.elementAt(i);
4241
+
4242
+ Object3D obj = copy.GetObject(elem.GetUUID());
4243
+
4244
+ if (obj == null)
4245
+ {
4246
+ copy.selection.remove(i--);
4247
+ }
4248
+ else
4249
+ {
4250
+ selection.add(obj);
4251
+ copy.selection.setElementAt(obj, i);
4252
+ }
4253
+ }
4254
+
4255
+ flashIt = false;
4256
+ GetTree().clearSelection();
4257
+ for (int i = 0; i < selection.size(); i++)
4258
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4259
+ flashIt = true;
4260
+
4261
+ //refreshContents(false);
4262
+ }
4263
+
4264
+ void CopyChanged()
4265
+ {
4266
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4267
+
4268
+ SetUndoStates();
4269
+
4270
+ boolean temp = CameraPane.SWITCH;
4271
+ CameraPane.SWITCH = false;
4272
+
4273
+ copy.ExtractBigData(versiontable);
4274
+
4275
+ copy.clear();
4276
+
4277
+ copy.skyboxname = obj.skyboxname;
4278
+ copy.skyboxext = obj.skyboxext;
4279
+
4280
+ for (int i=0; i<obj.Size(); i++)
4281
+ {
4282
+ copy.add(obj.get(i));
4283
+ }
4284
+
4285
+ copy.RestoreBigData(versiontable);
4286
+
4287
+ CameraPane.SWITCH = temp;
4288
+
4289
+ RefreshSelection();
4290
+ //assert(hashtable.isEmpty());
4291
+
4292
+ copy.Touch();
4293
+
4294
+ ResetModel();
4295
+ copy.HardTouch(); // recompile?
4296
+
4297
+ cRadio ab;
4298
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4299
+ {
4300
+ ab = (cRadio)e.nextElement();
4301
+ Object3D test = copy.GetObject(ab.object.GetUUID());
4302
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
4303
+ if (test != null)
4304
+ {
4305
+ test.editWindow = ab.object.editWindow;
4306
+ ab.object = test;
4307
+ }
4308
+ }
4309
+
4310
+ refreshContents(true);
4311
+ }
4312
+
4313
+ cButton previousVersionButton;
4314
+ cButton restoreButton;
4315
+ cButton replaceButton;
4316
+ cButton nextVersionButton;
4317
+ cButton saveVersionButton;
4318
+ cButton deleteVersionButton;
4319
+
4320
+ boolean muteSlider;
4321
+
4322
+ int VersionCount()
4323
+ {
4324
+ int count = 0;
4325
+
4326
+ for (int i = copy.versionlist.length; --i >= 0;)
4327
+ {
4328
+ if (copy.versionlist[i] != null)
4329
+ count++;
4330
+ }
4331
+
4332
+ return count;
4333
+ }
4334
+
4335
+ void SetUndoStates()
4336
+ {
4337
+ //if (true)
4338
+ // return;
4339
+
4340
+ //cRadio tab = GetCurrentTab();
4341
+
4342
+ restoreButton.setEnabled(copy.versionindex != -1);
4343
+ replaceButton.setEnabled(copy.versionindex != -1);
4344
+
4345
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4346
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4347
+
4348
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4349
+ copy.versionlist[copy.versionindex + 1] != null);
4350
+
4351
+ muteSlider = true;
4352
+ versionSlider.setMinimum(0);
4353
+ versionSlider.setMaximum(VersionCount() - 1);
4354
+ versionSlider.setInteger(copy.versionindex);
4355
+ versionSlider.setEnabled(copy.versionindex != -1);
4356
+ muteSlider = false;
4357
+ }
4358
+
4359
+ public boolean PreviousVersion()
4360
+ {
4361
+ // Option?
4362
+ Replace();
4363
+
4364
+ System.err.println("Undo");
4365
+
4366
+ //cRadio tab = GetCurrentTab();
4367
+
4368
+ if (copy.versionindex == 0)
4369
+ {
4370
+ java.awt.Toolkit.getDefaultToolkit().beep();
4371
+ return false;
4372
+ }
4373
+
4374
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4375
+// {
4376
+// if (Save(false))
4377
+// tab.versionindex -= 1;
4378
+// else
4379
+// {
4380
+// if (tab.versionindex <= 0)
4381
+// return false;
4382
+// else
4383
+// tab.versionindex -= 1;
4384
+// }
4385
+// }
4386
+
4387
+ copy.versionindex -= 1;
4388
+
4389
+ CopyChanged();
4390
+
4391
+ return true;
4392
+ }
4393
+
4394
+ public boolean Restore()
4395
+ {
4396
+ System.err.println("Restore");
4397
+
4398
+ //cRadio tab = GetCurrentTab();
4399
+
4400
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4401
+ {
4402
+ java.awt.Toolkit.getDefaultToolkit().beep();
4403
+ return false;
4404
+ }
4405
+
4406
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4407
+ CopyChanged();
4408
+
4409
+ return true;
4410
+ }
4411
+
4412
+ public boolean Replace()
4413
+ {
4414
+ System.err.println("Replace");
4415
+
4416
+ //cRadio tab = GetCurrentTab();
4417
+
4418
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4419
+ {
4420
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4421
+ return false;
4422
+ }
4423
+
4424
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4425
+
4426
+ return true;
4427
+ }
4428
+
4429
+ public void NextVersion()
4430
+ {
4431
+ // Option?
4432
+ Replace();
4433
+
4434
+ //cRadio tab = GetCurrentTab();
4435
+
4436
+ if (copy.versionlist[copy.versionindex + 1] == null)
4437
+ {
4438
+ java.awt.Toolkit.getDefaultToolkit().beep();
4439
+ return;
4440
+ }
4441
+
4442
+ copy.versionindex += 1;
4443
+
4444
+ CopyChanged();
4445
+
4446
+ //if (!tab.user[tab.versionindex])
4447
+ // tab.graphs[tab.versionindex] = null;
4448
+ }
4449
+
4450
+ void ImportGFD()
4451
+ {
4452
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
4453
+ browser.show();
4454
+ String filename = browser.getFile();
4455
+ if (filename != null && filename.length() > 0)
4456
+ {
4457
+ String fullname = browser.getDirectory() + filename;
4458
+
4459
+ //Object3D readobj =
4460
+ objEditor.ReadGFD(fullname, objEditor);
4461
+ //makeSomething(readobj);
4462
+ }
4463
+ }
4464
+
4465
+ void ImportVRMLX3D()
4466
+ {
4467
+ if (Grafreed.standAlone)
4468
+ {
4469
+ /**/
4470
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
4471
+ browser.show();
4472
+ String filename = browser.getFile();
4473
+ if (filename != null && filename.length() > 0)
4474
+ {
4475
+ String fullname = browser.getDirectory() + filename;
4476
+ LoadVRMLX3D(fullname);
4477
+ }
4478
+ /**/
4479
+ }
4480
+ }
4481
+
32034482 void ToggleAnimation()
32044483 {
32054484 if (!Globals.ANIMATION)
32064485 {
32074486 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3208
- browser.show();
4487
+ browser.setVisible(true);
32094488 String filename = browser.getFile();
32104489 if (filename != null && filename.length() > 0)
32114490 {
....@@ -3215,8 +4494,8 @@
32154494
32164495 Globals.ANIMATION ^= true;
32174496
3218
- GrafreeD.wav.cursor = 0;
3219
- GrafreeD.wav.loop = 0;
4497
+ Grafreed.wav.cursor = 0;
4498
+ Grafreed.wav.loop = 0;
32204499 }
32214500 } else
32224501 {
....@@ -3237,7 +4516,6 @@
32374516 callee.refreshContents();
32384517 } else
32394518 {
3240
- new Exception().printStackTrace();
32414519 System.exit(0);
32424520 }
32434521 }
....@@ -3267,7 +4545,7 @@
32674545 void CreateMaterial()
32684546 {
32694547 //copy.ClearMaterial(); // PATCH
3270
- copy.CreateMaterialS(multiplyToggle.isSelected());
4548
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32714549 if (copy.selection.size() > 0)
32724550 //SetMaterial(copy);
32734551 {
....@@ -3318,7 +4596,7 @@
33184596 assert false;
33194597 }
33204598
3321
- void EditSelection()
4599
+ void EditSelection(boolean newWindow)
33224600 {
33234601 }
33244602
....@@ -3326,11 +4604,11 @@
33264604 {
33274605 copy.ResetBlockLoop(); // temporary problem
33284606
3329
- boolean random = CameraPane.RANDOM;
3330
- CameraPane.RANDOM = false; // parse everything
4607
+ boolean random = CameraPane.SWITCH;
4608
+ CameraPane.SWITCH = false; // parse everything
33314609 copy.ResetDisplayList();
33324610 copy.HardTouch();
3333
- CameraPane.RANDOM = random;
4611
+ CameraPane.SWITCH = random;
33344612 }
33354613
33364614 // public void applySelf()
....@@ -3377,7 +4655,7 @@
33774655 //copy.material = new cMaterial(copy.GetMaterial());
33784656
33794657 current.color = (float) colorField.getFloat();
3380
- current.modulation = (float) modulationField.getFloat();
4658
+ current.modulation = (float) saturationField.getFloat();
33814659 current.metalness = (float) metalnessField.getFloat();
33824660 current.diffuse = (float) diffuseField.getFloat();
33834661 current.specular = (float) specularField.getFloat();
....@@ -3404,6 +4682,36 @@
34044682 {
34054683 //System.out.println("Propagate = " + propagate);
34064684 copy.UpdateMaterial(anchor, current, propagate);
4685
+
4686
+ if (copy.material != null)
4687
+ {
4688
+ cMaterial mat = copy.material;
4689
+
4690
+ colorField.SetToolTipValue((mat.color));
4691
+ saturationField.SetToolTipValue((mat.modulation));
4692
+ metalnessField.SetToolTipValue((mat.metalness));
4693
+ diffuseField.SetToolTipValue((mat.diffuse));
4694
+ specularField.SetToolTipValue((mat.specular));
4695
+ shininessField.SetToolTipValue((mat.shininess));
4696
+ shiftField.SetToolTipValue((mat.shift));
4697
+ ambientField.SetToolTipValue((mat.ambient));
4698
+ lightareaField.SetToolTipValue((mat.lightarea));
4699
+ diffusenessField.SetToolTipValue((mat.factor));
4700
+ velvetField.SetToolTipValue((mat.velvet));
4701
+ sheenField.SetToolTipValue((mat.sheen));
4702
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4703
+ backlitField.SetToolTipValue((mat.bump));
4704
+ anisoField.SetToolTipValue((mat.aniso));
4705
+ anisoVField.SetToolTipValue((mat.anisoV));
4706
+ cameraField.SetToolTipValue((mat.cameralight));
4707
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4708
+ shadowField.SetToolTipValue((mat.shadow));
4709
+ textureField.SetToolTipValue((mat.texture));
4710
+ opacityField.SetToolTipValue((mat.opacity));
4711
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4712
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
4713
+ }
4714
+
34074715 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34084716 {
34094717 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3432,9 +4740,26 @@
34324740 //copy.Touch();
34334741 }
34344742
4743
+ cNumberSlider versionSlider;
4744
+
34354745 public void stateChanged(ChangeEvent e)
34364746 {
34374747 // assert(false);
4748
+ if (e.getSource() == versionSlider)
4749
+ {
4750
+ if (muteSlider)
4751
+ return;
4752
+
4753
+ int version = versionSlider.getInteger();
4754
+
4755
+ if (version != -1 && copy.versionlist[version] != null)
4756
+ {
4757
+ copy.versionindex = version;
4758
+ CopyChanged();
4759
+ }
4760
+
4761
+ return;
4762
+ }
34384763
34394764 if (freezematerial)
34404765 {
....@@ -3470,6 +4795,12 @@
34704795 {
34714796 //System.out.println("stateChanged = " + this);
34724797 materialtouched = true;
4798
+
4799
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4800
+ {
4801
+ saturationField.setFloat(1);
4802
+ }
4803
+
34734804 applySelf();
34744805 //System.out.println("this = " + this);
34754806 //System.out.println("PARENT = " + parent);
....@@ -3519,7 +4850,7 @@
35194850 }
35204851
35214852 if (normalpushField != null)
3522
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4853
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35234854 }
35244855
35254856 void SnapObject()
....@@ -3769,6 +5100,7 @@
37695100 {
37705101 if (GetTree() != null)
37715102 {
5103
+ GetTree().revalidate();
37725104 GetTree().repaint();
37735105 }
37745106
....@@ -3777,12 +5109,17 @@
37775109 ctrlPanel.validate(); // ? new
37785110 ctrlPanel.repaint();
37795111 }
5112
+
5113
+ if (previousVersionButton != null && copy.versionlist != null)
5114
+ SetUndoStates();
37805115 }
37815116
37825117 static TweenManager tweenManager = new TweenManager();
37835118
37845119 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37855120 {
5121
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5122
+ Save();
37865123 //Tween.set(thing, 0).target(1).start(tweenManager);
37875124 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37885125 // if (thing instanceof GenericJointDemo)
....@@ -3869,6 +5206,12 @@
38695206 {
38705207 ResetModel();
38715208 Select(thing.GetTreePath(), true, false); // unselect... false);
5209
+
5210
+ if (thing.Size() == 0)
5211
+ {
5212
+ //EditSelection(false);
5213
+ }
5214
+
38725215 refreshContents();
38735216 }
38745217
....@@ -3986,6 +5329,7 @@
39865329 }
39875330 }
39885331 }
5332
+
39895333 LoadGFDThread loadGFDThread;
39905334
39915335 void ReadGFD(String fullname, iCallBack cb)
....@@ -4005,8 +5349,10 @@
40055349
40065350 try
40075351 {
5352
+ // Try compressed version first.
40085353 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4009
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5354
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
5355
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40105356
40115357 readobj = (Object3D) p.readObject();
40125358 istream.close();
....@@ -4014,7 +5360,22 @@
40145360 readobj.ResetDisplayList();
40155361 } catch (Exception e)
40165362 {
4017
- e.printStackTrace();
5363
+ if (!e.toString().contains("GZIP"))
5364
+ e.printStackTrace();
5365
+
5366
+ try
5367
+ {
5368
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
5369
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5370
+
5371
+ readobj = (Object3D) p.readObject();
5372
+ istream.close();
5373
+
5374
+ readobj.ResetDisplayList();
5375
+ } catch (Exception e2)
5376
+ {
5377
+ e2.printStackTrace();
5378
+ }
40185379 }
40195380 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40205381 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4060,6 +5421,12 @@
40605421
40615422 void LoadIt(Object obj)
40625423 {
5424
+ if (obj == null)
5425
+ {
5426
+ // Invalid file
5427
+ return;
5428
+ }
5429
+
40635430 System.out.println("Loaded " + obj);
40645431 //new Exception().printStackTrace();
40655432 Object3D readobj = (Object3D) obj;
....@@ -4069,10 +5436,14 @@
40695436
40705437 if (readobj != null)
40715438 {
5439
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5440
+ // Save();
40725441 try
40735442 {
40745443 //readobj.deepCopySelf(copy);
40755444 copy.clear(); // june 2014
5445
+ copy.skyboxname = readobj.skyboxname;
5446
+ copy.skyboxext = readobj.skyboxext;
40765447 for (int i = 0; i < readobj.size(); i++)
40775448 {
40785449 Object3D child = readobj.get(i); // reserve(i);
....@@ -4113,6 +5484,7 @@
41135484 }
41145485 } catch (ClassCastException e)
41155486 {
5487
+ e.printStackTrace();
41165488 assert (false);
41175489 Composite c = (Composite) copy;
41185490 c.children.clear();
....@@ -4123,17 +5495,31 @@
41235495 c.addChild(csg);
41245496 }
41255497
5498
+ copy.versionlist = readobj.versionlist;
5499
+ copy.versionindex = readobj.versionindex;
5500
+
5501
+ if (copy.versionlist == null)
5502
+ {
5503
+ // Backward compatibility
5504
+ copy.versionlist = new Object3D[100];
5505
+ copy.versionindex = -1;
5506
+
5507
+ Save(true);
5508
+ }
5509
+
5510
+ //? SetUndoStates();
5511
+
41265512 ResetModel();
41275513 copy.HardTouch(); // recompile?
41285514 refreshContents();
41295515 }
41305516 }
41315517
4132
- void load() // throws ClassNotFoundException
5518
+ void Open() // throws ClassNotFoundException
41335519 {
4134
- if (GrafreeD.standAlone)
5520
+ if (Grafreed.standAlone)
41355521 {
4136
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5522
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
41375523 browser.show();
41385524 String filename = browser.getFile();
41395525 if (filename != null && filename.length() > 0)
....@@ -4218,11 +5604,13 @@
42185604 try
42195605 {
42205606 FileOutputStream ostream = new FileOutputStream(lastname);
4221
- ObjectOutputStream p = new ObjectOutputStream(ostream);
5607
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5608
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42225609
42235610 p.writeObject(copy);
42245611 p.flush();
42255612
5613
+ zstream.close();
42265614 ostream.close();
42275615
42285616 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4230,19 +5618,23 @@
42305618 //ps.print(buffer.toString());
42315619 } catch (IOException e)
42325620 {
5621
+ e.printStackTrace();
42335622 }
42345623 }
5624
+
42355625 String lastname;
42365626
42375627 void saveAs()
42385628 {
4239
- if (GrafreeD.standAlone)
5629
+ if (Grafreed.standAlone)
42405630 {
42415631 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42425632 browser.setVisible(true);
42435633 String filename = browser.getFile();
42445634 if (filename != null && filename.length() > 0)
42455635 {
5636
+ if (!filename.endsWith(".gfd"))
5637
+ filename += ".gfd";
42465638 lastname = browser.getDirectory() + filename;
42475639 save();
42485640 }
....@@ -4341,13 +5733,13 @@
43415733 try
43425734 {
43435735 FileOutputStream ostream = new FileOutputStream(filename);
4344
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4345
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
5736
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5737
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43465738
43475739 Object3D objectparent = obj.parent;
43485740 obj.parent = null;
43495741
4350
- Object3D object = (Object3D) GrafreeD.clone(obj);
5742
+ Object3D object = (Object3D) Grafreed.clone(obj);
43515743
43525744 obj.parent = objectparent;
43535745
....@@ -4359,8 +5751,8 @@
43595751 p.writeObject(object);
43605752 p.flush();
43615753
5754
+ zstream.close();
43625755 ostream.close();
4363
- // zstream.close();
43645756
43655757 // group.selection.get(0).parent = parent;
43665758 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4381,7 +5773,7 @@
43815773 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43825774 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43835775 copy.generatePOV(buffer);
4384
- if (GrafreeD.standAlone)
5776
+ if (Grafreed.standAlone)
43855777 {
43865778 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43875779 browser.show();
....@@ -4407,19 +5799,18 @@
44075799 Object3D client;
44085800 Object3D copy;
44095801 MenuBar menuBar;
4410
- Menu windowMenu;
4411
- MenuItem loadItem;
5802
+ Menu fileMenu;
5803
+ MenuItem newItem;
5804
+ MenuItem openItem;
44125805 MenuItem saveItem;
44135806 MenuItem saveAsItem;
44145807 MenuItem exportAsItem;
44155808 MenuItem reexportItem;
44165809 MenuItem povItem;
44175810 MenuItem closeItem;
4418
- Menu cameraMenu;
5811
+
44195812 CheckboxMenuItem zBufferItem;
44205813 //MenuItem normalLensItem;
4421
- MenuItem editCameraItem;
4422
- MenuItem revertCameraItem;
44235814 MenuItem stepItem;
44245815 CheckboxMenuItem toggleLiveItem;
44255816 CheckboxMenuItem toggleFullScreenItem;
....@@ -4430,25 +5821,40 @@
44305821 CheckboxMenuItem toggleFootContactItem;
44315822 CheckboxMenuItem toggleDLItem;
44325823 CheckboxMenuItem toggleTextureItem;
4433
- CheckboxMenuItem toggleRandomItem;
5824
+ CheckboxMenuItem toggleSwitchItem;
44345825 CheckboxMenuItem toggleRootItem;
44355826 CheckboxMenuItem animationItem;
5827
+ MenuItem archiveItem;
44365828 CheckboxMenuItem toggleHandleItem;
44375829 CheckboxMenuItem togglePaintItem;
44385830 JSplitPane mainPanel;
44395831 JScrollPane scrollpane;
5832
+
44405833 JPanel toolbarPanel;
5834
+
44415835 cGridBag treePanel;
5836
+
44425837 JPanel radioPanel;
44435838 ButtonGroup buttonGroup;
4444
- cGridBag ctrlPanel;
5839
+
5840
+ cGridBag toolboxPanel;
5841
+ cGridBag skyboxPanel;
44455842 cGridBag materialPanel;
5843
+ cGridBag ctrlPanel;
5844
+
44465845 JScrollPane infoPanel;
5846
+
44475847 cGridBag optionsPanel;
5848
+
44485849 JTabbedPane objectPanel;
5850
+ boolean materialFlushed;
5851
+ Object3D latestObject;
5852
+
44495853 cGridBag XYZPanel;
5854
+
44505855 JSplitPane gridPanel;
44515856 JSplitPane bigPanel;
5857
+
44525858 cGridBag bigThree;
44535859 cGridBag scenePanel;
44545860 cGridBag centralPanel;
....@@ -4506,7 +5912,7 @@
45065912 JLabel colorLabel;
45075913 cNumberSlider colorField;
45085914 JLabel modulationLabel;
4509
- cNumberSlider modulationField;
5915
+ cNumberSlider saturationField;
45105916 JLabel metalnessLabel;
45115917 cNumberSlider metalnessField;
45125918 JLabel diffuseLabel;
....@@ -4537,6 +5943,7 @@
45375943 cNumberSlider anisoField;
45385944 JLabel anisoVLabel;
45395945 cNumberSlider anisoVField;
5946
+
45405947 JLabel cameraLabel;
45415948 cNumberSlider cameraField;
45425949 JLabel selfshadowLabel;
....@@ -4551,6 +5958,7 @@
45515958 cNumberSlider fakedepthField;
45525959 JLabel shadowbiasLabel;
45535960 cNumberSlider shadowbiasField;
5961
+
45545962 JLabel bumpLabel;
45555963 cNumberSlider bumpField;
45565964 JLabel noiseLabel;
....@@ -4563,8 +5971,13 @@
45635971 cNumberSlider fogField;
45645972 JLabel opacityPowerLabel;
45655973 cNumberSlider opacityPowerField;
4566
- JTree jTree;
5974
+ cTree jTree;
45675975 //ObjectUI parent;
45685976
45695977 cNumberSlider normalpushField;
5978
+
5979
+ private MenuItem importGFDItem;
5980
+ private MenuItem importVRMLX3DItem;
5981
+ private MenuItem import3DSItem;
5982
+ private MenuItem importOBJItem;
45705983 }