Normand Briere
2019-06-23 f1382bc839a74ef1d1534c61ea94e53cf54716df
ObjEditor.java
....@@ -36,6 +36,8 @@
3636 GroupEditor callee;
3737 JFrame frame;
3838
39
+ static ObjEditor theFrame;
40
+
3941 // SCRIPT
4042
4143 transient JFrame textpanel = null;
....@@ -143,6 +145,8 @@
143145 //nameField.removeActionListener(this);
144146 // objEditor.ctrlPanel.remove(nameField);
145147
148
+ objEditor.ctrlPanel.remove(namePanel);
149
+
146150 if (!GroupEditor.allparams)
147151 return;
148152
....@@ -165,9 +169,9 @@
165169 // objEditor.ctrlPanel.remove(fasterButton);
166170 // objEditor.ctrlPanel.remove(remarkButton);
167171
168
- objEditor.ctrlPanel.remove(namePanel);
169172 objEditor.ctrlPanel.remove(setupPanel);
170
- objEditor.ctrlPanel.remove(commandsPanel);
173
+ objEditor.ctrlPanel.remove(setupPanel2);
174
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
171175 objEditor.ctrlPanel.remove(pushPanel);
172176 //objEditor.ctrlPanel.remove(fillPanel);
173177
....@@ -242,6 +246,7 @@
242246 //localCopy.parent = null;
243247
244248 frame = new JFrame();
249
+ frame.setUndecorated(true);
245250 objEditor = this;
246251 this.callee = callee;
247252
....@@ -275,24 +280,40 @@
275280 void SetupMenu()
276281 {
277282 frame.setMenuBar(menuBar = new MenuBar());
278
- menuBar.add(windowMenu = new Menu("File"));
279
- windowMenu.add(loadItem = new MenuItem("Load..."));
280
- windowMenu.add("-");
281
- windowMenu.add(saveItem = new MenuItem("Save"));
282
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
283
+ menuBar.add(fileMenu = new Menu("File"));
284
+ fileMenu.add(newItem = new MenuItem("New"));
285
+ fileMenu.add(loadItem = new MenuItem("Open..."));
286
+
287
+ //oe.menuBar.add(menu = new Menu("Include"));
288
+ Menu menu = new Menu("Import");
289
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
290
+ importOBJItem.addActionListener(this);
291
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
292
+ import3DSItem.addActionListener(this);
293
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
294
+ importVRMLX3DItem.addActionListener(this);
295
+ menu.add("-");
296
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
297
+ importGFDItem.addActionListener(this);
298
+ fileMenu.add(menu);
299
+ fileMenu.add("-");
300
+
301
+ fileMenu.add(saveItem = new MenuItem("Save"));
302
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
283303 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
284
- windowMenu.add("-");
285
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
286
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
287
- windowMenu.add("-");
304
+ fileMenu.add("-");
305
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
306
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
307
+ fileMenu.add("-");
288308 if (client.parent != null)
289309 {
290
- windowMenu.add(closeItem = new MenuItem("Close"));
310
+ fileMenu.add(closeItem = new MenuItem("Close"));
291311 } else
292312 {
293
- windowMenu.add(closeItem = new MenuItem("Exit"));
313
+ fileMenu.add(closeItem = new MenuItem("Exit"));
294314 }
295315
316
+ newItem.addActionListener(this);
296317 loadItem.addActionListener(this);
297318 saveItem.addActionListener(this);
298319 saveAsItem.addActionListener(this);
....@@ -301,79 +322,35 @@
301322 //povItem.addActionListener(this);
302323 closeItem.addActionListener(this);
303324
304
- menuBar.add(cameraMenu = new Menu("View"));
305
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
306
- //zBufferItem.addActionListener(this);
307
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
308
- //normalLensItem.addActionListener(this);
309
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
310
- revertCameraItem.addActionListener(this);
311
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
312
- toggleTimelineItem.addItemListener(this);
313
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
314
- toggleFullScreenItem.addItemListener(this);
315
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
316
- cameraMenu.add("-");
317
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
318
- toggleTextureItem.addItemListener(this);
319
- toggleTextureItem.setState(CameraPane.textureon);
320
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
321
- toggleLiveItem.addItemListener(this);
322
- toggleLiveItem.setState(Globals.isLIVE());
323
- cameraMenu.add(stepItem = new MenuItem("Step"));
324
- stepItem.addActionListener(this);
325
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
326
-// toggleDLItem.addItemListener(this);
327
-// toggleDLItem.setState(false);
328
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
329
- toggleRenderItem.addItemListener(this);
330
- toggleRenderItem.setState(!CameraPane.frozen);
331
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
332
- toggleDebugItem.addItemListener(this);
333
- toggleDebugItem.setState(CameraPane.DEBUG);
334
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
335
- toggleFrustumItem.addItemListener(this);
336
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
337
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
338
- toggleFootContactItem.addItemListener(this);
339
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
340
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
341
- toggleRandomItem.addItemListener(this);
342
- toggleRandomItem.setState(CameraPane.RANDOM);
343
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
344
- toggleHandleItem.addItemListener(this);
345
- toggleHandleItem.setState(CameraPane.HANDLES);
346
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
347
- togglePaintItem.addItemListener(this);
348
- togglePaintItem.setState(CameraPane.PAINTMODE);
349
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
350
-// toggleRootItem.addItemListener(this);
351
-// toggleRootItem.setState(false);
352
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
353
-// animationItem.addItemListener(this);
354
-// animationItem.setState(CameraPane.ANIMATION);
355
- cameraMenu.add("-");
356
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
357
- editCameraItem.addActionListener(this);
358
-
359325 objectPanel = new JTabbedPane();
360326 toolbarPanel = new JPanel();
361327 toolbarPanel.setName("Toolbar");
362
- treePanel = new JPanel();
328
+ treePanel = new cGridBag();
363329 treePanel.setName("Tree");
330
+
331
+ editPanel = new cGridBag().setVertical(true);
332
+ editPanel.setName("Edit");
333
+
364334 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
365
- ctrlPanel.setName("Edit");
335
+
336
+ editCommandsPanel = new cGridBag();
337
+ editPanel.add(editCommandsPanel);
338
+ editPanel.add(ctrlPanel);
339
+
366340 materialPanel = new cGridBag().setVertical(true);
341
+
367342 materialPanel.setName("Material");
368343 /*JTextPane*/
369344 infoarea = createTextPane();
345
+ doc = infoarea.getStyledDocument();
346
+
370347 infoarea.setEditable(true);
371348 SetText();
372349 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
373350 // infoarea.setOpaque(false);
374351 // //infoarea.setForeground(textcolor);
375
- infoarea.setLineWrap(true);
376
- infoarea.setWrapStyleWord(true);
352
+// TEXTAREA infoarea.setLineWrap(true);
353
+// TEXTAREA infoarea.setWrapStyleWord(true);
377354 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
378355 infoPanel.setPreferredSize(new Dimension(50, 200));
379356 infoPanel.setName("Info");
....@@ -384,14 +361,14 @@
384361 mainPanel.setName("Main");
385362 mainPanel.setContinuousLayout(true);
386363 mainPanel.setOneTouchExpandable(true);
387
- mainPanel.setDividerLocation(1.0);
388364 mainPanel.setDividerSize(9);
389
- mainPanel.setResizeWeight(0);
365
+ mainPanel.setDividerLocation(0.5); //1.0);
366
+ mainPanel.setResizeWeight(0.5);
390367
391368 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
392369 //mainPanel.setLayout(new GridBagLayout());
393370 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
394
- treePanel.setLayout(new GridBagLayout());
371
+// treePanel.setLayout(new GridBagLayout());
395372 //ctrlPanel.setLayout(new GridBagLayout());
396373 //materialPanel.setLayout(new GridBagLayout());
397374
....@@ -432,7 +409,7 @@
432409 static String newline = "\n";
433410 protected static final String buttonString = "JButton";
434411 StyledDocument doc;
435
- JTextArea infoarea;
412
+ JTextPane infoarea;
436413
437414 void ClearInfo()
438415 {
....@@ -455,10 +432,10 @@
455432 e.printStackTrace();
456433 }
457434
458
- String selection = infoarea.getText();
459
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
460
- java.awt.datatransfer.Clipboard clipboard =
461
- Toolkit.getDefaultToolkit().getSystemClipboard();
435
+// String selection = infoarea.getText();
436
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
437
+// java.awt.datatransfer.Clipboard clipboard =
438
+// Toolkit.getDefaultToolkit().getSystemClipboard();
462439 //clipboard.setContents(data, data);
463440 }
464441
....@@ -481,13 +458,13 @@
481458 //SendInfo("Name:", "bold");
482459 if (sel.GetTextures() != null || debug)
483460 {
484
- si.SendInfo(sel.toString(), "bold");
461
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
485462 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
486463 if (sel.Size() > 0)
487464 {
488465 si.SendInfo("#children = " + sel.Size(), "regular");
489466 }
490
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
467
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
491468 if (debug)
492469 {
493470 try
....@@ -499,7 +476,10 @@
499476 }
500477
501478 if (full)
502
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
479
+ {
480
+ si.SendInfo(" BBox min: " + minima, "regular");
481
+ si.SendInfo(" BBox max: " + maxima, "regular");
482
+ }
503483
504484 if (sel.bRep != null)
505485 {
....@@ -526,7 +506,7 @@
526506 }
527507 if (sel.support != null)
528508 {
529
- si.SendInfo(" support: " + sel.support, "regular");
509
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
530510 }
531511 if (sel.scriptnode != null)
532512 {
....@@ -597,6 +577,9 @@
597577 {
598578 CameraPane.pointflow = (PointFlow) sel;
599579 }
580
+
581
+ si.SendInfo("_____________________", "regular");
582
+ si.SendInfo("", "regular");
600583 }
601584 }
602585
....@@ -612,68 +595,138 @@
612595 }
613596 }
614597
598
+static GraphicsDevice device = GraphicsEnvironment
599
+ .getLocalGraphicsEnvironment().getScreenDevices()[0];
600
+
601
+ Rectangle keeprect;
602
+ cRadio radio;
603
+
604
+cButton keepButton;
605
+ cButton twoButton; // Full 3D
606
+ cButton sixButton;
607
+ cButton threeButton;
608
+ cButton sevenButton;
609
+ cButton fourButton; // full panel
610
+ cButton oneButton; // full XYZ
611
+ //cButton currentLayout;
612
+
613
+ boolean maximized;
614
+
615
+ void Minimize()
616
+ {
617
+ frame.setState(Frame.ICONIFIED);
618
+ }
619
+
620
+ void Maximize()
621
+ {
622
+ if (maximized)
623
+ {
624
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
625
+ }
626
+ else
627
+ {
628
+ keeprect = frame.getBounds();
629
+ Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
630
+ Dimension rect2 = frame.getToolkit().getScreenSize();
631
+ frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
632
+// frame.setState(Frame.MAXIMIZED_BOTH);
633
+ }
634
+
635
+ maximized ^= true;
636
+ }
637
+
615638 void ToggleFullScreen()
616639 {
617640 if (CameraPane.FULLSCREEN)
618641 {
619
- frame.getContentPane().remove(/*"Center",*/bigThree);
620
- framePanel.add(bigThree);
621
- frame.getContentPane().add(/*"Center",*/framePanel);
642
+ device.setFullScreenWindow(null);
643
+ //frame.setVisible(false);
644
+// frame.removeNotify();
645
+// frame.setUndecorated(false);
646
+// frame.addNotify();
647
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
648
+
649
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
650
+// X framePanel.add(bigThree);
651
+// X frame.getContentPane().add(/*"Center",*/framePanel);
652
+ framePanel.setDividerLocation(1);
653
+
654
+ //frame.setVisible(true);
655
+ radio.layout = keepButton;
656
+ //theFrame = null;
657
+ keepButton = null;
658
+ radio.layout.doClick();
659
+
622660 } else
623661 {
624
- frame.getContentPane().remove(/*"Center",*/framePanel);
625
- framePanel.remove(bigThree);
626
- frame.getContentPane().add(/*"Center",*/bigThree);
662
+ keepButton = radio.layout;
663
+ //keeprect = frame.getBounds();
664
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
665
+// frame.getToolkit().getScreenSize().height);
666
+ //frame.setVisible(false);
667
+ device.setFullScreenWindow(frame);
668
+// frame.removeNotify();
669
+// frame.setUndecorated(true);
670
+// frame.addNotify();
671
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
672
+// X framePanel.remove(bigThree);
673
+// X frame.getContentPane().add(/*"Center",*/bigThree);
674
+ framePanel.setDividerLocation(0);
675
+
676
+ radio.layout = twoButton;
677
+ radio.layout.doClick();
678
+ //frame.setVisible(true);
627679 }
680
+
628681 cameraView.ToggleFullScreen();
629682 }
630683
631
- private JTextArea createTextPane()
684
+ private JTextPane createTextPane()
632685 {
633
- String[] initString =
634
- {
635
- "This is an editable JTextPane, ", //regular
636
- "another ", //italic
637
- "styled ", //bold
638
- "text ", //small
639
- "component, ", //large
640
- "which supports embedded components..." + newline,//regular
641
- " " + newline, //button
642
- "...and embedded icons..." + newline, //regular
643
- " ", //icon
644
- newline + "JTextPane is a subclass of JEditorPane that "
645
- + "uses a StyledEditorKit and StyledDocument, and provides "
646
- + "cover methods for interacting with those objects."
647
- };
686
+// TEXTAREA String[] initString =
687
+// {
688
+// "This is an editable JTextPane, ", //regular
689
+// "another ", //italic
690
+// "styled ", //bold
691
+// "text ", //small
692
+// "component, ", //large
693
+// "which supports embedded components..." + newline,//regular
694
+// " " + newline, //button
695
+// "...and embedded icons..." + newline, //regular
696
+// " ", //icon
697
+// newline + "JTextPane is a subclass of JEditorPane that "
698
+// + "uses a StyledEditorKit and StyledDocument, and provides "
699
+// + "cover methods for interacting with those objects."
700
+// };
701
+//
702
+// String[] initStyles =
703
+// {
704
+// "regular", "italic", "bold", "small", "large",
705
+// "regular", "button", "regular", "icon",
706
+// "regular"
707
+// };
708
+//
709
+// JTextPane textPane = new JTextPane();
710
+// textPane.setEditable(true);
711
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
712
+// addStylesToDocument(doc);
713
+//
714
+// try
715
+// {
716
+// for (int j = 0; j < 2; j++)
717
+// {
718
+// for (int i = 0; i < initString.length; i++)
719
+// {
720
+// doc.insertString(doc.getLength(), initString[i],
721
+// doc.getStyle(initStyles[i]));
722
+// }
723
+// }
724
+// } catch (BadLocationException ble)
725
+// {
726
+// System.err.println("Couldn't insert initial text into text pane.");
727
+// }
648728
649
- String[] initStyles =
650
- {
651
- "regular", "italic", "bold", "small", "large",
652
- "regular", "button", "regular", "icon",
653
- "regular"
654
- };
655
-
656
- JTextPane textPane = new JTextPane();
657
- textPane.setEditable(true);
658
- /*StyledDocument*/ doc = textPane.getStyledDocument();
659
- addStylesToDocument(doc);
660
-
661
- try
662
- {
663
- for (int j = 0; j < 2; j++)
664
- {
665
- for (int i = 0; i < initString.length; i++)
666
- {
667
- doc.insertString(doc.getLength(), initString[i],
668
- doc.getStyle(initStyles[i]));
669
- }
670
- }
671
- } catch (BadLocationException ble)
672
- {
673
- System.err.println("Couldn't insert initial text into text pane.");
674
- }
675
-
676
- return new JTextArea(); // textPane;
729
+ return new JTextPane(); // textPane;
677730 }
678731
679732 protected void addStylesToDocument(StyledDocument doc)
....@@ -726,7 +779,7 @@
726779 protected static ImageIcon createImageIcon(String path,
727780 String description)
728781 {
729
- java.net.URL imgURL = GrafreeD.class.getResource(path);
782
+ java.net.URL imgURL = Grafreed.class.getResource(path);
730783 if (imgURL != null)
731784 {
732785 return new ImageIcon(imgURL, description);
....@@ -758,6 +811,7 @@
758811 // NumberSlider vDivsField;
759812 // JCheckBox endcaps;
760813 JCheckBox liveCB;
814
+ JCheckBox selectCB;
761815 JCheckBox hideCB;
762816 JCheckBox link2masterCB;
763817 JCheckBox markCB;
....@@ -774,9 +828,13 @@
774828 JButton fasterButton;
775829 JButton remarkButton;
776830
831
+ cGridBag editPanel;
832
+ cGridBag editCommandsPanel;
833
+
777834 cGridBag namePanel;
778835 cGridBag setupPanel;
779
- cGridBag commandsPanel;
836
+ cGridBag setupPanel2;
837
+ cGridBag objectCommandsPanel;
780838 cGridBag pushPanel;
781839 cGridBag fillPanel;
782840
....@@ -943,10 +1001,6 @@
9431001
9441002 void SetupUI2(ObjEditor oe)
9451003 {
946
-// oe.aConstraints.weightx = 0;
947
-// oe.aConstraints.weighty = 0;
948
-// oe.aConstraints.gridx = 0;
949
-// oe.aConstraints.gridy = 0;
9501004 //SetupName(oe);
9511005
9521006 namePanel = new cGridBag();
....@@ -963,32 +1017,56 @@
9631017 setupPanel = new cGridBag().setVertical(false);
9641018
9651019 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
966
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
967
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1020
+ liveCB.setToolTipText("Animate object");
1021
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1022
+ selectCB.setToolTipText("Make object selectable");
9681023 // Return();
1024
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1025
+ hideCB.setToolTipText("Hide object");
9691026 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
970
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
971
- randomCB = AddCheckBox(setupPanel, "Rand", copy.random);
1027
+ markCB.setToolTipText("Set the animation target transform");
1028
+
1029
+ setupPanel2 = new cGridBag().setVertical(false);
1030
+
1031
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1032
+ rewindCB.setToolTipText("Rewind animation");
1033
+
1034
+ randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1035
+ randomCB.setToolTipText("Randomly Rewind or Go back and forth");
9721036
1037
+ if (Globals.ADVANCED)
1038
+ {
1039
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1040
+ link2masterCB.setToolTipText("Attach to support");
1041
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1042
+ speedupCB.setToolTipText("Option motion capture");
1043
+ }
1044
+
9731045 oe.ctrlPanel.add(setupPanel);
9741046 oe.ctrlPanel.Return();
1047
+ oe.ctrlPanel.add(setupPanel2);
1048
+ oe.ctrlPanel.Return();
9751049
976
- commandsPanel = new cGridBag().setVertical(false);
1050
+ objectCommandsPanel = new cGridBag().setVertical(false);
9771051
978
- resetButton = AddButton(commandsPanel, "Reset");
979
- stepButton = AddButton(commandsPanel, "Step");
1052
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1053
+ resetButton.setToolTipText("Jump to frame zero");
1054
+ stepButton = AddButton(objectCommandsPanel, "Step");
1055
+ stepButton.setToolTipText("Step one frame");
9801056 // resetAllButton = AddButton(oe, "Reset All");
9811057 // stepAllButton = AddButton(oe, "Step All");
982
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
9831058 // Return();
984
- slowerButton = AddButton(commandsPanel, "Slow");
985
- fasterButton = AddButton(commandsPanel, "Fast");
986
- remarkButton = AddButton(commandsPanel, "Remark");
1059
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1060
+ slowerButton.setToolTipText("Decrease animation speed");
1061
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1062
+ fasterButton.setToolTipText("Increase animation speed");
1063
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1064
+ remarkButton.setToolTipText("Set the current transform as the target");
9871065
988
- oe.ctrlPanel.add(commandsPanel);
1066
+ oe.ctrlPanel.add(objectCommandsPanel);
9891067 oe.ctrlPanel.Return();
9901068
991
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1069
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
9921070 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
9931071 //Return();
9941072
....@@ -1191,8 +1269,11 @@
11911269 //worldPanel.setName("World");
11921270 centralPanel = new cGridBag();
11931271 centralPanel.preferredWidth = 20;
1194
- timelinePanel = new JPanel(new BorderLayout());
1195
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1272
+
1273
+ if (Globals.ADVANCED)
1274
+ {
1275
+ timelinePanel = new JPanel(new BorderLayout());
1276
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11961277
11971278 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11981279 cameraPanel.setContinuousLayout(true);
....@@ -1201,7 +1282,10 @@
12011282 // cameraPanel.setDividerSize(9);
12021283 cameraPanel.setResizeWeight(1.0);
12031284
1285
+ }
1286
+
12041287 centralPanel.add(cameraView);
1288
+ centralPanel.setFocusable(true);
12051289 //frame.setJMenuBar(timelineMenubar);
12061290 //centralPanel.add(timelinePanel);
12071291
....@@ -1268,7 +1352,7 @@
12681352 // north.setName("Edit");
12691353 // north.add(ctrlPanel, BorderLayout.NORTH);
12701354 // objectPanel.add(north);
1271
- objectPanel.add(ctrlPanel);
1355
+ objectPanel.add(editPanel);
12721356 objectPanel.add(infoPanel);
12731357
12741358 /*
....@@ -1290,7 +1374,7 @@
12901374 scrollpane.addMouseWheelListener(this); // Default not fast enough
12911375
12921376 /*JTabbedPane*/ scenePanel = new cGridBag();
1293
- scenePanel.preferredWidth = 7;
1377
+ scenePanel.preferredWidth = 6;
12941378
12951379 JTabbedPane tabbedPane = new JTabbedPane();
12961380 tabbedPane.add(scrollpane);
....@@ -1396,9 +1480,11 @@
13961480
13971481 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13981482
1399
- frame.setSize(1024, 768);
1400
- frame.show();
1483
+ frame.setSize(1280, 860);
1484
+ frame.setVisible(true);
14011485
1486
+ cameraView.requestFocusInWindow();
1487
+
14021488 gridPanel.setDividerLocation(1.0);
14031489
14041490 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -1436,17 +1522,25 @@
14361522
14371523 cGridBag editBar = new cGridBag().setVertical(false);
14381524
1439
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
1525
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1526
+ createMaterialButton.setToolTipText("Create material");
14401527
14411528 /*
14421529 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14431530 */
14441531
1445
- editBar.add(clearMaterialButton = new cButton("Clear")); // , aConstraints);
1446
- editBar.add(resetSlidersButton = new cButton("Reset")); // , aConstraints);
1447
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1448
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1532
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1533
+ clearMaterialButton.setToolTipText("Clear material");
1534
+
1535
+ if (Globals.ADVANCED)
1536
+ {
1537
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1538
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1539
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1540
+ }
14491541
1542
+ editBar.preferredHeight = 15;
1543
+
14501544 panel.add(editBar);
14511545
14521546 /**/
....@@ -1712,12 +1806,15 @@
17121806 opacityPowerField.addChangeListener(this);
17131807 /**/
17141808
1715
- resetSlidersButton.addActionListener(this);
17161809 clearMaterialButton.addActionListener(this);
17171810 createMaterialButton.addActionListener(this);
1718
-
1719
- propagateToggle.addItemListener(this);
1720
- multiplyToggle.addItemListener(this);
1811
+
1812
+ if (Globals.ADVANCED)
1813
+ {
1814
+ resetSlidersButton.addActionListener(this);
1815
+ propagateToggle.addItemListener(this);
1816
+ multiplyToggle.addItemListener(this);
1817
+ }
17211818 }
17221819
17231820 void DropFile(java.io.File[] files, boolean textures)
....@@ -1888,7 +1985,7 @@
18881985
18891986 //? flashIt = false;
18901987 CameraPane pane = (CameraPane) cameraView;
1891
- pane.clickStart(location.x, location.y, 0);
1988
+ pane.clickStart(location.x, location.y, 0, 0);
18921989 pane.clickEnd(location.x, location.y, 0, true);
18931990
18941991 if (group.selection.size() == 1)
....@@ -1937,6 +2034,7 @@
19372034 e2.printStackTrace();
19382035 }
19392036 }
2037
+
19402038 LoadJMEThread loadThread;
19412039
19422040 class LoadJMEThread extends Thread
....@@ -1994,6 +2092,7 @@
19942092 //LoadFile0(filename, converter);
19952093 }
19962094 }
2095
+
19972096 LoadOBJThread loadObjThread;
19982097
19992098 class LoadOBJThread extends Thread
....@@ -2072,19 +2171,19 @@
20722171
20732172 void LoadObjFile(String fullname)
20742173 {
2075
- /*
2174
+ System.out.println("Loading " + fullname);
2175
+ /**/
20762176 //lastFilename = fullname;
20772177 if(loadObjThread == null)
20782178 {
2079
- loadObjThread = new LoadOBJThread();
2080
- loadObjThread.start();
2179
+ loadObjThread = new LoadOBJThread();
2180
+ loadObjThread.start();
20812181 }
20822182
20832183 loadObjThread.add(fullname);
2084
- */
2184
+ /**/
20852185
2086
- System.out.println("Loading " + fullname);
2087
- makeSomething(new FileObject(fullname, true), true);
2186
+ //makeSomething(new FileObject(fullname, true), true);
20882187 }
20892188
20902189 void LoadGFDFile(String fullname)
....@@ -2345,11 +2444,11 @@
23452444
23462445 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23472446 {
2348
- if (GrafreeD.standAlone)
2447
+ if (Grafreed.standAlone)
23492448 {
23502449 /**/
23512450 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2352
- browser.show();
2451
+ browser.setVisible(true);
23532452 String filename = browser.getFile();
23542453 if (filename != null && filename.length() > 0)
23552454 {
....@@ -2709,7 +2808,8 @@
27092808 return;
27102809 }
27112810
2712
- multiplyToggle.setSelected(mat.multiply);
2811
+ if (multiplyToggle != null)
2812
+ multiplyToggle.setSelected(mat.multiply);
27132813
27142814 assert (object.projectedVertices != null);
27152815
....@@ -2924,9 +3024,9 @@
29243024 frame.validate();
29253025
29263026 return;
2927
- } else if (event.getSource() == toggleRandomItem)
3027
+ } else if (event.getSource() == toggleSwitchItem)
29283028 {
2929
- cameraView.ToggleRandom();
3029
+ cameraView.ToggleSwitch();
29303030 cameraView.repaint();
29313031 return;
29323032 } else if (event.getSource() == toggleHandleItem)
....@@ -2955,6 +3055,10 @@
29553055 {
29563056 copy.live ^= true;
29573057 return;
3058
+ } else if (event.getSource() == selectCB)
3059
+ {
3060
+ copy.dontselect ^= true;
3061
+ return;
29583062 } else if (event.getSource() == hideCB)
29593063 {
29603064 copy.hide ^= true;
....@@ -2969,6 +3073,7 @@
29693073 if (event.getSource() == randomCB)
29703074 {
29713075 copy.random ^= true;
3076
+ objEditor.refreshContents();
29723077 return;
29733078 }
29743079 if (event.getSource() == speedupCB)
....@@ -2992,8 +3097,9 @@
29923097
29933098 public void actionPerformed(ActionEvent event)
29943099 {
3100
+ Object source = event.getSource();
29953101 // SCRIPT DIALOG
2996
- if (event.getSource() == okbutton)
3102
+ if (source == okbutton)
29973103 {
29983104 textpanel.setVisible(false);
29993105 textpanel.remove(textarea);
....@@ -3005,7 +3111,7 @@
30053111 textarea = null;
30063112 textpanel = null;
30073113 }
3008
- if (event.getSource() == cancelbutton)
3114
+ if (source == cancelbutton)
30093115 {
30103116 textpanel.setVisible(false);
30113117 textpanel.remove(textarea);
....@@ -3017,50 +3123,50 @@
30173123 //applySelf();
30183124 //client.refreshEditWindow();
30193125 //refreshContents();
3020
- if (event.getSource() == nameField)
3126
+ if (source == nameField)
30213127 {
30223128 //System.out.println("ObjEditor " + event);
30233129 applySelf0(true);
30243130 //parent.applySelf();
30253131 objEditor.refreshContents();
3026
- } else if (event.getSource() == resetButton)
3132
+ } else if (source == resetButton)
30273133 {
30283134 CameraPane.fullreset = true;
30293135 copy.Reset(); // ResetMeshes();
30303136 copy.Touch();
30313137 objEditor.refreshContents();
3032
- } else if (event.getSource() == stepItem)
3138
+ } else if (source == stepItem)
30333139 {
30343140 //cameraView.ONESTEP = true;
30353141 Globals.ONESTEP = true;
30363142 cameraView.repaint();
30373143 return;
3038
- } else if (event.getSource() == stepButton)
3144
+ } else if (source == stepButton)
30393145 {
30403146 copy.Step();
30413147 copy.Touch();
30423148 objEditor.refreshContents();
3043
- } else if (event.getSource() == slowerButton)
3149
+ } else if (source == slowerButton)
30443150 {
30453151 copy.Slower();
30463152 copy.Touch();
30473153 objEditor.refreshContents();
3048
- } else if (event.getSource() == fasterButton)
3154
+ } else if (source == fasterButton)
30493155 {
30503156 copy.Faster();
30513157 copy.Touch();
30523158 objEditor.refreshContents();
3053
- } else if (event.getSource() == remarkButton)
3159
+ } else if (source == remarkButton)
30543160 {
30553161 copy.Remark();
30563162 copy.Touch();
30573163 objEditor.refreshContents();
3058
- } else if (event.getSource() == stepAllButton)
3164
+ } else if (source == stepAllButton)
30593165 {
30603166 copy.StepAll();
30613167 copy.Touch();
30623168 objEditor.refreshContents();
3063
- } else if (event.getSource() == resetAllButton)
3169
+ } else if (source == resetAllButton)
30643170 {
30653171 //CameraPane.fullreset = true;
30663172 copy.ResetAll(); // ResetMeshes();
....@@ -3093,53 +3199,75 @@
30933199 // Close();
30943200 // }
30953201 // else
3096
- if (event.getSource() == resetSlidersButton)
3202
+ if (source == resetSlidersButton)
30973203 {
30983204 ResetSliders();
3099
- } else if (event.getSource() == clearMaterialButton)
3205
+ } else if (source == clearMaterialButton)
31003206 {
31013207 ClearMaterial();
3102
- } else if (event.getSource() == createMaterialButton)
3208
+ } else if (source == createMaterialButton)
31033209 {
31043210 CreateMaterial();
3105
- } else if (event.getSource() == clearPanelButton)
3211
+ } else if (source == clearPanelButton)
31063212 {
31073213 copy.ClearUI();
31083214 refreshContents(true);
3109
- } /*
3110
- }
3111
-
3112
- public boolean action(Event event, Object arg)
3113
- {
3114
- */ else if (event.getSource() == closeItem)
3215
+ } else if (source == importGFDItem)
3216
+ {
3217
+ ImportGFD();
3218
+ } else
3219
+ if (source == importVRMLX3DItem)
3220
+ {
3221
+ ImportVRMLX3D();
3222
+ } else
3223
+ if (source == import3DSItem)
3224
+ {
3225
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3226
+ } else
3227
+ if (source == importOBJItem)
3228
+ {
3229
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3230
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3231
+ browser.setVisible(true);
3232
+ String filename = browser.getFile();
3233
+ if (filename != null && filename.length() > 0)
3234
+ {
3235
+ String fullname = browser.getDirectory() + filename;
3236
+ makeSomething(ReadOBJ(fullname), true);
3237
+ }
3238
+ } else
3239
+ if (source == closeItem)
31153240 {
31163241 Close();
31173242 //return true;
3118
- } else if (event.getSource() == loadItem)
3243
+ } else if (source == loadItem)
31193244 {
31203245 load();
31213246 //return true;
3122
- } else if (event.getSource() == saveItem)
3247
+ } else if (source == newItem)
3248
+ {
3249
+ New();
3250
+ } else if (source == saveItem)
31233251 {
31243252 save();
31253253 //return true;
3126
- } else if (event.getSource() == saveAsItem)
3254
+ } else if (source == saveAsItem)
31273255 {
31283256 saveAs();
31293257 //return true;
3130
- } else if (event.getSource() == reexportItem)
3258
+ } else if (source == reexportItem)
31313259 {
31323260 reexport();
31333261 //return true;
3134
- } else if (event.getSource() == exportAsItem)
3262
+ } else if (source == exportAsItem)
31353263 {
31363264 export();
31373265 //return true;
3138
- } else if (event.getSource() == povItem)
3266
+ } else if (source == povItem)
31393267 {
31403268 generatePOV();
31413269 //return true;
3142
- } else if (event.getSource() == zBufferItem)
3270
+ } else if (source == zBufferItem)
31433271 {
31443272 try
31453273 {
....@@ -3161,21 +3289,8 @@
31613289 cameraView.repaint();
31623290 //return true;
31633291 }
3164
- */ else if (event.getSource() == editCameraItem)
3165
- {
3166
- cameraView.ProtectCamera();
3167
- cameraView.repaint();
3168
- return;
3169
- } else if (event.getSource() == revertCameraItem)
3170
- {
3171
- cameraView.RevertCamera();
3172
- cameraView.repaint();
3173
- return;
3174
-// } else if (event.getSource() == textureButton)
3175
-// {
3176
-// return; // true;
3177
- } else // combos...
3178
- if (event.getSource() == texresMenu)
3292
+ */ else // combos...
3293
+ if (source == texresMenu)
31793294 {
31803295 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31813296 copy.texres = texresMenu.getSelectedIndex();
....@@ -3187,12 +3302,268 @@
31873302 }
31883303 }
31893304
3305
+ void New()
3306
+ {
3307
+ while (copy.Size() > 1)
3308
+ {
3309
+ copy.remove(1);
3310
+ }
3311
+
3312
+ ResetModel();
3313
+ objEditor.refreshContents();
3314
+ }
3315
+
3316
+ static public byte[] Compress(Object3D o)
3317
+ {
3318
+ try
3319
+ {
3320
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3321
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3322
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3323
+
3324
+ Object3D parent = o.parent;
3325
+ o.parent = null;
3326
+
3327
+ out.writeObject(o);
3328
+
3329
+ o.parent = parent;
3330
+
3331
+ out.flush();
3332
+
3333
+ zstream.close();
3334
+ out.close();
3335
+
3336
+ return baos.toByteArray();
3337
+ } catch (Exception e)
3338
+ {
3339
+ System.err.println(e);
3340
+ return null;
3341
+ }
3342
+ }
3343
+
3344
+ static public Object Uncompress(byte[] bytes)
3345
+ {
3346
+ System.out.println("#bytes = " + bytes.length);
3347
+ try
3348
+ {
3349
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3350
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3351
+ ObjectInputStream in = new ObjectInputStream(istream);
3352
+ Object obj = in.readObject();
3353
+ in.close();
3354
+
3355
+ return obj;
3356
+ } catch (Exception e)
3357
+ {
3358
+ System.err.println(e);
3359
+ return null;
3360
+ }
3361
+ }
3362
+
3363
+ static public Object clone(Object o)
3364
+ {
3365
+ try
3366
+ {
3367
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3368
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3369
+
3370
+ out.writeObject(o);
3371
+
3372
+ out.flush();
3373
+ out.close();
3374
+
3375
+ byte[] bytes = baos.toByteArray();
3376
+
3377
+ System.out.println("clone = " + bytes.length);
3378
+
3379
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3380
+ ObjectInputStream in = new ObjectInputStream(bais);
3381
+ Object obj = in.readObject();
3382
+ in.close();
3383
+
3384
+ return obj;
3385
+ } catch (Exception e)
3386
+ {
3387
+ System.err.println(e);
3388
+ return null;
3389
+ }
3390
+ }
3391
+
3392
+ cRadio GetCurrentTab()
3393
+ {
3394
+ cRadio ab;
3395
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3396
+ {
3397
+ ab = (cRadio)e.nextElement();
3398
+ if(ab.GetObject() == copy)
3399
+ {
3400
+ return ab;
3401
+ }
3402
+ }
3403
+
3404
+ return null;
3405
+ }
3406
+
3407
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3408
+
3409
+ public void Save()
3410
+ {
3411
+ cRadio tab = GetCurrentTab();
3412
+
3413
+ boolean temp = CameraPane.SWITCH;
3414
+ CameraPane.SWITCH = false;
3415
+
3416
+ copy.ExtractBigData(hashtable);
3417
+
3418
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3419
+ tab.graphs[tab.undoindex++] = Compress(copy);
3420
+
3421
+ copy.RestoreBigData(hashtable);
3422
+
3423
+ CameraPane.SWITCH = temp;
3424
+
3425
+ //assert(hashtable.isEmpty());
3426
+
3427
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3428
+ {
3429
+ tab.graphs[i] = null;
3430
+ }
3431
+
3432
+ // test save
3433
+ if (false)
3434
+ {
3435
+ try
3436
+ {
3437
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3438
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3439
+
3440
+ p.writeObject(copy);
3441
+
3442
+ p.flush();
3443
+
3444
+ ostream.close();
3445
+ } catch (Exception e)
3446
+ {
3447
+ e.printStackTrace();
3448
+ }
3449
+ }
3450
+ }
3451
+
3452
+ void CopyChanged(Object3D obj)
3453
+ {
3454
+ boolean temp = CameraPane.SWITCH;
3455
+ CameraPane.SWITCH = false;
3456
+
3457
+ copy.ExtractBigData(hashtable);
3458
+
3459
+ copy.clear();
3460
+
3461
+ for (int i=0; i<obj.Size(); i++)
3462
+ {
3463
+ copy.add(obj.get(i));
3464
+ }
3465
+
3466
+ copy.RestoreBigData(hashtable);
3467
+
3468
+ CameraPane.SWITCH = temp;
3469
+
3470
+ //assert(hashtable.isEmpty());
3471
+
3472
+ copy.Touch();
3473
+
3474
+ ResetModel();
3475
+ copy.HardTouch(); // recompile?
3476
+
3477
+ cRadio ab;
3478
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3479
+ {
3480
+ ab = (cRadio)e.nextElement();
3481
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3482
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3483
+ if (test != null)
3484
+ {
3485
+ test.editWindow = ab.object.editWindow;
3486
+ ab.object = test;
3487
+ }
3488
+ }
3489
+
3490
+ refreshContents();
3491
+ }
3492
+
3493
+ public void Undo()
3494
+ {
3495
+ cRadio tab = GetCurrentTab();
3496
+
3497
+ if (tab.undoindex == 0)
3498
+ {
3499
+ java.awt.Toolkit.getDefaultToolkit().beep();
3500
+ return;
3501
+ }
3502
+
3503
+ if (tab.graphs[tab.undoindex] == null)
3504
+ {
3505
+ Save();
3506
+ tab.undoindex -= 1;
3507
+ }
3508
+
3509
+ tab.undoindex -= 1;
3510
+
3511
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3512
+ }
3513
+
3514
+ public void Redo()
3515
+ {
3516
+ cRadio tab = GetCurrentTab();
3517
+
3518
+ if (tab.graphs[tab.undoindex + 1] == null)
3519
+ {
3520
+ java.awt.Toolkit.getDefaultToolkit().beep();
3521
+ return;
3522
+ }
3523
+
3524
+ tab.undoindex += 1;
3525
+
3526
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3527
+ }
3528
+
3529
+ void ImportGFD()
3530
+ {
3531
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3532
+ browser.show();
3533
+ String filename = browser.getFile();
3534
+ if (filename != null && filename.length() > 0)
3535
+ {
3536
+ String fullname = browser.getDirectory() + filename;
3537
+
3538
+ //Object3D readobj =
3539
+ objEditor.ReadGFD(fullname, objEditor);
3540
+ //makeSomething(readobj);
3541
+ }
3542
+ }
3543
+
3544
+ void ImportVRMLX3D()
3545
+ {
3546
+ if (Grafreed.standAlone)
3547
+ {
3548
+ /**/
3549
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3550
+ browser.show();
3551
+ String filename = browser.getFile();
3552
+ if (filename != null && filename.length() > 0)
3553
+ {
3554
+ String fullname = browser.getDirectory() + filename;
3555
+ LoadVRMLX3D(fullname);
3556
+ }
3557
+ /**/
3558
+ }
3559
+ }
3560
+
31903561 void ToggleAnimation()
31913562 {
31923563 if (!Globals.ANIMATION)
31933564 {
31943565 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3195
- browser.show();
3566
+ browser.setVisible(true);
31963567 String filename = browser.getFile();
31973568 if (filename != null && filename.length() > 0)
31983569 {
....@@ -3202,8 +3573,8 @@
32023573
32033574 Globals.ANIMATION ^= true;
32043575
3205
- GrafreeD.wav.cursor = 0;
3206
- GrafreeD.wav.loop = 0;
3576
+ Grafreed.wav.cursor = 0;
3577
+ Grafreed.wav.loop = 0;
32073578 }
32083579 } else
32093580 {
....@@ -3224,7 +3595,6 @@
32243595 callee.refreshContents();
32253596 } else
32263597 {
3227
- new Exception().printStackTrace();
32283598 System.exit(0);
32293599 }
32303600 }
....@@ -3254,7 +3624,7 @@
32543624 void CreateMaterial()
32553625 {
32563626 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
3627
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32583628 if (copy.selection.size() > 0)
32593629 //SetMaterial(copy);
32603630 {
....@@ -3313,11 +3683,11 @@
33133683 {
33143684 copy.ResetBlockLoop(); // temporary problem
33153685
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
3686
+ boolean random = CameraPane.SWITCH;
3687
+ CameraPane.SWITCH = false; // parse everything
33183688 copy.ResetDisplayList();
33193689 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
3690
+ CameraPane.SWITCH = random;
33213691 }
33223692
33233693 // public void applySelf()
....@@ -3391,6 +3761,36 @@
33913761 {
33923762 //System.out.println("Propagate = " + propagate);
33933763 copy.UpdateMaterial(anchor, current, propagate);
3764
+
3765
+ if (copy.material != null)
3766
+ {
3767
+ cMaterial mat = copy.material;
3768
+
3769
+ colorField.SetToolTipValue((mat.color));
3770
+ modulationField.SetToolTipValue((mat.modulation));
3771
+ metalnessField.SetToolTipValue((mat.metalness));
3772
+ diffuseField.SetToolTipValue((mat.diffuse));
3773
+ specularField.SetToolTipValue((mat.specular));
3774
+ shininessField.SetToolTipValue((mat.shininess));
3775
+ shiftField.SetToolTipValue((mat.shift));
3776
+ ambientField.SetToolTipValue((mat.ambient));
3777
+ lightareaField.SetToolTipValue((mat.lightarea));
3778
+ diffusenessField.SetToolTipValue((mat.factor));
3779
+ velvetField.SetToolTipValue((mat.velvet));
3780
+ sheenField.SetToolTipValue((mat.sheen));
3781
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3782
+ backlitField.SetToolTipValue((mat.bump));
3783
+ anisoField.SetToolTipValue((mat.aniso));
3784
+ anisoVField.SetToolTipValue((mat.anisoV));
3785
+ cameraField.SetToolTipValue((mat.cameralight));
3786
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3787
+ shadowField.SetToolTipValue((mat.shadow));
3788
+ textureField.SetToolTipValue((mat.texture));
3789
+ opacityField.SetToolTipValue((mat.opacity));
3790
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3791
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3792
+ }
3793
+
33943794 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33953795 {
33963796 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3506,7 +3906,7 @@
35063906 }
35073907
35083908 if (normalpushField != null)
3509
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3909
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35103910 }
35113911
35123912 void SnapObject()
....@@ -3770,6 +4170,7 @@
37704170
37714171 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37724172 {
4173
+ Save();
37734174 //Tween.set(thing, 0).target(1).start(tweenManager);
37744175 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37754176 // if (thing instanceof GenericJointDemo)
....@@ -3973,6 +4374,7 @@
39734374 }
39744375 }
39754376 }
4377
+
39764378 LoadGFDThread loadGFDThread;
39774379
39784380 void ReadGFD(String fullname, iCallBack cb)
....@@ -3992,8 +4394,10 @@
39924394
39934395 try
39944396 {
4397
+ // Try compressed version first.
39954398 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3996
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4399
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4400
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39974401
39984402 readobj = (Object3D) p.readObject();
39994403 istream.close();
....@@ -4001,7 +4405,20 @@
40014405 readobj.ResetDisplayList();
40024406 } catch (Exception e)
40034407 {
4004
- e.printStackTrace();
4408
+ //e.printStackTrace();
4409
+ try
4410
+ {
4411
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4412
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4413
+
4414
+ readobj = (Object3D) p.readObject();
4415
+ istream.close();
4416
+
4417
+ readobj.ResetDisplayList();
4418
+ } catch (Exception e2)
4419
+ {
4420
+ e2.printStackTrace();
4421
+ }
40054422 }
40064423 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40074424 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4047,6 +4464,12 @@
40474464
40484465 void LoadIt(Object obj)
40494466 {
4467
+ if (obj == null)
4468
+ {
4469
+ // Invalid file
4470
+ return;
4471
+ }
4472
+
40504473 System.out.println("Loaded " + obj);
40514474 //new Exception().printStackTrace();
40524475 Object3D readobj = (Object3D) obj;
....@@ -4056,6 +4479,7 @@
40564479
40574480 if (readobj != null)
40584481 {
4482
+ Save();
40594483 try
40604484 {
40614485 //readobj.deepCopySelf(copy);
....@@ -4118,7 +4542,7 @@
41184542
41194543 void load() // throws ClassNotFoundException
41204544 {
4121
- if (GrafreeD.standAlone)
4545
+ if (Grafreed.standAlone)
41224546 {
41234547 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41244548 browser.show();
....@@ -4205,11 +4629,13 @@
42054629 try
42064630 {
42074631 FileOutputStream ostream = new FileOutputStream(lastname);
4208
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4632
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4633
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42094634
42104635 p.writeObject(copy);
42114636 p.flush();
42124637
4638
+ zstream.close();
42134639 ostream.close();
42144640
42154641 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4219,11 +4645,12 @@
42194645 {
42204646 }
42214647 }
4648
+
42224649 String lastname;
42234650
42244651 void saveAs()
42254652 {
4226
- if (GrafreeD.standAlone)
4653
+ if (Grafreed.standAlone)
42274654 {
42284655 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42294656 browser.setVisible(true);
....@@ -4328,13 +4755,13 @@
43284755 try
43294756 {
43304757 FileOutputStream ostream = new FileOutputStream(filename);
4331
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4332
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4758
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4759
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43334760
43344761 Object3D objectparent = obj.parent;
43354762 obj.parent = null;
43364763
4337
- Object3D object = (Object3D) GrafreeD.clone(obj);
4764
+ Object3D object = (Object3D) Grafreed.clone(obj);
43384765
43394766 obj.parent = objectparent;
43404767
....@@ -4346,8 +4773,8 @@
43464773 p.writeObject(object);
43474774 p.flush();
43484775
4776
+ zstream.close();
43494777 ostream.close();
4350
- // zstream.close();
43514778
43524779 // group.selection.get(0).parent = parent;
43534780 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4368,7 +4795,7 @@
43684795 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43694796 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43704797 copy.generatePOV(buffer);
4371
- if (GrafreeD.standAlone)
4798
+ if (Grafreed.standAlone)
43724799 {
43734800 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43744801 browser.show();
....@@ -4394,7 +4821,8 @@
43944821 Object3D client;
43954822 Object3D copy;
43964823 MenuBar menuBar;
4397
- Menu windowMenu;
4824
+ Menu fileMenu;
4825
+ MenuItem newItem;
43984826 MenuItem loadItem;
43994827 MenuItem saveItem;
44004828 MenuItem saveAsItem;
....@@ -4402,11 +4830,9 @@
44024830 MenuItem reexportItem;
44034831 MenuItem povItem;
44044832 MenuItem closeItem;
4405
- Menu cameraMenu;
4833
+
44064834 CheckboxMenuItem zBufferItem;
44074835 //MenuItem normalLensItem;
4408
- MenuItem editCameraItem;
4409
- MenuItem revertCameraItem;
44104836 MenuItem stepItem;
44114837 CheckboxMenuItem toggleLiveItem;
44124838 CheckboxMenuItem toggleFullScreenItem;
....@@ -4417,7 +4843,7 @@
44174843 CheckboxMenuItem toggleFootContactItem;
44184844 CheckboxMenuItem toggleDLItem;
44194845 CheckboxMenuItem toggleTextureItem;
4420
- CheckboxMenuItem toggleRandomItem;
4846
+ CheckboxMenuItem toggleSwitchItem;
44214847 CheckboxMenuItem toggleRootItem;
44224848 CheckboxMenuItem animationItem;
44234849 CheckboxMenuItem toggleHandleItem;
....@@ -4425,7 +4851,7 @@
44254851 JSplitPane mainPanel;
44264852 JScrollPane scrollpane;
44274853 JPanel toolbarPanel;
4428
- JPanel treePanel;
4854
+ cGridBag treePanel;
44294855 JPanel radioPanel;
44304856 ButtonGroup buttonGroup;
44314857 cGridBag ctrlPanel;
....@@ -4554,4 +4980,9 @@
45544980 //ObjectUI parent;
45554981
45564982 cNumberSlider normalpushField;
4983
+
4984
+ private MenuItem importGFDItem;
4985
+ private MenuItem importVRMLX3DItem;
4986
+ private MenuItem import3DSItem;
4987
+ private MenuItem importOBJItem;
45574988 }