Normand Briere
2019-07-18 d7a17c35c443e2cb6c09eaa3cfeaf590a571faa1
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
....@@ -35,6 +39,67 @@
3539
3640 GroupEditor callee;
3741 JFrame frame;
42
+
43
+ static ObjEditor theFrame;
44
+
45
+ cButton GetButton(String name, boolean border)
46
+ {
47
+ try
48
+ {
49
+ ImageIcon icon = GetIcon(name);
50
+ return new cButton(icon, border);
51
+ }
52
+ catch (Exception e)
53
+ {
54
+ return new cButton(name, border);
55
+ }
56
+ }
57
+
58
+ cToggleButton GetToggleButton(String name, boolean border)
59
+ {
60
+ try
61
+ {
62
+ ImageIcon icon = GetIcon(name);
63
+ return new cToggleButton(icon, border);
64
+ }
65
+ catch (Exception e)
66
+ {
67
+ return new cToggleButton(name, border);
68
+ }
69
+ }
70
+
71
+ cCheckBox GetCheckBox(String name, boolean border)
72
+ {
73
+ try
74
+ {
75
+ ImageIcon icon = GetIcon(name);
76
+ return new cCheckBox(icon, border);
77
+ }
78
+ catch (Exception e)
79
+ {
80
+ return new cCheckBox(name, border);
81
+ }
82
+ }
83
+
84
+ private ImageIcon GetIcon(String name) throws IOException
85
+ {
86
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
+
88
+ if (image.getWidth() != 24 && image.getHeight() != 24)
89
+ {
90
+ BufferedImage resized = new BufferedImage(24, 24, image.getType());
91
+ Graphics2D g = resized.createGraphics();
92
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
93
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
94
+ g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
95
+ g.dispose();
96
+
97
+ image = resized;
98
+ }
99
+
100
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
+ return icon;
102
+ }
38103
39104 // SCRIPT
40105
....@@ -143,7 +208,9 @@
143208 //nameField.removeActionListener(this);
144209 // objEditor.ctrlPanel.remove(nameField);
145210
146
- if (!GroupEditor.allparams)
211
+ objEditor.ctrlPanel.remove(namePanel);
212
+
213
+ if (!allparams)
147214 return;
148215
149216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -165,9 +232,9 @@
165232 // objEditor.ctrlPanel.remove(fasterButton);
166233 // objEditor.ctrlPanel.remove(remarkButton);
167234
168
- objEditor.ctrlPanel.remove(namePanel);
169235 objEditor.ctrlPanel.remove(setupPanel);
170
- objEditor.ctrlPanel.remove(commandsPanel);
236
+ objEditor.ctrlPanel.remove(setupPanel2);
237
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
171238 objEditor.ctrlPanel.remove(pushPanel);
172239 //objEditor.ctrlPanel.remove(fillPanel);
173240
....@@ -215,6 +282,12 @@
215282 client = inClient;
216283 copy = client;
217284
285
+ if (copy.versions == null)
286
+ {
287
+ copy.versions = new byte[100][];
288
+ copy.versionindex = -1;
289
+ }
290
+
218291 // "this" is not called: SetupUI2(objEditor);
219292 }
220293
....@@ -228,6 +301,12 @@
228301 client = inClient;
229302 copy = client;
230303
304
+ if (copy.versions == null)
305
+ {
306
+ copy.versions = new byte[100][];
307
+ copy.versionindex = -1;
308
+ }
309
+
231310 SetupUI2(callee.GetEditor());
232311 }
233312
....@@ -242,6 +321,7 @@
242321 //localCopy.parent = null;
243322
244323 frame = new JFrame();
324
+ frame.setUndecorated(false);
245325 objEditor = this;
246326 this.callee = callee;
247327
....@@ -259,6 +339,12 @@
259339 copy = localCopy;
260340 copy.editWindow = this;
261341
342
+ if (copy.versions == null)
343
+ {
344
+ copy.versions = new byte[100][];
345
+ copy.versionindex = -1;
346
+ }
347
+
262348 SetupMenu();
263349
264350 //SetupName(objEditor); // new
....@@ -272,28 +358,49 @@
272358 return frame.action(event, obj);
273359 }
274360
361
+ // Cannot work without static
362
+ static boolean allparams = true;
363
+
364
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
365
+
275366 void SetupMenu()
276367 {
277368 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..."));
369
+ menuBar.add(fileMenu = new Menu("File"));
370
+ fileMenu.add(newItem = new MenuItem("New"));
371
+ fileMenu.add(openItem = new MenuItem("Open..."));
372
+
373
+ //oe.menuBar.add(menu = new Menu("Include"));
374
+ Menu menu = new Menu("Import");
375
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
376
+ importOBJItem.addActionListener(this);
377
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
378
+ import3DSItem.addActionListener(this);
379
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
380
+ importVRMLX3DItem.addActionListener(this);
381
+ menu.add("-");
382
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
383
+ importGFDItem.addActionListener(this);
384
+ fileMenu.add(menu);
385
+ fileMenu.add("-");
386
+
387
+ fileMenu.add(saveItem = new MenuItem("Save"));
388
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
283389 //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("-");
390
+ fileMenu.add("-");
391
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
392
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
393
+ fileMenu.add("-");
288394 if (client.parent != null)
289395 {
290
- windowMenu.add(closeItem = new MenuItem("Close"));
396
+ fileMenu.add(closeItem = new MenuItem("Close"));
291397 } else
292398 {
293
- windowMenu.add(closeItem = new MenuItem("Exit"));
399
+ fileMenu.add(closeItem = new MenuItem("Exit"));
294400 }
295401
296
- loadItem.addActionListener(this);
402
+ newItem.addActionListener(this);
403
+ openItem.addActionListener(this);
297404 saveItem.addActionListener(this);
298405 saveAsItem.addActionListener(this);
299406 exportAsItem.addActionListener(this);
....@@ -301,70 +408,53 @@
301408 //povItem.addActionListener(this);
302409 closeItem.addActionListener(this);
303410
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
-
359411 objectPanel = new JTabbedPane();
412
+
413
+ ChangeListener changeListener = new ChangeListener()
414
+ {
415
+ public void stateChanged(ChangeEvent changeEvent)
416
+ {
417
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
418
+// {
419
+// if (latestObject != null)
420
+// {
421
+// refreshContents(true);
422
+// SetMaterial(latestObject);
423
+// }
424
+//
425
+// materialFlushed = true;
426
+// }
427
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
428
+// {
429
+// if (listUI.size() == 0)
430
+// EditSelection(false);
431
+// }
432
+
433
+ refreshContents(false); // To refresh Info tab
434
+ }
435
+ };
436
+ objectPanel.addChangeListener(changeListener);
437
+
360438 toolbarPanel = new JPanel();
361439 toolbarPanel.setName("Toolbar");
362440 treePanel = new cGridBag();
363441 treePanel.setName("Tree");
442
+
443
+ editPanel = new cGridBag().setVertical(true);
444
+ editPanel.setName("Edit");
445
+
364446 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
365
- ctrlPanel.setName("Edit");
447
+
448
+ editCommandsPanel = new cGridBag();
449
+ editPanel.add(editCommandsPanel);
450
+ editPanel.add(ctrlPanel);
451
+
452
+ toolboxPanel = new cGridBag().setVertical(false);
453
+ toolboxPanel.setName("Toolbox");
454
+
366455 materialPanel = new cGridBag().setVertical(true);
367456 materialPanel.setName("Material");
457
+
368458 /*JTextPane*/
369459 infoarea = createTextPane();
370460 doc = infoarea.getStyledDocument();
....@@ -377,7 +467,7 @@
377467 // TEXTAREA infoarea.setLineWrap(true);
378468 // TEXTAREA infoarea.setWrapStyleWord(true);
379469 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
380
- infoPanel.setPreferredSize(new Dimension(50, 200));
470
+ infoPanel.setPreferredSize(new Dimension(1, 1));
381471 infoPanel.setName("Info");
382472 //infoPanel.setLayout(new BorderLayout());
383473 //infoPanel.add(createTextPane());
....@@ -389,7 +479,14 @@
389479 mainPanel.setDividerSize(9);
390480 mainPanel.setDividerLocation(0.5); //1.0);
391481 mainPanel.setResizeWeight(0.5);
392
-
482
+
483
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
484
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
485
+ divider.setDividerSize(15);
486
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
487
+
488
+ mainPanel.setUI(new BasicSplitPaneUI());
489
+
393490 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
394491 //mainPanel.setLayout(new GridBagLayout());
395492 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -457,10 +554,10 @@
457554 e.printStackTrace();
458555 }
459556
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();
557
+// String selection = infoarea.getText();
558
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
559
+// java.awt.datatransfer.Clipboard clipboard =
560
+// Toolkit.getDefaultToolkit().getSystemClipboard();
464561 //clipboard.setContents(data, data);
465562 }
466563
....@@ -483,13 +580,13 @@
483580 //SendInfo("Name:", "bold");
484581 if (sel.GetTextures() != null || debug)
485582 {
486
- si.SendInfo(sel.toString(), "bold");
583
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
487584 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
488585 if (sel.Size() > 0)
489586 {
490587 si.SendInfo("#children = " + sel.Size(), "regular");
491588 }
492
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
589
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
493590 if (debug)
494591 {
495592 try
....@@ -531,7 +628,7 @@
531628 }
532629 if (sel.support != null)
533630 {
534
- si.SendInfo(" support: " + sel.support, "regular");
631
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
535632 }
536633 if (sel.scriptnode != null)
537634 {
....@@ -620,21 +717,144 @@
620717 }
621718 }
622719
720
+//static GraphicsDevice device = GraphicsEnvironment
721
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
722
+
723
+ Rectangle keeprect;
724
+ cRadio radio;
725
+
726
+cButton keepButton;
727
+ cButton twoButton; // Full 3D
728
+ cButton sixButton;
729
+ cButton threeButton;
730
+ cButton sevenButton;
731
+ cButton fourButton; // full panel
732
+ cButton oneButton; // full XYZ
733
+ //cButton currentLayout;
734
+
735
+ boolean maximized;
736
+
737
+ cButton fullscreenLayout;
738
+
739
+ void Minimize()
740
+ {
741
+ frame.setState(Frame.ICONIFIED);
742
+ frame.validate();
743
+ }
744
+
745
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
746
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
747
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
748
+ void Maximize()
749
+ {
750
+ if (CameraPane.FULLSCREEN)
751
+ {
752
+ ToggleFullScreen();
753
+ }
754
+
755
+ if (maximized)
756
+ {
757
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
758
+ }
759
+ else
760
+ {
761
+ keeprect = frame.getBounds();
762
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
763
+// Dimension rect2 = frame.getToolkit().getScreenSize();
764
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
765
+// frame.setState(Frame.MAXIMIZED_BOTH);
766
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
767
+ }
768
+
769
+ maximized ^= true;
770
+
771
+ frame.validate();
772
+ }
773
+
774
+ cButton minButton;
775
+ cButton maxButton;
776
+ cButton fullButton;
777
+
623778 void ToggleFullScreen()
624779 {
625
- if (CameraPane.FULLSCREEN)
780
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
781
+
782
+ cameraView.ToggleFullScreen();
783
+
784
+ if (!CameraPane.FULLSCREEN)
626785 {
627
- frame.getContentPane().remove(/*"Center",*/bigThree);
628
- framePanel.add(bigThree);
629
- frame.getContentPane().add(/*"Center",*/framePanel);
786
+ device.setFullScreenWindow(null);
787
+ frame.dispose();
788
+ frame.setUndecorated(false);
789
+ frame.validate();
790
+ frame.setVisible(true);
791
+
792
+ //frame.setVisible(false);
793
+// frame.removeNotify();
794
+// frame.setUndecorated(false);
795
+// frame.addNotify();
796
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
797
+
798
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
799
+// X framePanel.add(bigThree);
800
+// X frame.getContentPane().add(/*"Center",*/framePanel);
801
+ framePanel.setDividerLocation(46);
802
+
803
+ //frame.setVisible(true);
804
+ radio.layout = keepButton;
805
+ //theFrame = null;
806
+ keepButton = null;
807
+ radio.layout.doClick();
808
+
630809 } else
631810 {
632
- frame.getContentPane().remove(/*"Center",*/framePanel);
633
- framePanel.remove(bigThree);
634
- frame.getContentPane().add(/*"Center",*/bigThree);
811
+ keepButton = radio.layout;
812
+ //keeprect = frame.getBounds();
813
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
814
+// frame.getToolkit().getScreenSize().height);
815
+ //frame.setVisible(false);
816
+
817
+ frame.dispose();
818
+ frame.setUndecorated(true);
819
+ device.setFullScreenWindow(frame);
820
+ frame.validate();
821
+ frame.setVisible(true);
822
+// frame.removeNotify();
823
+// frame.setUndecorated(true);
824
+// frame.addNotify();
825
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
826
+// X framePanel.remove(bigThree);
827
+// X frame.getContentPane().add(/*"Center",*/bigThree);
828
+ framePanel.setDividerLocation(0);
829
+
830
+ radio.layout = fullscreenLayout;
831
+ radio.layout.doClick();
832
+ //frame.setVisible(true);
635833 }
636
- cameraView.ToggleFullScreen();
834
+ frame.validate();
637835 }
836
+
837
+ private byte[] CompressCopy()
838
+ {
839
+ boolean temp = CameraPane.SWITCH;
840
+ CameraPane.SWITCH = false;
841
+
842
+ copy.ExtractBigData(versiontable);
843
+ // if (copy == client)
844
+
845
+ byte[] versions[] = copy.versions;
846
+ copy.versions = null;
847
+
848
+ byte[] compress = Compress(copy);
849
+
850
+ copy.versions = versions;
851
+
852
+ copy.RestoreBigData(versiontable);
853
+
854
+ CameraPane.SWITCH = temp;
855
+
856
+ return compress;
857
+ }
638858
639859 private JTextPane createTextPane()
640860 {
....@@ -734,7 +954,7 @@
734954 protected static ImageIcon createImageIcon(String path,
735955 String description)
736956 {
737
- java.net.URL imgURL = GrafreeD.class.getResource(path);
957
+ java.net.URL imgURL = Grafreed.class.getResource(path);
738958 if (imgURL != null)
739959 {
740960 return new ImageIcon(imgURL, description);
....@@ -766,6 +986,7 @@
766986 // NumberSlider vDivsField;
767987 // JCheckBox endcaps;
768988 JCheckBox liveCB;
989
+ JCheckBox selectCB;
769990 JCheckBox hideCB;
770991 JCheckBox link2masterCB;
771992 JCheckBox markCB;
....@@ -773,7 +994,12 @@
773994 JCheckBox speedupCB;
774995 JCheckBox rewindCB;
775996 JCheckBox flipVCB;
997
+
998
+ cCheckBox toggleTextureCB;
999
+ cCheckBox toggleSwitchCB;
1000
+
7761001 JComboBox texresMenu;
1002
+
7771003 JButton resetButton;
7781004 JButton stepButton;
7791005 JButton stepAllButton;
....@@ -782,9 +1008,13 @@
7821008 JButton fasterButton;
7831009 JButton remarkButton;
7841010
1011
+ cGridBag editPanel;
1012
+ cGridBag editCommandsPanel;
1013
+
7851014 cGridBag namePanel;
7861015 cGridBag setupPanel;
787
- cGridBag commandsPanel;
1016
+ cGridBag setupPanel2;
1017
+ cGridBag objectCommandsPanel;
7881018 cGridBag pushPanel;
7891019 cGridBag fillPanel;
7901020
....@@ -951,52 +1181,73 @@
9511181
9521182 void SetupUI2(ObjEditor oe)
9531183 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
9581184 //SetupName(oe);
9591185
9601186 namePanel = new cGridBag();
9611187
9621188 nameField = AddText(namePanel, copy.GetName());
963
- namePanel.add(nameField);
1189
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9641190 oe.ctrlPanel.add(namePanel);
9651191
9661192 oe.ctrlPanel.Return();
9671193
968
- if (!GroupEditor.allparams)
1194
+ if (!allparams)
9691195 return;
9701196
9711197 setupPanel = new cGridBag().setVertical(false);
9721198
9731199 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
974
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
975
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1200
+ liveCB.setToolTipText("Animate object");
1201
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1202
+ selectCB.setToolTipText("Make object selectable");
9761203 // Return();
1204
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1205
+ hideCB.setToolTipText("Hide object");
9771206 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
978
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
979
- randomCB = AddCheckBox(setupPanel, "Rand", copy.random);
1207
+ markCB.setToolTipText("As animation target transform");
1208
+
1209
+ setupPanel2 = new cGridBag().setVertical(false);
1210
+
1211
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1212
+ rewindCB.setToolTipText("Rewind animation");
1213
+
1214
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1215
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9801216
1217
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1218
+ link2masterCB.setToolTipText("Attach to support");
1219
+
1220
+ if (Globals.ADVANCED)
1221
+ {
1222
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1223
+ speedupCB.setToolTipText("Option motion capture");
1224
+ }
1225
+
9811226 oe.ctrlPanel.add(setupPanel);
9821227 oe.ctrlPanel.Return();
1228
+ oe.ctrlPanel.add(setupPanel2);
1229
+ oe.ctrlPanel.Return();
9831230
984
- commandsPanel = new cGridBag().setVertical(false);
1231
+ objectCommandsPanel = new cGridBag().setVertical(false);
9851232
986
- resetButton = AddButton(commandsPanel, "Reset");
987
- stepButton = AddButton(commandsPanel, "Step");
1233
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1234
+ resetButton.setToolTipText("Jump to frame zero");
1235
+ stepButton = AddButton(objectCommandsPanel, "Step");
1236
+ stepButton.setToolTipText("Step one frame");
9881237 // resetAllButton = AddButton(oe, "Reset All");
9891238 // stepAllButton = AddButton(oe, "Step All");
990
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
9911239 // Return();
992
- slowerButton = AddButton(commandsPanel, "Slow");
993
- fasterButton = AddButton(commandsPanel, "Fast");
994
- remarkButton = AddButton(commandsPanel, "Remark");
1240
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1241
+ slowerButton.setToolTipText("Decrease animation speed");
1242
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1243
+ fasterButton.setToolTipText("Increase animation speed");
1244
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1245
+ remarkButton.setToolTipText("Set the current transform as the target");
9951246
996
- oe.ctrlPanel.add(commandsPanel);
1247
+ oe.ctrlPanel.add(objectCommandsPanel);
9971248 oe.ctrlPanel.Return();
9981249
999
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1250
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
10001251 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
10011252 //Return();
10021253
....@@ -1199,8 +1450,11 @@
11991450 //worldPanel.setName("World");
12001451 centralPanel = new cGridBag();
12011452 centralPanel.preferredWidth = 20;
1202
- timelinePanel = new JPanel(new BorderLayout());
1203
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1453
+
1454
+ if (Globals.ADVANCED)
1455
+ {
1456
+ timelinePanel = new JPanel(new BorderLayout());
1457
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
12041458
12051459 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
12061460 cameraPanel.setContinuousLayout(true);
....@@ -1209,7 +1463,10 @@
12091463 // cameraPanel.setDividerSize(9);
12101464 cameraPanel.setResizeWeight(1.0);
12111465
1466
+ }
1467
+
12121468 centralPanel.add(cameraView);
1469
+ centralPanel.setFocusable(true);
12131470 //frame.setJMenuBar(timelineMenubar);
12141471 //centralPanel.add(timelinePanel);
12151472
....@@ -1276,8 +1533,12 @@
12761533 // north.setName("Edit");
12771534 // north.add(ctrlPanel, BorderLayout.NORTH);
12781535 // objectPanel.add(north);
1279
- objectPanel.add(ctrlPanel);
1280
- objectPanel.add(infoPanel);
1536
+ objectPanel.add(editPanel);
1537
+
1538
+ //if (Globals.ADVANCED)
1539
+ objectPanel.add(infoPanel);
1540
+
1541
+ objectPanel.add(toolboxPanel);
12811542
12821543 /*
12831544 aConstraints.gridx = 0;
....@@ -1286,7 +1547,7 @@
12861547 aConstraints.gridy += 1;
12871548 aConstraints.gridwidth = 1;
12881549 mainPanel.add(objectPanel, aConstraints);
1289
- */
1550
+ */
12901551
12911552 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12921553 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1298,14 +1559,12 @@
12981559 scrollpane.addMouseWheelListener(this); // Default not fast enough
12991560
13001561 /*JTabbedPane*/ scenePanel = new cGridBag();
1301
- scenePanel.preferredWidth = 7;
1562
+ scenePanel.preferredWidth = 6;
13021563
13031564 JTabbedPane tabbedPane = new JTabbedPane();
13041565 tabbedPane.add(scrollpane);
13051566
1306
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1307
-
1308
- optionsPanel = new cGridBag().setVertical(true);
1567
+ optionsPanel = new cGridBag().setVertical(false);
13091568
13101569 optionsPanel.setName("Options");
13111570
....@@ -1313,6 +1572,8 @@
13131572
13141573 tabbedPane.add(optionsPanel);
13151574
1575
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1576
+
13161577 scenePanel.add(tabbedPane);
13171578
13181579 /*
....@@ -1385,9 +1646,9 @@
13851646 // aConstraints.gridheight = 1;
13861647
13871648 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1388
- framePanel.setContinuousLayout(true);
1389
- framePanel.setOneTouchExpandable(true);
1390
- framePanel.setDividerLocation(0.8);
1649
+ framePanel.setContinuousLayout(false);
1650
+ framePanel.setOneTouchExpandable(false);
1651
+ //.setDividerLocation(0.8);
13911652 //framePanel.setDividerSize(15);
13921653 //framePanel.setResizeWeight(0.15);
13931654 framePanel.setName("Frame");
....@@ -1404,10 +1665,15 @@
14041665
14051666 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14061667
1407
- frame.setSize(1024, 768);
1408
- frame.show();
1409
-
1668
+ frame.setSize(1280, 860);
1669
+
1670
+ cameraView.requestFocusInWindow();
1671
+
14101672 gridPanel.setDividerLocation(1.0);
1673
+
1674
+ frame.validate();
1675
+
1676
+ frame.setVisible(true);
14111677
14121678 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14131679 frame.addWindowListener(new WindowAdapter()
....@@ -1444,19 +1710,22 @@
14441710
14451711 cGridBag editBar = new cGridBag().setVertical(false);
14461712
1447
- editBar.add(createMaterialButton = new cButton("Create", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1713
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
14481714 createMaterialButton.setToolTipText("Create material");
14491715
14501716 /*
14511717 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14521718 */
14531719
1454
- editBar.add(clearMaterialButton = new cButton("Clear", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1720
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
14551721 clearMaterialButton.setToolTipText("Clear material");
14561722
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);
1723
+ if (Globals.ADVANCED)
1724
+ {
1725
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1726
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1727
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1728
+ }
14601729
14611730 editBar.preferredHeight = 15;
14621731
....@@ -1490,24 +1759,6 @@
14901759 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14911760 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14921761 colorSection.add(texture);
1493
-
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);
15111762
15121763 panel.add(new JSeparator());
15131764
....@@ -1559,6 +1810,12 @@
15591810 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15601811 diffuseSection.add(fakedepth);
15611812
1813
+ cGridBag shadowbias = new cGridBag();
1814
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1815
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1816
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1817
+ diffuseSection.add(shadowbias);
1818
+
15621819 panel.add(new JSeparator());
15631820
15641821 panel.add(diffuseSection);
....@@ -1609,6 +1866,18 @@
16091866 // aConstraints.gridy += 1;
16101867 // aConstraints.gridwidth = 1;
16111868
1869
+ cGridBag anisoU = new cGridBag();
1870
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1871
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1872
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1873
+ specularSection.add(anisoU);
1874
+
1875
+ cGridBag anisoV = new cGridBag();
1876
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1877
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1878
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1879
+ specularSection.add(anisoV);
1880
+
16121881
16131882 panel.add(new JSeparator());
16141883
....@@ -1616,35 +1885,35 @@
16161885
16171886 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16181887
1619
- cGridBag globalSection = new cGridBag().setVertical(true);
1888
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16201889
16211890 cGridBag camera = new cGridBag();
16221891 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16231892 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16241893 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1625
- globalSection.add(camera);
1894
+ colorSection.add(camera);
16261895
16271896 cGridBag ambient = new cGridBag();
16281897 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16291898 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16301899 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1631
- globalSection.add(ambient);
1900
+ colorSection.add(ambient);
16321901
16331902 cGridBag backlit = new cGridBag();
16341903 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16351904 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16361905 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1637
- globalSection.add(backlit);
1906
+ colorSection.add(backlit);
16381907
16391908 cGridBag opacity = new cGridBag();
16401909 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
16411910 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16421911 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1643
- globalSection.add(opacity);
1912
+ colorSection.add(opacity);
16441913
1645
- panel.add(new JSeparator());
1914
+ //panel.add(new JSeparator());
16461915
1647
- panel.add(globalSection);
1916
+ //panel.add(globalSection);
16481917
16491918 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16501919
....@@ -1725,12 +1994,15 @@
17251994 opacityPowerField.addChangeListener(this);
17261995 /**/
17271996
1728
- resetSlidersButton.addActionListener(this);
17291997 clearMaterialButton.addActionListener(this);
17301998 createMaterialButton.addActionListener(this);
1731
-
1732
- propagateToggle.addItemListener(this);
1733
- multiplyToggle.addItemListener(this);
1999
+
2000
+ if (Globals.ADVANCED)
2001
+ {
2002
+ resetSlidersButton.addActionListener(this);
2003
+ propagateToggle.addItemListener(this);
2004
+ multiplyToggle.addItemListener(this);
2005
+ }
17342006 }
17352007
17362008 void DropFile(java.io.File[] files, boolean textures)
....@@ -1748,8 +2020,9 @@
17482020 // 3D models
17492021 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17502022 {
1751
- lastConverter = new com.jmex.model.converters.MaxToJme();
1752
- LoadFile(filename, lastConverter);
2023
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2024
+ //LoadFile(filename, lastConverter);
2025
+ LoadObjFile(filename); // New 3ds loader
17532026 continue;
17542027 }
17552028 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1901,7 +2174,7 @@
19012174
19022175 //? flashIt = false;
19032176 CameraPane pane = (CameraPane) cameraView;
1904
- pane.clickStart(location.x, location.y, 0);
2177
+ pane.clickStart(location.x, location.y, 0, 0);
19052178 pane.clickEnd(location.x, location.y, 0, true);
19062179
19072180 if (group.selection.size() == 1)
....@@ -1950,6 +2223,7 @@
19502223 e2.printStackTrace();
19512224 }
19522225 }
2226
+
19532227 LoadJMEThread loadThread;
19542228
19552229 class LoadJMEThread extends Thread
....@@ -2007,6 +2281,7 @@
20072281 //LoadFile0(filename, converter);
20082282 }
20092283 }
2284
+
20102285 LoadOBJThread loadObjThread;
20112286
20122287 class LoadOBJThread extends Thread
....@@ -2085,19 +2360,19 @@
20852360
20862361 void LoadObjFile(String fullname)
20872362 {
2088
- /*
2363
+ System.out.println("Loading " + fullname);
2364
+ /**/
20892365 //lastFilename = fullname;
20902366 if(loadObjThread == null)
20912367 {
2092
- loadObjThread = new LoadOBJThread();
2093
- loadObjThread.start();
2368
+ loadObjThread = new LoadOBJThread();
2369
+ loadObjThread.start();
20942370 }
20952371
20962372 loadObjThread.add(fullname);
2097
- */
2373
+ /**/
20982374
2099
- System.out.println("Loading " + fullname);
2100
- makeSomething(new FileObject(fullname, true), true);
2375
+ //makeSomething(new FileObject(fullname, true), true);
21012376 }
21022377
21032378 void LoadGFDFile(String fullname)
....@@ -2358,11 +2633,11 @@
23582633
23592634 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23602635 {
2361
- if (GrafreeD.standAlone)
2636
+ if (Grafreed.standAlone)
23622637 {
23632638 /**/
23642639 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2365
- browser.show();
2640
+ browser.setVisible(true);
23662641 String filename = browser.getFile();
23672642 if (filename != null && filename.length() > 0)
23682643 {
....@@ -2473,6 +2748,7 @@
24732748 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24742749 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24752750 }
2751
+
24762752 //cJME.count++;
24772753 //cJME.count %= 12;
24782754 if (gc)
....@@ -2656,6 +2932,7 @@
26562932 }
26572933 }
26582934 }
2935
+
26592936 cFileSystemPane FSPane;
26602937
26612938 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2709,11 +2986,14 @@
27092986 }
27102987 }
27112988 }
2989
+
27122990 freezematerial = false;
27132991 }
27142992
27152993 void SetMaterial(Object3D object)
27162994 {
2995
+ latestObject = object;
2996
+
27172997 cMaterial mat = object.material;
27182998
27192999 if (mat == null)
....@@ -2722,7 +3002,8 @@
27223002 return;
27233003 }
27243004
2725
- multiplyToggle.setSelected(mat.multiply);
3005
+ if (multiplyToggle != null)
3006
+ multiplyToggle.setSelected(mat.multiply);
27263007
27273008 assert (object.projectedVertices != null);
27283009
....@@ -2824,12 +3105,17 @@
28243105 // }
28253106
28263107 /**/
2827
- if (deselect)
3108
+ if (deselect || child == null)
28283109 {
28293110 //group.deselectAll();
28303111 //freeze = true;
28313112 GetTree().clearSelection();
28323113 //freeze = false;
3114
+
3115
+ if (child == null)
3116
+ {
3117
+ return;
3118
+ }
28333119 }
28343120
28353121 //group.addSelectee(child);
....@@ -2898,7 +3184,7 @@
28983184 cameraView.ToggleDL();
28993185 cameraView.repaint();
29003186 return;
2901
- } else if (event.getSource() == toggleTextureItem)
3187
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29023188 {
29033189 cameraView.ToggleTexture();
29043190 // june 2013 copy.HardTouch();
....@@ -2937,9 +3223,9 @@
29373223 frame.validate();
29383224
29393225 return;
2940
- } else if (event.getSource() == toggleRandomItem)
3226
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29413227 {
2942
- cameraView.ToggleRandom();
3228
+ cameraView.ToggleSwitch();
29433229 cameraView.repaint();
29443230 return;
29453231 } else if (event.getSource() == toggleHandleItem)
....@@ -2968,6 +3254,10 @@
29683254 {
29693255 copy.live ^= true;
29703256 return;
3257
+ } else if (event.getSource() == selectCB)
3258
+ {
3259
+ copy.dontselect ^= true;
3260
+ return;
29713261 } else if (event.getSource() == hideCB)
29723262 {
29733263 copy.hide ^= true;
....@@ -2982,6 +3272,7 @@
29823272 if (event.getSource() == randomCB)
29833273 {
29843274 copy.random ^= true;
3275
+ objEditor.refreshContents();
29853276 return;
29863277 }
29873278 if (event.getSource() == speedupCB)
....@@ -3005,8 +3296,9 @@
30053296
30063297 public void actionPerformed(ActionEvent event)
30073298 {
3299
+ Object source = event.getSource();
30083300 // SCRIPT DIALOG
3009
- if (event.getSource() == okbutton)
3301
+ if (source == okbutton)
30103302 {
30113303 textpanel.setVisible(false);
30123304 textpanel.remove(textarea);
....@@ -3018,7 +3310,7 @@
30183310 textarea = null;
30193311 textpanel = null;
30203312 }
3021
- if (event.getSource() == cancelbutton)
3313
+ if (source == cancelbutton)
30223314 {
30233315 textpanel.setVisible(false);
30243316 textpanel.remove(textarea);
....@@ -3030,50 +3322,50 @@
30303322 //applySelf();
30313323 //client.refreshEditWindow();
30323324 //refreshContents();
3033
- if (event.getSource() == nameField)
3325
+ if (source == nameField)
30343326 {
30353327 //System.out.println("ObjEditor " + event);
30363328 applySelf0(true);
30373329 //parent.applySelf();
30383330 objEditor.refreshContents();
3039
- } else if (event.getSource() == resetButton)
3331
+ } else if (source == resetButton)
30403332 {
30413333 CameraPane.fullreset = true;
30423334 copy.Reset(); // ResetMeshes();
30433335 copy.Touch();
30443336 objEditor.refreshContents();
3045
- } else if (event.getSource() == stepItem)
3337
+ } else if (source == stepItem)
30463338 {
30473339 //cameraView.ONESTEP = true;
30483340 Globals.ONESTEP = true;
30493341 cameraView.repaint();
30503342 return;
3051
- } else if (event.getSource() == stepButton)
3343
+ } else if (source == stepButton)
30523344 {
30533345 copy.Step();
30543346 copy.Touch();
30553347 objEditor.refreshContents();
3056
- } else if (event.getSource() == slowerButton)
3348
+ } else if (source == slowerButton)
30573349 {
30583350 copy.Slower();
30593351 copy.Touch();
30603352 objEditor.refreshContents();
3061
- } else if (event.getSource() == fasterButton)
3353
+ } else if (source == fasterButton)
30623354 {
30633355 copy.Faster();
30643356 copy.Touch();
30653357 objEditor.refreshContents();
3066
- } else if (event.getSource() == remarkButton)
3358
+ } else if (source == remarkButton)
30673359 {
30683360 copy.Remark();
30693361 copy.Touch();
30703362 objEditor.refreshContents();
3071
- } else if (event.getSource() == stepAllButton)
3363
+ } else if (source == stepAllButton)
30723364 {
30733365 copy.StepAll();
30743366 copy.Touch();
30753367 objEditor.refreshContents();
3076
- } else if (event.getSource() == resetAllButton)
3368
+ } else if (source == resetAllButton)
30773369 {
30783370 //CameraPane.fullreset = true;
30793371 copy.ResetAll(); // ResetMeshes();
....@@ -3106,53 +3398,79 @@
31063398 // Close();
31073399 // }
31083400 // else
3109
- if (event.getSource() == resetSlidersButton)
3401
+ if (source == resetSlidersButton)
31103402 {
31113403 ResetSliders();
3112
- } else if (event.getSource() == clearMaterialButton)
3404
+ } else if (source == clearMaterialButton)
31133405 {
31143406 ClearMaterial();
3115
- } else if (event.getSource() == createMaterialButton)
3407
+ } else if (source == createMaterialButton)
31163408 {
31173409 CreateMaterial();
3118
- } else if (event.getSource() == clearPanelButton)
3410
+ } else if (source == clearPanelButton)
31193411 {
31203412 copy.ClearUI();
31213413 refreshContents(true);
3122
- } /*
3123
- }
3124
-
3125
- public boolean action(Event event, Object arg)
3126
- {
3127
- */ else if (event.getSource() == closeItem)
3414
+ } else if (source == importGFDItem)
3415
+ {
3416
+ ImportGFD();
3417
+ } else
3418
+ if (source == importVRMLX3DItem)
3419
+ {
3420
+ ImportVRMLX3D();
3421
+ } else
3422
+ if (source == import3DSItem)
3423
+ {
3424
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3425
+ } else
3426
+ if (source == importOBJItem)
3427
+ {
3428
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3429
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3430
+ browser.setVisible(true);
3431
+ String filename = browser.getFile();
3432
+ if (filename != null && filename.length() > 0)
3433
+ {
3434
+ String fullname = browser.getDirectory() + filename;
3435
+ makeSomething(ReadOBJ(fullname), true);
3436
+ }
3437
+ } else
3438
+ if (source == closeItem)
31283439 {
31293440 Close();
31303441 //return true;
3131
- } else if (event.getSource() == loadItem)
3442
+ } else if (source == openItem)
31323443 {
3133
- load();
3444
+ Open();
31343445 //return true;
3135
- } else if (event.getSource() == saveItem)
3446
+ } else if (source == newItem)
3447
+ {
3448
+ New();
3449
+ } else if (source == saveItem)
31363450 {
31373451 save();
31383452 //return true;
3139
- } else if (event.getSource() == saveAsItem)
3453
+ } else if (source == saveAsItem)
31403454 {
31413455 saveAs();
31423456 //return true;
3143
- } else if (event.getSource() == reexportItem)
3457
+ } else if (source == reexportItem)
31443458 {
31453459 reexport();
31463460 //return true;
3147
- } else if (event.getSource() == exportAsItem)
3461
+ } else if (source == exportAsItem)
31483462 {
31493463 export();
31503464 //return true;
3151
- } else if (event.getSource() == povItem)
3465
+ } else if (source == povItem)
31523466 {
31533467 generatePOV();
31543468 //return true;
3155
- } else if (event.getSource() == zBufferItem)
3469
+ } else if (event.getSource() == archiveItem)
3470
+ {
3471
+ cTools.Archive(frame);
3472
+ return;
3473
+ } else if (source == zBufferItem)
31563474 {
31573475 try
31583476 {
....@@ -3174,21 +3492,8 @@
31743492 cameraView.repaint();
31753493 //return true;
31763494 }
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)
3495
+ */ else // combos...
3496
+ if (source == texresMenu)
31923497 {
31933498 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31943499 copy.texres = texresMenu.getSelectedIndex();
....@@ -3200,6 +3505,403 @@
32003505 }
32013506 }
32023507
3508
+ void New()
3509
+ {
3510
+ while (copy.Size() > 1)
3511
+ {
3512
+ copy.remove(1);
3513
+ }
3514
+
3515
+ ResetModel();
3516
+ objEditor.refreshContents();
3517
+ }
3518
+
3519
+ static public byte[] Compress(Object3D o)
3520
+ {
3521
+ try
3522
+ {
3523
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3524
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3525
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
3526
+
3527
+ Object3D parent = o.parent;
3528
+ o.parent = null;
3529
+
3530
+ out.writeObject(o);
3531
+
3532
+ o.parent = parent;
3533
+
3534
+ out.flush();
3535
+
3536
+ baos //zstream
3537
+ .close();
3538
+ out.close();
3539
+
3540
+ byte[] bytes = baos.toByteArray();
3541
+
3542
+ System.out.println("save #bytes = " + bytes.length);
3543
+ return bytes;
3544
+ } catch (Exception e)
3545
+ {
3546
+ System.err.println(e);
3547
+ return null;
3548
+ }
3549
+ }
3550
+
3551
+ static public Object Uncompress(byte[] bytes)
3552
+ {
3553
+ System.out.println("restore #bytes = " + bytes.length);
3554
+ try
3555
+ {
3556
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3557
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3558
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
3559
+ Object obj = in.readObject();
3560
+
3561
+ bais //istream
3562
+ .close();
3563
+ in.close();
3564
+
3565
+ return obj;
3566
+ } catch (Exception e)
3567
+ {
3568
+ System.err.println(e);
3569
+ return null;
3570
+ }
3571
+ }
3572
+
3573
+ static public Object clone(Object o)
3574
+ {
3575
+ try
3576
+ {
3577
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3578
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3579
+
3580
+ out.writeObject(o);
3581
+
3582
+ out.flush();
3583
+ out.close();
3584
+
3585
+ byte[] bytes = baos.toByteArray();
3586
+
3587
+ System.out.println("clone = " + bytes.length);
3588
+
3589
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3590
+ ObjectInputStream in = new ObjectInputStream(bais);
3591
+ Object obj = in.readObject();
3592
+ in.close();
3593
+
3594
+ return obj;
3595
+ } catch (Exception e)
3596
+ {
3597
+ System.err.println(e);
3598
+ return null;
3599
+ }
3600
+ }
3601
+
3602
+ cRadio GetCurrentTab()
3603
+ {
3604
+ cRadio ab;
3605
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3606
+ {
3607
+ ab = (cRadio)e.nextElement();
3608
+ if(ab.GetObject() == copy)
3609
+ {
3610
+ return ab;
3611
+ }
3612
+ }
3613
+
3614
+ return null;
3615
+ }
3616
+
3617
+
3618
+ public void Save()
3619
+ {
3620
+ //Save(true);
3621
+ Replace();
3622
+ }
3623
+
3624
+ private boolean Equal(byte[] compress, byte[] name)
3625
+ {
3626
+ if (compress.length != name.length)
3627
+ {
3628
+ return false;
3629
+ }
3630
+
3631
+ for (int i=compress.length; --i>=0;)
3632
+ {
3633
+ if (compress[i] != name[i])
3634
+ return false;
3635
+ }
3636
+
3637
+ return true;
3638
+ }
3639
+
3640
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3641
+
3642
+ public boolean Save(boolean user)
3643
+ {
3644
+ System.err.println("Save");
3645
+
3646
+ cRadio tab = GetCurrentTab();
3647
+
3648
+ byte[] compress = CompressCopy();
3649
+
3650
+ boolean thesame = false;
3651
+
3652
+ // Quick heuristic using length. Works only when stream is compressed.
3653
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3654
+ {
3655
+ thesame = true;
3656
+ }
3657
+
3658
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3659
+ if (!thesame)
3660
+ {
3661
+ //tab.user[tab.versionindex] = user;
3662
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3663
+
3664
+ copy.versions[++copy.versionindex] = compress;
3665
+
3666
+ // if (increment)
3667
+ // tab.versionindex++;
3668
+ }
3669
+
3670
+ //copy.RestoreBigData(versiontable);
3671
+
3672
+ //assert(hashtable.isEmpty());
3673
+
3674
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3675
+ {
3676
+ //tab.user[i] = false;
3677
+ copy.versions[i] = null;
3678
+ }
3679
+
3680
+ SetUndoStates();
3681
+
3682
+ // test save
3683
+ if (false)
3684
+ {
3685
+ try
3686
+ {
3687
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
3688
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3689
+
3690
+ p.writeObject(copy);
3691
+
3692
+ p.flush();
3693
+
3694
+ ostream.close();
3695
+ } catch (Exception e)
3696
+ {
3697
+ e.printStackTrace();
3698
+ }
3699
+ }
3700
+
3701
+ return !thesame;
3702
+ }
3703
+
3704
+ void CopyChanged(Object3D obj)
3705
+ {
3706
+ SetUndoStates();
3707
+
3708
+ boolean temp = CameraPane.SWITCH;
3709
+ CameraPane.SWITCH = false;
3710
+
3711
+ copy.ExtractBigData(versiontable);
3712
+
3713
+ copy.clear();
3714
+
3715
+ for (int i=0; i<obj.Size(); i++)
3716
+ {
3717
+ copy.add(obj.get(i));
3718
+ }
3719
+
3720
+ copy.RestoreBigData(versiontable);
3721
+
3722
+ CameraPane.SWITCH = temp;
3723
+
3724
+ //assert(hashtable.isEmpty());
3725
+
3726
+ copy.Touch();
3727
+
3728
+ ResetModel();
3729
+ copy.HardTouch(); // recompile?
3730
+
3731
+ cRadio ab;
3732
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3733
+ {
3734
+ ab = (cRadio)e.nextElement();
3735
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3736
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3737
+ if (test != null)
3738
+ {
3739
+ test.editWindow = ab.object.editWindow;
3740
+ ab.object = test;
3741
+ }
3742
+ }
3743
+
3744
+ refreshContents();
3745
+ }
3746
+
3747
+ cButton undoButton;
3748
+ cButton restoreButton;
3749
+ cButton replaceButton;
3750
+ cButton redoButton;
3751
+
3752
+ boolean muteSlider;
3753
+
3754
+ int VersionCount()
3755
+ {
3756
+ int count = 0;
3757
+
3758
+ for (int i = copy.versions.length; --i >= 0;)
3759
+ {
3760
+ if (copy.versions[i] != null)
3761
+ count++;
3762
+ }
3763
+
3764
+ return count;
3765
+ }
3766
+
3767
+ void SetUndoStates()
3768
+ {
3769
+ cRadio tab = GetCurrentTab();
3770
+
3771
+ restoreButton.setEnabled(copy.versionindex != -1);
3772
+ replaceButton.setEnabled(copy.versionindex != -1);
3773
+
3774
+ undoButton.setEnabled(copy.versionindex > 0);
3775
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3776
+
3777
+ muteSlider = true;
3778
+ versionSlider.setMaximum(VersionCount() - 1);
3779
+ versionSlider.setInteger(copy.versionindex);
3780
+ muteSlider = false;
3781
+ }
3782
+
3783
+ public boolean Undo()
3784
+ {
3785
+ // Option?
3786
+ Replace();
3787
+
3788
+ System.err.println("Undo");
3789
+
3790
+ cRadio tab = GetCurrentTab();
3791
+
3792
+ if (copy.versionindex == 0)
3793
+ {
3794
+ java.awt.Toolkit.getDefaultToolkit().beep();
3795
+ return false;
3796
+ }
3797
+
3798
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3799
+// {
3800
+// if (Save(false))
3801
+// tab.versionindex -= 1;
3802
+// else
3803
+// {
3804
+// if (tab.versionindex <= 0)
3805
+// return false;
3806
+// else
3807
+// tab.versionindex -= 1;
3808
+// }
3809
+// }
3810
+
3811
+ copy.versionindex -= 1;
3812
+
3813
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3814
+
3815
+ return true;
3816
+ }
3817
+
3818
+ public boolean Restore()
3819
+ {
3820
+ System.err.println("Restore");
3821
+
3822
+ cRadio tab = GetCurrentTab();
3823
+
3824
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3825
+ {
3826
+ java.awt.Toolkit.getDefaultToolkit().beep();
3827
+ return false;
3828
+ }
3829
+
3830
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3831
+
3832
+ return true;
3833
+ }
3834
+
3835
+ public boolean Replace()
3836
+ {
3837
+ System.err.println("Replace");
3838
+
3839
+ cRadio tab = GetCurrentTab();
3840
+
3841
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3842
+ {
3843
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3844
+ return false;
3845
+ }
3846
+
3847
+ copy.versions[copy.versionindex] = CompressCopy();
3848
+
3849
+ return true;
3850
+ }
3851
+
3852
+ public void Redo()
3853
+ {
3854
+ // Option?
3855
+ Replace();
3856
+
3857
+ cRadio tab = GetCurrentTab();
3858
+
3859
+ if (copy.versions[copy.versionindex + 1] == null)
3860
+ {
3861
+ java.awt.Toolkit.getDefaultToolkit().beep();
3862
+ return;
3863
+ }
3864
+
3865
+ copy.versionindex += 1;
3866
+
3867
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3868
+
3869
+ //if (!tab.user[tab.versionindex])
3870
+ // tab.graphs[tab.versionindex] = null;
3871
+ }
3872
+
3873
+ void ImportGFD()
3874
+ {
3875
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3876
+ browser.show();
3877
+ String filename = browser.getFile();
3878
+ if (filename != null && filename.length() > 0)
3879
+ {
3880
+ String fullname = browser.getDirectory() + filename;
3881
+
3882
+ //Object3D readobj =
3883
+ objEditor.ReadGFD(fullname, objEditor);
3884
+ //makeSomething(readobj);
3885
+ }
3886
+ }
3887
+
3888
+ void ImportVRMLX3D()
3889
+ {
3890
+ if (Grafreed.standAlone)
3891
+ {
3892
+ /**/
3893
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3894
+ browser.show();
3895
+ String filename = browser.getFile();
3896
+ if (filename != null && filename.length() > 0)
3897
+ {
3898
+ String fullname = browser.getDirectory() + filename;
3899
+ LoadVRMLX3D(fullname);
3900
+ }
3901
+ /**/
3902
+ }
3903
+ }
3904
+
32033905 void ToggleAnimation()
32043906 {
32053907 if (!Globals.ANIMATION)
....@@ -3215,8 +3917,8 @@
32153917
32163918 Globals.ANIMATION ^= true;
32173919
3218
- GrafreeD.wav.cursor = 0;
3219
- GrafreeD.wav.loop = 0;
3920
+ Grafreed.wav.cursor = 0;
3921
+ Grafreed.wav.loop = 0;
32203922 }
32213923 } else
32223924 {
....@@ -3237,7 +3939,6 @@
32373939 callee.refreshContents();
32383940 } else
32393941 {
3240
- new Exception().printStackTrace();
32413942 System.exit(0);
32423943 }
32433944 }
....@@ -3267,7 +3968,7 @@
32673968 void CreateMaterial()
32683969 {
32693970 //copy.ClearMaterial(); // PATCH
3270
- copy.CreateMaterialS(multiplyToggle.isSelected());
3971
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32713972 if (copy.selection.size() > 0)
32723973 //SetMaterial(copy);
32733974 {
....@@ -3318,7 +4019,7 @@
33184019 assert false;
33194020 }
33204021
3321
- void EditSelection()
4022
+ void EditSelection(boolean newWindow)
33224023 {
33234024 }
33244025
....@@ -3326,11 +4027,11 @@
33264027 {
33274028 copy.ResetBlockLoop(); // temporary problem
33284029
3329
- boolean random = CameraPane.RANDOM;
3330
- CameraPane.RANDOM = false; // parse everything
4030
+ boolean random = CameraPane.SWITCH;
4031
+ CameraPane.SWITCH = false; // parse everything
33314032 copy.ResetDisplayList();
33324033 copy.HardTouch();
3333
- CameraPane.RANDOM = random;
4034
+ CameraPane.SWITCH = random;
33344035 }
33354036
33364037 // public void applySelf()
....@@ -3404,6 +4105,36 @@
34044105 {
34054106 //System.out.println("Propagate = " + propagate);
34064107 copy.UpdateMaterial(anchor, current, propagate);
4108
+
4109
+ if (copy.material != null)
4110
+ {
4111
+ cMaterial mat = copy.material;
4112
+
4113
+ colorField.SetToolTipValue((mat.color));
4114
+ modulationField.SetToolTipValue((mat.modulation));
4115
+ metalnessField.SetToolTipValue((mat.metalness));
4116
+ diffuseField.SetToolTipValue((mat.diffuse));
4117
+ specularField.SetToolTipValue((mat.specular));
4118
+ shininessField.SetToolTipValue((mat.shininess));
4119
+ shiftField.SetToolTipValue((mat.shift));
4120
+ ambientField.SetToolTipValue((mat.ambient));
4121
+ lightareaField.SetToolTipValue((mat.lightarea));
4122
+ diffusenessField.SetToolTipValue((mat.factor));
4123
+ velvetField.SetToolTipValue((mat.velvet));
4124
+ sheenField.SetToolTipValue((mat.sheen));
4125
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4126
+ backlitField.SetToolTipValue((mat.bump));
4127
+ anisoField.SetToolTipValue((mat.aniso));
4128
+ anisoVField.SetToolTipValue((mat.anisoV));
4129
+ cameraField.SetToolTipValue((mat.cameralight));
4130
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4131
+ shadowField.SetToolTipValue((mat.shadow));
4132
+ textureField.SetToolTipValue((mat.texture));
4133
+ opacityField.SetToolTipValue((mat.opacity));
4134
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4135
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
4136
+ }
4137
+
34074138 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34084139 {
34094140 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3432,9 +4163,25 @@
34324163 //copy.Touch();
34334164 }
34344165
4166
+ cNumberSlider versionSlider;
4167
+
34354168 public void stateChanged(ChangeEvent e)
34364169 {
34374170 // assert(false);
4171
+ if (e.getSource() == versionSlider)
4172
+ {
4173
+ if (muteSlider)
4174
+ return;
4175
+
4176
+ int version = versionSlider.getInteger();
4177
+
4178
+ if (copy.versions[version] != null)
4179
+ {
4180
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4181
+ }
4182
+
4183
+ return;
4184
+ }
34384185
34394186 if (freezematerial)
34404187 {
....@@ -3519,7 +4266,7 @@
35194266 }
35204267
35214268 if (normalpushField != null)
3522
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4269
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35234270 }
35244271
35254272 void SnapObject()
....@@ -3783,6 +4530,8 @@
37834530
37844531 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37854532 {
4533
+ if (Globals.REPLACEONMAKE) // && resetmodel)
4534
+ Save();
37864535 //Tween.set(thing, 0).target(1).start(tweenManager);
37874536 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37884537 // if (thing instanceof GenericJointDemo)
....@@ -3869,6 +4618,12 @@
38694618 {
38704619 ResetModel();
38714620 Select(thing.GetTreePath(), true, false); // unselect... false);
4621
+
4622
+ if (thing.Size() == 0)
4623
+ {
4624
+ //EditSelection(false);
4625
+ }
4626
+
38724627 refreshContents();
38734628 }
38744629
....@@ -3986,6 +4741,7 @@
39864741 }
39874742 }
39884743 }
4744
+
39894745 LoadGFDThread loadGFDThread;
39904746
39914747 void ReadGFD(String fullname, iCallBack cb)
....@@ -4005,8 +4761,10 @@
40054761
40064762 try
40074763 {
4764
+ // Try compressed version first.
40084765 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4009
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4766
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4767
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40104768
40114769 readobj = (Object3D) p.readObject();
40124770 istream.close();
....@@ -4014,7 +4772,20 @@
40144772 readobj.ResetDisplayList();
40154773 } catch (Exception e)
40164774 {
4017
- e.printStackTrace();
4775
+ //e.printStackTrace();
4776
+ try
4777
+ {
4778
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4779
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4780
+
4781
+ readobj = (Object3D) p.readObject();
4782
+ istream.close();
4783
+
4784
+ readobj.ResetDisplayList();
4785
+ } catch (Exception e2)
4786
+ {
4787
+ e2.printStackTrace();
4788
+ }
40184789 }
40194790 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40204791 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4060,6 +4831,12 @@
40604831
40614832 void LoadIt(Object obj)
40624833 {
4834
+ if (obj == null)
4835
+ {
4836
+ // Invalid file
4837
+ return;
4838
+ }
4839
+
40634840 System.out.println("Loaded " + obj);
40644841 //new Exception().printStackTrace();
40654842 Object3D readobj = (Object3D) obj;
....@@ -4069,6 +4846,8 @@
40694846
40704847 if (readobj != null)
40714848 {
4849
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4850
+ // Save();
40724851 try
40734852 {
40744853 //readobj.deepCopySelf(copy);
....@@ -4123,15 +4902,26 @@
41234902 c.addChild(csg);
41244903 }
41254904
4905
+ copy.versions = readobj.versions;
4906
+ copy.versionindex = readobj.versionindex;
4907
+
4908
+ if (copy.versions == null)
4909
+ {
4910
+ copy.versions = new byte[100][];
4911
+ copy.versionindex = -1;
4912
+ }
4913
+
4914
+ //? SetUndoStates();
4915
+
41264916 ResetModel();
41274917 copy.HardTouch(); // recompile?
41284918 refreshContents();
41294919 }
41304920 }
41314921
4132
- void load() // throws ClassNotFoundException
4922
+ void Open() // throws ClassNotFoundException
41334923 {
4134
- if (GrafreeD.standAlone)
4924
+ if (Grafreed.standAlone)
41354925 {
41364926 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41374927 browser.show();
....@@ -4218,11 +5008,13 @@
42185008 try
42195009 {
42205010 FileOutputStream ostream = new FileOutputStream(lastname);
4221
- ObjectOutputStream p = new ObjectOutputStream(ostream);
5011
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5012
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42225013
42235014 p.writeObject(copy);
42245015 p.flush();
42255016
5017
+ zstream.close();
42265018 ostream.close();
42275019
42285020 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4232,17 +5024,20 @@
42325024 {
42335025 }
42345026 }
5027
+
42355028 String lastname;
42365029
42375030 void saveAs()
42385031 {
4239
- if (GrafreeD.standAlone)
5032
+ if (Grafreed.standAlone)
42405033 {
42415034 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42425035 browser.setVisible(true);
42435036 String filename = browser.getFile();
42445037 if (filename != null && filename.length() > 0)
42455038 {
5039
+ if (!filename.endsWith(".gfd"))
5040
+ filename += ".gfd";
42465041 lastname = browser.getDirectory() + filename;
42475042 save();
42485043 }
....@@ -4341,13 +5136,13 @@
43415136 try
43425137 {
43435138 FileOutputStream ostream = new FileOutputStream(filename);
4344
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4345
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
5139
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5140
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43465141
43475142 Object3D objectparent = obj.parent;
43485143 obj.parent = null;
43495144
4350
- Object3D object = (Object3D) GrafreeD.clone(obj);
5145
+ Object3D object = (Object3D) Grafreed.clone(obj);
43515146
43525147 obj.parent = objectparent;
43535148
....@@ -4359,8 +5154,8 @@
43595154 p.writeObject(object);
43605155 p.flush();
43615156
5157
+ zstream.close();
43625158 ostream.close();
4363
- // zstream.close();
43645159
43655160 // group.selection.get(0).parent = parent;
43665161 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4381,7 +5176,7 @@
43815176 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43825177 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43835178 copy.generatePOV(buffer);
4384
- if (GrafreeD.standAlone)
5179
+ if (Grafreed.standAlone)
43855180 {
43865181 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43875182 browser.show();
....@@ -4407,19 +5202,18 @@
44075202 Object3D client;
44085203 Object3D copy;
44095204 MenuBar menuBar;
4410
- Menu windowMenu;
4411
- MenuItem loadItem;
5205
+ Menu fileMenu;
5206
+ MenuItem newItem;
5207
+ MenuItem openItem;
44125208 MenuItem saveItem;
44135209 MenuItem saveAsItem;
44145210 MenuItem exportAsItem;
44155211 MenuItem reexportItem;
44165212 MenuItem povItem;
44175213 MenuItem closeItem;
4418
- Menu cameraMenu;
5214
+
44195215 CheckboxMenuItem zBufferItem;
44205216 //MenuItem normalLensItem;
4421
- MenuItem editCameraItem;
4422
- MenuItem revertCameraItem;
44235217 MenuItem stepItem;
44245218 CheckboxMenuItem toggleLiveItem;
44255219 CheckboxMenuItem toggleFullScreenItem;
....@@ -4430,25 +5224,39 @@
44305224 CheckboxMenuItem toggleFootContactItem;
44315225 CheckboxMenuItem toggleDLItem;
44325226 CheckboxMenuItem toggleTextureItem;
4433
- CheckboxMenuItem toggleRandomItem;
5227
+ CheckboxMenuItem toggleSwitchItem;
44345228 CheckboxMenuItem toggleRootItem;
44355229 CheckboxMenuItem animationItem;
5230
+ MenuItem archiveItem;
44365231 CheckboxMenuItem toggleHandleItem;
44375232 CheckboxMenuItem togglePaintItem;
44385233 JSplitPane mainPanel;
44395234 JScrollPane scrollpane;
5235
+
44405236 JPanel toolbarPanel;
5237
+
44415238 cGridBag treePanel;
5239
+
44425240 JPanel radioPanel;
44435241 ButtonGroup buttonGroup;
4444
- cGridBag ctrlPanel;
5242
+
5243
+ cGridBag toolboxPanel;
44455244 cGridBag materialPanel;
5245
+ cGridBag ctrlPanel;
5246
+
44465247 JScrollPane infoPanel;
5248
+
44475249 cGridBag optionsPanel;
5250
+
44485251 JTabbedPane objectPanel;
5252
+ boolean materialFlushed;
5253
+ Object3D latestObject;
5254
+
44495255 cGridBag XYZPanel;
5256
+
44505257 JSplitPane gridPanel;
44515258 JSplitPane bigPanel;
5259
+
44525260 cGridBag bigThree;
44535261 cGridBag scenePanel;
44545262 cGridBag centralPanel;
....@@ -4563,8 +5371,13 @@
45635371 cNumberSlider fogField;
45645372 JLabel opacityPowerLabel;
45655373 cNumberSlider opacityPowerField;
4566
- JTree jTree;
5374
+ cTree jTree;
45675375 //ObjectUI parent;
45685376
45695377 cNumberSlider normalpushField;
5378
+
5379
+ private MenuItem importGFDItem;
5380
+ private MenuItem importVRMLX3DItem;
5381
+ private MenuItem import3DSItem;
5382
+ private MenuItem importOBJItem;
45705383 }