Normand Briere
2019-06-27 f78dd18c66d607b693c0bf5937fc59181bf5a26b
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
....@@ -242,6 +309,7 @@
242309 //localCopy.parent = null;
243310
244311 frame = new JFrame();
312
+ frame.setUndecorated(true);
245313 objEditor = this;
246314 this.callee = callee;
247315
....@@ -272,27 +340,48 @@
272340 return frame.action(event, obj);
273341 }
274342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
275348 void SetupMenu()
276349 {
277350 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..."));
351
+ menuBar.add(fileMenu = new Menu("File"));
352
+ fileMenu.add(newItem = new MenuItem("New"));
353
+ fileMenu.add(loadItem = new MenuItem("Open..."));
354
+
355
+ //oe.menuBar.add(menu = new Menu("Include"));
356
+ Menu menu = new Menu("Import");
357
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
358
+ importOBJItem.addActionListener(this);
359
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
360
+ import3DSItem.addActionListener(this);
361
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
362
+ importVRMLX3DItem.addActionListener(this);
363
+ menu.add("-");
364
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
365
+ importGFDItem.addActionListener(this);
366
+ fileMenu.add(menu);
367
+ fileMenu.add("-");
368
+
369
+ fileMenu.add(saveItem = new MenuItem("Save"));
370
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
283371 //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("-");
372
+ fileMenu.add("-");
373
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
374
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
375
+ fileMenu.add("-");
288376 if (client.parent != null)
289377 {
290
- windowMenu.add(closeItem = new MenuItem("Close"));
378
+ fileMenu.add(closeItem = new MenuItem("Close"));
291379 } else
292380 {
293
- windowMenu.add(closeItem = new MenuItem("Exit"));
381
+ fileMenu.add(closeItem = new MenuItem("Exit"));
294382 }
295383
384
+ newItem.addActionListener(this);
296385 loadItem.addActionListener(this);
297386 saveItem.addActionListener(this);
298387 saveAsItem.addActionListener(this);
....@@ -301,79 +390,64 @@
301390 //povItem.addActionListener(this);
302391 closeItem.addActionListener(this);
303392
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
-
359393 objectPanel = new JTabbedPane();
394
+
395
+ ChangeListener changeListener = new ChangeListener()
396
+ {
397
+ public void stateChanged(ChangeEvent changeEvent)
398
+ {
399
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
400
+// {
401
+// if (latestObject != null)
402
+// {
403
+// refreshContents(true);
404
+// SetMaterial(latestObject);
405
+// }
406
+//
407
+// materialFlushed = true;
408
+// }
409
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
410
+// {
411
+// if (listUI.size() == 0)
412
+// EditSelection(false);
413
+// }
414
+
415
+ refreshContents(false); // To refresh Info tab
416
+ }
417
+ };
418
+ objectPanel.addChangeListener(changeListener);
419
+
360420 toolbarPanel = new JPanel();
361421 toolbarPanel.setName("Toolbar");
362
- treePanel = new JPanel();
422
+ treePanel = new cGridBag();
363423 treePanel.setName("Tree");
424
+
425
+ editPanel = new cGridBag().setVertical(true);
426
+ editPanel.setName("Edit");
427
+
364428 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
365
- ctrlPanel.setName("Edit");
429
+
430
+ editCommandsPanel = new cGridBag();
431
+ editPanel.add(editCommandsPanel);
432
+ editPanel.add(ctrlPanel);
433
+
434
+ toolboxPanel = new cGridBag().setVertical(false);
435
+ toolboxPanel.setName("Toolbox");
436
+
366437 materialPanel = new cGridBag().setVertical(true);
367438 materialPanel.setName("Material");
439
+
368440 /*JTextPane*/
369441 infoarea = createTextPane();
442
+ doc = infoarea.getStyledDocument();
443
+
370444 infoarea.setEditable(true);
371445 SetText();
372446 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
373447 // infoarea.setOpaque(false);
374448 // //infoarea.setForeground(textcolor);
375
- infoarea.setLineWrap(true);
376
- infoarea.setWrapStyleWord(true);
449
+// TEXTAREA infoarea.setLineWrap(true);
450
+// TEXTAREA infoarea.setWrapStyleWord(true);
377451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
378452 infoPanel.setPreferredSize(new Dimension(50, 200));
379453 infoPanel.setName("Info");
....@@ -384,14 +458,20 @@
384458 mainPanel.setName("Main");
385459 mainPanel.setContinuousLayout(true);
386460 mainPanel.setOneTouchExpandable(true);
387
- mainPanel.setDividerLocation(1.0);
388461 mainPanel.setDividerSize(9);
389
- mainPanel.setResizeWeight(0);
390
-
462
+ mainPanel.setDividerLocation(0.5); //1.0);
463
+ mainPanel.setResizeWeight(0.5);
464
+
465
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
466
+// BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
467
+// divider.setDividerSize(15);
468
+// divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
469
+
470
+
391471 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
392472 //mainPanel.setLayout(new GridBagLayout());
393473 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
394
- treePanel.setLayout(new GridBagLayout());
474
+// treePanel.setLayout(new GridBagLayout());
395475 //ctrlPanel.setLayout(new GridBagLayout());
396476 //materialPanel.setLayout(new GridBagLayout());
397477
....@@ -432,7 +512,7 @@
432512 static String newline = "\n";
433513 protected static final String buttonString = "JButton";
434514 StyledDocument doc;
435
- JTextArea infoarea;
515
+ JTextPane infoarea;
436516
437517 void ClearInfo()
438518 {
....@@ -455,10 +535,10 @@
455535 e.printStackTrace();
456536 }
457537
458
- String selection = infoarea.getText();
459
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
460
- java.awt.datatransfer.Clipboard clipboard =
461
- Toolkit.getDefaultToolkit().getSystemClipboard();
538
+// String selection = infoarea.getText();
539
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
540
+// java.awt.datatransfer.Clipboard clipboard =
541
+// Toolkit.getDefaultToolkit().getSystemClipboard();
462542 //clipboard.setContents(data, data);
463543 }
464544
....@@ -481,13 +561,13 @@
481561 //SendInfo("Name:", "bold");
482562 if (sel.GetTextures() != null || debug)
483563 {
484
- si.SendInfo(sel.toString(), "bold");
564
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
485565 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
486566 if (sel.Size() > 0)
487567 {
488568 si.SendInfo("#children = " + sel.Size(), "regular");
489569 }
490
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
570
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
491571 if (debug)
492572 {
493573 try
....@@ -499,7 +579,10 @@
499579 }
500580
501581 if (full)
502
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
582
+ {
583
+ si.SendInfo(" BBox min: " + minima, "regular");
584
+ si.SendInfo(" BBox max: " + maxima, "regular");
585
+ }
503586
504587 if (sel.bRep != null)
505588 {
....@@ -526,7 +609,7 @@
526609 }
527610 if (sel.support != null)
528611 {
529
- si.SendInfo(" support: " + sel.support, "regular");
612
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
530613 }
531614 if (sel.scriptnode != null)
532615 {
....@@ -597,6 +680,9 @@
597680 {
598681 CameraPane.pointflow = (PointFlow) sel;
599682 }
683
+
684
+ si.SendInfo("_____________________", "regular");
685
+ si.SendInfo("", "regular");
600686 }
601687 }
602688
....@@ -612,68 +698,140 @@
612698 }
613699 }
614700
701
+static GraphicsDevice device = GraphicsEnvironment
702
+ .getLocalGraphicsEnvironment().getScreenDevices()[0];
703
+
704
+ Rectangle keeprect;
705
+ cRadio radio;
706
+
707
+cButton keepButton;
708
+ cButton twoButton; // Full 3D
709
+ cButton sixButton;
710
+ cButton threeButton;
711
+ cButton sevenButton;
712
+ cButton fourButton; // full panel
713
+ cButton oneButton; // full XYZ
714
+ //cButton currentLayout;
715
+
716
+ boolean maximized;
717
+
718
+ cButton fullscreenLayout;
719
+
720
+ void Minimize()
721
+ {
722
+ frame.setState(Frame.ICONIFIED);
723
+ }
724
+
725
+ void Maximize()
726
+ {
727
+ if (maximized)
728
+ {
729
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
730
+ }
731
+ else
732
+ {
733
+ keeprect = frame.getBounds();
734
+ Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
735
+ Dimension rect2 = frame.getToolkit().getScreenSize();
736
+ frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
737
+// frame.setState(Frame.MAXIMIZED_BOTH);
738
+ }
739
+
740
+ maximized ^= true;
741
+ }
742
+
615743 void ToggleFullScreen()
616744 {
617
- if (CameraPane.FULLSCREEN)
745
+ cameraView.ToggleFullScreen();
746
+
747
+ if (!CameraPane.FULLSCREEN)
618748 {
619
- frame.getContentPane().remove(/*"Center",*/bigThree);
620
- framePanel.add(bigThree);
621
- frame.getContentPane().add(/*"Center",*/framePanel);
749
+ device.setFullScreenWindow(null);
750
+ //frame.setVisible(false);
751
+// frame.removeNotify();
752
+// frame.setUndecorated(false);
753
+// frame.addNotify();
754
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
755
+
756
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
757
+// X framePanel.add(bigThree);
758
+// X frame.getContentPane().add(/*"Center",*/framePanel);
759
+ framePanel.setDividerLocation(1);
760
+
761
+ //frame.setVisible(true);
762
+ radio.layout = keepButton;
763
+ //theFrame = null;
764
+ keepButton = null;
765
+ radio.layout.doClick();
766
+
622767 } else
623768 {
624
- frame.getContentPane().remove(/*"Center",*/framePanel);
625
- framePanel.remove(bigThree);
626
- frame.getContentPane().add(/*"Center",*/bigThree);
769
+ keepButton = radio.layout;
770
+ //keeprect = frame.getBounds();
771
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
772
+// frame.getToolkit().getScreenSize().height);
773
+ //frame.setVisible(false);
774
+ device.setFullScreenWindow(frame);
775
+// frame.removeNotify();
776
+// frame.setUndecorated(true);
777
+// frame.addNotify();
778
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
779
+// X framePanel.remove(bigThree);
780
+// X frame.getContentPane().add(/*"Center",*/bigThree);
781
+ framePanel.setDividerLocation(0);
782
+
783
+ radio.layout = fullscreenLayout;
784
+ radio.layout.doClick();
785
+ //frame.setVisible(true);
627786 }
628
- cameraView.ToggleFullScreen();
629787 }
630788
631
- private JTextArea createTextPane()
789
+ private JTextPane createTextPane()
632790 {
633
- String[] initString =
634
- {
635
- "This is an editable JTextPane, ", //regular
636
- "another ", //italic
637
- "styled ", //bold
638
- "text ", //small
639
- "component, ", //large
640
- "which supports embedded components..." + newline,//regular
641
- " " + newline, //button
642
- "...and embedded icons..." + newline, //regular
643
- " ", //icon
644
- newline + "JTextPane is a subclass of JEditorPane that "
645
- + "uses a StyledEditorKit and StyledDocument, and provides "
646
- + "cover methods for interacting with those objects."
647
- };
791
+// TEXTAREA String[] initString =
792
+// {
793
+// "This is an editable JTextPane, ", //regular
794
+// "another ", //italic
795
+// "styled ", //bold
796
+// "text ", //small
797
+// "component, ", //large
798
+// "which supports embedded components..." + newline,//regular
799
+// " " + newline, //button
800
+// "...and embedded icons..." + newline, //regular
801
+// " ", //icon
802
+// newline + "JTextPane is a subclass of JEditorPane that "
803
+// + "uses a StyledEditorKit and StyledDocument, and provides "
804
+// + "cover methods for interacting with those objects."
805
+// };
806
+//
807
+// String[] initStyles =
808
+// {
809
+// "regular", "italic", "bold", "small", "large",
810
+// "regular", "button", "regular", "icon",
811
+// "regular"
812
+// };
813
+//
814
+// JTextPane textPane = new JTextPane();
815
+// textPane.setEditable(true);
816
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
817
+// addStylesToDocument(doc);
818
+//
819
+// try
820
+// {
821
+// for (int j = 0; j < 2; j++)
822
+// {
823
+// for (int i = 0; i < initString.length; i++)
824
+// {
825
+// doc.insertString(doc.getLength(), initString[i],
826
+// doc.getStyle(initStyles[i]));
827
+// }
828
+// }
829
+// } catch (BadLocationException ble)
830
+// {
831
+// System.err.println("Couldn't insert initial text into text pane.");
832
+// }
648833
649
- String[] initStyles =
650
- {
651
- "regular", "italic", "bold", "small", "large",
652
- "regular", "button", "regular", "icon",
653
- "regular"
654
- };
655
-
656
- JTextPane textPane = new JTextPane();
657
- textPane.setEditable(true);
658
- /*StyledDocument*/ doc = textPane.getStyledDocument();
659
- addStylesToDocument(doc);
660
-
661
- try
662
- {
663
- for (int j = 0; j < 2; j++)
664
- {
665
- for (int i = 0; i < initString.length; i++)
666
- {
667
- doc.insertString(doc.getLength(), initString[i],
668
- doc.getStyle(initStyles[i]));
669
- }
670
- }
671
- } catch (BadLocationException ble)
672
- {
673
- System.err.println("Couldn't insert initial text into text pane.");
674
- }
675
-
676
- return new JTextArea(); // textPane;
834
+ return new JTextPane(); // textPane;
677835 }
678836
679837 protected void addStylesToDocument(StyledDocument doc)
....@@ -726,7 +884,7 @@
726884 protected static ImageIcon createImageIcon(String path,
727885 String description)
728886 {
729
- java.net.URL imgURL = GrafreeD.class.getResource(path);
887
+ java.net.URL imgURL = Grafreed.class.getResource(path);
730888 if (imgURL != null)
731889 {
732890 return new ImageIcon(imgURL, description);
....@@ -758,6 +916,7 @@
758916 // NumberSlider vDivsField;
759917 // JCheckBox endcaps;
760918 JCheckBox liveCB;
919
+ JCheckBox selectCB;
761920 JCheckBox hideCB;
762921 JCheckBox link2masterCB;
763922 JCheckBox markCB;
....@@ -765,7 +924,12 @@
765924 JCheckBox speedupCB;
766925 JCheckBox rewindCB;
767926 JCheckBox flipVCB;
927
+
928
+ cCheckBox toggleTextureCB;
929
+ cCheckBox toggleSwitchCB;
930
+
768931 JComboBox texresMenu;
932
+
769933 JButton resetButton;
770934 JButton stepButton;
771935 JButton stepAllButton;
....@@ -774,9 +938,13 @@
774938 JButton fasterButton;
775939 JButton remarkButton;
776940
941
+ cGridBag editPanel;
942
+ cGridBag editCommandsPanel;
943
+
777944 cGridBag namePanel;
778945 cGridBag setupPanel;
779
- cGridBag commandsPanel;
946
+ cGridBag setupPanel2;
947
+ cGridBag objectCommandsPanel;
780948 cGridBag pushPanel;
781949 cGridBag fillPanel;
782950
....@@ -943,10 +1111,6 @@
9431111
9441112 void SetupUI2(ObjEditor oe)
9451113 {
946
-// oe.aConstraints.weightx = 0;
947
-// oe.aConstraints.weighty = 0;
948
-// oe.aConstraints.gridx = 0;
949
-// oe.aConstraints.gridy = 0;
9501114 //SetupName(oe);
9511115
9521116 namePanel = new cGridBag();
....@@ -957,38 +1121,62 @@
9571121
9581122 oe.ctrlPanel.Return();
9591123
960
- if (!GroupEditor.allparams)
1124
+ if (!allparams)
9611125 return;
9621126
9631127 setupPanel = new cGridBag().setVertical(false);
9641128
9651129 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
966
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
967
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1130
+ liveCB.setToolTipText("Animate object");
1131
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1132
+ selectCB.setToolTipText("Make object selectable");
9681133 // Return();
1134
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1135
+ hideCB.setToolTipText("Hide object");
9691136 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
970
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
971
- randomCB = AddCheckBox(setupPanel, "Rand", copy.random);
1137
+ markCB.setToolTipText("As animation target transform");
1138
+
1139
+ setupPanel2 = new cGridBag().setVertical(false);
1140
+
1141
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1142
+ rewindCB.setToolTipText("Rewind animation");
1143
+
1144
+ randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1145
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9721146
1147
+ if (Globals.ADVANCED)
1148
+ {
1149
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1150
+ link2masterCB.setToolTipText("Attach to support");
1151
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1152
+ speedupCB.setToolTipText("Option motion capture");
1153
+ }
1154
+
9731155 oe.ctrlPanel.add(setupPanel);
9741156 oe.ctrlPanel.Return();
1157
+ oe.ctrlPanel.add(setupPanel2);
1158
+ oe.ctrlPanel.Return();
9751159
976
- commandsPanel = new cGridBag().setVertical(false);
1160
+ objectCommandsPanel = new cGridBag().setVertical(false);
9771161
978
- resetButton = AddButton(commandsPanel, "Reset");
979
- stepButton = AddButton(commandsPanel, "Step");
1162
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1163
+ resetButton.setToolTipText("Jump to frame zero");
1164
+ stepButton = AddButton(objectCommandsPanel, "Step");
1165
+ stepButton.setToolTipText("Step one frame");
9801166 // resetAllButton = AddButton(oe, "Reset All");
9811167 // stepAllButton = AddButton(oe, "Step All");
982
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
9831168 // Return();
984
- slowerButton = AddButton(commandsPanel, "Slow");
985
- fasterButton = AddButton(commandsPanel, "Fast");
986
- remarkButton = AddButton(commandsPanel, "Remark");
1169
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1170
+ slowerButton.setToolTipText("Decrease animation speed");
1171
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1172
+ fasterButton.setToolTipText("Increase animation speed");
1173
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1174
+ remarkButton.setToolTipText("Set the current transform as the target");
9871175
988
- oe.ctrlPanel.add(commandsPanel);
1176
+ oe.ctrlPanel.add(objectCommandsPanel);
9891177 oe.ctrlPanel.Return();
9901178
991
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1179
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
9921180 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
9931181 //Return();
9941182
....@@ -1191,8 +1379,11 @@
11911379 //worldPanel.setName("World");
11921380 centralPanel = new cGridBag();
11931381 centralPanel.preferredWidth = 20;
1194
- timelinePanel = new JPanel(new BorderLayout());
1195
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1382
+
1383
+ if (Globals.ADVANCED)
1384
+ {
1385
+ timelinePanel = new JPanel(new BorderLayout());
1386
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11961387
11971388 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11981389 cameraPanel.setContinuousLayout(true);
....@@ -1201,7 +1392,10 @@
12011392 // cameraPanel.setDividerSize(9);
12021393 cameraPanel.setResizeWeight(1.0);
12031394
1395
+ }
1396
+
12041397 centralPanel.add(cameraView);
1398
+ centralPanel.setFocusable(true);
12051399 //frame.setJMenuBar(timelineMenubar);
12061400 //centralPanel.add(timelinePanel);
12071401
....@@ -1268,8 +1462,9 @@
12681462 // north.setName("Edit");
12691463 // north.add(ctrlPanel, BorderLayout.NORTH);
12701464 // objectPanel.add(north);
1271
- objectPanel.add(ctrlPanel);
1465
+ objectPanel.add(editPanel);
12721466 objectPanel.add(infoPanel);
1467
+ objectPanel.add(toolboxPanel);
12731468
12741469 /*
12751470 aConstraints.gridx = 0;
....@@ -1278,7 +1473,7 @@
12781473 aConstraints.gridy += 1;
12791474 aConstraints.gridwidth = 1;
12801475 mainPanel.add(objectPanel, aConstraints);
1281
- */
1476
+ */
12821477
12831478 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12841479 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1290,14 +1485,12 @@
12901485 scrollpane.addMouseWheelListener(this); // Default not fast enough
12911486
12921487 /*JTabbedPane*/ scenePanel = new cGridBag();
1293
- scenePanel.preferredWidth = 7;
1488
+ scenePanel.preferredWidth = 6;
12941489
12951490 JTabbedPane tabbedPane = new JTabbedPane();
12961491 tabbedPane.add(scrollpane);
12971492
1298
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1299
-
1300
- optionsPanel = new cGridBag().setVertical(true);
1493
+ optionsPanel = new cGridBag().setVertical(false);
13011494
13021495 optionsPanel.setName("Options");
13031496
....@@ -1305,6 +1498,8 @@
13051498
13061499 tabbedPane.add(optionsPanel);
13071500
1501
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1502
+
13081503 scenePanel.add(tabbedPane);
13091504
13101505 /*
....@@ -1396,9 +1591,13 @@
13961591
13971592 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13981593
1399
- frame.setSize(1024, 768);
1400
- frame.show();
1594
+ frame.setSize(1280, 860);
1595
+
1596
+ frame.validate();
1597
+ frame.setVisible(true);
14011598
1599
+ cameraView.requestFocusInWindow();
1600
+
14021601 gridPanel.setDividerLocation(1.0);
14031602
14041603 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -1436,17 +1635,25 @@
14361635
14371636 cGridBag editBar = new cGridBag().setVertical(false);
14381637
1439
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
1638
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1639
+ createMaterialButton.setToolTipText("Create material");
14401640
14411641 /*
14421642 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14431643 */
14441644
1445
- editBar.add(clearMaterialButton = new cButton("Clear")); // , aConstraints);
1446
- editBar.add(resetSlidersButton = new cButton("Reset")); // , aConstraints);
1447
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1448
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1645
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1646
+ clearMaterialButton.setToolTipText("Clear material");
1647
+
1648
+ if (Globals.ADVANCED)
1649
+ {
1650
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1651
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1652
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1653
+ }
14491654
1655
+ editBar.preferredHeight = 15;
1656
+
14501657 panel.add(editBar);
14511658
14521659 /**/
....@@ -1712,12 +1919,15 @@
17121919 opacityPowerField.addChangeListener(this);
17131920 /**/
17141921
1715
- resetSlidersButton.addActionListener(this);
17161922 clearMaterialButton.addActionListener(this);
17171923 createMaterialButton.addActionListener(this);
1718
-
1719
- propagateToggle.addItemListener(this);
1720
- multiplyToggle.addItemListener(this);
1924
+
1925
+ if (Globals.ADVANCED)
1926
+ {
1927
+ resetSlidersButton.addActionListener(this);
1928
+ propagateToggle.addItemListener(this);
1929
+ multiplyToggle.addItemListener(this);
1930
+ }
17211931 }
17221932
17231933 void DropFile(java.io.File[] files, boolean textures)
....@@ -1888,7 +2098,7 @@
18882098
18892099 //? flashIt = false;
18902100 CameraPane pane = (CameraPane) cameraView;
1891
- pane.clickStart(location.x, location.y, 0);
2101
+ pane.clickStart(location.x, location.y, 0, 0);
18922102 pane.clickEnd(location.x, location.y, 0, true);
18932103
18942104 if (group.selection.size() == 1)
....@@ -1937,6 +2147,7 @@
19372147 e2.printStackTrace();
19382148 }
19392149 }
2150
+
19402151 LoadJMEThread loadThread;
19412152
19422153 class LoadJMEThread extends Thread
....@@ -1994,6 +2205,7 @@
19942205 //LoadFile0(filename, converter);
19952206 }
19962207 }
2208
+
19972209 LoadOBJThread loadObjThread;
19982210
19992211 class LoadOBJThread extends Thread
....@@ -2072,19 +2284,19 @@
20722284
20732285 void LoadObjFile(String fullname)
20742286 {
2075
- /*
2287
+ System.out.println("Loading " + fullname);
2288
+ /**/
20762289 //lastFilename = fullname;
20772290 if(loadObjThread == null)
20782291 {
2079
- loadObjThread = new LoadOBJThread();
2080
- loadObjThread.start();
2292
+ loadObjThread = new LoadOBJThread();
2293
+ loadObjThread.start();
20812294 }
20822295
20832296 loadObjThread.add(fullname);
2084
- */
2297
+ /**/
20852298
2086
- System.out.println("Loading " + fullname);
2087
- makeSomething(new FileObject(fullname, true), true);
2299
+ //makeSomething(new FileObject(fullname, true), true);
20882300 }
20892301
20902302 void LoadGFDFile(String fullname)
....@@ -2345,11 +2557,11 @@
23452557
23462558 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23472559 {
2348
- if (GrafreeD.standAlone)
2560
+ if (Grafreed.standAlone)
23492561 {
23502562 /**/
23512563 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2352
- browser.show();
2564
+ browser.setVisible(true);
23532565 String filename = browser.getFile();
23542566 if (filename != null && filename.length() > 0)
23552567 {
....@@ -2701,6 +2913,8 @@
27012913
27022914 void SetMaterial(Object3D object)
27032915 {
2916
+ latestObject = object;
2917
+
27042918 cMaterial mat = object.material;
27052919
27062920 if (mat == null)
....@@ -2709,7 +2923,8 @@
27092923 return;
27102924 }
27112925
2712
- multiplyToggle.setSelected(mat.multiply);
2926
+ if (multiplyToggle != null)
2927
+ multiplyToggle.setSelected(mat.multiply);
27132928
27142929 assert (object.projectedVertices != null);
27152930
....@@ -2811,12 +3026,17 @@
28113026 // }
28123027
28133028 /**/
2814
- if (deselect)
3029
+ if (deselect || child == null)
28153030 {
28163031 //group.deselectAll();
28173032 //freeze = true;
28183033 GetTree().clearSelection();
28193034 //freeze = false;
3035
+
3036
+ if (child == null)
3037
+ {
3038
+ return;
3039
+ }
28203040 }
28213041
28223042 //group.addSelectee(child);
....@@ -2885,7 +3105,7 @@
28853105 cameraView.ToggleDL();
28863106 cameraView.repaint();
28873107 return;
2888
- } else if (event.getSource() == toggleTextureItem)
3108
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28893109 {
28903110 cameraView.ToggleTexture();
28913111 // june 2013 copy.HardTouch();
....@@ -2924,9 +3144,9 @@
29243144 frame.validate();
29253145
29263146 return;
2927
- } else if (event.getSource() == toggleRandomItem)
3147
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29283148 {
2929
- cameraView.ToggleRandom();
3149
+ cameraView.ToggleSwitch();
29303150 cameraView.repaint();
29313151 return;
29323152 } else if (event.getSource() == toggleHandleItem)
....@@ -2955,6 +3175,10 @@
29553175 {
29563176 copy.live ^= true;
29573177 return;
3178
+ } else if (event.getSource() == selectCB)
3179
+ {
3180
+ copy.dontselect ^= true;
3181
+ return;
29583182 } else if (event.getSource() == hideCB)
29593183 {
29603184 copy.hide ^= true;
....@@ -2969,6 +3193,7 @@
29693193 if (event.getSource() == randomCB)
29703194 {
29713195 copy.random ^= true;
3196
+ objEditor.refreshContents();
29723197 return;
29733198 }
29743199 if (event.getSource() == speedupCB)
....@@ -2992,8 +3217,9 @@
29923217
29933218 public void actionPerformed(ActionEvent event)
29943219 {
3220
+ Object source = event.getSource();
29953221 // SCRIPT DIALOG
2996
- if (event.getSource() == okbutton)
3222
+ if (source == okbutton)
29973223 {
29983224 textpanel.setVisible(false);
29993225 textpanel.remove(textarea);
....@@ -3005,7 +3231,7 @@
30053231 textarea = null;
30063232 textpanel = null;
30073233 }
3008
- if (event.getSource() == cancelbutton)
3234
+ if (source == cancelbutton)
30093235 {
30103236 textpanel.setVisible(false);
30113237 textpanel.remove(textarea);
....@@ -3017,50 +3243,50 @@
30173243 //applySelf();
30183244 //client.refreshEditWindow();
30193245 //refreshContents();
3020
- if (event.getSource() == nameField)
3246
+ if (source == nameField)
30213247 {
30223248 //System.out.println("ObjEditor " + event);
30233249 applySelf0(true);
30243250 //parent.applySelf();
30253251 objEditor.refreshContents();
3026
- } else if (event.getSource() == resetButton)
3252
+ } else if (source == resetButton)
30273253 {
30283254 CameraPane.fullreset = true;
30293255 copy.Reset(); // ResetMeshes();
30303256 copy.Touch();
30313257 objEditor.refreshContents();
3032
- } else if (event.getSource() == stepItem)
3258
+ } else if (source == stepItem)
30333259 {
30343260 //cameraView.ONESTEP = true;
30353261 Globals.ONESTEP = true;
30363262 cameraView.repaint();
30373263 return;
3038
- } else if (event.getSource() == stepButton)
3264
+ } else if (source == stepButton)
30393265 {
30403266 copy.Step();
30413267 copy.Touch();
30423268 objEditor.refreshContents();
3043
- } else if (event.getSource() == slowerButton)
3269
+ } else if (source == slowerButton)
30443270 {
30453271 copy.Slower();
30463272 copy.Touch();
30473273 objEditor.refreshContents();
3048
- } else if (event.getSource() == fasterButton)
3274
+ } else if (source == fasterButton)
30493275 {
30503276 copy.Faster();
30513277 copy.Touch();
30523278 objEditor.refreshContents();
3053
- } else if (event.getSource() == remarkButton)
3279
+ } else if (source == remarkButton)
30543280 {
30553281 copy.Remark();
30563282 copy.Touch();
30573283 objEditor.refreshContents();
3058
- } else if (event.getSource() == stepAllButton)
3284
+ } else if (source == stepAllButton)
30593285 {
30603286 copy.StepAll();
30613287 copy.Touch();
30623288 objEditor.refreshContents();
3063
- } else if (event.getSource() == resetAllButton)
3289
+ } else if (source == resetAllButton)
30643290 {
30653291 //CameraPane.fullreset = true;
30663292 copy.ResetAll(); // ResetMeshes();
....@@ -3093,53 +3319,75 @@
30933319 // Close();
30943320 // }
30953321 // else
3096
- if (event.getSource() == resetSlidersButton)
3322
+ if (source == resetSlidersButton)
30973323 {
30983324 ResetSliders();
3099
- } else if (event.getSource() == clearMaterialButton)
3325
+ } else if (source == clearMaterialButton)
31003326 {
31013327 ClearMaterial();
3102
- } else if (event.getSource() == createMaterialButton)
3328
+ } else if (source == createMaterialButton)
31033329 {
31043330 CreateMaterial();
3105
- } else if (event.getSource() == clearPanelButton)
3331
+ } else if (source == clearPanelButton)
31063332 {
31073333 copy.ClearUI();
31083334 refreshContents(true);
3109
- } /*
3110
- }
3111
-
3112
- public boolean action(Event event, Object arg)
3113
- {
3114
- */ else if (event.getSource() == closeItem)
3335
+ } else if (source == importGFDItem)
3336
+ {
3337
+ ImportGFD();
3338
+ } else
3339
+ if (source == importVRMLX3DItem)
3340
+ {
3341
+ ImportVRMLX3D();
3342
+ } else
3343
+ if (source == import3DSItem)
3344
+ {
3345
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3346
+ } else
3347
+ if (source == importOBJItem)
3348
+ {
3349
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3350
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3351
+ browser.setVisible(true);
3352
+ String filename = browser.getFile();
3353
+ if (filename != null && filename.length() > 0)
3354
+ {
3355
+ String fullname = browser.getDirectory() + filename;
3356
+ makeSomething(ReadOBJ(fullname), true);
3357
+ }
3358
+ } else
3359
+ if (source == closeItem)
31153360 {
31163361 Close();
31173362 //return true;
3118
- } else if (event.getSource() == loadItem)
3363
+ } else if (source == loadItem)
31193364 {
31203365 load();
31213366 //return true;
3122
- } else if (event.getSource() == saveItem)
3367
+ } else if (source == newItem)
3368
+ {
3369
+ New();
3370
+ } else if (source == saveItem)
31233371 {
31243372 save();
31253373 //return true;
3126
- } else if (event.getSource() == saveAsItem)
3374
+ } else if (source == saveAsItem)
31273375 {
31283376 saveAs();
31293377 //return true;
3130
- } else if (event.getSource() == reexportItem)
3378
+ } else if (source == reexportItem)
31313379 {
31323380 reexport();
31333381 //return true;
3134
- } else if (event.getSource() == exportAsItem)
3382
+ } else if (source == exportAsItem)
31353383 {
31363384 export();
31373385 //return true;
3138
- } else if (event.getSource() == povItem)
3386
+ } else if (source == povItem)
31393387 {
31403388 generatePOV();
31413389 //return true;
3142
- } else if (event.getSource() == zBufferItem)
3390
+ } else if (source == zBufferItem)
31433391 {
31443392 try
31453393 {
....@@ -3161,21 +3409,8 @@
31613409 cameraView.repaint();
31623410 //return true;
31633411 }
3164
- */ else if (event.getSource() == editCameraItem)
3165
- {
3166
- cameraView.ProtectCamera();
3167
- cameraView.repaint();
3168
- return;
3169
- } else if (event.getSource() == revertCameraItem)
3170
- {
3171
- cameraView.RevertCamera();
3172
- cameraView.repaint();
3173
- return;
3174
-// } else if (event.getSource() == textureButton)
3175
-// {
3176
-// return; // true;
3177
- } else // combos...
3178
- if (event.getSource() == texresMenu)
3412
+ */ else // combos...
3413
+ if (source == texresMenu)
31793414 {
31803415 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31813416 copy.texres = texresMenu.getSelectedIndex();
....@@ -3187,12 +3422,287 @@
31873422 }
31883423 }
31893424
3425
+ void New()
3426
+ {
3427
+ while (copy.Size() > 1)
3428
+ {
3429
+ copy.remove(1);
3430
+ }
3431
+
3432
+ ResetModel();
3433
+ objEditor.refreshContents();
3434
+ }
3435
+
3436
+ static public byte[] Compress(Object3D o)
3437
+ {
3438
+ try
3439
+ {
3440
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3441
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3442
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3443
+
3444
+ Object3D parent = o.parent;
3445
+ o.parent = null;
3446
+
3447
+ out.writeObject(o);
3448
+
3449
+ o.parent = parent;
3450
+
3451
+ out.flush();
3452
+
3453
+ zstream.close();
3454
+ out.close();
3455
+
3456
+ return baos.toByteArray();
3457
+ } catch (Exception e)
3458
+ {
3459
+ System.err.println(e);
3460
+ return null;
3461
+ }
3462
+ }
3463
+
3464
+ static public Object Uncompress(byte[] bytes)
3465
+ {
3466
+ System.out.println("#bytes = " + bytes.length);
3467
+ try
3468
+ {
3469
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3470
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3471
+ ObjectInputStream in = new ObjectInputStream(istream);
3472
+ Object obj = in.readObject();
3473
+ in.close();
3474
+
3475
+ return obj;
3476
+ } catch (Exception e)
3477
+ {
3478
+ System.err.println(e);
3479
+ return null;
3480
+ }
3481
+ }
3482
+
3483
+ static public Object clone(Object o)
3484
+ {
3485
+ try
3486
+ {
3487
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3488
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3489
+
3490
+ out.writeObject(o);
3491
+
3492
+ out.flush();
3493
+ out.close();
3494
+
3495
+ byte[] bytes = baos.toByteArray();
3496
+
3497
+ System.out.println("clone = " + bytes.length);
3498
+
3499
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3500
+ ObjectInputStream in = new ObjectInputStream(bais);
3501
+ Object obj = in.readObject();
3502
+ in.close();
3503
+
3504
+ return obj;
3505
+ } catch (Exception e)
3506
+ {
3507
+ System.err.println(e);
3508
+ return null;
3509
+ }
3510
+ }
3511
+
3512
+ cRadio GetCurrentTab()
3513
+ {
3514
+ cRadio ab;
3515
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3516
+ {
3517
+ ab = (cRadio)e.nextElement();
3518
+ if(ab.GetObject() == copy)
3519
+ {
3520
+ return ab;
3521
+ }
3522
+ }
3523
+
3524
+ return null;
3525
+ }
3526
+
3527
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3528
+
3529
+ public void Save()
3530
+ {
3531
+ System.err.println("Save");
3532
+
3533
+ cRadio tab = GetCurrentTab();
3534
+
3535
+ boolean temp = CameraPane.SWITCH;
3536
+ CameraPane.SWITCH = false;
3537
+
3538
+ copy.ExtractBigData(hashtable);
3539
+
3540
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3541
+ tab.graphs[tab.undoindex++] = Compress(copy);
3542
+
3543
+ copy.RestoreBigData(hashtable);
3544
+
3545
+ CameraPane.SWITCH = temp;
3546
+
3547
+ //assert(hashtable.isEmpty());
3548
+
3549
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3550
+ {
3551
+ tab.graphs[i] = null;
3552
+ }
3553
+
3554
+ SetUndoStates();
3555
+
3556
+ // test save
3557
+ if (false)
3558
+ {
3559
+ try
3560
+ {
3561
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3562
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3563
+
3564
+ p.writeObject(copy);
3565
+
3566
+ p.flush();
3567
+
3568
+ ostream.close();
3569
+ } catch (Exception e)
3570
+ {
3571
+ e.printStackTrace();
3572
+ }
3573
+ }
3574
+ }
3575
+
3576
+ void CopyChanged(Object3D obj)
3577
+ {
3578
+ SetUndoStates();
3579
+
3580
+ boolean temp = CameraPane.SWITCH;
3581
+ CameraPane.SWITCH = false;
3582
+
3583
+ copy.ExtractBigData(hashtable);
3584
+
3585
+ copy.clear();
3586
+
3587
+ for (int i=0; i<obj.Size(); i++)
3588
+ {
3589
+ copy.add(obj.get(i));
3590
+ }
3591
+
3592
+ copy.RestoreBigData(hashtable);
3593
+
3594
+ CameraPane.SWITCH = temp;
3595
+
3596
+ //assert(hashtable.isEmpty());
3597
+
3598
+ copy.Touch();
3599
+
3600
+ ResetModel();
3601
+ copy.HardTouch(); // recompile?
3602
+
3603
+ cRadio ab;
3604
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3605
+ {
3606
+ ab = (cRadio)e.nextElement();
3607
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3608
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3609
+ if (test != null)
3610
+ {
3611
+ test.editWindow = ab.object.editWindow;
3612
+ ab.object = test;
3613
+ }
3614
+ }
3615
+
3616
+ refreshContents();
3617
+ }
3618
+
3619
+ cButton undoButton;
3620
+ cButton redoButton;
3621
+
3622
+ void SetUndoStates()
3623
+ {
3624
+ cRadio tab = GetCurrentTab();
3625
+
3626
+ undoButton.setEnabled(tab.undoindex > 0);
3627
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3628
+ }
3629
+
3630
+ public void Undo()
3631
+ {
3632
+ System.err.println("Undo");
3633
+
3634
+ cRadio tab = GetCurrentTab();
3635
+
3636
+ if (tab.undoindex == 0)
3637
+ {
3638
+ java.awt.Toolkit.getDefaultToolkit().beep();
3639
+ return;
3640
+ }
3641
+
3642
+ if (tab.graphs[tab.undoindex] == null)
3643
+ {
3644
+ Save();
3645
+ tab.undoindex -= 1;
3646
+ }
3647
+
3648
+ tab.undoindex -= 1;
3649
+
3650
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3651
+ }
3652
+
3653
+ public void Redo()
3654
+ {
3655
+ cRadio tab = GetCurrentTab();
3656
+
3657
+ if (tab.graphs[tab.undoindex + 1] == null)
3658
+ {
3659
+ java.awt.Toolkit.getDefaultToolkit().beep();
3660
+ return;
3661
+ }
3662
+
3663
+ tab.undoindex += 1;
3664
+
3665
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3666
+ }
3667
+
3668
+ void ImportGFD()
3669
+ {
3670
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3671
+ browser.show();
3672
+ String filename = browser.getFile();
3673
+ if (filename != null && filename.length() > 0)
3674
+ {
3675
+ String fullname = browser.getDirectory() + filename;
3676
+
3677
+ //Object3D readobj =
3678
+ objEditor.ReadGFD(fullname, objEditor);
3679
+ //makeSomething(readobj);
3680
+ }
3681
+ }
3682
+
3683
+ void ImportVRMLX3D()
3684
+ {
3685
+ if (Grafreed.standAlone)
3686
+ {
3687
+ /**/
3688
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3689
+ browser.show();
3690
+ String filename = browser.getFile();
3691
+ if (filename != null && filename.length() > 0)
3692
+ {
3693
+ String fullname = browser.getDirectory() + filename;
3694
+ LoadVRMLX3D(fullname);
3695
+ }
3696
+ /**/
3697
+ }
3698
+ }
3699
+
31903700 void ToggleAnimation()
31913701 {
31923702 if (!Globals.ANIMATION)
31933703 {
31943704 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3195
- browser.show();
3705
+ browser.setVisible(true);
31963706 String filename = browser.getFile();
31973707 if (filename != null && filename.length() > 0)
31983708 {
....@@ -3202,8 +3712,8 @@
32023712
32033713 Globals.ANIMATION ^= true;
32043714
3205
- GrafreeD.wav.cursor = 0;
3206
- GrafreeD.wav.loop = 0;
3715
+ Grafreed.wav.cursor = 0;
3716
+ Grafreed.wav.loop = 0;
32073717 }
32083718 } else
32093719 {
....@@ -3224,7 +3734,6 @@
32243734 callee.refreshContents();
32253735 } else
32263736 {
3227
- new Exception().printStackTrace();
32283737 System.exit(0);
32293738 }
32303739 }
....@@ -3254,7 +3763,7 @@
32543763 void CreateMaterial()
32553764 {
32563765 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
3766
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32583767 if (copy.selection.size() > 0)
32593768 //SetMaterial(copy);
32603769 {
....@@ -3305,7 +3814,7 @@
33053814 assert false;
33063815 }
33073816
3308
- void EditSelection()
3817
+ void EditSelection(boolean newWindow)
33093818 {
33103819 }
33113820
....@@ -3313,11 +3822,11 @@
33133822 {
33143823 copy.ResetBlockLoop(); // temporary problem
33153824
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
3825
+ boolean random = CameraPane.SWITCH;
3826
+ CameraPane.SWITCH = false; // parse everything
33183827 copy.ResetDisplayList();
33193828 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
3829
+ CameraPane.SWITCH = random;
33213830 }
33223831
33233832 // public void applySelf()
....@@ -3391,6 +3900,36 @@
33913900 {
33923901 //System.out.println("Propagate = " + propagate);
33933902 copy.UpdateMaterial(anchor, current, propagate);
3903
+
3904
+ if (copy.material != null)
3905
+ {
3906
+ cMaterial mat = copy.material;
3907
+
3908
+ colorField.SetToolTipValue((mat.color));
3909
+ modulationField.SetToolTipValue((mat.modulation));
3910
+ metalnessField.SetToolTipValue((mat.metalness));
3911
+ diffuseField.SetToolTipValue((mat.diffuse));
3912
+ specularField.SetToolTipValue((mat.specular));
3913
+ shininessField.SetToolTipValue((mat.shininess));
3914
+ shiftField.SetToolTipValue((mat.shift));
3915
+ ambientField.SetToolTipValue((mat.ambient));
3916
+ lightareaField.SetToolTipValue((mat.lightarea));
3917
+ diffusenessField.SetToolTipValue((mat.factor));
3918
+ velvetField.SetToolTipValue((mat.velvet));
3919
+ sheenField.SetToolTipValue((mat.sheen));
3920
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3921
+ backlitField.SetToolTipValue((mat.bump));
3922
+ anisoField.SetToolTipValue((mat.aniso));
3923
+ anisoVField.SetToolTipValue((mat.anisoV));
3924
+ cameraField.SetToolTipValue((mat.cameralight));
3925
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3926
+ shadowField.SetToolTipValue((mat.shadow));
3927
+ textureField.SetToolTipValue((mat.texture));
3928
+ opacityField.SetToolTipValue((mat.opacity));
3929
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3930
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3931
+ }
3932
+
33943933 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33953934 {
33963935 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3506,7 +4045,7 @@
35064045 }
35074046
35084047 if (normalpushField != null)
3509
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4048
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35104049 }
35114050
35124051 void SnapObject()
....@@ -3770,6 +4309,8 @@
37704309
37714310 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37724311 {
4312
+ if (Globals.SAVEONMAKE) // && resetmodel)
4313
+ Save();
37734314 //Tween.set(thing, 0).target(1).start(tweenManager);
37744315 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37754316 // if (thing instanceof GenericJointDemo)
....@@ -3856,6 +4397,12 @@
38564397 {
38574398 ResetModel();
38584399 Select(thing.GetTreePath(), true, false); // unselect... false);
4400
+
4401
+ if (thing.Size() == 0)
4402
+ {
4403
+ //EditSelection(false);
4404
+ }
4405
+
38594406 refreshContents();
38604407 }
38614408
....@@ -3973,6 +4520,7 @@
39734520 }
39744521 }
39754522 }
4523
+
39764524 LoadGFDThread loadGFDThread;
39774525
39784526 void ReadGFD(String fullname, iCallBack cb)
....@@ -3992,8 +4540,10 @@
39924540
39934541 try
39944542 {
4543
+ // Try compressed version first.
39954544 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3996
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4545
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4546
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39974547
39984548 readobj = (Object3D) p.readObject();
39994549 istream.close();
....@@ -4001,7 +4551,20 @@
40014551 readobj.ResetDisplayList();
40024552 } catch (Exception e)
40034553 {
4004
- e.printStackTrace();
4554
+ //e.printStackTrace();
4555
+ try
4556
+ {
4557
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4558
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4559
+
4560
+ readobj = (Object3D) p.readObject();
4561
+ istream.close();
4562
+
4563
+ readobj.ResetDisplayList();
4564
+ } catch (Exception e2)
4565
+ {
4566
+ e2.printStackTrace();
4567
+ }
40054568 }
40064569 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40074570 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4047,6 +4610,12 @@
40474610
40484611 void LoadIt(Object obj)
40494612 {
4613
+ if (obj == null)
4614
+ {
4615
+ // Invalid file
4616
+ return;
4617
+ }
4618
+
40504619 System.out.println("Loaded " + obj);
40514620 //new Exception().printStackTrace();
40524621 Object3D readobj = (Object3D) obj;
....@@ -4056,6 +4625,8 @@
40564625
40574626 if (readobj != null)
40584627 {
4628
+ if (Globals.SAVEONMAKE)
4629
+ Save();
40594630 try
40604631 {
40614632 //readobj.deepCopySelf(copy);
....@@ -4118,7 +4689,7 @@
41184689
41194690 void load() // throws ClassNotFoundException
41204691 {
4121
- if (GrafreeD.standAlone)
4692
+ if (Grafreed.standAlone)
41224693 {
41234694 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41244695 browser.show();
....@@ -4205,11 +4776,13 @@
42054776 try
42064777 {
42074778 FileOutputStream ostream = new FileOutputStream(lastname);
4208
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4779
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4780
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42094781
42104782 p.writeObject(copy);
42114783 p.flush();
42124784
4785
+ zstream.close();
42134786 ostream.close();
42144787
42154788 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4219,17 +4792,20 @@
42194792 {
42204793 }
42214794 }
4795
+
42224796 String lastname;
42234797
42244798 void saveAs()
42254799 {
4226
- if (GrafreeD.standAlone)
4800
+ if (Grafreed.standAlone)
42274801 {
42284802 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42294803 browser.setVisible(true);
42304804 String filename = browser.getFile();
42314805 if (filename != null && filename.length() > 0)
42324806 {
4807
+ if (!filename.endsWith(".gfd"))
4808
+ filename += ".gfd";
42334809 lastname = browser.getDirectory() + filename;
42344810 save();
42354811 }
....@@ -4328,13 +4904,13 @@
43284904 try
43294905 {
43304906 FileOutputStream ostream = new FileOutputStream(filename);
4331
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4332
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4907
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4908
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43334909
43344910 Object3D objectparent = obj.parent;
43354911 obj.parent = null;
43364912
4337
- Object3D object = (Object3D) GrafreeD.clone(obj);
4913
+ Object3D object = (Object3D) Grafreed.clone(obj);
43384914
43394915 obj.parent = objectparent;
43404916
....@@ -4346,8 +4922,8 @@
43464922 p.writeObject(object);
43474923 p.flush();
43484924
4925
+ zstream.close();
43494926 ostream.close();
4350
- // zstream.close();
43514927
43524928 // group.selection.get(0).parent = parent;
43534929 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4368,7 +4944,7 @@
43684944 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43694945 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43704946 copy.generatePOV(buffer);
4371
- if (GrafreeD.standAlone)
4947
+ if (Grafreed.standAlone)
43724948 {
43734949 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43744950 browser.show();
....@@ -4394,7 +4970,8 @@
43944970 Object3D client;
43954971 Object3D copy;
43964972 MenuBar menuBar;
4397
- Menu windowMenu;
4973
+ Menu fileMenu;
4974
+ MenuItem newItem;
43984975 MenuItem loadItem;
43994976 MenuItem saveItem;
44004977 MenuItem saveAsItem;
....@@ -4402,11 +4979,9 @@
44024979 MenuItem reexportItem;
44034980 MenuItem povItem;
44044981 MenuItem closeItem;
4405
- Menu cameraMenu;
4982
+
44064983 CheckboxMenuItem zBufferItem;
44074984 //MenuItem normalLensItem;
4408
- MenuItem editCameraItem;
4409
- MenuItem revertCameraItem;
44104985 MenuItem stepItem;
44114986 CheckboxMenuItem toggleLiveItem;
44124987 CheckboxMenuItem toggleFullScreenItem;
....@@ -4417,25 +4992,38 @@
44174992 CheckboxMenuItem toggleFootContactItem;
44184993 CheckboxMenuItem toggleDLItem;
44194994 CheckboxMenuItem toggleTextureItem;
4420
- CheckboxMenuItem toggleRandomItem;
4995
+ CheckboxMenuItem toggleSwitchItem;
44214996 CheckboxMenuItem toggleRootItem;
44224997 CheckboxMenuItem animationItem;
44234998 CheckboxMenuItem toggleHandleItem;
44244999 CheckboxMenuItem togglePaintItem;
44255000 JSplitPane mainPanel;
44265001 JScrollPane scrollpane;
5002
+
44275003 JPanel toolbarPanel;
4428
- JPanel treePanel;
5004
+
5005
+ cGridBag treePanel;
5006
+
44295007 JPanel radioPanel;
44305008 ButtonGroup buttonGroup;
4431
- cGridBag ctrlPanel;
5009
+
5010
+ cGridBag toolboxPanel;
44325011 cGridBag materialPanel;
5012
+ cGridBag ctrlPanel;
5013
+
44335014 JScrollPane infoPanel;
5015
+
44345016 cGridBag optionsPanel;
5017
+
44355018 JTabbedPane objectPanel;
5019
+ boolean materialFlushed;
5020
+ Object3D latestObject;
5021
+
44365022 cGridBag XYZPanel;
5023
+
44375024 JSplitPane gridPanel;
44385025 JSplitPane bigPanel;
5026
+
44395027 cGridBag bigThree;
44405028 cGridBag scenePanel;
44415029 cGridBag centralPanel;
....@@ -4550,8 +5138,13 @@
45505138 cNumberSlider fogField;
45515139 JLabel opacityPowerLabel;
45525140 cNumberSlider opacityPowerField;
4553
- JTree jTree;
5141
+ cTree jTree;
45545142 //ObjectUI parent;
45555143
45565144 cNumberSlider normalpushField;
5145
+
5146
+ private MenuItem importGFDItem;
5147
+ private MenuItem importVRMLX3DItem;
5148
+ private MenuItem import3DSItem;
5149
+ private MenuItem importOBJItem;
45575150 }