Normand Briere
2019-06-29 a69bb4474a3264a9a7a7f8b8d8154ea771f167c8
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
....@@ -145,7 +210,7 @@
145210
146211 objEditor.ctrlPanel.remove(namePanel);
147212
148
- if (!GroupEditor.allparams)
213
+ if (!allparams)
149214 return;
150215
151216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -168,7 +233,8 @@
168233 // objEditor.ctrlPanel.remove(remarkButton);
169234
170235 objEditor.ctrlPanel.remove(setupPanel);
171
- objEditor.ctrlPanel.remove(commandsPanel);
236
+ objEditor.ctrlPanel.remove(setupPanel2);
237
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
172238 objEditor.ctrlPanel.remove(pushPanel);
173239 //objEditor.ctrlPanel.remove(fillPanel);
174240
....@@ -243,6 +309,7 @@
243309 //localCopy.parent = null;
244310
245311 frame = new JFrame();
312
+ frame.setUndecorated(true);
246313 objEditor = this;
247314 this.callee = callee;
248315
....@@ -273,27 +340,48 @@
273340 return frame.action(event, obj);
274341 }
275342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
276348 void SetupMenu()
277349 {
278350 frame.setMenuBar(menuBar = new MenuBar());
279
- menuBar.add(windowMenu = new Menu("File"));
280
- windowMenu.add(loadItem = new MenuItem("Load..."));
281
- windowMenu.add("-");
282
- windowMenu.add(saveItem = new MenuItem("Save"));
283
- 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..."));
284371 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
285
- windowMenu.add("-");
286
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
287
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
288
- windowMenu.add("-");
372
+ fileMenu.add("-");
373
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
374
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
375
+ fileMenu.add("-");
289376 if (client.parent != null)
290377 {
291
- windowMenu.add(closeItem = new MenuItem("Close"));
378
+ fileMenu.add(closeItem = new MenuItem("Close"));
292379 } else
293380 {
294
- windowMenu.add(closeItem = new MenuItem("Exit"));
381
+ fileMenu.add(closeItem = new MenuItem("Exit"));
295382 }
296383
384
+ newItem.addActionListener(this);
297385 loadItem.addActionListener(this);
298386 saveItem.addActionListener(this);
299387 saveAsItem.addActionListener(this);
....@@ -302,86 +390,53 @@
302390 //povItem.addActionListener(this);
303391 closeItem.addActionListener(this);
304392
305
- menuBar.add(cameraMenu = new Menu("View"));
306
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
307
- //zBufferItem.addActionListener(this);
308
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
309
- //normalLensItem.addActionListener(this);
310
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
311
- revertCameraItem.addActionListener(this);
312
-
313
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
314
- toggleFullScreenItem.addItemListener(this);
315
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
316
- cameraMenu.add("-");
317
-
318
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
319
- toggleTextureItem.addItemListener(this);
320
- toggleTextureItem.setState(CameraPane.textureon);
321
-
322
- if (Globals.ADVANCED)
323
- {
324
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
325
- toggleLiveItem.addItemListener(this);
326
- toggleLiveItem.setState(Globals.isLIVE());
327
-
328
- cameraMenu.add(stepItem = new MenuItem("Step"));
329
- stepItem.addActionListener(this);
330
- // cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
331
- // toggleDLItem.addItemListener(this);
332
- // toggleDLItem.setState(false);
333
-
334
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
335
- toggleRenderItem.addItemListener(this);
336
- toggleRenderItem.setState(!CameraPane.frozen);
337
-
338
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
339
- toggleDebugItem.addItemListener(this);
340
- toggleDebugItem.setState(CameraPane.DEBUG);
341
-
342
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
343
- toggleFrustumItem.addItemListener(this);
344
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
345
-
346
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
347
- toggleFootContactItem.addItemListener(this);
348
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
349
-
350
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
351
- toggleTimelineItem.addItemListener(this);
352
- }
353
-
354
- cameraMenu.add(toggleSwitchItem = new CheckboxMenuItem("Switch"));
355
- toggleSwitchItem.addItemListener(this);
356
- toggleSwitchItem.setState(CameraPane.SWITCH);
357
-
358
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
359
- toggleHandleItem.addItemListener(this);
360
- toggleHandleItem.setState(CameraPane.HANDLES);
361
-
362
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
363
- togglePaintItem.addItemListener(this);
364
- togglePaintItem.setState(CameraPane.PAINTMODE);
365
-
366
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
367
-// toggleRootItem.addItemListener(this);
368
-// toggleRootItem.setState(false);
369
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
370
-// animationItem.addItemListener(this);
371
-// animationItem.setState(CameraPane.ANIMATION);
372
- cameraMenu.add("-");
373
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
374
- editCameraItem.addActionListener(this);
375
-
376393 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
+
377420 toolbarPanel = new JPanel();
378421 toolbarPanel.setName("Toolbar");
379422 treePanel = new cGridBag();
380423 treePanel.setName("Tree");
424
+
425
+ editPanel = new cGridBag().setVertical(true);
426
+ editPanel.setName("Edit");
427
+
381428 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
382
- 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
+
383437 materialPanel = new cGridBag().setVertical(true);
384438 materialPanel.setName("Material");
439
+
385440 /*JTextPane*/
386441 infoarea = createTextPane();
387442 doc = infoarea.getStyledDocument();
....@@ -394,7 +449,7 @@
394449 // TEXTAREA infoarea.setLineWrap(true);
395450 // TEXTAREA infoarea.setWrapStyleWord(true);
396451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
397
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ //infoPanel.setPreferredSize(new Dimension(50, 200));
398453 infoPanel.setName("Info");
399454 //infoPanel.setLayout(new BorderLayout());
400455 //infoPanel.add(createTextPane());
....@@ -406,7 +461,14 @@
406461 mainPanel.setDividerSize(9);
407462 mainPanel.setDividerLocation(0.5); //1.0);
408463 mainPanel.setResizeWeight(0.5);
409
-
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
+
410472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
411473 //mainPanel.setLayout(new GridBagLayout());
412474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -474,10 +536,10 @@
474536 e.printStackTrace();
475537 }
476538
477
- String selection = infoarea.getText();
478
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
479
- java.awt.datatransfer.Clipboard clipboard =
480
- 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();
481543 //clipboard.setContents(data, data);
482544 }
483545
....@@ -500,13 +562,13 @@
500562 //SendInfo("Name:", "bold");
501563 if (sel.GetTextures() != null || debug)
502564 {
503
- si.SendInfo(sel.toString(), "bold");
565
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
504566 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
505567 if (sel.Size() > 0)
506568 {
507569 si.SendInfo("#children = " + sel.Size(), "regular");
508570 }
509
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
571
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
510572 if (debug)
511573 {
512574 try
....@@ -548,7 +610,7 @@
548610 }
549611 if (sel.support != null)
550612 {
551
- si.SendInfo(" support: " + sel.support, "regular");
613
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
552614 }
553615 if (sel.scriptnode != null)
554616 {
....@@ -637,20 +699,111 @@
637699 }
638700 }
639701
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
+ }
749
+
750
+ maximized ^= true;
751
+
752
+ frame.validate();
753
+ }
754
+
755
+ cButton minButton;
756
+ cButton maxButton;
757
+ cButton fullButton;
758
+
640759 void ToggleFullScreen()
641760 {
642
- if (CameraPane.FULLSCREEN)
761
+ cameraView.ToggleFullScreen();
762
+
763
+ if (!CameraPane.FULLSCREEN)
643764 {
644
- frame.getContentPane().remove(/*"Center",*/bigThree);
645
- framePanel.add(bigThree);
646
- frame.getContentPane().add(/*"Center",*/framePanel);
765
+ device.setFullScreenWindow(null);
766
+ frame.validate();
767
+
768
+ //frame.setVisible(false);
769
+// frame.removeNotify();
770
+// frame.setUndecorated(false);
771
+// frame.addNotify();
772
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
773
+
774
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
775
+// X framePanel.add(bigThree);
776
+// X frame.getContentPane().add(/*"Center",*/framePanel);
777
+ framePanel.setDividerLocation(1);
778
+
779
+ //frame.setVisible(true);
780
+ radio.layout = keepButton;
781
+ //theFrame = null;
782
+ keepButton = null;
783
+ radio.layout.doClick();
784
+
647785 } else
648786 {
649
- frame.getContentPane().remove(/*"Center",*/framePanel);
650
- framePanel.remove(bigThree);
651
- frame.getContentPane().add(/*"Center",*/bigThree);
787
+ keepButton = radio.layout;
788
+ //keeprect = frame.getBounds();
789
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
790
+// frame.getToolkit().getScreenSize().height);
791
+ //frame.setVisible(false);
792
+ device.setFullScreenWindow(frame);
793
+ frame.validate();
794
+// frame.removeNotify();
795
+// frame.setUndecorated(true);
796
+// frame.addNotify();
797
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
798
+// X framePanel.remove(bigThree);
799
+// X frame.getContentPane().add(/*"Center",*/bigThree);
800
+ framePanel.setDividerLocation(0);
801
+
802
+ radio.layout = fullscreenLayout;
803
+ radio.layout.doClick();
804
+ //frame.setVisible(true);
652805 }
653
- cameraView.ToggleFullScreen();
806
+ frame.validate();
654807 }
655808
656809 private JTextPane createTextPane()
....@@ -751,7 +904,7 @@
751904 protected static ImageIcon createImageIcon(String path,
752905 String description)
753906 {
754
- java.net.URL imgURL = GrafreeD.class.getResource(path);
907
+ java.net.URL imgURL = Grafreed.class.getResource(path);
755908 if (imgURL != null)
756909 {
757910 return new ImageIcon(imgURL, description);
....@@ -783,6 +936,7 @@
783936 // NumberSlider vDivsField;
784937 // JCheckBox endcaps;
785938 JCheckBox liveCB;
939
+ JCheckBox selectCB;
786940 JCheckBox hideCB;
787941 JCheckBox link2masterCB;
788942 JCheckBox markCB;
....@@ -790,7 +944,12 @@
790944 JCheckBox speedupCB;
791945 JCheckBox rewindCB;
792946 JCheckBox flipVCB;
947
+
948
+ cCheckBox toggleTextureCB;
949
+ cCheckBox toggleSwitchCB;
950
+
793951 JComboBox texresMenu;
952
+
794953 JButton resetButton;
795954 JButton stepButton;
796955 JButton stepAllButton;
....@@ -799,9 +958,13 @@
799958 JButton fasterButton;
800959 JButton remarkButton;
801960
961
+ cGridBag editPanel;
962
+ cGridBag editCommandsPanel;
963
+
802964 cGridBag namePanel;
803965 cGridBag setupPanel;
804
- cGridBag commandsPanel;
966
+ cGridBag setupPanel2;
967
+ cGridBag objectCommandsPanel;
805968 cGridBag pushPanel;
806969 cGridBag fillPanel;
807970
....@@ -973,61 +1136,67 @@
9731136 namePanel = new cGridBag();
9741137
9751138 nameField = AddText(namePanel, copy.GetName());
976
- namePanel.add(nameField);
1139
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9771140 oe.ctrlPanel.add(namePanel);
9781141
9791142 oe.ctrlPanel.Return();
9801143
981
- if (!GroupEditor.allparams)
1144
+ if (!allparams)
9821145 return;
9831146
9841147 setupPanel = new cGridBag().setVertical(false);
9851148
9861149 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
9871150 liveCB.setToolTipText("Animate object");
1151
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1152
+ selectCB.setToolTipText("Make object selectable");
1153
+// Return();
9881154 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9891155 hideCB.setToolTipText("Hide object");
990
-// Return();
9911156 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
992
- markCB.setToolTipText("Set the animation target transform");
1157
+ markCB.setToolTipText("As animation target transform");
9931158
994
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1159
+ setupPanel2 = new cGridBag().setVertical(false);
1160
+
1161
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9951162 rewindCB.setToolTipText("Rewind animation");
9961163
997
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
998
- randomCB.setToolTipText("Option for switch node");
1164
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1165
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9991166
10001167 if (Globals.ADVANCED)
10011168 {
1002
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
1169
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
10031170 link2masterCB.setToolTipText("Attach to support");
1004
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1171
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10051172 speedupCB.setToolTipText("Option motion capture");
10061173 }
10071174
10081175 oe.ctrlPanel.add(setupPanel);
10091176 oe.ctrlPanel.Return();
1177
+ oe.ctrlPanel.add(setupPanel2);
1178
+ oe.ctrlPanel.Return();
10101179
1011
- commandsPanel = new cGridBag().setVertical(false);
1180
+ objectCommandsPanel = new cGridBag().setVertical(false);
10121181
1013
- resetButton = AddButton(commandsPanel, "Reset");
1182
+ resetButton = AddButton(objectCommandsPanel, "Reset");
10141183 resetButton.setToolTipText("Jump to frame zero");
1015
- stepButton = AddButton(commandsPanel, "Step");
1184
+ stepButton = AddButton(objectCommandsPanel, "Step");
10161185 stepButton.setToolTipText("Step one frame");
10171186 // resetAllButton = AddButton(oe, "Reset All");
10181187 // stepAllButton = AddButton(oe, "Step All");
10191188 // Return();
1020
- slowerButton = AddButton(commandsPanel, "Slow");
1189
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
10211190 slowerButton.setToolTipText("Decrease animation speed");
1022
- fasterButton = AddButton(commandsPanel, "Fast");
1191
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
10231192 fasterButton.setToolTipText("Increase animation speed");
1024
- remarkButton = AddButton(commandsPanel, "Remark");
1193
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
10251194 remarkButton.setToolTipText("Set the current transform as the target");
10261195
1027
- oe.ctrlPanel.add(commandsPanel);
1196
+ oe.ctrlPanel.add(objectCommandsPanel);
10281197 oe.ctrlPanel.Return();
10291198
1030
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1199
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
10311200 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
10321201 //Return();
10331202
....@@ -1230,8 +1399,11 @@
12301399 //worldPanel.setName("World");
12311400 centralPanel = new cGridBag();
12321401 centralPanel.preferredWidth = 20;
1233
- timelinePanel = new JPanel(new BorderLayout());
1234
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1402
+
1403
+ if (Globals.ADVANCED)
1404
+ {
1405
+ timelinePanel = new JPanel(new BorderLayout());
1406
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
12351407
12361408 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
12371409 cameraPanel.setContinuousLayout(true);
....@@ -1240,7 +1412,10 @@
12401412 // cameraPanel.setDividerSize(9);
12411413 cameraPanel.setResizeWeight(1.0);
12421414
1415
+ }
1416
+
12431417 centralPanel.add(cameraView);
1418
+ centralPanel.setFocusable(true);
12441419 //frame.setJMenuBar(timelineMenubar);
12451420 //centralPanel.add(timelinePanel);
12461421
....@@ -1307,8 +1482,9 @@
13071482 // north.setName("Edit");
13081483 // north.add(ctrlPanel, BorderLayout.NORTH);
13091484 // objectPanel.add(north);
1310
- objectPanel.add(ctrlPanel);
1485
+ objectPanel.add(editPanel);
13111486 objectPanel.add(infoPanel);
1487
+ objectPanel.add(toolboxPanel);
13121488
13131489 /*
13141490 aConstraints.gridx = 0;
....@@ -1317,7 +1493,7 @@
13171493 aConstraints.gridy += 1;
13181494 aConstraints.gridwidth = 1;
13191495 mainPanel.add(objectPanel, aConstraints);
1320
- */
1496
+ */
13211497
13221498 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
13231499 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1329,14 +1505,12 @@
13291505 scrollpane.addMouseWheelListener(this); // Default not fast enough
13301506
13311507 /*JTabbedPane*/ scenePanel = new cGridBag();
1332
- scenePanel.preferredWidth = 7;
1508
+ scenePanel.preferredWidth = 6;
13331509
13341510 JTabbedPane tabbedPane = new JTabbedPane();
13351511 tabbedPane.add(scrollpane);
13361512
1337
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1338
-
1339
- optionsPanel = new cGridBag().setVertical(true);
1513
+ optionsPanel = new cGridBag().setVertical(false);
13401514
13411515 optionsPanel.setName("Options");
13421516
....@@ -1344,6 +1518,8 @@
13441518
13451519 tabbedPane.add(optionsPanel);
13461520
1521
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1522
+
13471523 scenePanel.add(tabbedPane);
13481524
13491525 /*
....@@ -1435,9 +1611,13 @@
14351611
14361612 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14371613
1438
- frame.setSize(1024, 768);
1439
- frame.show();
1614
+ frame.setSize(1280, 860);
1615
+
1616
+ frame.validate();
1617
+ frame.setVisible(true);
14401618
1619
+ cameraView.requestFocusInWindow();
1620
+
14411621 gridPanel.setDividerLocation(1.0);
14421622
14431623 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -1475,19 +1655,19 @@
14751655
14761656 cGridBag editBar = new cGridBag().setVertical(false);
14771657
1478
- editBar.add(createMaterialButton = new cButton("Create", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1658
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
14791659 createMaterialButton.setToolTipText("Create material");
14801660
14811661 /*
14821662 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14831663 */
14841664
1485
- editBar.add(clearMaterialButton = new cButton("Clear", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1665
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
14861666 clearMaterialButton.setToolTipText("Clear material");
14871667
14881668 if (Globals.ADVANCED)
14891669 {
1490
- editBar.add(resetSlidersButton = new cButton("Reset", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1670
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
14911671 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
14921672 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
14931673 }
....@@ -1524,24 +1704,6 @@
15241704 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15251705 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
15261706 colorSection.add(texture);
1527
-
1528
- cGridBag anisoU = new cGridBag();
1529
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1530
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1531
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1532
- colorSection.add(anisoU);
1533
-
1534
- cGridBag anisoV = new cGridBag();
1535
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1536
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1537
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1538
- colorSection.add(anisoV);
1539
-
1540
- cGridBag shadowbias = new cGridBag();
1541
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1542
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1543
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1544
- colorSection.add(shadowbias);
15451707
15461708 panel.add(new JSeparator());
15471709
....@@ -1593,6 +1755,12 @@
15931755 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15941756 diffuseSection.add(fakedepth);
15951757
1758
+ cGridBag shadowbias = new cGridBag();
1759
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1760
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1761
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1762
+ diffuseSection.add(shadowbias);
1763
+
15961764 panel.add(new JSeparator());
15971765
15981766 panel.add(diffuseSection);
....@@ -1643,6 +1811,18 @@
16431811 // aConstraints.gridy += 1;
16441812 // aConstraints.gridwidth = 1;
16451813
1814
+ cGridBag anisoU = new cGridBag();
1815
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1816
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1817
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1818
+ specularSection.add(anisoU);
1819
+
1820
+ cGridBag anisoV = new cGridBag();
1821
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1822
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1823
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1824
+ specularSection.add(anisoV);
1825
+
16461826
16471827 panel.add(new JSeparator());
16481828
....@@ -1650,35 +1830,35 @@
16501830
16511831 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16521832
1653
- cGridBag globalSection = new cGridBag().setVertical(true);
1833
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16541834
16551835 cGridBag camera = new cGridBag();
16561836 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16571837 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16581838 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1659
- globalSection.add(camera);
1839
+ colorSection.add(camera);
16601840
16611841 cGridBag ambient = new cGridBag();
16621842 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16631843 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16641844 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1665
- globalSection.add(ambient);
1845
+ colorSection.add(ambient);
16661846
16671847 cGridBag backlit = new cGridBag();
16681848 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16691849 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16701850 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1671
- globalSection.add(backlit);
1851
+ colorSection.add(backlit);
16721852
16731853 cGridBag opacity = new cGridBag();
16741854 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
16751855 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16761856 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1677
- globalSection.add(opacity);
1857
+ colorSection.add(opacity);
16781858
1679
- panel.add(new JSeparator());
1859
+ //panel.add(new JSeparator());
16801860
1681
- panel.add(globalSection);
1861
+ //panel.add(globalSection);
16821862
16831863 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16841864
....@@ -1938,7 +2118,7 @@
19382118
19392119 //? flashIt = false;
19402120 CameraPane pane = (CameraPane) cameraView;
1941
- pane.clickStart(location.x, location.y, 0);
2121
+ pane.clickStart(location.x, location.y, 0, 0);
19422122 pane.clickEnd(location.x, location.y, 0, true);
19432123
19442124 if (group.selection.size() == 1)
....@@ -1987,6 +2167,7 @@
19872167 e2.printStackTrace();
19882168 }
19892169 }
2170
+
19902171 LoadJMEThread loadThread;
19912172
19922173 class LoadJMEThread extends Thread
....@@ -2044,6 +2225,7 @@
20442225 //LoadFile0(filename, converter);
20452226 }
20462227 }
2228
+
20472229 LoadOBJThread loadObjThread;
20482230
20492231 class LoadOBJThread extends Thread
....@@ -2122,19 +2304,19 @@
21222304
21232305 void LoadObjFile(String fullname)
21242306 {
2125
- /*
2307
+ System.out.println("Loading " + fullname);
2308
+ /**/
21262309 //lastFilename = fullname;
21272310 if(loadObjThread == null)
21282311 {
2129
- loadObjThread = new LoadOBJThread();
2130
- loadObjThread.start();
2312
+ loadObjThread = new LoadOBJThread();
2313
+ loadObjThread.start();
21312314 }
21322315
21332316 loadObjThread.add(fullname);
2134
- */
2317
+ /**/
21352318
2136
- System.out.println("Loading " + fullname);
2137
- makeSomething(new FileObject(fullname, true), true);
2319
+ //makeSomething(new FileObject(fullname, true), true);
21382320 }
21392321
21402322 void LoadGFDFile(String fullname)
....@@ -2395,11 +2577,11 @@
23952577
23962578 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23972579 {
2398
- if (GrafreeD.standAlone)
2580
+ if (Grafreed.standAlone)
23992581 {
24002582 /**/
24012583 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2402
- browser.show();
2584
+ browser.setVisible(true);
24032585 String filename = browser.getFile();
24042586 if (filename != null && filename.length() > 0)
24052587 {
....@@ -2751,6 +2933,8 @@
27512933
27522934 void SetMaterial(Object3D object)
27532935 {
2936
+ latestObject = object;
2937
+
27542938 cMaterial mat = object.material;
27552939
27562940 if (mat == null)
....@@ -2862,12 +3046,17 @@
28623046 // }
28633047
28643048 /**/
2865
- if (deselect)
3049
+ if (deselect || child == null)
28663050 {
28673051 //group.deselectAll();
28683052 //freeze = true;
28693053 GetTree().clearSelection();
28703054 //freeze = false;
3055
+
3056
+ if (child == null)
3057
+ {
3058
+ return;
3059
+ }
28713060 }
28723061
28733062 //group.addSelectee(child);
....@@ -2936,7 +3125,7 @@
29363125 cameraView.ToggleDL();
29373126 cameraView.repaint();
29383127 return;
2939
- } else if (event.getSource() == toggleTextureItem)
3128
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29403129 {
29413130 cameraView.ToggleTexture();
29423131 // june 2013 copy.HardTouch();
....@@ -2975,9 +3164,9 @@
29753164 frame.validate();
29763165
29773166 return;
2978
- } else if (event.getSource() == toggleSwitchItem)
3167
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29793168 {
2980
- cameraView.ToggleRandom();
3169
+ cameraView.ToggleSwitch();
29813170 cameraView.repaint();
29823171 return;
29833172 } else if (event.getSource() == toggleHandleItem)
....@@ -3005,6 +3194,10 @@
30053194 } else if (event.getSource() == liveCB)
30063195 {
30073196 copy.live ^= true;
3197
+ return;
3198
+ } else if (event.getSource() == selectCB)
3199
+ {
3200
+ copy.dontselect ^= true;
30083201 return;
30093202 } else if (event.getSource() == hideCB)
30103203 {
....@@ -3044,8 +3237,9 @@
30443237
30453238 public void actionPerformed(ActionEvent event)
30463239 {
3240
+ Object source = event.getSource();
30473241 // SCRIPT DIALOG
3048
- if (event.getSource() == okbutton)
3242
+ if (source == okbutton)
30493243 {
30503244 textpanel.setVisible(false);
30513245 textpanel.remove(textarea);
....@@ -3057,7 +3251,7 @@
30573251 textarea = null;
30583252 textpanel = null;
30593253 }
3060
- if (event.getSource() == cancelbutton)
3254
+ if (source == cancelbutton)
30613255 {
30623256 textpanel.setVisible(false);
30633257 textpanel.remove(textarea);
....@@ -3069,50 +3263,50 @@
30693263 //applySelf();
30703264 //client.refreshEditWindow();
30713265 //refreshContents();
3072
- if (event.getSource() == nameField)
3266
+ if (source == nameField)
30733267 {
30743268 //System.out.println("ObjEditor " + event);
30753269 applySelf0(true);
30763270 //parent.applySelf();
30773271 objEditor.refreshContents();
3078
- } else if (event.getSource() == resetButton)
3272
+ } else if (source == resetButton)
30793273 {
30803274 CameraPane.fullreset = true;
30813275 copy.Reset(); // ResetMeshes();
30823276 copy.Touch();
30833277 objEditor.refreshContents();
3084
- } else if (event.getSource() == stepItem)
3278
+ } else if (source == stepItem)
30853279 {
30863280 //cameraView.ONESTEP = true;
30873281 Globals.ONESTEP = true;
30883282 cameraView.repaint();
30893283 return;
3090
- } else if (event.getSource() == stepButton)
3284
+ } else if (source == stepButton)
30913285 {
30923286 copy.Step();
30933287 copy.Touch();
30943288 objEditor.refreshContents();
3095
- } else if (event.getSource() == slowerButton)
3289
+ } else if (source == slowerButton)
30963290 {
30973291 copy.Slower();
30983292 copy.Touch();
30993293 objEditor.refreshContents();
3100
- } else if (event.getSource() == fasterButton)
3294
+ } else if (source == fasterButton)
31013295 {
31023296 copy.Faster();
31033297 copy.Touch();
31043298 objEditor.refreshContents();
3105
- } else if (event.getSource() == remarkButton)
3299
+ } else if (source == remarkButton)
31063300 {
31073301 copy.Remark();
31083302 copy.Touch();
31093303 objEditor.refreshContents();
3110
- } else if (event.getSource() == stepAllButton)
3304
+ } else if (source == stepAllButton)
31113305 {
31123306 copy.StepAll();
31133307 copy.Touch();
31143308 objEditor.refreshContents();
3115
- } else if (event.getSource() == resetAllButton)
3309
+ } else if (source == resetAllButton)
31163310 {
31173311 //CameraPane.fullreset = true;
31183312 copy.ResetAll(); // ResetMeshes();
....@@ -3145,53 +3339,75 @@
31453339 // Close();
31463340 // }
31473341 // else
3148
- if (event.getSource() == resetSlidersButton)
3342
+ if (source == resetSlidersButton)
31493343 {
31503344 ResetSliders();
3151
- } else if (event.getSource() == clearMaterialButton)
3345
+ } else if (source == clearMaterialButton)
31523346 {
31533347 ClearMaterial();
3154
- } else if (event.getSource() == createMaterialButton)
3348
+ } else if (source == createMaterialButton)
31553349 {
31563350 CreateMaterial();
3157
- } else if (event.getSource() == clearPanelButton)
3351
+ } else if (source == clearPanelButton)
31583352 {
31593353 copy.ClearUI();
31603354 refreshContents(true);
3161
- } /*
3162
- }
3163
-
3164
- public boolean action(Event event, Object arg)
3165
- {
3166
- */ else if (event.getSource() == closeItem)
3355
+ } else if (source == importGFDItem)
3356
+ {
3357
+ ImportGFD();
3358
+ } else
3359
+ if (source == importVRMLX3DItem)
3360
+ {
3361
+ ImportVRMLX3D();
3362
+ } else
3363
+ if (source == import3DSItem)
3364
+ {
3365
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3366
+ } else
3367
+ if (source == importOBJItem)
3368
+ {
3369
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3370
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3371
+ browser.setVisible(true);
3372
+ String filename = browser.getFile();
3373
+ if (filename != null && filename.length() > 0)
3374
+ {
3375
+ String fullname = browser.getDirectory() + filename;
3376
+ makeSomething(ReadOBJ(fullname), true);
3377
+ }
3378
+ } else
3379
+ if (source == closeItem)
31673380 {
31683381 Close();
31693382 //return true;
3170
- } else if (event.getSource() == loadItem)
3383
+ } else if (source == loadItem)
31713384 {
31723385 load();
31733386 //return true;
3174
- } else if (event.getSource() == saveItem)
3387
+ } else if (source == newItem)
3388
+ {
3389
+ New();
3390
+ } else if (source == saveItem)
31753391 {
31763392 save();
31773393 //return true;
3178
- } else if (event.getSource() == saveAsItem)
3394
+ } else if (source == saveAsItem)
31793395 {
31803396 saveAs();
31813397 //return true;
3182
- } else if (event.getSource() == reexportItem)
3398
+ } else if (source == reexportItem)
31833399 {
31843400 reexport();
31853401 //return true;
3186
- } else if (event.getSource() == exportAsItem)
3402
+ } else if (source == exportAsItem)
31873403 {
31883404 export();
31893405 //return true;
3190
- } else if (event.getSource() == povItem)
3406
+ } else if (source == povItem)
31913407 {
31923408 generatePOV();
31933409 //return true;
3194
- } else if (event.getSource() == zBufferItem)
3410
+ } else if (source == zBufferItem)
31953411 {
31963412 try
31973413 {
....@@ -3213,21 +3429,8 @@
32133429 cameraView.repaint();
32143430 //return true;
32153431 }
3216
- */ else if (event.getSource() == editCameraItem)
3217
- {
3218
- cameraView.ProtectCamera();
3219
- cameraView.repaint();
3220
- return;
3221
- } else if (event.getSource() == revertCameraItem)
3222
- {
3223
- cameraView.RevertCamera();
3224
- cameraView.repaint();
3225
- return;
3226
-// } else if (event.getSource() == textureButton)
3227
-// {
3228
-// return; // true;
3229
- } else // combos...
3230
- if (event.getSource() == texresMenu)
3432
+ */ else // combos...
3433
+ if (source == texresMenu)
32313434 {
32323435 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
32333436 copy.texres = texresMenu.getSelectedIndex();
....@@ -3239,6 +3442,283 @@
32393442 }
32403443 }
32413444
3445
+ void New()
3446
+ {
3447
+ while (copy.Size() > 1)
3448
+ {
3449
+ copy.remove(1);
3450
+ }
3451
+
3452
+ ResetModel();
3453
+ objEditor.refreshContents();
3454
+ }
3455
+
3456
+ static public byte[] Compress(Object3D o)
3457
+ {
3458
+ try
3459
+ {
3460
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3461
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3462
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3463
+
3464
+ Object3D parent = o.parent;
3465
+ o.parent = null;
3466
+
3467
+ out.writeObject(o);
3468
+
3469
+ o.parent = parent;
3470
+
3471
+ out.flush();
3472
+
3473
+ zstream.close();
3474
+ out.close();
3475
+
3476
+ return baos.toByteArray();
3477
+ } catch (Exception e)
3478
+ {
3479
+ System.err.println(e);
3480
+ return null;
3481
+ }
3482
+ }
3483
+
3484
+ static public Object Uncompress(byte[] bytes)
3485
+ {
3486
+ System.out.println("#bytes = " + bytes.length);
3487
+ try
3488
+ {
3489
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3490
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3491
+ ObjectInputStream in = new ObjectInputStream(istream);
3492
+ Object obj = in.readObject();
3493
+ in.close();
3494
+
3495
+ return obj;
3496
+ } catch (Exception e)
3497
+ {
3498
+ System.err.println(e);
3499
+ return null;
3500
+ }
3501
+ }
3502
+
3503
+ static public Object clone(Object o)
3504
+ {
3505
+ try
3506
+ {
3507
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3508
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3509
+
3510
+ out.writeObject(o);
3511
+
3512
+ out.flush();
3513
+ out.close();
3514
+
3515
+ byte[] bytes = baos.toByteArray();
3516
+
3517
+ System.out.println("clone = " + bytes.length);
3518
+
3519
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3520
+ ObjectInputStream in = new ObjectInputStream(bais);
3521
+ Object obj = in.readObject();
3522
+ in.close();
3523
+
3524
+ return obj;
3525
+ } catch (Exception e)
3526
+ {
3527
+ System.err.println(e);
3528
+ return null;
3529
+ }
3530
+ }
3531
+
3532
+ cRadio GetCurrentTab()
3533
+ {
3534
+ cRadio ab;
3535
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3536
+ {
3537
+ ab = (cRadio)e.nextElement();
3538
+ if(ab.GetObject() == copy)
3539
+ {
3540
+ return ab;
3541
+ }
3542
+ }
3543
+
3544
+ return null;
3545
+ }
3546
+
3547
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3548
+
3549
+ public void Save()
3550
+ {
3551
+ System.err.println("Save");
3552
+
3553
+ cRadio tab = GetCurrentTab();
3554
+
3555
+ boolean temp = CameraPane.SWITCH;
3556
+ CameraPane.SWITCH = false;
3557
+
3558
+ copy.ExtractBigData(hashtable);
3559
+
3560
+ byte[] compress = Compress(copy);
3561
+
3562
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3563
+ tab.graphs[tab.undoindex++] = compress;
3564
+
3565
+ copy.RestoreBigData(hashtable);
3566
+
3567
+ CameraPane.SWITCH = temp;
3568
+
3569
+ //assert(hashtable.isEmpty());
3570
+
3571
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3572
+ {
3573
+ tab.graphs[i] = null;
3574
+ }
3575
+
3576
+ SetUndoStates();
3577
+
3578
+ // test save
3579
+ if (false)
3580
+ {
3581
+ try
3582
+ {
3583
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3584
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3585
+
3586
+ p.writeObject(copy);
3587
+
3588
+ p.flush();
3589
+
3590
+ ostream.close();
3591
+ } catch (Exception e)
3592
+ {
3593
+ e.printStackTrace();
3594
+ }
3595
+ }
3596
+ }
3597
+
3598
+ void CopyChanged(Object3D obj)
3599
+ {
3600
+ SetUndoStates();
3601
+
3602
+ boolean temp = CameraPane.SWITCH;
3603
+ CameraPane.SWITCH = false;
3604
+
3605
+ copy.ExtractBigData(hashtable);
3606
+
3607
+ copy.clear();
3608
+
3609
+ for (int i=0; i<obj.Size(); i++)
3610
+ {
3611
+ copy.add(obj.get(i));
3612
+ }
3613
+
3614
+ copy.RestoreBigData(hashtable);
3615
+
3616
+ CameraPane.SWITCH = temp;
3617
+
3618
+ //assert(hashtable.isEmpty());
3619
+
3620
+ copy.Touch();
3621
+
3622
+ ResetModel();
3623
+ copy.HardTouch(); // recompile?
3624
+
3625
+ cRadio ab;
3626
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3627
+ {
3628
+ ab = (cRadio)e.nextElement();
3629
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3630
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3631
+ if (test != null)
3632
+ {
3633
+ test.editWindow = ab.object.editWindow;
3634
+ ab.object = test;
3635
+ }
3636
+ }
3637
+
3638
+ refreshContents();
3639
+ }
3640
+
3641
+ cButton undoButton;
3642
+ cButton redoButton;
3643
+
3644
+ void SetUndoStates()
3645
+ {
3646
+ cRadio tab = GetCurrentTab();
3647
+
3648
+ undoButton.setEnabled(tab.undoindex > 0);
3649
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3650
+ }
3651
+
3652
+ public void Undo()
3653
+ {
3654
+ System.err.println("Undo");
3655
+
3656
+ cRadio tab = GetCurrentTab();
3657
+
3658
+ if (tab.undoindex == 0)
3659
+ {
3660
+ java.awt.Toolkit.getDefaultToolkit().beep();
3661
+ return;
3662
+ }
3663
+
3664
+ if (tab.graphs[tab.undoindex] == null)
3665
+ {
3666
+ Save();
3667
+ tab.undoindex -= 1;
3668
+ }
3669
+
3670
+ tab.undoindex -= 1;
3671
+
3672
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3673
+ }
3674
+
3675
+ public void Redo()
3676
+ {
3677
+ cRadio tab = GetCurrentTab();
3678
+
3679
+ if (tab.graphs[tab.undoindex + 1] == null)
3680
+ {
3681
+ java.awt.Toolkit.getDefaultToolkit().beep();
3682
+ return;
3683
+ }
3684
+
3685
+ tab.undoindex += 1;
3686
+
3687
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3688
+ }
3689
+
3690
+ void ImportGFD()
3691
+ {
3692
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3693
+ browser.show();
3694
+ String filename = browser.getFile();
3695
+ if (filename != null && filename.length() > 0)
3696
+ {
3697
+ String fullname = browser.getDirectory() + filename;
3698
+
3699
+ //Object3D readobj =
3700
+ objEditor.ReadGFD(fullname, objEditor);
3701
+ //makeSomething(readobj);
3702
+ }
3703
+ }
3704
+
3705
+ void ImportVRMLX3D()
3706
+ {
3707
+ if (Grafreed.standAlone)
3708
+ {
3709
+ /**/
3710
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3711
+ browser.show();
3712
+ String filename = browser.getFile();
3713
+ if (filename != null && filename.length() > 0)
3714
+ {
3715
+ String fullname = browser.getDirectory() + filename;
3716
+ LoadVRMLX3D(fullname);
3717
+ }
3718
+ /**/
3719
+ }
3720
+ }
3721
+
32423722 void ToggleAnimation()
32433723 {
32443724 if (!Globals.ANIMATION)
....@@ -3254,8 +3734,8 @@
32543734
32553735 Globals.ANIMATION ^= true;
32563736
3257
- GrafreeD.wav.cursor = 0;
3258
- GrafreeD.wav.loop = 0;
3737
+ Grafreed.wav.cursor = 0;
3738
+ Grafreed.wav.loop = 0;
32593739 }
32603740 } else
32613741 {
....@@ -3276,7 +3756,6 @@
32763756 callee.refreshContents();
32773757 } else
32783758 {
3279
- new Exception().printStackTrace();
32803759 System.exit(0);
32813760 }
32823761 }
....@@ -3357,7 +3836,7 @@
33573836 assert false;
33583837 }
33593838
3360
- void EditSelection()
3839
+ void EditSelection(boolean newWindow)
33613840 {
33623841 }
33633842
....@@ -3443,6 +3922,36 @@
34433922 {
34443923 //System.out.println("Propagate = " + propagate);
34453924 copy.UpdateMaterial(anchor, current, propagate);
3925
+
3926
+ if (copy.material != null)
3927
+ {
3928
+ cMaterial mat = copy.material;
3929
+
3930
+ colorField.SetToolTipValue((mat.color));
3931
+ modulationField.SetToolTipValue((mat.modulation));
3932
+ metalnessField.SetToolTipValue((mat.metalness));
3933
+ diffuseField.SetToolTipValue((mat.diffuse));
3934
+ specularField.SetToolTipValue((mat.specular));
3935
+ shininessField.SetToolTipValue((mat.shininess));
3936
+ shiftField.SetToolTipValue((mat.shift));
3937
+ ambientField.SetToolTipValue((mat.ambient));
3938
+ lightareaField.SetToolTipValue((mat.lightarea));
3939
+ diffusenessField.SetToolTipValue((mat.factor));
3940
+ velvetField.SetToolTipValue((mat.velvet));
3941
+ sheenField.SetToolTipValue((mat.sheen));
3942
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3943
+ backlitField.SetToolTipValue((mat.bump));
3944
+ anisoField.SetToolTipValue((mat.aniso));
3945
+ anisoVField.SetToolTipValue((mat.anisoV));
3946
+ cameraField.SetToolTipValue((mat.cameralight));
3947
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3948
+ shadowField.SetToolTipValue((mat.shadow));
3949
+ textureField.SetToolTipValue((mat.texture));
3950
+ opacityField.SetToolTipValue((mat.opacity));
3951
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3952
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3953
+ }
3954
+
34463955 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34473956 {
34483957 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3558,7 +4067,7 @@
35584067 }
35594068
35604069 if (normalpushField != null)
3561
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4070
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35624071 }
35634072
35644073 void SnapObject()
....@@ -3822,6 +4331,8 @@
38224331
38234332 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
38244333 {
4334
+ if (Globals.SAVEONMAKE) // && resetmodel)
4335
+ Save();
38254336 //Tween.set(thing, 0).target(1).start(tweenManager);
38264337 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
38274338 // if (thing instanceof GenericJointDemo)
....@@ -3908,6 +4419,12 @@
39084419 {
39094420 ResetModel();
39104421 Select(thing.GetTreePath(), true, false); // unselect... false);
4422
+
4423
+ if (thing.Size() == 0)
4424
+ {
4425
+ //EditSelection(false);
4426
+ }
4427
+
39114428 refreshContents();
39124429 }
39134430
....@@ -4025,6 +4542,7 @@
40254542 }
40264543 }
40274544 }
4545
+
40284546 LoadGFDThread loadGFDThread;
40294547
40304548 void ReadGFD(String fullname, iCallBack cb)
....@@ -4044,8 +4562,10 @@
40444562
40454563 try
40464564 {
4565
+ // Try compressed version first.
40474566 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4048
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4567
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4568
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40494569
40504570 readobj = (Object3D) p.readObject();
40514571 istream.close();
....@@ -4053,7 +4573,20 @@
40534573 readobj.ResetDisplayList();
40544574 } catch (Exception e)
40554575 {
4056
- e.printStackTrace();
4576
+ //e.printStackTrace();
4577
+ try
4578
+ {
4579
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4580
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4581
+
4582
+ readobj = (Object3D) p.readObject();
4583
+ istream.close();
4584
+
4585
+ readobj.ResetDisplayList();
4586
+ } catch (Exception e2)
4587
+ {
4588
+ e2.printStackTrace();
4589
+ }
40574590 }
40584591 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40594592 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4099,6 +4632,12 @@
40994632
41004633 void LoadIt(Object obj)
41014634 {
4635
+ if (obj == null)
4636
+ {
4637
+ // Invalid file
4638
+ return;
4639
+ }
4640
+
41024641 System.out.println("Loaded " + obj);
41034642 //new Exception().printStackTrace();
41044643 Object3D readobj = (Object3D) obj;
....@@ -4108,6 +4647,8 @@
41084647
41094648 if (readobj != null)
41104649 {
4650
+ if (Globals.SAVEONMAKE)
4651
+ Save();
41114652 try
41124653 {
41134654 //readobj.deepCopySelf(copy);
....@@ -4170,7 +4711,7 @@
41704711
41714712 void load() // throws ClassNotFoundException
41724713 {
4173
- if (GrafreeD.standAlone)
4714
+ if (Grafreed.standAlone)
41744715 {
41754716 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41764717 browser.show();
....@@ -4257,11 +4798,13 @@
42574798 try
42584799 {
42594800 FileOutputStream ostream = new FileOutputStream(lastname);
4260
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4801
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4802
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42614803
42624804 p.writeObject(copy);
42634805 p.flush();
42644806
4807
+ zstream.close();
42654808 ostream.close();
42664809
42674810 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4271,17 +4814,20 @@
42714814 {
42724815 }
42734816 }
4817
+
42744818 String lastname;
42754819
42764820 void saveAs()
42774821 {
4278
- if (GrafreeD.standAlone)
4822
+ if (Grafreed.standAlone)
42794823 {
42804824 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42814825 browser.setVisible(true);
42824826 String filename = browser.getFile();
42834827 if (filename != null && filename.length() > 0)
42844828 {
4829
+ if (!filename.endsWith(".gfd"))
4830
+ filename += ".gfd";
42854831 lastname = browser.getDirectory() + filename;
42864832 save();
42874833 }
....@@ -4380,13 +4926,13 @@
43804926 try
43814927 {
43824928 FileOutputStream ostream = new FileOutputStream(filename);
4383
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4384
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4929
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4930
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43854931
43864932 Object3D objectparent = obj.parent;
43874933 obj.parent = null;
43884934
4389
- Object3D object = (Object3D) GrafreeD.clone(obj);
4935
+ Object3D object = (Object3D) Grafreed.clone(obj);
43904936
43914937 obj.parent = objectparent;
43924938
....@@ -4398,8 +4944,8 @@
43984944 p.writeObject(object);
43994945 p.flush();
44004946
4947
+ zstream.close();
44014948 ostream.close();
4402
- // zstream.close();
44034949
44044950 // group.selection.get(0).parent = parent;
44054951 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4420,7 +4966,7 @@
44204966 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
44214967 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
44224968 copy.generatePOV(buffer);
4423
- if (GrafreeD.standAlone)
4969
+ if (Grafreed.standAlone)
44244970 {
44254971 FileDialog browser = new FileDialog(frame, "Export POV", 1);
44264972 browser.show();
....@@ -4446,7 +4992,8 @@
44464992 Object3D client;
44474993 Object3D copy;
44484994 MenuBar menuBar;
4449
- Menu windowMenu;
4995
+ Menu fileMenu;
4996
+ MenuItem newItem;
44504997 MenuItem loadItem;
44514998 MenuItem saveItem;
44524999 MenuItem saveAsItem;
....@@ -4454,11 +5001,9 @@
44545001 MenuItem reexportItem;
44555002 MenuItem povItem;
44565003 MenuItem closeItem;
4457
- Menu cameraMenu;
5004
+
44585005 CheckboxMenuItem zBufferItem;
44595006 //MenuItem normalLensItem;
4460
- MenuItem editCameraItem;
4461
- MenuItem revertCameraItem;
44625007 MenuItem stepItem;
44635008 CheckboxMenuItem toggleLiveItem;
44645009 CheckboxMenuItem toggleFullScreenItem;
....@@ -4476,18 +5021,31 @@
44765021 CheckboxMenuItem togglePaintItem;
44775022 JSplitPane mainPanel;
44785023 JScrollPane scrollpane;
5024
+
44795025 JPanel toolbarPanel;
5026
+
44805027 cGridBag treePanel;
5028
+
44815029 JPanel radioPanel;
44825030 ButtonGroup buttonGroup;
4483
- cGridBag ctrlPanel;
5031
+
5032
+ cGridBag toolboxPanel;
44845033 cGridBag materialPanel;
5034
+ cGridBag ctrlPanel;
5035
+
44855036 JScrollPane infoPanel;
5037
+
44865038 cGridBag optionsPanel;
5039
+
44875040 JTabbedPane objectPanel;
5041
+ boolean materialFlushed;
5042
+ Object3D latestObject;
5043
+
44885044 cGridBag XYZPanel;
5045
+
44895046 JSplitPane gridPanel;
44905047 JSplitPane bigPanel;
5048
+
44915049 cGridBag bigThree;
44925050 cGridBag scenePanel;
44935051 cGridBag centralPanel;
....@@ -4602,8 +5160,13 @@
46025160 cNumberSlider fogField;
46035161 JLabel opacityPowerLabel;
46045162 cNumberSlider opacityPowerField;
4605
- JTree jTree;
5163
+ cTree jTree;
46065164 //ObjectUI parent;
46075165
46085166 cNumberSlider normalpushField;
5167
+
5168
+ private MenuItem importGFDItem;
5169
+ private MenuItem importVRMLX3DItem;
5170
+ private MenuItem import3DSItem;
5171
+ private MenuItem importOBJItem;
46095172 }