Normand Briere
2019-06-30 cfd7a643cb5a445016ddb15595158ecc59b184fd
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,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,70 +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
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
313
- toggleTimelineItem.addItemListener(this);
314
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
315
- toggleFullScreenItem.addItemListener(this);
316
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
317
- cameraMenu.add("-");
318
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
319
- toggleTextureItem.addItemListener(this);
320
- toggleTextureItem.setState(CameraPane.textureon);
321
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
322
- toggleLiveItem.addItemListener(this);
323
- toggleLiveItem.setState(Globals.isLIVE());
324
- cameraMenu.add(stepItem = new MenuItem("Step"));
325
- stepItem.addActionListener(this);
326
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
327
-// toggleDLItem.addItemListener(this);
328
-// toggleDLItem.setState(false);
329
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
330
- toggleRenderItem.addItemListener(this);
331
- toggleRenderItem.setState(!CameraPane.frozen);
332
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
333
- toggleDebugItem.addItemListener(this);
334
- toggleDebugItem.setState(CameraPane.DEBUG);
335
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
336
- toggleFrustumItem.addItemListener(this);
337
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
338
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
339
- toggleFootContactItem.addItemListener(this);
340
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
341
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
342
- toggleRandomItem.addItemListener(this);
343
- toggleRandomItem.setState(CameraPane.RANDOM);
344
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
345
- toggleHandleItem.addItemListener(this);
346
- toggleHandleItem.setState(CameraPane.HANDLES);
347
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
348
- togglePaintItem.addItemListener(this);
349
- togglePaintItem.setState(CameraPane.PAINTMODE);
350
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
351
-// toggleRootItem.addItemListener(this);
352
-// toggleRootItem.setState(false);
353
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
354
-// animationItem.addItemListener(this);
355
-// animationItem.setState(CameraPane.ANIMATION);
356
- cameraMenu.add("-");
357
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
358
- editCameraItem.addActionListener(this);
359
-
360393 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
+
361420 toolbarPanel = new JPanel();
362421 toolbarPanel.setName("Toolbar");
363422 treePanel = new cGridBag();
364423 treePanel.setName("Tree");
424
+
425
+ editPanel = new cGridBag().setVertical(true);
426
+ editPanel.setName("Edit");
427
+
365428 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
366
- 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
+
367437 materialPanel = new cGridBag().setVertical(true);
368438 materialPanel.setName("Material");
439
+
369440 /*JTextPane*/
370441 infoarea = createTextPane();
371442 doc = infoarea.getStyledDocument();
....@@ -378,7 +449,7 @@
378449 // TEXTAREA infoarea.setLineWrap(true);
379450 // TEXTAREA infoarea.setWrapStyleWord(true);
380451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
381
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ //infoPanel.setPreferredSize(new Dimension(50, 200));
382453 infoPanel.setName("Info");
383454 //infoPanel.setLayout(new BorderLayout());
384455 //infoPanel.add(createTextPane());
....@@ -390,7 +461,14 @@
390461 mainPanel.setDividerSize(9);
391462 mainPanel.setDividerLocation(0.5); //1.0);
392463 mainPanel.setResizeWeight(0.5);
393
-
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
+
394472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
395473 //mainPanel.setLayout(new GridBagLayout());
396474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -458,10 +536,10 @@
458536 e.printStackTrace();
459537 }
460538
461
- String selection = infoarea.getText();
462
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
463
- java.awt.datatransfer.Clipboard clipboard =
464
- 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();
465543 //clipboard.setContents(data, data);
466544 }
467545
....@@ -484,13 +562,13 @@
484562 //SendInfo("Name:", "bold");
485563 if (sel.GetTextures() != null || debug)
486564 {
487
- si.SendInfo(sel.toString(), "bold");
565
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
488566 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
489567 if (sel.Size() > 0)
490568 {
491569 si.SendInfo("#children = " + sel.Size(), "regular");
492570 }
493
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
571
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
494572 if (debug)
495573 {
496574 try
....@@ -532,7 +610,7 @@
532610 }
533611 if (sel.support != null)
534612 {
535
- si.SendInfo(" support: " + sel.support, "regular");
613
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
536614 }
537615 if (sel.scriptnode != null)
538616 {
....@@ -621,20 +699,121 @@
621699 }
622700 }
623701
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
+
624760 void ToggleFullScreen()
625761 {
626
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
627767 {
628
- frame.getContentPane().remove(/*"Center",*/bigThree);
629
- framePanel.add(bigThree);
630
- 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(1);
784
+
785
+ //frame.setVisible(true);
786
+ radio.layout = keepButton;
787
+ //theFrame = null;
788
+ keepButton = null;
789
+ radio.layout.doClick();
790
+
631791 } else
632792 {
633
- frame.getContentPane().remove(/*"Center",*/framePanel);
634
- framePanel.remove(bigThree);
635
- 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);
636815 }
637
- cameraView.ToggleFullScreen();
816
+ frame.validate();
638817 }
639818
640819 private JTextPane createTextPane()
....@@ -735,7 +914,7 @@
735914 protected static ImageIcon createImageIcon(String path,
736915 String description)
737916 {
738
- java.net.URL imgURL = GrafreeD.class.getResource(path);
917
+ java.net.URL imgURL = Grafreed.class.getResource(path);
739918 if (imgURL != null)
740919 {
741920 return new ImageIcon(imgURL, description);
....@@ -767,6 +946,7 @@
767946 // NumberSlider vDivsField;
768947 // JCheckBox endcaps;
769948 JCheckBox liveCB;
949
+ JCheckBox selectCB;
770950 JCheckBox hideCB;
771951 JCheckBox link2masterCB;
772952 JCheckBox markCB;
....@@ -774,7 +954,12 @@
774954 JCheckBox speedupCB;
775955 JCheckBox rewindCB;
776956 JCheckBox flipVCB;
957
+
958
+ cCheckBox toggleTextureCB;
959
+ cCheckBox toggleSwitchCB;
960
+
777961 JComboBox texresMenu;
962
+
778963 JButton resetButton;
779964 JButton stepButton;
780965 JButton stepAllButton;
....@@ -783,9 +968,13 @@
783968 JButton fasterButton;
784969 JButton remarkButton;
785970
971
+ cGridBag editPanel;
972
+ cGridBag editCommandsPanel;
973
+
786974 cGridBag namePanel;
787975 cGridBag setupPanel;
788
- cGridBag commandsPanel;
976
+ cGridBag setupPanel2;
977
+ cGridBag objectCommandsPanel;
789978 cGridBag pushPanel;
790979 cGridBag fillPanel;
791980
....@@ -957,61 +1146,67 @@
9571146 namePanel = new cGridBag();
9581147
9591148 nameField = AddText(namePanel, copy.GetName());
960
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9611150 oe.ctrlPanel.add(namePanel);
9621151
9631152 oe.ctrlPanel.Return();
9641153
965
- if (!GroupEditor.allparams)
1154
+ if (!allparams)
9661155 return;
9671156
9681157 setupPanel = new cGridBag().setVertical(false);
9691158
9701159 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
9711160 liveCB.setToolTipText("Animate object");
1161
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1162
+ selectCB.setToolTipText("Make object selectable");
1163
+// Return();
9721164 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9731165 hideCB.setToolTipText("Hide object");
974
-// Return();
9751166 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
976
- markCB.setToolTipText("Set the animation target transform");
1167
+ markCB.setToolTipText("As animation target transform");
9771168
978
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1169
+ setupPanel2 = new cGridBag().setVertical(false);
1170
+
1171
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9791172 rewindCB.setToolTipText("Rewind animation");
9801173
981
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
982
- randomCB.setToolTipText("Option for switch node");
1174
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1175
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9831176
9841177 if (Globals.ADVANCED)
9851178 {
986
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
1179
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
9871180 link2masterCB.setToolTipText("Attach to support");
988
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1181
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9891182 speedupCB.setToolTipText("Option motion capture");
9901183 }
9911184
9921185 oe.ctrlPanel.add(setupPanel);
9931186 oe.ctrlPanel.Return();
1187
+ oe.ctrlPanel.add(setupPanel2);
1188
+ oe.ctrlPanel.Return();
9941189
995
- commandsPanel = new cGridBag().setVertical(false);
1190
+ objectCommandsPanel = new cGridBag().setVertical(false);
9961191
997
- resetButton = AddButton(commandsPanel, "Reset");
1192
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9981193 resetButton.setToolTipText("Jump to frame zero");
999
- stepButton = AddButton(commandsPanel, "Step");
1194
+ stepButton = AddButton(objectCommandsPanel, "Step");
10001195 stepButton.setToolTipText("Step one frame");
10011196 // resetAllButton = AddButton(oe, "Reset All");
10021197 // stepAllButton = AddButton(oe, "Step All");
10031198 // Return();
1004
- slowerButton = AddButton(commandsPanel, "Slow");
1199
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
10051200 slowerButton.setToolTipText("Decrease animation speed");
1006
- fasterButton = AddButton(commandsPanel, "Fast");
1201
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
10071202 fasterButton.setToolTipText("Increase animation speed");
1008
- remarkButton = AddButton(commandsPanel, "Remark");
1203
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
10091204 remarkButton.setToolTipText("Set the current transform as the target");
10101205
1011
- oe.ctrlPanel.add(commandsPanel);
1206
+ oe.ctrlPanel.add(objectCommandsPanel);
10121207 oe.ctrlPanel.Return();
10131208
1014
- 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
10151210 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
10161211 //Return();
10171212
....@@ -1214,8 +1409,11 @@
12141409 //worldPanel.setName("World");
12151410 centralPanel = new cGridBag();
12161411 centralPanel.preferredWidth = 20;
1217
- timelinePanel = new JPanel(new BorderLayout());
1218
- 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);
12191417
12201418 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
12211419 cameraPanel.setContinuousLayout(true);
....@@ -1224,7 +1422,10 @@
12241422 // cameraPanel.setDividerSize(9);
12251423 cameraPanel.setResizeWeight(1.0);
12261424
1425
+ }
1426
+
12271427 centralPanel.add(cameraView);
1428
+ centralPanel.setFocusable(true);
12281429 //frame.setJMenuBar(timelineMenubar);
12291430 //centralPanel.add(timelinePanel);
12301431
....@@ -1291,8 +1492,9 @@
12911492 // north.setName("Edit");
12921493 // north.add(ctrlPanel, BorderLayout.NORTH);
12931494 // objectPanel.add(north);
1294
- objectPanel.add(ctrlPanel);
1495
+ objectPanel.add(editPanel);
12951496 objectPanel.add(infoPanel);
1497
+ objectPanel.add(toolboxPanel);
12961498
12971499 /*
12981500 aConstraints.gridx = 0;
....@@ -1301,7 +1503,7 @@
13011503 aConstraints.gridy += 1;
13021504 aConstraints.gridwidth = 1;
13031505 mainPanel.add(objectPanel, aConstraints);
1304
- */
1506
+ */
13051507
13061508 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
13071509 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1313,14 +1515,12 @@
13131515 scrollpane.addMouseWheelListener(this); // Default not fast enough
13141516
13151517 /*JTabbedPane*/ scenePanel = new cGridBag();
1316
- scenePanel.preferredWidth = 7;
1518
+ scenePanel.preferredWidth = 6;
13171519
13181520 JTabbedPane tabbedPane = new JTabbedPane();
13191521 tabbedPane.add(scrollpane);
13201522
1321
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1322
-
1323
- optionsPanel = new cGridBag().setVertical(true);
1523
+ optionsPanel = new cGridBag().setVertical(false);
13241524
13251525 optionsPanel.setName("Options");
13261526
....@@ -1328,6 +1528,8 @@
13281528
13291529 tabbedPane.add(optionsPanel);
13301530
1531
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1532
+
13311533 scenePanel.add(tabbedPane);
13321534
13331535 /*
....@@ -1419,10 +1621,15 @@
14191621
14201622 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14211623
1422
- frame.setSize(1024, 768);
1423
- frame.show();
1424
-
1624
+ frame.setSize(1280, 860);
1625
+
1626
+ cameraView.requestFocusInWindow();
1627
+
14251628 gridPanel.setDividerLocation(1.0);
1629
+
1630
+ frame.validate();
1631
+
1632
+ frame.setVisible(true);
14261633
14271634 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14281635 frame.addWindowListener(new WindowAdapter()
....@@ -1459,19 +1666,22 @@
14591666
14601667 cGridBag editBar = new cGridBag().setVertical(false);
14611668
1462
- editBar.add(createMaterialButton = new cButton("Create", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1669
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
14631670 createMaterialButton.setToolTipText("Create material");
14641671
14651672 /*
14661673 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14671674 */
14681675
1469
- editBar.add(clearMaterialButton = new cButton("Clear", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1676
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
14701677 clearMaterialButton.setToolTipText("Clear material");
14711678
1472
- editBar.add(resetSlidersButton = new cButton("Reset", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1473
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1474
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1679
+ if (Globals.ADVANCED)
1680
+ {
1681
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1682
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1683
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1684
+ }
14751685
14761686 editBar.preferredHeight = 15;
14771687
....@@ -1505,24 +1715,6 @@
15051715 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15061716 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
15071717 colorSection.add(texture);
1508
-
1509
- cGridBag anisoU = new cGridBag();
1510
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1511
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1512
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1513
- colorSection.add(anisoU);
1514
-
1515
- cGridBag anisoV = new cGridBag();
1516
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1517
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1518
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1519
- colorSection.add(anisoV);
1520
-
1521
- cGridBag shadowbias = new cGridBag();
1522
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1523
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1524
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1525
- colorSection.add(shadowbias);
15261718
15271719 panel.add(new JSeparator());
15281720
....@@ -1574,6 +1766,12 @@
15741766 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15751767 diffuseSection.add(fakedepth);
15761768
1769
+ cGridBag shadowbias = new cGridBag();
1770
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1771
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1772
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1773
+ diffuseSection.add(shadowbias);
1774
+
15771775 panel.add(new JSeparator());
15781776
15791777 panel.add(diffuseSection);
....@@ -1624,6 +1822,18 @@
16241822 // aConstraints.gridy += 1;
16251823 // aConstraints.gridwidth = 1;
16261824
1825
+ cGridBag anisoU = new cGridBag();
1826
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1827
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1828
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1829
+ specularSection.add(anisoU);
1830
+
1831
+ cGridBag anisoV = new cGridBag();
1832
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1833
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1834
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1835
+ specularSection.add(anisoV);
1836
+
16271837
16281838 panel.add(new JSeparator());
16291839
....@@ -1631,35 +1841,35 @@
16311841
16321842 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16331843
1634
- cGridBag globalSection = new cGridBag().setVertical(true);
1844
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16351845
16361846 cGridBag camera = new cGridBag();
16371847 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16381848 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16391849 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1640
- globalSection.add(camera);
1850
+ colorSection.add(camera);
16411851
16421852 cGridBag ambient = new cGridBag();
16431853 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16441854 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16451855 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1646
- globalSection.add(ambient);
1856
+ colorSection.add(ambient);
16471857
16481858 cGridBag backlit = new cGridBag();
16491859 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16501860 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16511861 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1652
- globalSection.add(backlit);
1862
+ colorSection.add(backlit);
16531863
16541864 cGridBag opacity = new cGridBag();
16551865 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
16561866 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16571867 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1658
- globalSection.add(opacity);
1868
+ colorSection.add(opacity);
16591869
1660
- panel.add(new JSeparator());
1870
+ //panel.add(new JSeparator());
16611871
1662
- panel.add(globalSection);
1872
+ //panel.add(globalSection);
16631873
16641874 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16651875
....@@ -1740,12 +1950,15 @@
17401950 opacityPowerField.addChangeListener(this);
17411951 /**/
17421952
1743
- resetSlidersButton.addActionListener(this);
17441953 clearMaterialButton.addActionListener(this);
17451954 createMaterialButton.addActionListener(this);
1746
-
1747
- propagateToggle.addItemListener(this);
1748
- multiplyToggle.addItemListener(this);
1955
+
1956
+ if (Globals.ADVANCED)
1957
+ {
1958
+ resetSlidersButton.addActionListener(this);
1959
+ propagateToggle.addItemListener(this);
1960
+ multiplyToggle.addItemListener(this);
1961
+ }
17491962 }
17501963
17511964 void DropFile(java.io.File[] files, boolean textures)
....@@ -1916,7 +2129,7 @@
19162129
19172130 //? flashIt = false;
19182131 CameraPane pane = (CameraPane) cameraView;
1919
- pane.clickStart(location.x, location.y, 0);
2132
+ pane.clickStart(location.x, location.y, 0, 0);
19202133 pane.clickEnd(location.x, location.y, 0, true);
19212134
19222135 if (group.selection.size() == 1)
....@@ -1965,6 +2178,7 @@
19652178 e2.printStackTrace();
19662179 }
19672180 }
2181
+
19682182 LoadJMEThread loadThread;
19692183
19702184 class LoadJMEThread extends Thread
....@@ -2022,6 +2236,7 @@
20222236 //LoadFile0(filename, converter);
20232237 }
20242238 }
2239
+
20252240 LoadOBJThread loadObjThread;
20262241
20272242 class LoadOBJThread extends Thread
....@@ -2100,19 +2315,19 @@
21002315
21012316 void LoadObjFile(String fullname)
21022317 {
2103
- /*
2318
+ System.out.println("Loading " + fullname);
2319
+ /**/
21042320 //lastFilename = fullname;
21052321 if(loadObjThread == null)
21062322 {
2107
- loadObjThread = new LoadOBJThread();
2108
- loadObjThread.start();
2323
+ loadObjThread = new LoadOBJThread();
2324
+ loadObjThread.start();
21092325 }
21102326
21112327 loadObjThread.add(fullname);
2112
- */
2328
+ /**/
21132329
2114
- System.out.println("Loading " + fullname);
2115
- makeSomething(new FileObject(fullname, true), true);
2330
+ //makeSomething(new FileObject(fullname, true), true);
21162331 }
21172332
21182333 void LoadGFDFile(String fullname)
....@@ -2373,11 +2588,11 @@
23732588
23742589 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23752590 {
2376
- if (GrafreeD.standAlone)
2591
+ if (Grafreed.standAlone)
23772592 {
23782593 /**/
23792594 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2380
- browser.show();
2595
+ browser.setVisible(true);
23812596 String filename = browser.getFile();
23822597 if (filename != null && filename.length() > 0)
23832598 {
....@@ -2729,6 +2944,8 @@
27292944
27302945 void SetMaterial(Object3D object)
27312946 {
2947
+ latestObject = object;
2948
+
27322949 cMaterial mat = object.material;
27332950
27342951 if (mat == null)
....@@ -2737,7 +2954,8 @@
27372954 return;
27382955 }
27392956
2740
- multiplyToggle.setSelected(mat.multiply);
2957
+ if (multiplyToggle != null)
2958
+ multiplyToggle.setSelected(mat.multiply);
27412959
27422960 assert (object.projectedVertices != null);
27432961
....@@ -2839,12 +3057,17 @@
28393057 // }
28403058
28413059 /**/
2842
- if (deselect)
3060
+ if (deselect || child == null)
28433061 {
28443062 //group.deselectAll();
28453063 //freeze = true;
28463064 GetTree().clearSelection();
28473065 //freeze = false;
3066
+
3067
+ if (child == null)
3068
+ {
3069
+ return;
3070
+ }
28483071 }
28493072
28503073 //group.addSelectee(child);
....@@ -2913,7 +3136,7 @@
29133136 cameraView.ToggleDL();
29143137 cameraView.repaint();
29153138 return;
2916
- } else if (event.getSource() == toggleTextureItem)
3139
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29173140 {
29183141 cameraView.ToggleTexture();
29193142 // june 2013 copy.HardTouch();
....@@ -2952,9 +3175,9 @@
29523175 frame.validate();
29533176
29543177 return;
2955
- } else if (event.getSource() == toggleRandomItem)
3178
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29563179 {
2957
- cameraView.ToggleRandom();
3180
+ cameraView.ToggleSwitch();
29583181 cameraView.repaint();
29593182 return;
29603183 } else if (event.getSource() == toggleHandleItem)
....@@ -2982,6 +3205,10 @@
29823205 } else if (event.getSource() == liveCB)
29833206 {
29843207 copy.live ^= true;
3208
+ return;
3209
+ } else if (event.getSource() == selectCB)
3210
+ {
3211
+ copy.dontselect ^= true;
29853212 return;
29863213 } else if (event.getSource() == hideCB)
29873214 {
....@@ -3021,8 +3248,9 @@
30213248
30223249 public void actionPerformed(ActionEvent event)
30233250 {
3251
+ Object source = event.getSource();
30243252 // SCRIPT DIALOG
3025
- if (event.getSource() == okbutton)
3253
+ if (source == okbutton)
30263254 {
30273255 textpanel.setVisible(false);
30283256 textpanel.remove(textarea);
....@@ -3034,7 +3262,7 @@
30343262 textarea = null;
30353263 textpanel = null;
30363264 }
3037
- if (event.getSource() == cancelbutton)
3265
+ if (source == cancelbutton)
30383266 {
30393267 textpanel.setVisible(false);
30403268 textpanel.remove(textarea);
....@@ -3046,50 +3274,50 @@
30463274 //applySelf();
30473275 //client.refreshEditWindow();
30483276 //refreshContents();
3049
- if (event.getSource() == nameField)
3277
+ if (source == nameField)
30503278 {
30513279 //System.out.println("ObjEditor " + event);
30523280 applySelf0(true);
30533281 //parent.applySelf();
30543282 objEditor.refreshContents();
3055
- } else if (event.getSource() == resetButton)
3283
+ } else if (source == resetButton)
30563284 {
30573285 CameraPane.fullreset = true;
30583286 copy.Reset(); // ResetMeshes();
30593287 copy.Touch();
30603288 objEditor.refreshContents();
3061
- } else if (event.getSource() == stepItem)
3289
+ } else if (source == stepItem)
30623290 {
30633291 //cameraView.ONESTEP = true;
30643292 Globals.ONESTEP = true;
30653293 cameraView.repaint();
30663294 return;
3067
- } else if (event.getSource() == stepButton)
3295
+ } else if (source == stepButton)
30683296 {
30693297 copy.Step();
30703298 copy.Touch();
30713299 objEditor.refreshContents();
3072
- } else if (event.getSource() == slowerButton)
3300
+ } else if (source == slowerButton)
30733301 {
30743302 copy.Slower();
30753303 copy.Touch();
30763304 objEditor.refreshContents();
3077
- } else if (event.getSource() == fasterButton)
3305
+ } else if (source == fasterButton)
30783306 {
30793307 copy.Faster();
30803308 copy.Touch();
30813309 objEditor.refreshContents();
3082
- } else if (event.getSource() == remarkButton)
3310
+ } else if (source == remarkButton)
30833311 {
30843312 copy.Remark();
30853313 copy.Touch();
30863314 objEditor.refreshContents();
3087
- } else if (event.getSource() == stepAllButton)
3315
+ } else if (source == stepAllButton)
30883316 {
30893317 copy.StepAll();
30903318 copy.Touch();
30913319 objEditor.refreshContents();
3092
- } else if (event.getSource() == resetAllButton)
3320
+ } else if (source == resetAllButton)
30933321 {
30943322 //CameraPane.fullreset = true;
30953323 copy.ResetAll(); // ResetMeshes();
....@@ -3122,53 +3350,75 @@
31223350 // Close();
31233351 // }
31243352 // else
3125
- if (event.getSource() == resetSlidersButton)
3353
+ if (source == resetSlidersButton)
31263354 {
31273355 ResetSliders();
3128
- } else if (event.getSource() == clearMaterialButton)
3356
+ } else if (source == clearMaterialButton)
31293357 {
31303358 ClearMaterial();
3131
- } else if (event.getSource() == createMaterialButton)
3359
+ } else if (source == createMaterialButton)
31323360 {
31333361 CreateMaterial();
3134
- } else if (event.getSource() == clearPanelButton)
3362
+ } else if (source == clearPanelButton)
31353363 {
31363364 copy.ClearUI();
31373365 refreshContents(true);
3138
- } /*
3139
- }
3140
-
3141
- public boolean action(Event event, Object arg)
3142
- {
3143
- */ else if (event.getSource() == closeItem)
3366
+ } else if (source == importGFDItem)
3367
+ {
3368
+ ImportGFD();
3369
+ } else
3370
+ if (source == importVRMLX3DItem)
3371
+ {
3372
+ ImportVRMLX3D();
3373
+ } else
3374
+ if (source == import3DSItem)
3375
+ {
3376
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3377
+ } else
3378
+ if (source == importOBJItem)
3379
+ {
3380
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3381
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3382
+ browser.setVisible(true);
3383
+ String filename = browser.getFile();
3384
+ if (filename != null && filename.length() > 0)
3385
+ {
3386
+ String fullname = browser.getDirectory() + filename;
3387
+ makeSomething(ReadOBJ(fullname), true);
3388
+ }
3389
+ } else
3390
+ if (source == closeItem)
31443391 {
31453392 Close();
31463393 //return true;
3147
- } else if (event.getSource() == loadItem)
3394
+ } else if (source == loadItem)
31483395 {
31493396 load();
31503397 //return true;
3151
- } else if (event.getSource() == saveItem)
3398
+ } else if (source == newItem)
3399
+ {
3400
+ New();
3401
+ } else if (source == saveItem)
31523402 {
31533403 save();
31543404 //return true;
3155
- } else if (event.getSource() == saveAsItem)
3405
+ } else if (source == saveAsItem)
31563406 {
31573407 saveAs();
31583408 //return true;
3159
- } else if (event.getSource() == reexportItem)
3409
+ } else if (source == reexportItem)
31603410 {
31613411 reexport();
31623412 //return true;
3163
- } else if (event.getSource() == exportAsItem)
3413
+ } else if (source == exportAsItem)
31643414 {
31653415 export();
31663416 //return true;
3167
- } else if (event.getSource() == povItem)
3417
+ } else if (source == povItem)
31683418 {
31693419 generatePOV();
31703420 //return true;
3171
- } else if (event.getSource() == zBufferItem)
3421
+ } else if (source == zBufferItem)
31723422 {
31733423 try
31743424 {
....@@ -3190,21 +3440,8 @@
31903440 cameraView.repaint();
31913441 //return true;
31923442 }
3193
- */ else if (event.getSource() == editCameraItem)
3194
- {
3195
- cameraView.ProtectCamera();
3196
- cameraView.repaint();
3197
- return;
3198
- } else if (event.getSource() == revertCameraItem)
3199
- {
3200
- cameraView.RevertCamera();
3201
- cameraView.repaint();
3202
- return;
3203
-// } else if (event.getSource() == textureButton)
3204
-// {
3205
-// return; // true;
3206
- } else // combos...
3207
- if (event.getSource() == texresMenu)
3443
+ */ else // combos...
3444
+ if (source == texresMenu)
32083445 {
32093446 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
32103447 copy.texres = texresMenu.getSelectedIndex();
....@@ -3216,6 +3453,283 @@
32163453 }
32173454 }
32183455
3456
+ void New()
3457
+ {
3458
+ while (copy.Size() > 1)
3459
+ {
3460
+ copy.remove(1);
3461
+ }
3462
+
3463
+ ResetModel();
3464
+ objEditor.refreshContents();
3465
+ }
3466
+
3467
+ static public byte[] Compress(Object3D o)
3468
+ {
3469
+ try
3470
+ {
3471
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3472
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3473
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3474
+
3475
+ Object3D parent = o.parent;
3476
+ o.parent = null;
3477
+
3478
+ out.writeObject(o);
3479
+
3480
+ o.parent = parent;
3481
+
3482
+ out.flush();
3483
+
3484
+ zstream.close();
3485
+ out.close();
3486
+
3487
+ return baos.toByteArray();
3488
+ } catch (Exception e)
3489
+ {
3490
+ System.err.println(e);
3491
+ return null;
3492
+ }
3493
+ }
3494
+
3495
+ static public Object Uncompress(byte[] bytes)
3496
+ {
3497
+ System.out.println("#bytes = " + bytes.length);
3498
+ try
3499
+ {
3500
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3501
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3502
+ ObjectInputStream in = new ObjectInputStream(istream);
3503
+ Object obj = in.readObject();
3504
+ in.close();
3505
+
3506
+ return obj;
3507
+ } catch (Exception e)
3508
+ {
3509
+ System.err.println(e);
3510
+ return null;
3511
+ }
3512
+ }
3513
+
3514
+ static public Object clone(Object o)
3515
+ {
3516
+ try
3517
+ {
3518
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3519
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3520
+
3521
+ out.writeObject(o);
3522
+
3523
+ out.flush();
3524
+ out.close();
3525
+
3526
+ byte[] bytes = baos.toByteArray();
3527
+
3528
+ System.out.println("clone = " + bytes.length);
3529
+
3530
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3531
+ ObjectInputStream in = new ObjectInputStream(bais);
3532
+ Object obj = in.readObject();
3533
+ in.close();
3534
+
3535
+ return obj;
3536
+ } catch (Exception e)
3537
+ {
3538
+ System.err.println(e);
3539
+ return null;
3540
+ }
3541
+ }
3542
+
3543
+ cRadio GetCurrentTab()
3544
+ {
3545
+ cRadio ab;
3546
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3547
+ {
3548
+ ab = (cRadio)e.nextElement();
3549
+ if(ab.GetObject() == copy)
3550
+ {
3551
+ return ab;
3552
+ }
3553
+ }
3554
+
3555
+ return null;
3556
+ }
3557
+
3558
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3559
+
3560
+ public void Save()
3561
+ {
3562
+ System.err.println("Save");
3563
+
3564
+ cRadio tab = GetCurrentTab();
3565
+
3566
+ boolean temp = CameraPane.SWITCH;
3567
+ CameraPane.SWITCH = false;
3568
+
3569
+ copy.ExtractBigData(hashtable);
3570
+
3571
+ byte[] compress = Compress(copy);
3572
+
3573
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3574
+ tab.graphs[tab.undoindex++] = compress;
3575
+
3576
+ copy.RestoreBigData(hashtable);
3577
+
3578
+ CameraPane.SWITCH = temp;
3579
+
3580
+ //assert(hashtable.isEmpty());
3581
+
3582
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3583
+ {
3584
+ tab.graphs[i] = null;
3585
+ }
3586
+
3587
+ SetUndoStates();
3588
+
3589
+ // test save
3590
+ if (false)
3591
+ {
3592
+ try
3593
+ {
3594
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3595
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3596
+
3597
+ p.writeObject(copy);
3598
+
3599
+ p.flush();
3600
+
3601
+ ostream.close();
3602
+ } catch (Exception e)
3603
+ {
3604
+ e.printStackTrace();
3605
+ }
3606
+ }
3607
+ }
3608
+
3609
+ void CopyChanged(Object3D obj)
3610
+ {
3611
+ SetUndoStates();
3612
+
3613
+ boolean temp = CameraPane.SWITCH;
3614
+ CameraPane.SWITCH = false;
3615
+
3616
+ copy.ExtractBigData(hashtable);
3617
+
3618
+ copy.clear();
3619
+
3620
+ for (int i=0; i<obj.Size(); i++)
3621
+ {
3622
+ copy.add(obj.get(i));
3623
+ }
3624
+
3625
+ copy.RestoreBigData(hashtable);
3626
+
3627
+ CameraPane.SWITCH = temp;
3628
+
3629
+ //assert(hashtable.isEmpty());
3630
+
3631
+ copy.Touch();
3632
+
3633
+ ResetModel();
3634
+ copy.HardTouch(); // recompile?
3635
+
3636
+ cRadio ab;
3637
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3638
+ {
3639
+ ab = (cRadio)e.nextElement();
3640
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3641
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3642
+ if (test != null)
3643
+ {
3644
+ test.editWindow = ab.object.editWindow;
3645
+ ab.object = test;
3646
+ }
3647
+ }
3648
+
3649
+ refreshContents();
3650
+ }
3651
+
3652
+ cButton undoButton;
3653
+ cButton redoButton;
3654
+
3655
+ void SetUndoStates()
3656
+ {
3657
+ cRadio tab = GetCurrentTab();
3658
+
3659
+ undoButton.setEnabled(tab.undoindex > 0);
3660
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3661
+ }
3662
+
3663
+ public void Undo()
3664
+ {
3665
+ System.err.println("Undo");
3666
+
3667
+ cRadio tab = GetCurrentTab();
3668
+
3669
+ if (tab.undoindex == 0)
3670
+ {
3671
+ java.awt.Toolkit.getDefaultToolkit().beep();
3672
+ return;
3673
+ }
3674
+
3675
+ if (tab.graphs[tab.undoindex] == null)
3676
+ {
3677
+ Save();
3678
+ tab.undoindex -= 1;
3679
+ }
3680
+
3681
+ tab.undoindex -= 1;
3682
+
3683
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3684
+ }
3685
+
3686
+ public void Redo()
3687
+ {
3688
+ cRadio tab = GetCurrentTab();
3689
+
3690
+ if (tab.graphs[tab.undoindex + 1] == null)
3691
+ {
3692
+ java.awt.Toolkit.getDefaultToolkit().beep();
3693
+ return;
3694
+ }
3695
+
3696
+ tab.undoindex += 1;
3697
+
3698
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3699
+ }
3700
+
3701
+ void ImportGFD()
3702
+ {
3703
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3704
+ browser.show();
3705
+ String filename = browser.getFile();
3706
+ if (filename != null && filename.length() > 0)
3707
+ {
3708
+ String fullname = browser.getDirectory() + filename;
3709
+
3710
+ //Object3D readobj =
3711
+ objEditor.ReadGFD(fullname, objEditor);
3712
+ //makeSomething(readobj);
3713
+ }
3714
+ }
3715
+
3716
+ void ImportVRMLX3D()
3717
+ {
3718
+ if (Grafreed.standAlone)
3719
+ {
3720
+ /**/
3721
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3722
+ browser.show();
3723
+ String filename = browser.getFile();
3724
+ if (filename != null && filename.length() > 0)
3725
+ {
3726
+ String fullname = browser.getDirectory() + filename;
3727
+ LoadVRMLX3D(fullname);
3728
+ }
3729
+ /**/
3730
+ }
3731
+ }
3732
+
32193733 void ToggleAnimation()
32203734 {
32213735 if (!Globals.ANIMATION)
....@@ -3231,8 +3745,8 @@
32313745
32323746 Globals.ANIMATION ^= true;
32333747
3234
- GrafreeD.wav.cursor = 0;
3235
- GrafreeD.wav.loop = 0;
3748
+ Grafreed.wav.cursor = 0;
3749
+ Grafreed.wav.loop = 0;
32363750 }
32373751 } else
32383752 {
....@@ -3253,7 +3767,6 @@
32533767 callee.refreshContents();
32543768 } else
32553769 {
3256
- new Exception().printStackTrace();
32573770 System.exit(0);
32583771 }
32593772 }
....@@ -3283,7 +3796,7 @@
32833796 void CreateMaterial()
32843797 {
32853798 //copy.ClearMaterial(); // PATCH
3286
- copy.CreateMaterialS(multiplyToggle.isSelected());
3799
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32873800 if (copy.selection.size() > 0)
32883801 //SetMaterial(copy);
32893802 {
....@@ -3334,7 +3847,7 @@
33343847 assert false;
33353848 }
33363849
3337
- void EditSelection()
3850
+ void EditSelection(boolean newWindow)
33383851 {
33393852 }
33403853
....@@ -3342,11 +3855,11 @@
33423855 {
33433856 copy.ResetBlockLoop(); // temporary problem
33443857
3345
- boolean random = CameraPane.RANDOM;
3346
- CameraPane.RANDOM = false; // parse everything
3858
+ boolean random = CameraPane.SWITCH;
3859
+ CameraPane.SWITCH = false; // parse everything
33473860 copy.ResetDisplayList();
33483861 copy.HardTouch();
3349
- CameraPane.RANDOM = random;
3862
+ CameraPane.SWITCH = random;
33503863 }
33513864
33523865 // public void applySelf()
....@@ -3420,6 +3933,36 @@
34203933 {
34213934 //System.out.println("Propagate = " + propagate);
34223935 copy.UpdateMaterial(anchor, current, propagate);
3936
+
3937
+ if (copy.material != null)
3938
+ {
3939
+ cMaterial mat = copy.material;
3940
+
3941
+ colorField.SetToolTipValue((mat.color));
3942
+ modulationField.SetToolTipValue((mat.modulation));
3943
+ metalnessField.SetToolTipValue((mat.metalness));
3944
+ diffuseField.SetToolTipValue((mat.diffuse));
3945
+ specularField.SetToolTipValue((mat.specular));
3946
+ shininessField.SetToolTipValue((mat.shininess));
3947
+ shiftField.SetToolTipValue((mat.shift));
3948
+ ambientField.SetToolTipValue((mat.ambient));
3949
+ lightareaField.SetToolTipValue((mat.lightarea));
3950
+ diffusenessField.SetToolTipValue((mat.factor));
3951
+ velvetField.SetToolTipValue((mat.velvet));
3952
+ sheenField.SetToolTipValue((mat.sheen));
3953
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3954
+ backlitField.SetToolTipValue((mat.bump));
3955
+ anisoField.SetToolTipValue((mat.aniso));
3956
+ anisoVField.SetToolTipValue((mat.anisoV));
3957
+ cameraField.SetToolTipValue((mat.cameralight));
3958
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3959
+ shadowField.SetToolTipValue((mat.shadow));
3960
+ textureField.SetToolTipValue((mat.texture));
3961
+ opacityField.SetToolTipValue((mat.opacity));
3962
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3963
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3964
+ }
3965
+
34233966 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34243967 {
34253968 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3535,7 +4078,7 @@
35354078 }
35364079
35374080 if (normalpushField != null)
3538
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4081
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35394082 }
35404083
35414084 void SnapObject()
....@@ -3799,6 +4342,8 @@
37994342
38004343 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
38014344 {
4345
+ if (Globals.SAVEONMAKE) // && resetmodel)
4346
+ Save();
38024347 //Tween.set(thing, 0).target(1).start(tweenManager);
38034348 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
38044349 // if (thing instanceof GenericJointDemo)
....@@ -3885,6 +4430,12 @@
38854430 {
38864431 ResetModel();
38874432 Select(thing.GetTreePath(), true, false); // unselect... false);
4433
+
4434
+ if (thing.Size() == 0)
4435
+ {
4436
+ //EditSelection(false);
4437
+ }
4438
+
38884439 refreshContents();
38894440 }
38904441
....@@ -4002,6 +4553,7 @@
40024553 }
40034554 }
40044555 }
4556
+
40054557 LoadGFDThread loadGFDThread;
40064558
40074559 void ReadGFD(String fullname, iCallBack cb)
....@@ -4021,8 +4573,10 @@
40214573
40224574 try
40234575 {
4576
+ // Try compressed version first.
40244577 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4025
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4578
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4579
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40264580
40274581 readobj = (Object3D) p.readObject();
40284582 istream.close();
....@@ -4030,7 +4584,20 @@
40304584 readobj.ResetDisplayList();
40314585 } catch (Exception e)
40324586 {
4033
- e.printStackTrace();
4587
+ //e.printStackTrace();
4588
+ try
4589
+ {
4590
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4591
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4592
+
4593
+ readobj = (Object3D) p.readObject();
4594
+ istream.close();
4595
+
4596
+ readobj.ResetDisplayList();
4597
+ } catch (Exception e2)
4598
+ {
4599
+ e2.printStackTrace();
4600
+ }
40344601 }
40354602 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40364603 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4076,6 +4643,12 @@
40764643
40774644 void LoadIt(Object obj)
40784645 {
4646
+ if (obj == null)
4647
+ {
4648
+ // Invalid file
4649
+ return;
4650
+ }
4651
+
40794652 System.out.println("Loaded " + obj);
40804653 //new Exception().printStackTrace();
40814654 Object3D readobj = (Object3D) obj;
....@@ -4085,6 +4658,8 @@
40854658
40864659 if (readobj != null)
40874660 {
4661
+ if (Globals.SAVEONMAKE)
4662
+ Save();
40884663 try
40894664 {
40904665 //readobj.deepCopySelf(copy);
....@@ -4147,7 +4722,7 @@
41474722
41484723 void load() // throws ClassNotFoundException
41494724 {
4150
- if (GrafreeD.standAlone)
4725
+ if (Grafreed.standAlone)
41514726 {
41524727 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41534728 browser.show();
....@@ -4234,11 +4809,13 @@
42344809 try
42354810 {
42364811 FileOutputStream ostream = new FileOutputStream(lastname);
4237
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4812
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4813
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42384814
42394815 p.writeObject(copy);
42404816 p.flush();
42414817
4818
+ zstream.close();
42424819 ostream.close();
42434820
42444821 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4248,17 +4825,20 @@
42484825 {
42494826 }
42504827 }
4828
+
42514829 String lastname;
42524830
42534831 void saveAs()
42544832 {
4255
- if (GrafreeD.standAlone)
4833
+ if (Grafreed.standAlone)
42564834 {
42574835 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42584836 browser.setVisible(true);
42594837 String filename = browser.getFile();
42604838 if (filename != null && filename.length() > 0)
42614839 {
4840
+ if (!filename.endsWith(".gfd"))
4841
+ filename += ".gfd";
42624842 lastname = browser.getDirectory() + filename;
42634843 save();
42644844 }
....@@ -4357,13 +4937,13 @@
43574937 try
43584938 {
43594939 FileOutputStream ostream = new FileOutputStream(filename);
4360
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4361
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4940
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4941
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43624942
43634943 Object3D objectparent = obj.parent;
43644944 obj.parent = null;
43654945
4366
- Object3D object = (Object3D) GrafreeD.clone(obj);
4946
+ Object3D object = (Object3D) Grafreed.clone(obj);
43674947
43684948 obj.parent = objectparent;
43694949
....@@ -4375,8 +4955,8 @@
43754955 p.writeObject(object);
43764956 p.flush();
43774957
4958
+ zstream.close();
43784959 ostream.close();
4379
- // zstream.close();
43804960
43814961 // group.selection.get(0).parent = parent;
43824962 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4397,7 +4977,7 @@
43974977 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43984978 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43994979 copy.generatePOV(buffer);
4400
- if (GrafreeD.standAlone)
4980
+ if (Grafreed.standAlone)
44014981 {
44024982 FileDialog browser = new FileDialog(frame, "Export POV", 1);
44034983 browser.show();
....@@ -4423,7 +5003,8 @@
44235003 Object3D client;
44245004 Object3D copy;
44255005 MenuBar menuBar;
4426
- Menu windowMenu;
5006
+ Menu fileMenu;
5007
+ MenuItem newItem;
44275008 MenuItem loadItem;
44285009 MenuItem saveItem;
44295010 MenuItem saveAsItem;
....@@ -4431,11 +5012,9 @@
44315012 MenuItem reexportItem;
44325013 MenuItem povItem;
44335014 MenuItem closeItem;
4434
- Menu cameraMenu;
5015
+
44355016 CheckboxMenuItem zBufferItem;
44365017 //MenuItem normalLensItem;
4437
- MenuItem editCameraItem;
4438
- MenuItem revertCameraItem;
44395018 MenuItem stepItem;
44405019 CheckboxMenuItem toggleLiveItem;
44415020 CheckboxMenuItem toggleFullScreenItem;
....@@ -4446,25 +5025,38 @@
44465025 CheckboxMenuItem toggleFootContactItem;
44475026 CheckboxMenuItem toggleDLItem;
44485027 CheckboxMenuItem toggleTextureItem;
4449
- CheckboxMenuItem toggleRandomItem;
5028
+ CheckboxMenuItem toggleSwitchItem;
44505029 CheckboxMenuItem toggleRootItem;
44515030 CheckboxMenuItem animationItem;
44525031 CheckboxMenuItem toggleHandleItem;
44535032 CheckboxMenuItem togglePaintItem;
44545033 JSplitPane mainPanel;
44555034 JScrollPane scrollpane;
5035
+
44565036 JPanel toolbarPanel;
5037
+
44575038 cGridBag treePanel;
5039
+
44585040 JPanel radioPanel;
44595041 ButtonGroup buttonGroup;
4460
- cGridBag ctrlPanel;
5042
+
5043
+ cGridBag toolboxPanel;
44615044 cGridBag materialPanel;
5045
+ cGridBag ctrlPanel;
5046
+
44625047 JScrollPane infoPanel;
5048
+
44635049 cGridBag optionsPanel;
5050
+
44645051 JTabbedPane objectPanel;
5052
+ boolean materialFlushed;
5053
+ Object3D latestObject;
5054
+
44655055 cGridBag XYZPanel;
5056
+
44665057 JSplitPane gridPanel;
44675058 JSplitPane bigPanel;
5059
+
44685060 cGridBag bigThree;
44695061 cGridBag scenePanel;
44705062 cGridBag centralPanel;
....@@ -4579,8 +5171,13 @@
45795171 cNumberSlider fogField;
45805172 JLabel opacityPowerLabel;
45815173 cNumberSlider opacityPowerField;
4582
- JTree jTree;
5174
+ cTree jTree;
45835175 //ObjectUI parent;
45845176
45855177 cNumberSlider normalpushField;
5178
+
5179
+ private MenuItem importGFDItem;
5180
+ private MenuItem importVRMLX3DItem;
5181
+ private MenuItem import3DSItem;
5182
+ private MenuItem importOBJItem;
45865183 }