Normand Briere
2019-07-01 6600d22461ccc1cb602f238a9ffa83cf07dd830e
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(false);
246313 objEditor = this;
247314 this.callee = callee;
248315
....@@ -273,28 +340,49 @@
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(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..."));
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
297
- loadItem.addActionListener(this);
384
+ newItem.addActionListener(this);
385
+ openItem.addActionListener(this);
298386 saveItem.addActionListener(this);
299387 saveAsItem.addActionListener(this);
300388 exportAsItem.addActionListener(this);
....@@ -302,87 +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
- cameraMenu.add(toggleSwitchItem = new CheckboxMenuItem("Switch"));
323
- toggleSwitchItem.addItemListener(this);
324
- toggleSwitchItem.setState(CameraPane.SWITCH);
325
-
326
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
327
- toggleHandleItem.addItemListener(this);
328
- toggleHandleItem.setState(CameraPane.HANDLES);
329
-
330
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
331
- togglePaintItem.addItemListener(this);
332
- togglePaintItem.setState(CameraPane.PAINTMODE);
333
-
334
- if (Globals.ADVANCED)
335
- {
336
- cameraMenu.add("-");
337
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
338
- toggleLiveItem.addItemListener(this);
339
- toggleLiveItem.setState(Globals.isLIVE());
340
-
341
- cameraMenu.add(stepItem = new MenuItem("Step"));
342
- stepItem.addActionListener(this);
343
- // cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
344
- // toggleDLItem.addItemListener(this);
345
- // toggleDLItem.setState(false);
346
-
347
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
348
- toggleRenderItem.addItemListener(this);
349
- toggleRenderItem.setState(!CameraPane.frozen);
350
-
351
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
352
- toggleDebugItem.addItemListener(this);
353
- toggleDebugItem.setState(CameraPane.DEBUG);
354
-
355
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
356
- toggleFrustumItem.addItemListener(this);
357
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
358
-
359
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
360
- toggleFootContactItem.addItemListener(this);
361
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
362
-
363
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
364
- toggleTimelineItem.addItemListener(this);
365
- }
366
-
367
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
368
-// toggleRootItem.addItemListener(this);
369
-// toggleRootItem.setState(false);
370
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
371
-// animationItem.addItemListener(this);
372
-// animationItem.setState(CameraPane.ANIMATION);
373
- cameraMenu.add("-");
374
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
375
- editCameraItem.addActionListener(this);
376
-
377393 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
+
378420 toolbarPanel = new JPanel();
379421 toolbarPanel.setName("Toolbar");
380422 treePanel = new cGridBag();
381423 treePanel.setName("Tree");
424
+
425
+ editPanel = new cGridBag().setVertical(true);
426
+ editPanel.setName("Edit");
427
+
382428 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
383
- 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
+
384437 materialPanel = new cGridBag().setVertical(true);
385438 materialPanel.setName("Material");
439
+
386440 /*JTextPane*/
387441 infoarea = createTextPane();
388442 doc = infoarea.getStyledDocument();
....@@ -395,7 +449,7 @@
395449 // TEXTAREA infoarea.setLineWrap(true);
396450 // TEXTAREA infoarea.setWrapStyleWord(true);
397451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
398
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ infoPanel.setPreferredSize(new Dimension(1, 1));
399453 infoPanel.setName("Info");
400454 //infoPanel.setLayout(new BorderLayout());
401455 //infoPanel.add(createTextPane());
....@@ -407,7 +461,14 @@
407461 mainPanel.setDividerSize(9);
408462 mainPanel.setDividerLocation(0.5); //1.0);
409463 mainPanel.setResizeWeight(0.5);
410
-
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
+
411472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
412473 //mainPanel.setLayout(new GridBagLayout());
413474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -475,10 +536,10 @@
475536 e.printStackTrace();
476537 }
477538
478
- String selection = infoarea.getText();
479
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
480
- java.awt.datatransfer.Clipboard clipboard =
481
- 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();
482543 //clipboard.setContents(data, data);
483544 }
484545
....@@ -501,13 +562,13 @@
501562 //SendInfo("Name:", "bold");
502563 if (sel.GetTextures() != null || debug)
503564 {
504
- si.SendInfo(sel.toString(), "bold");
565
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
505566 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
506567 if (sel.Size() > 0)
507568 {
508569 si.SendInfo("#children = " + sel.Size(), "regular");
509570 }
510
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
571
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
511572 if (debug)
512573 {
513574 try
....@@ -549,7 +610,7 @@
549610 }
550611 if (sel.support != null)
551612 {
552
- si.SendInfo(" support: " + sel.support, "regular");
613
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
553614 }
554615 if (sel.scriptnode != null)
555616 {
....@@ -638,20 +699,121 @@
638699 }
639700 }
640701
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
+
641760 void ToggleFullScreen()
642761 {
643
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
644767 {
645
- frame.getContentPane().remove(/*"Center",*/bigThree);
646
- framePanel.add(bigThree);
647
- 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
+
648791 } else
649792 {
650
- frame.getContentPane().remove(/*"Center",*/framePanel);
651
- framePanel.remove(bigThree);
652
- 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);
653815 }
654
- cameraView.ToggleFullScreen();
816
+ frame.validate();
655817 }
656818
657819 private JTextPane createTextPane()
....@@ -752,7 +914,7 @@
752914 protected static ImageIcon createImageIcon(String path,
753915 String description)
754916 {
755
- java.net.URL imgURL = GrafreeD.class.getResource(path);
917
+ java.net.URL imgURL = Grafreed.class.getResource(path);
756918 if (imgURL != null)
757919 {
758920 return new ImageIcon(imgURL, description);
....@@ -784,6 +946,7 @@
784946 // NumberSlider vDivsField;
785947 // JCheckBox endcaps;
786948 JCheckBox liveCB;
949
+ JCheckBox selectCB;
787950 JCheckBox hideCB;
788951 JCheckBox link2masterCB;
789952 JCheckBox markCB;
....@@ -791,7 +954,12 @@
791954 JCheckBox speedupCB;
792955 JCheckBox rewindCB;
793956 JCheckBox flipVCB;
957
+
958
+ cCheckBox toggleTextureCB;
959
+ cCheckBox toggleSwitchCB;
960
+
794961 JComboBox texresMenu;
962
+
795963 JButton resetButton;
796964 JButton stepButton;
797965 JButton stepAllButton;
....@@ -800,9 +968,13 @@
800968 JButton fasterButton;
801969 JButton remarkButton;
802970
971
+ cGridBag editPanel;
972
+ cGridBag editCommandsPanel;
973
+
803974 cGridBag namePanel;
804975 cGridBag setupPanel;
805
- cGridBag commandsPanel;
976
+ cGridBag setupPanel2;
977
+ cGridBag objectCommandsPanel;
806978 cGridBag pushPanel;
807979 cGridBag fillPanel;
808980
....@@ -974,61 +1146,67 @@
9741146 namePanel = new cGridBag();
9751147
9761148 nameField = AddText(namePanel, copy.GetName());
977
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9781150 oe.ctrlPanel.add(namePanel);
9791151
9801152 oe.ctrlPanel.Return();
9811153
982
- if (!GroupEditor.allparams)
1154
+ if (!allparams)
9831155 return;
9841156
9851157 setupPanel = new cGridBag().setVertical(false);
9861158
9871159 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
9881160 liveCB.setToolTipText("Animate object");
1161
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1162
+ selectCB.setToolTipText("Make object selectable");
1163
+// Return();
9891164 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9901165 hideCB.setToolTipText("Hide object");
991
-// Return();
9921166 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
993
- markCB.setToolTipText("Set the animation target transform");
1167
+ markCB.setToolTipText("As animation target transform");
9941168
995
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1169
+ setupPanel2 = new cGridBag().setVertical(false);
1170
+
1171
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9961172 rewindCB.setToolTipText("Rewind animation");
9971173
998
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
999
- randomCB.setToolTipText("Option for switch node");
1174
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1175
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
10001176
10011177 if (Globals.ADVANCED)
10021178 {
1003
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
1179
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
10041180 link2masterCB.setToolTipText("Attach to support");
1005
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1181
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10061182 speedupCB.setToolTipText("Option motion capture");
10071183 }
10081184
10091185 oe.ctrlPanel.add(setupPanel);
10101186 oe.ctrlPanel.Return();
1187
+ oe.ctrlPanel.add(setupPanel2);
1188
+ oe.ctrlPanel.Return();
10111189
1012
- commandsPanel = new cGridBag().setVertical(false);
1190
+ objectCommandsPanel = new cGridBag().setVertical(false);
10131191
1014
- resetButton = AddButton(commandsPanel, "Reset");
1192
+ resetButton = AddButton(objectCommandsPanel, "Reset");
10151193 resetButton.setToolTipText("Jump to frame zero");
1016
- stepButton = AddButton(commandsPanel, "Step");
1194
+ stepButton = AddButton(objectCommandsPanel, "Step");
10171195 stepButton.setToolTipText("Step one frame");
10181196 // resetAllButton = AddButton(oe, "Reset All");
10191197 // stepAllButton = AddButton(oe, "Step All");
10201198 // Return();
1021
- slowerButton = AddButton(commandsPanel, "Slow");
1199
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
10221200 slowerButton.setToolTipText("Decrease animation speed");
1023
- fasterButton = AddButton(commandsPanel, "Fast");
1201
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
10241202 fasterButton.setToolTipText("Increase animation speed");
1025
- remarkButton = AddButton(commandsPanel, "Remark");
1203
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
10261204 remarkButton.setToolTipText("Set the current transform as the target");
10271205
1028
- oe.ctrlPanel.add(commandsPanel);
1206
+ oe.ctrlPanel.add(objectCommandsPanel);
10291207 oe.ctrlPanel.Return();
10301208
1031
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1209
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
10321210 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
10331211 //Return();
10341212
....@@ -1231,8 +1409,11 @@
12311409 //worldPanel.setName("World");
12321410 centralPanel = new cGridBag();
12331411 centralPanel.preferredWidth = 20;
1234
- timelinePanel = new JPanel(new BorderLayout());
1235
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1412
+
1413
+ if (Globals.ADVANCED)
1414
+ {
1415
+ timelinePanel = new JPanel(new BorderLayout());
1416
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
12361417
12371418 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
12381419 cameraPanel.setContinuousLayout(true);
....@@ -1241,7 +1422,10 @@
12411422 // cameraPanel.setDividerSize(9);
12421423 cameraPanel.setResizeWeight(1.0);
12431424
1425
+ }
1426
+
12441427 centralPanel.add(cameraView);
1428
+ centralPanel.setFocusable(true);
12451429 //frame.setJMenuBar(timelineMenubar);
12461430 //centralPanel.add(timelinePanel);
12471431
....@@ -1308,8 +1492,12 @@
13081492 // north.setName("Edit");
13091493 // north.add(ctrlPanel, BorderLayout.NORTH);
13101494 // objectPanel.add(north);
1311
- objectPanel.add(ctrlPanel);
1312
- objectPanel.add(infoPanel);
1495
+ objectPanel.add(editPanel);
1496
+
1497
+ //if (Globals.ADVANCED)
1498
+ objectPanel.add(infoPanel);
1499
+
1500
+ objectPanel.add(toolboxPanel);
13131501
13141502 /*
13151503 aConstraints.gridx = 0;
....@@ -1318,7 +1506,7 @@
13181506 aConstraints.gridy += 1;
13191507 aConstraints.gridwidth = 1;
13201508 mainPanel.add(objectPanel, aConstraints);
1321
- */
1509
+ */
13221510
13231511 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
13241512 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1335,9 +1523,7 @@
13351523 JTabbedPane tabbedPane = new JTabbedPane();
13361524 tabbedPane.add(scrollpane);
13371525
1338
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1339
-
1340
- optionsPanel = new cGridBag().setVertical(true);
1526
+ optionsPanel = new cGridBag().setVertical(false);
13411527
13421528 optionsPanel.setName("Options");
13431529
....@@ -1345,6 +1531,8 @@
13451531
13461532 tabbedPane.add(optionsPanel);
13471533
1534
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1535
+
13481536 scenePanel.add(tabbedPane);
13491537
13501538 /*
....@@ -1417,9 +1605,9 @@
14171605 // aConstraints.gridheight = 1;
14181606
14191607 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1420
- framePanel.setContinuousLayout(true);
1421
- framePanel.setOneTouchExpandable(true);
1422
- framePanel.setDividerLocation(0.8);
1608
+ framePanel.setContinuousLayout(false);
1609
+ framePanel.setOneTouchExpandable(false);
1610
+ //.setDividerLocation(0.8);
14231611 //framePanel.setDividerSize(15);
14241612 //framePanel.setResizeWeight(0.15);
14251613 framePanel.setName("Frame");
....@@ -1437,9 +1625,14 @@
14371625 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14381626
14391627 frame.setSize(1280, 860);
1440
- frame.setVisible(true);
1441
-
1628
+
1629
+ cameraView.requestFocusInWindow();
1630
+
14421631 gridPanel.setDividerLocation(1.0);
1632
+
1633
+ frame.validate();
1634
+
1635
+ frame.setVisible(true);
14431636
14441637 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14451638 frame.addWindowListener(new WindowAdapter()
....@@ -1476,19 +1669,19 @@
14761669
14771670 cGridBag editBar = new cGridBag().setVertical(false);
14781671
1479
- editBar.add(createMaterialButton = new cButton("Create", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1672
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
14801673 createMaterialButton.setToolTipText("Create material");
14811674
14821675 /*
14831676 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14841677 */
14851678
1486
- editBar.add(clearMaterialButton = new cButton("Clear", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1679
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
14871680 clearMaterialButton.setToolTipText("Clear material");
14881681
14891682 if (Globals.ADVANCED)
14901683 {
1491
- editBar.add(resetSlidersButton = new cButton("Reset", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1684
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
14921685 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
14931686 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
14941687 }
....@@ -1525,24 +1718,6 @@
15251718 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15261719 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
15271720 colorSection.add(texture);
1528
-
1529
- cGridBag anisoU = new cGridBag();
1530
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1531
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1532
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1533
- colorSection.add(anisoU);
1534
-
1535
- cGridBag anisoV = new cGridBag();
1536
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1537
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1538
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1539
- colorSection.add(anisoV);
1540
-
1541
- cGridBag shadowbias = new cGridBag();
1542
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1543
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1544
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1545
- colorSection.add(shadowbias);
15461721
15471722 panel.add(new JSeparator());
15481723
....@@ -1594,6 +1769,12 @@
15941769 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15951770 diffuseSection.add(fakedepth);
15961771
1772
+ cGridBag shadowbias = new cGridBag();
1773
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1774
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1775
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1776
+ diffuseSection.add(shadowbias);
1777
+
15971778 panel.add(new JSeparator());
15981779
15991780 panel.add(diffuseSection);
....@@ -1644,6 +1825,18 @@
16441825 // aConstraints.gridy += 1;
16451826 // aConstraints.gridwidth = 1;
16461827
1828
+ cGridBag anisoU = new cGridBag();
1829
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1830
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1831
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1832
+ specularSection.add(anisoU);
1833
+
1834
+ cGridBag anisoV = new cGridBag();
1835
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1836
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1837
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
+ specularSection.add(anisoV);
1839
+
16471840
16481841 panel.add(new JSeparator());
16491842
....@@ -1651,35 +1844,35 @@
16511844
16521845 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16531846
1654
- cGridBag globalSection = new cGridBag().setVertical(true);
1847
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16551848
16561849 cGridBag camera = new cGridBag();
16571850 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16581851 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16591852 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1660
- globalSection.add(camera);
1853
+ colorSection.add(camera);
16611854
16621855 cGridBag ambient = new cGridBag();
16631856 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16641857 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16651858 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1666
- globalSection.add(ambient);
1859
+ colorSection.add(ambient);
16671860
16681861 cGridBag backlit = new cGridBag();
16691862 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16701863 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16711864 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1672
- globalSection.add(backlit);
1865
+ colorSection.add(backlit);
16731866
16741867 cGridBag opacity = new cGridBag();
16751868 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
16761869 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16771870 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1678
- globalSection.add(opacity);
1871
+ colorSection.add(opacity);
16791872
1680
- panel.add(new JSeparator());
1873
+ //panel.add(new JSeparator());
16811874
1682
- panel.add(globalSection);
1875
+ //panel.add(globalSection);
16831876
16841877 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16851878
....@@ -1988,6 +2181,7 @@
19882181 e2.printStackTrace();
19892182 }
19902183 }
2184
+
19912185 LoadJMEThread loadThread;
19922186
19932187 class LoadJMEThread extends Thread
....@@ -2045,6 +2239,7 @@
20452239 //LoadFile0(filename, converter);
20462240 }
20472241 }
2242
+
20482243 LoadOBJThread loadObjThread;
20492244
20502245 class LoadOBJThread extends Thread
....@@ -2123,19 +2318,19 @@
21232318
21242319 void LoadObjFile(String fullname)
21252320 {
2126
- /*
2321
+ System.out.println("Loading " + fullname);
2322
+ /**/
21272323 //lastFilename = fullname;
21282324 if(loadObjThread == null)
21292325 {
2130
- loadObjThread = new LoadOBJThread();
2131
- loadObjThread.start();
2326
+ loadObjThread = new LoadOBJThread();
2327
+ loadObjThread.start();
21322328 }
21332329
21342330 loadObjThread.add(fullname);
2135
- */
2331
+ /**/
21362332
2137
- System.out.println("Loading " + fullname);
2138
- makeSomething(new FileObject(fullname, true), true);
2333
+ //makeSomething(new FileObject(fullname, true), true);
21392334 }
21402335
21412336 void LoadGFDFile(String fullname)
....@@ -2396,7 +2591,7 @@
23962591
23972592 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23982593 {
2399
- if (GrafreeD.standAlone)
2594
+ if (Grafreed.standAlone)
24002595 {
24012596 /**/
24022597 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
....@@ -2752,6 +2947,8 @@
27522947
27532948 void SetMaterial(Object3D object)
27542949 {
2950
+ latestObject = object;
2951
+
27552952 cMaterial mat = object.material;
27562953
27572954 if (mat == null)
....@@ -2863,12 +3060,17 @@
28633060 // }
28643061
28653062 /**/
2866
- if (deselect)
3063
+ if (deselect || child == null)
28673064 {
28683065 //group.deselectAll();
28693066 //freeze = true;
28703067 GetTree().clearSelection();
28713068 //freeze = false;
3069
+
3070
+ if (child == null)
3071
+ {
3072
+ return;
3073
+ }
28723074 }
28733075
28743076 //group.addSelectee(child);
....@@ -2937,7 +3139,7 @@
29373139 cameraView.ToggleDL();
29383140 cameraView.repaint();
29393141 return;
2940
- } else if (event.getSource() == toggleTextureItem)
3142
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29413143 {
29423144 cameraView.ToggleTexture();
29433145 // june 2013 copy.HardTouch();
....@@ -2976,9 +3178,9 @@
29763178 frame.validate();
29773179
29783180 return;
2979
- } else if (event.getSource() == toggleSwitchItem)
3181
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29803182 {
2981
- cameraView.ToggleRandom();
3183
+ cameraView.ToggleSwitch();
29823184 cameraView.repaint();
29833185 return;
29843186 } else if (event.getSource() == toggleHandleItem)
....@@ -3006,6 +3208,10 @@
30063208 } else if (event.getSource() == liveCB)
30073209 {
30083210 copy.live ^= true;
3211
+ return;
3212
+ } else if (event.getSource() == selectCB)
3213
+ {
3214
+ copy.dontselect ^= true;
30093215 return;
30103216 } else if (event.getSource() == hideCB)
30113217 {
....@@ -3045,8 +3251,9 @@
30453251
30463252 public void actionPerformed(ActionEvent event)
30473253 {
3254
+ Object source = event.getSource();
30483255 // SCRIPT DIALOG
3049
- if (event.getSource() == okbutton)
3256
+ if (source == okbutton)
30503257 {
30513258 textpanel.setVisible(false);
30523259 textpanel.remove(textarea);
....@@ -3058,7 +3265,7 @@
30583265 textarea = null;
30593266 textpanel = null;
30603267 }
3061
- if (event.getSource() == cancelbutton)
3268
+ if (source == cancelbutton)
30623269 {
30633270 textpanel.setVisible(false);
30643271 textpanel.remove(textarea);
....@@ -3070,50 +3277,50 @@
30703277 //applySelf();
30713278 //client.refreshEditWindow();
30723279 //refreshContents();
3073
- if (event.getSource() == nameField)
3280
+ if (source == nameField)
30743281 {
30753282 //System.out.println("ObjEditor " + event);
30763283 applySelf0(true);
30773284 //parent.applySelf();
30783285 objEditor.refreshContents();
3079
- } else if (event.getSource() == resetButton)
3286
+ } else if (source == resetButton)
30803287 {
30813288 CameraPane.fullreset = true;
30823289 copy.Reset(); // ResetMeshes();
30833290 copy.Touch();
30843291 objEditor.refreshContents();
3085
- } else if (event.getSource() == stepItem)
3292
+ } else if (source == stepItem)
30863293 {
30873294 //cameraView.ONESTEP = true;
30883295 Globals.ONESTEP = true;
30893296 cameraView.repaint();
30903297 return;
3091
- } else if (event.getSource() == stepButton)
3298
+ } else if (source == stepButton)
30923299 {
30933300 copy.Step();
30943301 copy.Touch();
30953302 objEditor.refreshContents();
3096
- } else if (event.getSource() == slowerButton)
3303
+ } else if (source == slowerButton)
30973304 {
30983305 copy.Slower();
30993306 copy.Touch();
31003307 objEditor.refreshContents();
3101
- } else if (event.getSource() == fasterButton)
3308
+ } else if (source == fasterButton)
31023309 {
31033310 copy.Faster();
31043311 copy.Touch();
31053312 objEditor.refreshContents();
3106
- } else if (event.getSource() == remarkButton)
3313
+ } else if (source == remarkButton)
31073314 {
31083315 copy.Remark();
31093316 copy.Touch();
31103317 objEditor.refreshContents();
3111
- } else if (event.getSource() == stepAllButton)
3318
+ } else if (source == stepAllButton)
31123319 {
31133320 copy.StepAll();
31143321 copy.Touch();
31153322 objEditor.refreshContents();
3116
- } else if (event.getSource() == resetAllButton)
3323
+ } else if (source == resetAllButton)
31173324 {
31183325 //CameraPane.fullreset = true;
31193326 copy.ResetAll(); // ResetMeshes();
....@@ -3146,53 +3353,79 @@
31463353 // Close();
31473354 // }
31483355 // else
3149
- if (event.getSource() == resetSlidersButton)
3356
+ if (source == resetSlidersButton)
31503357 {
31513358 ResetSliders();
3152
- } else if (event.getSource() == clearMaterialButton)
3359
+ } else if (source == clearMaterialButton)
31533360 {
31543361 ClearMaterial();
3155
- } else if (event.getSource() == createMaterialButton)
3362
+ } else if (source == createMaterialButton)
31563363 {
31573364 CreateMaterial();
3158
- } else if (event.getSource() == clearPanelButton)
3365
+ } else if (source == clearPanelButton)
31593366 {
31603367 copy.ClearUI();
31613368 refreshContents(true);
3162
- } /*
3163
- }
3164
-
3165
- public boolean action(Event event, Object arg)
3166
- {
3167
- */ else if (event.getSource() == closeItem)
3369
+ } else if (source == importGFDItem)
3370
+ {
3371
+ ImportGFD();
3372
+ } else
3373
+ if (source == importVRMLX3DItem)
3374
+ {
3375
+ ImportVRMLX3D();
3376
+ } else
3377
+ if (source == import3DSItem)
3378
+ {
3379
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3380
+ } else
3381
+ if (source == importOBJItem)
3382
+ {
3383
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3384
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3385
+ browser.setVisible(true);
3386
+ String filename = browser.getFile();
3387
+ if (filename != null && filename.length() > 0)
3388
+ {
3389
+ String fullname = browser.getDirectory() + filename;
3390
+ makeSomething(ReadOBJ(fullname), true);
3391
+ }
3392
+ } else
3393
+ if (source == closeItem)
31683394 {
31693395 Close();
31703396 //return true;
3171
- } else if (event.getSource() == loadItem)
3397
+ } else if (source == openItem)
31723398 {
3173
- load();
3399
+ Open();
31743400 //return true;
3175
- } else if (event.getSource() == saveItem)
3401
+ } else if (source == newItem)
3402
+ {
3403
+ New();
3404
+ } else if (source == saveItem)
31763405 {
31773406 save();
31783407 //return true;
3179
- } else if (event.getSource() == saveAsItem)
3408
+ } else if (source == saveAsItem)
31803409 {
31813410 saveAs();
31823411 //return true;
3183
- } else if (event.getSource() == reexportItem)
3412
+ } else if (source == reexportItem)
31843413 {
31853414 reexport();
31863415 //return true;
3187
- } else if (event.getSource() == exportAsItem)
3416
+ } else if (source == exportAsItem)
31883417 {
31893418 export();
31903419 //return true;
3191
- } else if (event.getSource() == povItem)
3420
+ } else if (source == povItem)
31923421 {
31933422 generatePOV();
31943423 //return true;
3195
- } else if (event.getSource() == zBufferItem)
3424
+ } else if (event.getSource() == archiveItem)
3425
+ {
3426
+ cTools.Archive(frame);
3427
+ return;
3428
+ } else if (source == zBufferItem)
31963429 {
31973430 try
31983431 {
....@@ -3214,21 +3447,8 @@
32143447 cameraView.repaint();
32153448 //return true;
32163449 }
3217
- */ else if (event.getSource() == editCameraItem)
3218
- {
3219
- cameraView.ProtectCamera();
3220
- cameraView.repaint();
3221
- return;
3222
- } else if (event.getSource() == revertCameraItem)
3223
- {
3224
- cameraView.RevertCamera();
3225
- cameraView.repaint();
3226
- return;
3227
-// } else if (event.getSource() == textureButton)
3228
-// {
3229
-// return; // true;
3230
- } else // combos...
3231
- if (event.getSource() == texresMenu)
3450
+ */ else // combos...
3451
+ if (source == texresMenu)
32323452 {
32333453 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
32343454 copy.texres = texresMenu.getSelectedIndex();
....@@ -3240,6 +3460,283 @@
32403460 }
32413461 }
32423462
3463
+ void New()
3464
+ {
3465
+ while (copy.Size() > 1)
3466
+ {
3467
+ copy.remove(1);
3468
+ }
3469
+
3470
+ ResetModel();
3471
+ objEditor.refreshContents();
3472
+ }
3473
+
3474
+ static public byte[] Compress(Object3D o)
3475
+ {
3476
+ try
3477
+ {
3478
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3479
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3480
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3481
+
3482
+ Object3D parent = o.parent;
3483
+ o.parent = null;
3484
+
3485
+ out.writeObject(o);
3486
+
3487
+ o.parent = parent;
3488
+
3489
+ out.flush();
3490
+
3491
+ zstream.close();
3492
+ out.close();
3493
+
3494
+ return baos.toByteArray();
3495
+ } catch (Exception e)
3496
+ {
3497
+ System.err.println(e);
3498
+ return null;
3499
+ }
3500
+ }
3501
+
3502
+ static public Object Uncompress(byte[] bytes)
3503
+ {
3504
+ System.out.println("#bytes = " + bytes.length);
3505
+ try
3506
+ {
3507
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3508
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3509
+ ObjectInputStream in = new ObjectInputStream(istream);
3510
+ Object obj = in.readObject();
3511
+ in.close();
3512
+
3513
+ return obj;
3514
+ } catch (Exception e)
3515
+ {
3516
+ System.err.println(e);
3517
+ return null;
3518
+ }
3519
+ }
3520
+
3521
+ static public Object clone(Object o)
3522
+ {
3523
+ try
3524
+ {
3525
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3526
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3527
+
3528
+ out.writeObject(o);
3529
+
3530
+ out.flush();
3531
+ out.close();
3532
+
3533
+ byte[] bytes = baos.toByteArray();
3534
+
3535
+ System.out.println("clone = " + bytes.length);
3536
+
3537
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3538
+ ObjectInputStream in = new ObjectInputStream(bais);
3539
+ Object obj = in.readObject();
3540
+ in.close();
3541
+
3542
+ return obj;
3543
+ } catch (Exception e)
3544
+ {
3545
+ System.err.println(e);
3546
+ return null;
3547
+ }
3548
+ }
3549
+
3550
+ cRadio GetCurrentTab()
3551
+ {
3552
+ cRadio ab;
3553
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3554
+ {
3555
+ ab = (cRadio)e.nextElement();
3556
+ if(ab.GetObject() == copy)
3557
+ {
3558
+ return ab;
3559
+ }
3560
+ }
3561
+
3562
+ return null;
3563
+ }
3564
+
3565
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3566
+
3567
+ public void Save()
3568
+ {
3569
+ System.err.println("Save");
3570
+
3571
+ cRadio tab = GetCurrentTab();
3572
+
3573
+ boolean temp = CameraPane.SWITCH;
3574
+ CameraPane.SWITCH = false;
3575
+
3576
+ copy.ExtractBigData(hashtable);
3577
+
3578
+ byte[] compress = Compress(copy);
3579
+
3580
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3581
+ tab.graphs[tab.undoindex++] = compress;
3582
+
3583
+ copy.RestoreBigData(hashtable);
3584
+
3585
+ CameraPane.SWITCH = temp;
3586
+
3587
+ //assert(hashtable.isEmpty());
3588
+
3589
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3590
+ {
3591
+ tab.graphs[i] = null;
3592
+ }
3593
+
3594
+ SetUndoStates();
3595
+
3596
+ // test save
3597
+ if (false)
3598
+ {
3599
+ try
3600
+ {
3601
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3602
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3603
+
3604
+ p.writeObject(copy);
3605
+
3606
+ p.flush();
3607
+
3608
+ ostream.close();
3609
+ } catch (Exception e)
3610
+ {
3611
+ e.printStackTrace();
3612
+ }
3613
+ }
3614
+ }
3615
+
3616
+ void CopyChanged(Object3D obj)
3617
+ {
3618
+ SetUndoStates();
3619
+
3620
+ boolean temp = CameraPane.SWITCH;
3621
+ CameraPane.SWITCH = false;
3622
+
3623
+ copy.ExtractBigData(hashtable);
3624
+
3625
+ copy.clear();
3626
+
3627
+ for (int i=0; i<obj.Size(); i++)
3628
+ {
3629
+ copy.add(obj.get(i));
3630
+ }
3631
+
3632
+ copy.RestoreBigData(hashtable);
3633
+
3634
+ CameraPane.SWITCH = temp;
3635
+
3636
+ //assert(hashtable.isEmpty());
3637
+
3638
+ copy.Touch();
3639
+
3640
+ ResetModel();
3641
+ copy.HardTouch(); // recompile?
3642
+
3643
+ cRadio ab;
3644
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3645
+ {
3646
+ ab = (cRadio)e.nextElement();
3647
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3648
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3649
+ if (test != null)
3650
+ {
3651
+ test.editWindow = ab.object.editWindow;
3652
+ ab.object = test;
3653
+ }
3654
+ }
3655
+
3656
+ refreshContents();
3657
+ }
3658
+
3659
+ cButton undoButton;
3660
+ cButton redoButton;
3661
+
3662
+ void SetUndoStates()
3663
+ {
3664
+ cRadio tab = GetCurrentTab();
3665
+
3666
+ undoButton.setEnabled(tab.undoindex > 0);
3667
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3668
+ }
3669
+
3670
+ public void Undo()
3671
+ {
3672
+ System.err.println("Undo");
3673
+
3674
+ cRadio tab = GetCurrentTab();
3675
+
3676
+ if (tab.undoindex == 0)
3677
+ {
3678
+ java.awt.Toolkit.getDefaultToolkit().beep();
3679
+ return;
3680
+ }
3681
+
3682
+ if (tab.graphs[tab.undoindex] == null)
3683
+ {
3684
+ Save();
3685
+ tab.undoindex -= 1;
3686
+ }
3687
+
3688
+ tab.undoindex -= 1;
3689
+
3690
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3691
+ }
3692
+
3693
+ public void Redo()
3694
+ {
3695
+ cRadio tab = GetCurrentTab();
3696
+
3697
+ if (tab.graphs[tab.undoindex + 1] == null)
3698
+ {
3699
+ java.awt.Toolkit.getDefaultToolkit().beep();
3700
+ return;
3701
+ }
3702
+
3703
+ tab.undoindex += 1;
3704
+
3705
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3706
+ }
3707
+
3708
+ void ImportGFD()
3709
+ {
3710
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", 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
+
3717
+ //Object3D readobj =
3718
+ objEditor.ReadGFD(fullname, objEditor);
3719
+ //makeSomething(readobj);
3720
+ }
3721
+ }
3722
+
3723
+ void ImportVRMLX3D()
3724
+ {
3725
+ if (Grafreed.standAlone)
3726
+ {
3727
+ /**/
3728
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3729
+ browser.show();
3730
+ String filename = browser.getFile();
3731
+ if (filename != null && filename.length() > 0)
3732
+ {
3733
+ String fullname = browser.getDirectory() + filename;
3734
+ LoadVRMLX3D(fullname);
3735
+ }
3736
+ /**/
3737
+ }
3738
+ }
3739
+
32433740 void ToggleAnimation()
32443741 {
32453742 if (!Globals.ANIMATION)
....@@ -3255,8 +3752,8 @@
32553752
32563753 Globals.ANIMATION ^= true;
32573754
3258
- GrafreeD.wav.cursor = 0;
3259
- GrafreeD.wav.loop = 0;
3755
+ Grafreed.wav.cursor = 0;
3756
+ Grafreed.wav.loop = 0;
32603757 }
32613758 } else
32623759 {
....@@ -3357,7 +3854,7 @@
33573854 assert false;
33583855 }
33593856
3360
- void EditSelection()
3857
+ void EditSelection(boolean newWindow)
33613858 {
33623859 }
33633860
....@@ -3443,6 +3940,36 @@
34433940 {
34443941 //System.out.println("Propagate = " + propagate);
34453942 copy.UpdateMaterial(anchor, current, propagate);
3943
+
3944
+ if (copy.material != null)
3945
+ {
3946
+ cMaterial mat = copy.material;
3947
+
3948
+ colorField.SetToolTipValue((mat.color));
3949
+ modulationField.SetToolTipValue((mat.modulation));
3950
+ metalnessField.SetToolTipValue((mat.metalness));
3951
+ diffuseField.SetToolTipValue((mat.diffuse));
3952
+ specularField.SetToolTipValue((mat.specular));
3953
+ shininessField.SetToolTipValue((mat.shininess));
3954
+ shiftField.SetToolTipValue((mat.shift));
3955
+ ambientField.SetToolTipValue((mat.ambient));
3956
+ lightareaField.SetToolTipValue((mat.lightarea));
3957
+ diffusenessField.SetToolTipValue((mat.factor));
3958
+ velvetField.SetToolTipValue((mat.velvet));
3959
+ sheenField.SetToolTipValue((mat.sheen));
3960
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3961
+ backlitField.SetToolTipValue((mat.bump));
3962
+ anisoField.SetToolTipValue((mat.aniso));
3963
+ anisoVField.SetToolTipValue((mat.anisoV));
3964
+ cameraField.SetToolTipValue((mat.cameralight));
3965
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3966
+ shadowField.SetToolTipValue((mat.shadow));
3967
+ textureField.SetToolTipValue((mat.texture));
3968
+ opacityField.SetToolTipValue((mat.opacity));
3969
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3970
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3971
+ }
3972
+
34463973 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34473974 {
34483975 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3558,7 +4085,7 @@
35584085 }
35594086
35604087 if (normalpushField != null)
3561
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4088
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35624089 }
35634090
35644091 void SnapObject()
....@@ -3822,6 +4349,8 @@
38224349
38234350 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
38244351 {
4352
+ if (Globals.SAVEONMAKE) // && resetmodel)
4353
+ Save();
38254354 //Tween.set(thing, 0).target(1).start(tweenManager);
38264355 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
38274356 // if (thing instanceof GenericJointDemo)
....@@ -3908,6 +4437,12 @@
39084437 {
39094438 ResetModel();
39104439 Select(thing.GetTreePath(), true, false); // unselect... false);
4440
+
4441
+ if (thing.Size() == 0)
4442
+ {
4443
+ //EditSelection(false);
4444
+ }
4445
+
39114446 refreshContents();
39124447 }
39134448
....@@ -4025,6 +4560,7 @@
40254560 }
40264561 }
40274562 }
4563
+
40284564 LoadGFDThread loadGFDThread;
40294565
40304566 void ReadGFD(String fullname, iCallBack cb)
....@@ -4044,8 +4580,10 @@
40444580
40454581 try
40464582 {
4583
+ // Try compressed version first.
40474584 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4048
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4585
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4586
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40494587
40504588 readobj = (Object3D) p.readObject();
40514589 istream.close();
....@@ -4053,7 +4591,20 @@
40534591 readobj.ResetDisplayList();
40544592 } catch (Exception e)
40554593 {
4056
- e.printStackTrace();
4594
+ //e.printStackTrace();
4595
+ try
4596
+ {
4597
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4598
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4599
+
4600
+ readobj = (Object3D) p.readObject();
4601
+ istream.close();
4602
+
4603
+ readobj.ResetDisplayList();
4604
+ } catch (Exception e2)
4605
+ {
4606
+ e2.printStackTrace();
4607
+ }
40574608 }
40584609 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40594610 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4099,6 +4650,12 @@
40994650
41004651 void LoadIt(Object obj)
41014652 {
4653
+ if (obj == null)
4654
+ {
4655
+ // Invalid file
4656
+ return;
4657
+ }
4658
+
41024659 System.out.println("Loaded " + obj);
41034660 //new Exception().printStackTrace();
41044661 Object3D readobj = (Object3D) obj;
....@@ -4108,6 +4665,8 @@
41084665
41094666 if (readobj != null)
41104667 {
4668
+ if (Globals.SAVEONMAKE)
4669
+ Save();
41114670 try
41124671 {
41134672 //readobj.deepCopySelf(copy);
....@@ -4168,9 +4727,9 @@
41684727 }
41694728 }
41704729
4171
- void load() // throws ClassNotFoundException
4730
+ void Open() // throws ClassNotFoundException
41724731 {
4173
- if (GrafreeD.standAlone)
4732
+ if (Grafreed.standAlone)
41744733 {
41754734 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41764735 browser.show();
....@@ -4257,11 +4816,13 @@
42574816 try
42584817 {
42594818 FileOutputStream ostream = new FileOutputStream(lastname);
4260
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4819
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4820
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42614821
42624822 p.writeObject(copy);
42634823 p.flush();
42644824
4825
+ zstream.close();
42654826 ostream.close();
42664827
42674828 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4271,17 +4832,20 @@
42714832 {
42724833 }
42734834 }
4835
+
42744836 String lastname;
42754837
42764838 void saveAs()
42774839 {
4278
- if (GrafreeD.standAlone)
4840
+ if (Grafreed.standAlone)
42794841 {
42804842 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42814843 browser.setVisible(true);
42824844 String filename = browser.getFile();
42834845 if (filename != null && filename.length() > 0)
42844846 {
4847
+ if (!filename.endsWith(".gfd"))
4848
+ filename += ".gfd";
42854849 lastname = browser.getDirectory() + filename;
42864850 save();
42874851 }
....@@ -4380,13 +4944,13 @@
43804944 try
43814945 {
43824946 FileOutputStream ostream = new FileOutputStream(filename);
4383
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4384
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4947
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4948
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43854949
43864950 Object3D objectparent = obj.parent;
43874951 obj.parent = null;
43884952
4389
- Object3D object = (Object3D) GrafreeD.clone(obj);
4953
+ Object3D object = (Object3D) Grafreed.clone(obj);
43904954
43914955 obj.parent = objectparent;
43924956
....@@ -4398,8 +4962,8 @@
43984962 p.writeObject(object);
43994963 p.flush();
44004964
4965
+ zstream.close();
44014966 ostream.close();
4402
- // zstream.close();
44034967
44044968 // group.selection.get(0).parent = parent;
44054969 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4420,7 +4984,7 @@
44204984 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
44214985 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
44224986 copy.generatePOV(buffer);
4423
- if (GrafreeD.standAlone)
4987
+ if (Grafreed.standAlone)
44244988 {
44254989 FileDialog browser = new FileDialog(frame, "Export POV", 1);
44264990 browser.show();
....@@ -4446,19 +5010,18 @@
44465010 Object3D client;
44475011 Object3D copy;
44485012 MenuBar menuBar;
4449
- Menu windowMenu;
4450
- MenuItem loadItem;
5013
+ Menu fileMenu;
5014
+ MenuItem newItem;
5015
+ MenuItem openItem;
44515016 MenuItem saveItem;
44525017 MenuItem saveAsItem;
44535018 MenuItem exportAsItem;
44545019 MenuItem reexportItem;
44555020 MenuItem povItem;
44565021 MenuItem closeItem;
4457
- Menu cameraMenu;
5022
+
44585023 CheckboxMenuItem zBufferItem;
44595024 //MenuItem normalLensItem;
4460
- MenuItem editCameraItem;
4461
- MenuItem revertCameraItem;
44625025 MenuItem stepItem;
44635026 CheckboxMenuItem toggleLiveItem;
44645027 CheckboxMenuItem toggleFullScreenItem;
....@@ -4472,22 +5035,36 @@
44725035 CheckboxMenuItem toggleSwitchItem;
44735036 CheckboxMenuItem toggleRootItem;
44745037 CheckboxMenuItem animationItem;
5038
+ MenuItem archiveItem;
44755039 CheckboxMenuItem toggleHandleItem;
44765040 CheckboxMenuItem togglePaintItem;
44775041 JSplitPane mainPanel;
44785042 JScrollPane scrollpane;
5043
+
44795044 JPanel toolbarPanel;
5045
+
44805046 cGridBag treePanel;
5047
+
44815048 JPanel radioPanel;
44825049 ButtonGroup buttonGroup;
4483
- cGridBag ctrlPanel;
5050
+
5051
+ cGridBag toolboxPanel;
44845052 cGridBag materialPanel;
5053
+ cGridBag ctrlPanel;
5054
+
44855055 JScrollPane infoPanel;
5056
+
44865057 cGridBag optionsPanel;
5058
+
44875059 JTabbedPane objectPanel;
5060
+ boolean materialFlushed;
5061
+ Object3D latestObject;
5062
+
44885063 cGridBag XYZPanel;
5064
+
44895065 JSplitPane gridPanel;
44905066 JSplitPane bigPanel;
5067
+
44915068 cGridBag bigThree;
44925069 cGridBag scenePanel;
44935070 cGridBag centralPanel;
....@@ -4602,8 +5179,13 @@
46025179 cNumberSlider fogField;
46035180 JLabel opacityPowerLabel;
46045181 cNumberSlider opacityPowerField;
4605
- JTree jTree;
5182
+ cTree jTree;
46065183 //ObjectUI parent;
46075184
46085185 cNumberSlider normalpushField;
5186
+
5187
+ private MenuItem importGFDItem;
5188
+ private MenuItem importVRMLX3DItem;
5189
+ private MenuItem import3DSItem;
5190
+ private MenuItem importOBJItem;
46095191 }