Normand Briere
2019-07-14 bc829f47837b5a001f911542140b0b8e63c2bb0c
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(false);
245313 objEditor = this;
246314 this.callee = callee;
247315
....@@ -272,28 +340,49 @@
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(openItem = 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
296
- loadItem.addActionListener(this);
384
+ newItem.addActionListener(this);
385
+ openItem.addActionListener(this);
297386 saveItem.addActionListener(this);
298387 saveAsItem.addActionListener(this);
299388 exportAsItem.addActionListener(this);
....@@ -301,81 +390,66 @@
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);
378
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ infoPanel.setPreferredSize(new Dimension(1, 1));
379453 infoPanel.setName("Info");
380454 //infoPanel.setLayout(new BorderLayout());
381455 //infoPanel.add(createTextPane());
....@@ -384,14 +458,21 @@
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
+ mainPanel.setUI(new BasicSplitPaneUI());
471
+
391472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
392473 //mainPanel.setLayout(new GridBagLayout());
393474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
394
- treePanel.setLayout(new GridBagLayout());
475
+// treePanel.setLayout(new GridBagLayout());
395476 //ctrlPanel.setLayout(new GridBagLayout());
396477 //materialPanel.setLayout(new GridBagLayout());
397478
....@@ -432,7 +513,7 @@
432513 static String newline = "\n";
433514 protected static final String buttonString = "JButton";
434515 StyledDocument doc;
435
- JTextArea infoarea;
516
+ JTextPane infoarea;
436517
437518 void ClearInfo()
438519 {
....@@ -455,10 +536,10 @@
455536 e.printStackTrace();
456537 }
457538
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();
539
+// String selection = infoarea.getText();
540
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
541
+// java.awt.datatransfer.Clipboard clipboard =
542
+// Toolkit.getDefaultToolkit().getSystemClipboard();
462543 //clipboard.setContents(data, data);
463544 }
464545
....@@ -481,13 +562,13 @@
481562 //SendInfo("Name:", "bold");
482563 if (sel.GetTextures() != null || debug)
483564 {
484
- si.SendInfo(sel.toString(), "bold");
565
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
485566 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
486567 if (sel.Size() > 0)
487568 {
488569 si.SendInfo("#children = " + sel.Size(), "regular");
489570 }
490
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
571
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
491572 if (debug)
492573 {
493574 try
....@@ -499,7 +580,10 @@
499580 }
500581
501582 if (full)
502
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
583
+ {
584
+ si.SendInfo(" BBox min: " + minima, "regular");
585
+ si.SendInfo(" BBox max: " + maxima, "regular");
586
+ }
503587
504588 if (sel.bRep != null)
505589 {
....@@ -526,7 +610,7 @@
526610 }
527611 if (sel.support != null)
528612 {
529
- si.SendInfo(" support: " + sel.support, "regular");
613
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
530614 }
531615 if (sel.scriptnode != null)
532616 {
....@@ -597,6 +681,9 @@
597681 {
598682 CameraPane.pointflow = (PointFlow) sel;
599683 }
684
+
685
+ si.SendInfo("_____________________", "regular");
686
+ si.SendInfo("", "regular");
600687 }
601688 }
602689
....@@ -612,68 +699,169 @@
612699 }
613700 }
614701
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
704
+
705
+ Rectangle keeprect;
706
+ cRadio radio;
707
+
708
+cButton keepButton;
709
+ cButton twoButton; // Full 3D
710
+ cButton sixButton;
711
+ cButton threeButton;
712
+ cButton sevenButton;
713
+ cButton fourButton; // full panel
714
+ cButton oneButton; // full XYZ
715
+ //cButton currentLayout;
716
+
717
+ boolean maximized;
718
+
719
+ cButton fullscreenLayout;
720
+
721
+ void Minimize()
722
+ {
723
+ frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
725
+ }
726
+
727
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
728
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
729
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
730
+ void Maximize()
731
+ {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
737
+ if (maximized)
738
+ {
739
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
740
+ }
741
+ else
742
+ {
743
+ keeprect = frame.getBounds();
744
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
745
+// Dimension rect2 = frame.getToolkit().getScreenSize();
746
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
747
+// frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
749
+ }
750
+
751
+ maximized ^= true;
752
+
753
+ frame.validate();
754
+ }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
759
+
615760 void ToggleFullScreen()
616761 {
617
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
618767 {
619
- frame.getContentPane().remove(/*"Center",*/bigThree);
620
- framePanel.add(bigThree);
621
- frame.getContentPane().add(/*"Center",*/framePanel);
768
+ device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
774
+ //frame.setVisible(false);
775
+// frame.removeNotify();
776
+// frame.setUndecorated(false);
777
+// frame.addNotify();
778
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
779
+
780
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
781
+// X framePanel.add(bigThree);
782
+// X frame.getContentPane().add(/*"Center",*/framePanel);
783
+ framePanel.setDividerLocation(46);
784
+
785
+ //frame.setVisible(true);
786
+ radio.layout = keepButton;
787
+ //theFrame = null;
788
+ keepButton = null;
789
+ radio.layout.doClick();
790
+
622791 } else
623792 {
624
- frame.getContentPane().remove(/*"Center",*/framePanel);
625
- framePanel.remove(bigThree);
626
- frame.getContentPane().add(/*"Center",*/bigThree);
793
+ keepButton = radio.layout;
794
+ //keeprect = frame.getBounds();
795
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
796
+// frame.getToolkit().getScreenSize().height);
797
+ //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
801
+ device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
804
+// frame.removeNotify();
805
+// frame.setUndecorated(true);
806
+// frame.addNotify();
807
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
808
+// X framePanel.remove(bigThree);
809
+// X frame.getContentPane().add(/*"Center",*/bigThree);
810
+ framePanel.setDividerLocation(0);
811
+
812
+ radio.layout = fullscreenLayout;
813
+ radio.layout.doClick();
814
+ //frame.setVisible(true);
627815 }
628
- cameraView.ToggleFullScreen();
816
+ frame.validate();
629817 }
630818
631
- private JTextArea createTextPane()
819
+ private JTextPane createTextPane()
632820 {
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
- };
821
+// TEXTAREA String[] initString =
822
+// {
823
+// "This is an editable JTextPane, ", //regular
824
+// "another ", //italic
825
+// "styled ", //bold
826
+// "text ", //small
827
+// "component, ", //large
828
+// "which supports embedded components..." + newline,//regular
829
+// " " + newline, //button
830
+// "...and embedded icons..." + newline, //regular
831
+// " ", //icon
832
+// newline + "JTextPane is a subclass of JEditorPane that "
833
+// + "uses a StyledEditorKit and StyledDocument, and provides "
834
+// + "cover methods for interacting with those objects."
835
+// };
836
+//
837
+// String[] initStyles =
838
+// {
839
+// "regular", "italic", "bold", "small", "large",
840
+// "regular", "button", "regular", "icon",
841
+// "regular"
842
+// };
843
+//
844
+// JTextPane textPane = new JTextPane();
845
+// textPane.setEditable(true);
846
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
847
+// addStylesToDocument(doc);
848
+//
849
+// try
850
+// {
851
+// for (int j = 0; j < 2; j++)
852
+// {
853
+// for (int i = 0; i < initString.length; i++)
854
+// {
855
+// doc.insertString(doc.getLength(), initString[i],
856
+// doc.getStyle(initStyles[i]));
857
+// }
858
+// }
859
+// } catch (BadLocationException ble)
860
+// {
861
+// System.err.println("Couldn't insert initial text into text pane.");
862
+// }
648863
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;
864
+ return new JTextPane(); // textPane;
677865 }
678866
679867 protected void addStylesToDocument(StyledDocument doc)
....@@ -726,7 +914,7 @@
726914 protected static ImageIcon createImageIcon(String path,
727915 String description)
728916 {
729
- java.net.URL imgURL = GrafreeD.class.getResource(path);
917
+ java.net.URL imgURL = Grafreed.class.getResource(path);
730918 if (imgURL != null)
731919 {
732920 return new ImageIcon(imgURL, description);
....@@ -758,6 +946,7 @@
758946 // NumberSlider vDivsField;
759947 // JCheckBox endcaps;
760948 JCheckBox liveCB;
949
+ JCheckBox selectCB;
761950 JCheckBox hideCB;
762951 JCheckBox link2masterCB;
763952 JCheckBox markCB;
....@@ -765,7 +954,12 @@
765954 JCheckBox speedupCB;
766955 JCheckBox rewindCB;
767956 JCheckBox flipVCB;
957
+
958
+ cCheckBox toggleTextureCB;
959
+ cCheckBox toggleSwitchCB;
960
+
768961 JComboBox texresMenu;
962
+
769963 JButton resetButton;
770964 JButton stepButton;
771965 JButton stepAllButton;
....@@ -774,9 +968,13 @@
774968 JButton fasterButton;
775969 JButton remarkButton;
776970
971
+ cGridBag editPanel;
972
+ cGridBag editCommandsPanel;
973
+
777974 cGridBag namePanel;
778975 cGridBag setupPanel;
779
- cGridBag commandsPanel;
976
+ cGridBag setupPanel2;
977
+ cGridBag objectCommandsPanel;
780978 cGridBag pushPanel;
781979 cGridBag fillPanel;
782980
....@@ -943,52 +1141,73 @@
9431141
9441142 void SetupUI2(ObjEditor oe)
9451143 {
946
-// oe.aConstraints.weightx = 0;
947
-// oe.aConstraints.weighty = 0;
948
-// oe.aConstraints.gridx = 0;
949
-// oe.aConstraints.gridy = 0;
9501144 //SetupName(oe);
9511145
9521146 namePanel = new cGridBag();
9531147
9541148 nameField = AddText(namePanel, copy.GetName());
955
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9561150 oe.ctrlPanel.add(namePanel);
9571151
9581152 oe.ctrlPanel.Return();
9591153
960
- if (!GroupEditor.allparams)
1154
+ if (!allparams)
9611155 return;
9621156
9631157 setupPanel = new cGridBag().setVertical(false);
9641158
9651159 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
966
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
967
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1160
+ liveCB.setToolTipText("Animate object");
1161
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1162
+ selectCB.setToolTipText("Make object selectable");
9681163 // Return();
1164
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1165
+ hideCB.setToolTipText("Hide object");
9691166 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
970
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
971
- randomCB = AddCheckBox(setupPanel, "Rand", copy.random);
1167
+ markCB.setToolTipText("As animation target transform");
1168
+
1169
+ setupPanel2 = new cGridBag().setVertical(false);
1170
+
1171
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1172
+ rewindCB.setToolTipText("Rewind animation");
1173
+
1174
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1175
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9721176
1177
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1178
+ link2masterCB.setToolTipText("Attach to support");
1179
+
1180
+ if (Globals.ADVANCED)
1181
+ {
1182
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1183
+ speedupCB.setToolTipText("Option motion capture");
1184
+ }
1185
+
9731186 oe.ctrlPanel.add(setupPanel);
9741187 oe.ctrlPanel.Return();
1188
+ oe.ctrlPanel.add(setupPanel2);
1189
+ oe.ctrlPanel.Return();
9751190
976
- commandsPanel = new cGridBag().setVertical(false);
1191
+ objectCommandsPanel = new cGridBag().setVertical(false);
9771192
978
- resetButton = AddButton(commandsPanel, "Reset");
979
- stepButton = AddButton(commandsPanel, "Step");
1193
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1194
+ resetButton.setToolTipText("Jump to frame zero");
1195
+ stepButton = AddButton(objectCommandsPanel, "Step");
1196
+ stepButton.setToolTipText("Step one frame");
9801197 // resetAllButton = AddButton(oe, "Reset All");
9811198 // stepAllButton = AddButton(oe, "Step All");
982
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
9831199 // Return();
984
- slowerButton = AddButton(commandsPanel, "Slow");
985
- fasterButton = AddButton(commandsPanel, "Fast");
986
- remarkButton = AddButton(commandsPanel, "Remark");
1200
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1201
+ slowerButton.setToolTipText("Decrease animation speed");
1202
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1203
+ fasterButton.setToolTipText("Increase animation speed");
1204
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1205
+ remarkButton.setToolTipText("Set the current transform as the target");
9871206
988
- oe.ctrlPanel.add(commandsPanel);
1207
+ oe.ctrlPanel.add(objectCommandsPanel);
9891208 oe.ctrlPanel.Return();
9901209
991
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1210
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
9921211 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
9931212 //Return();
9941213
....@@ -1191,8 +1410,11 @@
11911410 //worldPanel.setName("World");
11921411 centralPanel = new cGridBag();
11931412 centralPanel.preferredWidth = 20;
1194
- timelinePanel = new JPanel(new BorderLayout());
1195
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1413
+
1414
+ if (Globals.ADVANCED)
1415
+ {
1416
+ timelinePanel = new JPanel(new BorderLayout());
1417
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11961418
11971419 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11981420 cameraPanel.setContinuousLayout(true);
....@@ -1201,7 +1423,10 @@
12011423 // cameraPanel.setDividerSize(9);
12021424 cameraPanel.setResizeWeight(1.0);
12031425
1426
+ }
1427
+
12041428 centralPanel.add(cameraView);
1429
+ centralPanel.setFocusable(true);
12051430 //frame.setJMenuBar(timelineMenubar);
12061431 //centralPanel.add(timelinePanel);
12071432
....@@ -1268,8 +1493,12 @@
12681493 // north.setName("Edit");
12691494 // north.add(ctrlPanel, BorderLayout.NORTH);
12701495 // objectPanel.add(north);
1271
- objectPanel.add(ctrlPanel);
1272
- objectPanel.add(infoPanel);
1496
+ objectPanel.add(editPanel);
1497
+
1498
+ //if (Globals.ADVANCED)
1499
+ objectPanel.add(infoPanel);
1500
+
1501
+ objectPanel.add(toolboxPanel);
12731502
12741503 /*
12751504 aConstraints.gridx = 0;
....@@ -1278,7 +1507,7 @@
12781507 aConstraints.gridy += 1;
12791508 aConstraints.gridwidth = 1;
12801509 mainPanel.add(objectPanel, aConstraints);
1281
- */
1510
+ */
12821511
12831512 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12841513 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1290,14 +1519,12 @@
12901519 scrollpane.addMouseWheelListener(this); // Default not fast enough
12911520
12921521 /*JTabbedPane*/ scenePanel = new cGridBag();
1293
- scenePanel.preferredWidth = 7;
1522
+ scenePanel.preferredWidth = 6;
12941523
12951524 JTabbedPane tabbedPane = new JTabbedPane();
12961525 tabbedPane.add(scrollpane);
12971526
1298
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1299
-
1300
- optionsPanel = new cGridBag().setVertical(true);
1527
+ optionsPanel = new cGridBag().setVertical(false);
13011528
13021529 optionsPanel.setName("Options");
13031530
....@@ -1305,6 +1532,8 @@
13051532
13061533 tabbedPane.add(optionsPanel);
13071534
1535
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1536
+
13081537 scenePanel.add(tabbedPane);
13091538
13101539 /*
....@@ -1377,9 +1606,9 @@
13771606 // aConstraints.gridheight = 1;
13781607
13791608 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1380
- framePanel.setContinuousLayout(true);
1381
- framePanel.setOneTouchExpandable(true);
1382
- framePanel.setDividerLocation(0.8);
1609
+ framePanel.setContinuousLayout(false);
1610
+ framePanel.setOneTouchExpandable(false);
1611
+ //.setDividerLocation(0.8);
13831612 //framePanel.setDividerSize(15);
13841613 //framePanel.setResizeWeight(0.15);
13851614 framePanel.setName("Frame");
....@@ -1396,10 +1625,15 @@
13961625
13971626 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13981627
1399
- frame.setSize(1024, 768);
1400
- frame.show();
1401
-
1628
+ frame.setSize(1280, 860);
1629
+
1630
+ cameraView.requestFocusInWindow();
1631
+
14021632 gridPanel.setDividerLocation(1.0);
1633
+
1634
+ frame.validate();
1635
+
1636
+ frame.setVisible(true);
14031637
14041638 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14051639 frame.addWindowListener(new WindowAdapter()
....@@ -1436,17 +1670,25 @@
14361670
14371671 cGridBag editBar = new cGridBag().setVertical(false);
14381672
1439
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
1673
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1674
+ createMaterialButton.setToolTipText("Create material");
14401675
14411676 /*
14421677 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14431678 */
14441679
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);
1680
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1681
+ clearMaterialButton.setToolTipText("Clear material");
1682
+
1683
+ if (Globals.ADVANCED)
1684
+ {
1685
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1686
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1687
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1688
+ }
14491689
1690
+ editBar.preferredHeight = 15;
1691
+
14501692 panel.add(editBar);
14511693
14521694 /**/
....@@ -1477,24 +1719,6 @@
14771719 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14781720 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14791721 colorSection.add(texture);
1480
-
1481
- cGridBag anisoU = new cGridBag();
1482
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1483
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1484
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1485
- colorSection.add(anisoU);
1486
-
1487
- cGridBag anisoV = new cGridBag();
1488
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1489
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1490
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1491
- colorSection.add(anisoV);
1492
-
1493
- cGridBag shadowbias = new cGridBag();
1494
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1495
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1496
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1497
- colorSection.add(shadowbias);
14981722
14991723 panel.add(new JSeparator());
15001724
....@@ -1546,6 +1770,12 @@
15461770 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15471771 diffuseSection.add(fakedepth);
15481772
1773
+ cGridBag shadowbias = new cGridBag();
1774
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1775
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1776
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1777
+ diffuseSection.add(shadowbias);
1778
+
15491779 panel.add(new JSeparator());
15501780
15511781 panel.add(diffuseSection);
....@@ -1596,6 +1826,18 @@
15961826 // aConstraints.gridy += 1;
15971827 // aConstraints.gridwidth = 1;
15981828
1829
+ cGridBag anisoU = new cGridBag();
1830
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1831
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1832
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1833
+ specularSection.add(anisoU);
1834
+
1835
+ cGridBag anisoV = new cGridBag();
1836
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1837
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1838
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1839
+ specularSection.add(anisoV);
1840
+
15991841
16001842 panel.add(new JSeparator());
16011843
....@@ -1603,35 +1845,35 @@
16031845
16041846 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16051847
1606
- cGridBag globalSection = new cGridBag().setVertical(true);
1848
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16071849
16081850 cGridBag camera = new cGridBag();
16091851 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16101852 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16111853 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1612
- globalSection.add(camera);
1854
+ colorSection.add(camera);
16131855
16141856 cGridBag ambient = new cGridBag();
16151857 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16161858 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16171859 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1618
- globalSection.add(ambient);
1860
+ colorSection.add(ambient);
16191861
16201862 cGridBag backlit = new cGridBag();
16211863 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16221864 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16231865 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1624
- globalSection.add(backlit);
1866
+ colorSection.add(backlit);
16251867
16261868 cGridBag opacity = new cGridBag();
16271869 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
16281870 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16291871 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1630
- globalSection.add(opacity);
1872
+ colorSection.add(opacity);
16311873
1632
- panel.add(new JSeparator());
1874
+ //panel.add(new JSeparator());
16331875
1634
- panel.add(globalSection);
1876
+ //panel.add(globalSection);
16351877
16361878 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16371879
....@@ -1712,12 +1954,15 @@
17121954 opacityPowerField.addChangeListener(this);
17131955 /**/
17141956
1715
- resetSlidersButton.addActionListener(this);
17161957 clearMaterialButton.addActionListener(this);
17171958 createMaterialButton.addActionListener(this);
1718
-
1719
- propagateToggle.addItemListener(this);
1720
- multiplyToggle.addItemListener(this);
1959
+
1960
+ if (Globals.ADVANCED)
1961
+ {
1962
+ resetSlidersButton.addActionListener(this);
1963
+ propagateToggle.addItemListener(this);
1964
+ multiplyToggle.addItemListener(this);
1965
+ }
17211966 }
17221967
17231968 void DropFile(java.io.File[] files, boolean textures)
....@@ -1735,8 +1980,9 @@
17351980 // 3D models
17361981 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17371982 {
1738
- lastConverter = new com.jmex.model.converters.MaxToJme();
1739
- LoadFile(filename, lastConverter);
1983
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
1984
+ //LoadFile(filename, lastConverter);
1985
+ LoadObjFile(filename); // New 3ds loader
17401986 continue;
17411987 }
17421988 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1888,7 +2134,7 @@
18882134
18892135 //? flashIt = false;
18902136 CameraPane pane = (CameraPane) cameraView;
1891
- pane.clickStart(location.x, location.y, 0);
2137
+ pane.clickStart(location.x, location.y, 0, 0);
18922138 pane.clickEnd(location.x, location.y, 0, true);
18932139
18942140 if (group.selection.size() == 1)
....@@ -1937,6 +2183,7 @@
19372183 e2.printStackTrace();
19382184 }
19392185 }
2186
+
19402187 LoadJMEThread loadThread;
19412188
19422189 class LoadJMEThread extends Thread
....@@ -1994,6 +2241,7 @@
19942241 //LoadFile0(filename, converter);
19952242 }
19962243 }
2244
+
19972245 LoadOBJThread loadObjThread;
19982246
19992247 class LoadOBJThread extends Thread
....@@ -2072,19 +2320,19 @@
20722320
20732321 void LoadObjFile(String fullname)
20742322 {
2075
- /*
2323
+ System.out.println("Loading " + fullname);
2324
+ /**/
20762325 //lastFilename = fullname;
20772326 if(loadObjThread == null)
20782327 {
2079
- loadObjThread = new LoadOBJThread();
2080
- loadObjThread.start();
2328
+ loadObjThread = new LoadOBJThread();
2329
+ loadObjThread.start();
20812330 }
20822331
20832332 loadObjThread.add(fullname);
2084
- */
2333
+ /**/
20852334
2086
- System.out.println("Loading " + fullname);
2087
- makeSomething(new FileObject(fullname, true), true);
2335
+ //makeSomething(new FileObject(fullname, true), true);
20882336 }
20892337
20902338 void LoadGFDFile(String fullname)
....@@ -2345,11 +2593,11 @@
23452593
23462594 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23472595 {
2348
- if (GrafreeD.standAlone)
2596
+ if (Grafreed.standAlone)
23492597 {
23502598 /**/
23512599 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2352
- browser.show();
2600
+ browser.setVisible(true);
23532601 String filename = browser.getFile();
23542602 if (filename != null && filename.length() > 0)
23552603 {
....@@ -2460,6 +2708,7 @@
24602708 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24612709 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24622710 }
2711
+
24632712 //cJME.count++;
24642713 //cJME.count %= 12;
24652714 if (gc)
....@@ -2643,6 +2892,7 @@
26432892 }
26442893 }
26452894 }
2895
+
26462896 cFileSystemPane FSPane;
26472897
26482898 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2696,11 +2946,14 @@
26962946 }
26972947 }
26982948 }
2949
+
26992950 freezematerial = false;
27002951 }
27012952
27022953 void SetMaterial(Object3D object)
27032954 {
2955
+ latestObject = object;
2956
+
27042957 cMaterial mat = object.material;
27052958
27062959 if (mat == null)
....@@ -2709,7 +2962,8 @@
27092962 return;
27102963 }
27112964
2712
- multiplyToggle.setSelected(mat.multiply);
2965
+ if (multiplyToggle != null)
2966
+ multiplyToggle.setSelected(mat.multiply);
27132967
27142968 assert (object.projectedVertices != null);
27152969
....@@ -2811,12 +3065,17 @@
28113065 // }
28123066
28133067 /**/
2814
- if (deselect)
3068
+ if (deselect || child == null)
28153069 {
28163070 //group.deselectAll();
28173071 //freeze = true;
28183072 GetTree().clearSelection();
28193073 //freeze = false;
3074
+
3075
+ if (child == null)
3076
+ {
3077
+ return;
3078
+ }
28203079 }
28213080
28223081 //group.addSelectee(child);
....@@ -2885,7 +3144,7 @@
28853144 cameraView.ToggleDL();
28863145 cameraView.repaint();
28873146 return;
2888
- } else if (event.getSource() == toggleTextureItem)
3147
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28893148 {
28903149 cameraView.ToggleTexture();
28913150 // june 2013 copy.HardTouch();
....@@ -2924,9 +3183,9 @@
29243183 frame.validate();
29253184
29263185 return;
2927
- } else if (event.getSource() == toggleRandomItem)
3186
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29283187 {
2929
- cameraView.ToggleRandom();
3188
+ cameraView.ToggleSwitch();
29303189 cameraView.repaint();
29313190 return;
29323191 } else if (event.getSource() == toggleHandleItem)
....@@ -2955,6 +3214,10 @@
29553214 {
29563215 copy.live ^= true;
29573216 return;
3217
+ } else if (event.getSource() == selectCB)
3218
+ {
3219
+ copy.dontselect ^= true;
3220
+ return;
29583221 } else if (event.getSource() == hideCB)
29593222 {
29603223 copy.hide ^= true;
....@@ -2969,6 +3232,7 @@
29693232 if (event.getSource() == randomCB)
29703233 {
29713234 copy.random ^= true;
3235
+ objEditor.refreshContents();
29723236 return;
29733237 }
29743238 if (event.getSource() == speedupCB)
....@@ -2992,8 +3256,9 @@
29923256
29933257 public void actionPerformed(ActionEvent event)
29943258 {
3259
+ Object source = event.getSource();
29953260 // SCRIPT DIALOG
2996
- if (event.getSource() == okbutton)
3261
+ if (source == okbutton)
29973262 {
29983263 textpanel.setVisible(false);
29993264 textpanel.remove(textarea);
....@@ -3005,7 +3270,7 @@
30053270 textarea = null;
30063271 textpanel = null;
30073272 }
3008
- if (event.getSource() == cancelbutton)
3273
+ if (source == cancelbutton)
30093274 {
30103275 textpanel.setVisible(false);
30113276 textpanel.remove(textarea);
....@@ -3017,50 +3282,50 @@
30173282 //applySelf();
30183283 //client.refreshEditWindow();
30193284 //refreshContents();
3020
- if (event.getSource() == nameField)
3285
+ if (source == nameField)
30213286 {
30223287 //System.out.println("ObjEditor " + event);
30233288 applySelf0(true);
30243289 //parent.applySelf();
30253290 objEditor.refreshContents();
3026
- } else if (event.getSource() == resetButton)
3291
+ } else if (source == resetButton)
30273292 {
30283293 CameraPane.fullreset = true;
30293294 copy.Reset(); // ResetMeshes();
30303295 copy.Touch();
30313296 objEditor.refreshContents();
3032
- } else if (event.getSource() == stepItem)
3297
+ } else if (source == stepItem)
30333298 {
30343299 //cameraView.ONESTEP = true;
30353300 Globals.ONESTEP = true;
30363301 cameraView.repaint();
30373302 return;
3038
- } else if (event.getSource() == stepButton)
3303
+ } else if (source == stepButton)
30393304 {
30403305 copy.Step();
30413306 copy.Touch();
30423307 objEditor.refreshContents();
3043
- } else if (event.getSource() == slowerButton)
3308
+ } else if (source == slowerButton)
30443309 {
30453310 copy.Slower();
30463311 copy.Touch();
30473312 objEditor.refreshContents();
3048
- } else if (event.getSource() == fasterButton)
3313
+ } else if (source == fasterButton)
30493314 {
30503315 copy.Faster();
30513316 copy.Touch();
30523317 objEditor.refreshContents();
3053
- } else if (event.getSource() == remarkButton)
3318
+ } else if (source == remarkButton)
30543319 {
30553320 copy.Remark();
30563321 copy.Touch();
30573322 objEditor.refreshContents();
3058
- } else if (event.getSource() == stepAllButton)
3323
+ } else if (source == stepAllButton)
30593324 {
30603325 copy.StepAll();
30613326 copy.Touch();
30623327 objEditor.refreshContents();
3063
- } else if (event.getSource() == resetAllButton)
3328
+ } else if (source == resetAllButton)
30643329 {
30653330 //CameraPane.fullreset = true;
30663331 copy.ResetAll(); // ResetMeshes();
....@@ -3093,53 +3358,79 @@
30933358 // Close();
30943359 // }
30953360 // else
3096
- if (event.getSource() == resetSlidersButton)
3361
+ if (source == resetSlidersButton)
30973362 {
30983363 ResetSliders();
3099
- } else if (event.getSource() == clearMaterialButton)
3364
+ } else if (source == clearMaterialButton)
31003365 {
31013366 ClearMaterial();
3102
- } else if (event.getSource() == createMaterialButton)
3367
+ } else if (source == createMaterialButton)
31033368 {
31043369 CreateMaterial();
3105
- } else if (event.getSource() == clearPanelButton)
3370
+ } else if (source == clearPanelButton)
31063371 {
31073372 copy.ClearUI();
31083373 refreshContents(true);
3109
- } /*
3110
- }
3111
-
3112
- public boolean action(Event event, Object arg)
3113
- {
3114
- */ else if (event.getSource() == closeItem)
3374
+ } else if (source == importGFDItem)
3375
+ {
3376
+ ImportGFD();
3377
+ } else
3378
+ if (source == importVRMLX3DItem)
3379
+ {
3380
+ ImportVRMLX3D();
3381
+ } else
3382
+ if (source == import3DSItem)
3383
+ {
3384
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3385
+ } else
3386
+ if (source == importOBJItem)
3387
+ {
3388
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3389
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3390
+ browser.setVisible(true);
3391
+ String filename = browser.getFile();
3392
+ if (filename != null && filename.length() > 0)
3393
+ {
3394
+ String fullname = browser.getDirectory() + filename;
3395
+ makeSomething(ReadOBJ(fullname), true);
3396
+ }
3397
+ } else
3398
+ if (source == closeItem)
31153399 {
31163400 Close();
31173401 //return true;
3118
- } else if (event.getSource() == loadItem)
3402
+ } else if (source == openItem)
31193403 {
3120
- load();
3404
+ Open();
31213405 //return true;
3122
- } else if (event.getSource() == saveItem)
3406
+ } else if (source == newItem)
3407
+ {
3408
+ New();
3409
+ } else if (source == saveItem)
31233410 {
31243411 save();
31253412 //return true;
3126
- } else if (event.getSource() == saveAsItem)
3413
+ } else if (source == saveAsItem)
31273414 {
31283415 saveAs();
31293416 //return true;
3130
- } else if (event.getSource() == reexportItem)
3417
+ } else if (source == reexportItem)
31313418 {
31323419 reexport();
31333420 //return true;
3134
- } else if (event.getSource() == exportAsItem)
3421
+ } else if (source == exportAsItem)
31353422 {
31363423 export();
31373424 //return true;
3138
- } else if (event.getSource() == povItem)
3425
+ } else if (source == povItem)
31393426 {
31403427 generatePOV();
31413428 //return true;
3142
- } else if (event.getSource() == zBufferItem)
3429
+ } else if (event.getSource() == archiveItem)
3430
+ {
3431
+ cTools.Archive(frame);
3432
+ return;
3433
+ } else if (source == zBufferItem)
31433434 {
31443435 try
31453436 {
....@@ -3161,21 +3452,8 @@
31613452 cameraView.repaint();
31623453 //return true;
31633454 }
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)
3455
+ */ else // combos...
3456
+ if (source == texresMenu)
31793457 {
31803458 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31813459 copy.texres = texresMenu.getSelectedIndex();
....@@ -3187,12 +3465,349 @@
31873465 }
31883466 }
31893467
3468
+ void New()
3469
+ {
3470
+ while (copy.Size() > 1)
3471
+ {
3472
+ copy.remove(1);
3473
+ }
3474
+
3475
+ ResetModel();
3476
+ objEditor.refreshContents();
3477
+ }
3478
+
3479
+ static public byte[] Compress(Object3D o)
3480
+ {
3481
+ try
3482
+ {
3483
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3484
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3485
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
3486
+
3487
+ Object3D parent = o.parent;
3488
+ o.parent = null;
3489
+
3490
+ out.writeObject(o);
3491
+
3492
+ o.parent = parent;
3493
+
3494
+ out.flush();
3495
+
3496
+ baos //zstream
3497
+ .close();
3498
+ out.close();
3499
+
3500
+ byte[] bytes = baos.toByteArray();
3501
+
3502
+ System.out.println("save #bytes = " + bytes.length);
3503
+ return bytes;
3504
+ } catch (Exception e)
3505
+ {
3506
+ System.err.println(e);
3507
+ return null;
3508
+ }
3509
+ }
3510
+
3511
+ static public Object Uncompress(byte[] bytes)
3512
+ {
3513
+ System.out.println("restore #bytes = " + bytes.length);
3514
+ try
3515
+ {
3516
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3517
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3518
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
3519
+ Object obj = in.readObject();
3520
+
3521
+ bais //istream
3522
+ .close();
3523
+ in.close();
3524
+
3525
+ return obj;
3526
+ } catch (Exception e)
3527
+ {
3528
+ System.err.println(e);
3529
+ return null;
3530
+ }
3531
+ }
3532
+
3533
+ static public Object clone(Object o)
3534
+ {
3535
+ try
3536
+ {
3537
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3538
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3539
+
3540
+ out.writeObject(o);
3541
+
3542
+ out.flush();
3543
+ out.close();
3544
+
3545
+ byte[] bytes = baos.toByteArray();
3546
+
3547
+ System.out.println("clone = " + bytes.length);
3548
+
3549
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3550
+ ObjectInputStream in = new ObjectInputStream(bais);
3551
+ Object obj = in.readObject();
3552
+ in.close();
3553
+
3554
+ return obj;
3555
+ } catch (Exception e)
3556
+ {
3557
+ System.err.println(e);
3558
+ return null;
3559
+ }
3560
+ }
3561
+
3562
+ cRadio GetCurrentTab()
3563
+ {
3564
+ cRadio ab;
3565
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3566
+ {
3567
+ ab = (cRadio)e.nextElement();
3568
+ if(ab.GetObject() == copy)
3569
+ {
3570
+ return ab;
3571
+ }
3572
+ }
3573
+
3574
+ return null;
3575
+ }
3576
+
3577
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3578
+
3579
+ public void Save()
3580
+ {
3581
+ Save(true);
3582
+ }
3583
+
3584
+ private boolean Equal(byte[] compress, byte[] name)
3585
+ {
3586
+ if (compress.length != name.length)
3587
+ {
3588
+ return false;
3589
+ }
3590
+
3591
+ for (int i=compress.length; --i>=0;)
3592
+ {
3593
+ if (compress[i] != name[i])
3594
+ return false;
3595
+ }
3596
+
3597
+ return true;
3598
+ }
3599
+
3600
+ public boolean Save(boolean user)
3601
+ {
3602
+ System.err.println("Save");
3603
+
3604
+ cRadio tab = GetCurrentTab();
3605
+
3606
+ boolean temp = CameraPane.SWITCH;
3607
+ CameraPane.SWITCH = false;
3608
+
3609
+ copy.ExtractBigData(hashtable);
3610
+
3611
+ byte[] compress = Compress(copy);
3612
+
3613
+ CameraPane.SWITCH = temp;
3614
+
3615
+ boolean thesame = false;
3616
+
3617
+ // Quick heuristic using length. Works only when stream is compressed.
3618
+ if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1]))
3619
+ {
3620
+ thesame = true;
3621
+ }
3622
+
3623
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3624
+ if (!thesame)
3625
+ {
3626
+ //tab.user[tab.undoindex] = user;
3627
+ boolean increment = tab.graphs[tab.undoindex] == null;
3628
+
3629
+ tab.graphs[tab.undoindex] = compress;
3630
+
3631
+ if (increment)
3632
+ tab.undoindex++;
3633
+ }
3634
+
3635
+ copy.RestoreBigData(hashtable);
3636
+
3637
+ //assert(hashtable.isEmpty());
3638
+
3639
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3640
+ {
3641
+ //tab.user[i] = false;
3642
+ // tab.graphs[i] = null;
3643
+ }
3644
+
3645
+ SetUndoStates();
3646
+
3647
+ // test save
3648
+ if (false)
3649
+ {
3650
+ try
3651
+ {
3652
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3653
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3654
+
3655
+ p.writeObject(copy);
3656
+
3657
+ p.flush();
3658
+
3659
+ ostream.close();
3660
+ } catch (Exception e)
3661
+ {
3662
+ e.printStackTrace();
3663
+ }
3664
+ }
3665
+
3666
+ return !thesame;
3667
+ }
3668
+
3669
+ void CopyChanged(Object3D obj)
3670
+ {
3671
+ SetUndoStates();
3672
+
3673
+ boolean temp = CameraPane.SWITCH;
3674
+ CameraPane.SWITCH = false;
3675
+
3676
+ copy.ExtractBigData(hashtable);
3677
+
3678
+ copy.clear();
3679
+
3680
+ for (int i=0; i<obj.Size(); i++)
3681
+ {
3682
+ copy.add(obj.get(i));
3683
+ }
3684
+
3685
+ copy.RestoreBigData(hashtable);
3686
+
3687
+ CameraPane.SWITCH = temp;
3688
+
3689
+ //assert(hashtable.isEmpty());
3690
+
3691
+ copy.Touch();
3692
+
3693
+ ResetModel();
3694
+ copy.HardTouch(); // recompile?
3695
+
3696
+ cRadio ab;
3697
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3698
+ {
3699
+ ab = (cRadio)e.nextElement();
3700
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3701
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3702
+ if (test != null)
3703
+ {
3704
+ test.editWindow = ab.object.editWindow;
3705
+ ab.object = test;
3706
+ }
3707
+ }
3708
+
3709
+ refreshContents();
3710
+ }
3711
+
3712
+ cButton undoButton;
3713
+ cButton redoButton;
3714
+
3715
+ void SetUndoStates()
3716
+ {
3717
+ cRadio tab = GetCurrentTab();
3718
+
3719
+ undoButton.setEnabled(tab.undoindex > 0);
3720
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3721
+ }
3722
+
3723
+ public boolean Undo()
3724
+ {
3725
+ System.err.println("Undo");
3726
+
3727
+ cRadio tab = GetCurrentTab();
3728
+
3729
+ if (tab.undoindex == 0)
3730
+ {
3731
+ java.awt.Toolkit.getDefaultToolkit().beep();
3732
+ return false;
3733
+ }
3734
+
3735
+ if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex])
3736
+ {
3737
+ if (Save(false))
3738
+ tab.undoindex -= 1;
3739
+ else
3740
+ {
3741
+ if (tab.undoindex <= 0)
3742
+ return false;
3743
+ else
3744
+ tab.undoindex -= 1;
3745
+ }
3746
+ }
3747
+
3748
+ tab.undoindex -= 1;
3749
+
3750
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3751
+
3752
+ return true;
3753
+ }
3754
+
3755
+ public void Redo()
3756
+ {
3757
+ cRadio tab = GetCurrentTab();
3758
+
3759
+ if (tab.graphs[tab.undoindex + 1] == null)
3760
+ {
3761
+ java.awt.Toolkit.getDefaultToolkit().beep();
3762
+ return;
3763
+ }
3764
+
3765
+ tab.undoindex += 1;
3766
+
3767
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3768
+
3769
+ //if (!tab.user[tab.undoindex])
3770
+ // tab.graphs[tab.undoindex] = null;
3771
+ }
3772
+
3773
+ void ImportGFD()
3774
+ {
3775
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3776
+ browser.show();
3777
+ String filename = browser.getFile();
3778
+ if (filename != null && filename.length() > 0)
3779
+ {
3780
+ String fullname = browser.getDirectory() + filename;
3781
+
3782
+ //Object3D readobj =
3783
+ objEditor.ReadGFD(fullname, objEditor);
3784
+ //makeSomething(readobj);
3785
+ }
3786
+ }
3787
+
3788
+ void ImportVRMLX3D()
3789
+ {
3790
+ if (Grafreed.standAlone)
3791
+ {
3792
+ /**/
3793
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3794
+ browser.show();
3795
+ String filename = browser.getFile();
3796
+ if (filename != null && filename.length() > 0)
3797
+ {
3798
+ String fullname = browser.getDirectory() + filename;
3799
+ LoadVRMLX3D(fullname);
3800
+ }
3801
+ /**/
3802
+ }
3803
+ }
3804
+
31903805 void ToggleAnimation()
31913806 {
31923807 if (!Globals.ANIMATION)
31933808 {
31943809 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3195
- browser.show();
3810
+ browser.setVisible(true);
31963811 String filename = browser.getFile();
31973812 if (filename != null && filename.length() > 0)
31983813 {
....@@ -3202,8 +3817,8 @@
32023817
32033818 Globals.ANIMATION ^= true;
32043819
3205
- GrafreeD.wav.cursor = 0;
3206
- GrafreeD.wav.loop = 0;
3820
+ Grafreed.wav.cursor = 0;
3821
+ Grafreed.wav.loop = 0;
32073822 }
32083823 } else
32093824 {
....@@ -3224,7 +3839,6 @@
32243839 callee.refreshContents();
32253840 } else
32263841 {
3227
- new Exception().printStackTrace();
32283842 System.exit(0);
32293843 }
32303844 }
....@@ -3254,7 +3868,7 @@
32543868 void CreateMaterial()
32553869 {
32563870 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
3871
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32583872 if (copy.selection.size() > 0)
32593873 //SetMaterial(copy);
32603874 {
....@@ -3305,7 +3919,7 @@
33053919 assert false;
33063920 }
33073921
3308
- void EditSelection()
3922
+ void EditSelection(boolean newWindow)
33093923 {
33103924 }
33113925
....@@ -3313,11 +3927,11 @@
33133927 {
33143928 copy.ResetBlockLoop(); // temporary problem
33153929
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
3930
+ boolean random = CameraPane.SWITCH;
3931
+ CameraPane.SWITCH = false; // parse everything
33183932 copy.ResetDisplayList();
33193933 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
3934
+ CameraPane.SWITCH = random;
33213935 }
33223936
33233937 // public void applySelf()
....@@ -3391,6 +4005,36 @@
33914005 {
33924006 //System.out.println("Propagate = " + propagate);
33934007 copy.UpdateMaterial(anchor, current, propagate);
4008
+
4009
+ if (copy.material != null)
4010
+ {
4011
+ cMaterial mat = copy.material;
4012
+
4013
+ colorField.SetToolTipValue((mat.color));
4014
+ modulationField.SetToolTipValue((mat.modulation));
4015
+ metalnessField.SetToolTipValue((mat.metalness));
4016
+ diffuseField.SetToolTipValue((mat.diffuse));
4017
+ specularField.SetToolTipValue((mat.specular));
4018
+ shininessField.SetToolTipValue((mat.shininess));
4019
+ shiftField.SetToolTipValue((mat.shift));
4020
+ ambientField.SetToolTipValue((mat.ambient));
4021
+ lightareaField.SetToolTipValue((mat.lightarea));
4022
+ diffusenessField.SetToolTipValue((mat.factor));
4023
+ velvetField.SetToolTipValue((mat.velvet));
4024
+ sheenField.SetToolTipValue((mat.sheen));
4025
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4026
+ backlitField.SetToolTipValue((mat.bump));
4027
+ anisoField.SetToolTipValue((mat.aniso));
4028
+ anisoVField.SetToolTipValue((mat.anisoV));
4029
+ cameraField.SetToolTipValue((mat.cameralight));
4030
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4031
+ shadowField.SetToolTipValue((mat.shadow));
4032
+ textureField.SetToolTipValue((mat.texture));
4033
+ opacityField.SetToolTipValue((mat.opacity));
4034
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4035
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
4036
+ }
4037
+
33944038 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33954039 {
33964040 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3506,7 +4150,7 @@
35064150 }
35074151
35084152 if (normalpushField != null)
3509
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4153
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35104154 }
35114155
35124156 void SnapObject()
....@@ -3770,6 +4414,8 @@
37704414
37714415 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37724416 {
4417
+ if (Globals.SAVEONMAKE) // && resetmodel)
4418
+ Save();
37734419 //Tween.set(thing, 0).target(1).start(tweenManager);
37744420 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37754421 // if (thing instanceof GenericJointDemo)
....@@ -3856,6 +4502,12 @@
38564502 {
38574503 ResetModel();
38584504 Select(thing.GetTreePath(), true, false); // unselect... false);
4505
+
4506
+ if (thing.Size() == 0)
4507
+ {
4508
+ //EditSelection(false);
4509
+ }
4510
+
38594511 refreshContents();
38604512 }
38614513
....@@ -3973,6 +4625,7 @@
39734625 }
39744626 }
39754627 }
4628
+
39764629 LoadGFDThread loadGFDThread;
39774630
39784631 void ReadGFD(String fullname, iCallBack cb)
....@@ -3992,8 +4645,10 @@
39924645
39934646 try
39944647 {
4648
+ // Try compressed version first.
39954649 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3996
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4650
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4651
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39974652
39984653 readobj = (Object3D) p.readObject();
39994654 istream.close();
....@@ -4001,7 +4656,20 @@
40014656 readobj.ResetDisplayList();
40024657 } catch (Exception e)
40034658 {
4004
- e.printStackTrace();
4659
+ //e.printStackTrace();
4660
+ try
4661
+ {
4662
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4663
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4664
+
4665
+ readobj = (Object3D) p.readObject();
4666
+ istream.close();
4667
+
4668
+ readobj.ResetDisplayList();
4669
+ } catch (Exception e2)
4670
+ {
4671
+ e2.printStackTrace();
4672
+ }
40054673 }
40064674 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40074675 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4047,6 +4715,12 @@
40474715
40484716 void LoadIt(Object obj)
40494717 {
4718
+ if (obj == null)
4719
+ {
4720
+ // Invalid file
4721
+ return;
4722
+ }
4723
+
40504724 System.out.println("Loaded " + obj);
40514725 //new Exception().printStackTrace();
40524726 Object3D readobj = (Object3D) obj;
....@@ -4056,6 +4730,8 @@
40564730
40574731 if (readobj != null)
40584732 {
4733
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4734
+ // Save();
40594735 try
40604736 {
40614737 //readobj.deepCopySelf(copy);
....@@ -4116,9 +4792,9 @@
41164792 }
41174793 }
41184794
4119
- void load() // throws ClassNotFoundException
4795
+ void Open() // throws ClassNotFoundException
41204796 {
4121
- if (GrafreeD.standAlone)
4797
+ if (Grafreed.standAlone)
41224798 {
41234799 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41244800 browser.show();
....@@ -4205,11 +4881,13 @@
42054881 try
42064882 {
42074883 FileOutputStream ostream = new FileOutputStream(lastname);
4208
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4884
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4885
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42094886
42104887 p.writeObject(copy);
42114888 p.flush();
42124889
4890
+ zstream.close();
42134891 ostream.close();
42144892
42154893 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4219,17 +4897,20 @@
42194897 {
42204898 }
42214899 }
4900
+
42224901 String lastname;
42234902
42244903 void saveAs()
42254904 {
4226
- if (GrafreeD.standAlone)
4905
+ if (Grafreed.standAlone)
42274906 {
42284907 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42294908 browser.setVisible(true);
42304909 String filename = browser.getFile();
42314910 if (filename != null && filename.length() > 0)
42324911 {
4912
+ if (!filename.endsWith(".gfd"))
4913
+ filename += ".gfd";
42334914 lastname = browser.getDirectory() + filename;
42344915 save();
42354916 }
....@@ -4328,13 +5009,13 @@
43285009 try
43295010 {
43305011 FileOutputStream ostream = new FileOutputStream(filename);
4331
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4332
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
5012
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5013
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43335014
43345015 Object3D objectparent = obj.parent;
43355016 obj.parent = null;
43365017
4337
- Object3D object = (Object3D) GrafreeD.clone(obj);
5018
+ Object3D object = (Object3D) Grafreed.clone(obj);
43385019
43395020 obj.parent = objectparent;
43405021
....@@ -4346,8 +5027,8 @@
43465027 p.writeObject(object);
43475028 p.flush();
43485029
5030
+ zstream.close();
43495031 ostream.close();
4350
- // zstream.close();
43515032
43525033 // group.selection.get(0).parent = parent;
43535034 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4368,7 +5049,7 @@
43685049 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43695050 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43705051 copy.generatePOV(buffer);
4371
- if (GrafreeD.standAlone)
5052
+ if (Grafreed.standAlone)
43725053 {
43735054 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43745055 browser.show();
....@@ -4394,19 +5075,18 @@
43945075 Object3D client;
43955076 Object3D copy;
43965077 MenuBar menuBar;
4397
- Menu windowMenu;
4398
- MenuItem loadItem;
5078
+ Menu fileMenu;
5079
+ MenuItem newItem;
5080
+ MenuItem openItem;
43995081 MenuItem saveItem;
44005082 MenuItem saveAsItem;
44015083 MenuItem exportAsItem;
44025084 MenuItem reexportItem;
44035085 MenuItem povItem;
44045086 MenuItem closeItem;
4405
- Menu cameraMenu;
5087
+
44065088 CheckboxMenuItem zBufferItem;
44075089 //MenuItem normalLensItem;
4408
- MenuItem editCameraItem;
4409
- MenuItem revertCameraItem;
44105090 MenuItem stepItem;
44115091 CheckboxMenuItem toggleLiveItem;
44125092 CheckboxMenuItem toggleFullScreenItem;
....@@ -4417,25 +5097,39 @@
44175097 CheckboxMenuItem toggleFootContactItem;
44185098 CheckboxMenuItem toggleDLItem;
44195099 CheckboxMenuItem toggleTextureItem;
4420
- CheckboxMenuItem toggleRandomItem;
5100
+ CheckboxMenuItem toggleSwitchItem;
44215101 CheckboxMenuItem toggleRootItem;
44225102 CheckboxMenuItem animationItem;
5103
+ MenuItem archiveItem;
44235104 CheckboxMenuItem toggleHandleItem;
44245105 CheckboxMenuItem togglePaintItem;
44255106 JSplitPane mainPanel;
44265107 JScrollPane scrollpane;
5108
+
44275109 JPanel toolbarPanel;
4428
- JPanel treePanel;
5110
+
5111
+ cGridBag treePanel;
5112
+
44295113 JPanel radioPanel;
44305114 ButtonGroup buttonGroup;
4431
- cGridBag ctrlPanel;
5115
+
5116
+ cGridBag toolboxPanel;
44325117 cGridBag materialPanel;
5118
+ cGridBag ctrlPanel;
5119
+
44335120 JScrollPane infoPanel;
5121
+
44345122 cGridBag optionsPanel;
5123
+
44355124 JTabbedPane objectPanel;
5125
+ boolean materialFlushed;
5126
+ Object3D latestObject;
5127
+
44365128 cGridBag XYZPanel;
5129
+
44375130 JSplitPane gridPanel;
44385131 JSplitPane bigPanel;
5132
+
44395133 cGridBag bigThree;
44405134 cGridBag scenePanel;
44415135 cGridBag centralPanel;
....@@ -4550,8 +5244,13 @@
45505244 cNumberSlider fogField;
45515245 JLabel opacityPowerLabel;
45525246 cNumberSlider opacityPowerField;
4553
- JTree jTree;
5247
+ cTree jTree;
45545248 //ObjectUI parent;
45555249
45565250 cNumberSlider normalpushField;
5251
+
5252
+ private MenuItem importGFDItem;
5253
+ private MenuItem importVRMLX3DItem;
5254
+ private MenuItem import3DSItem;
5255
+ private MenuItem importOBJItem;
45575256 }