Normand Briere
2019-06-17 26b49d8e26625491f4a407a05e9bc9d72037f938
ObjEditor.java
....@@ -138,34 +138,41 @@
138138 public void closeUI()
139139 {
140140 //new Exception().printStackTrace();
141
- System.out.println("this = " + this);
142
- System.out.println("objEditor = " + objEditor);
141
+// System.out.println("this = " + this);
142
+// System.out.println("objEditor = " + objEditor);
143143 //nameField.removeActionListener(this);
144
- objEditor.ctrlPanel.remove(nameField);
144
+// objEditor.ctrlPanel.remove(nameField);
145
+
146
+ objEditor.ctrlPanel.remove(namePanel);
145147
146148 if (!GroupEditor.allparams)
147149 return;
148150
149
- objEditor.ctrlPanel.remove(liveCB);
150
- objEditor.ctrlPanel.remove(hideCB);
151
- objEditor.ctrlPanel.remove(markCB);
152
-
153
- objEditor.ctrlPanel.remove(randomCB);
154
- objEditor.ctrlPanel.remove(speedupCB);
155
- objEditor.ctrlPanel.remove(rewindCB);
156
-
157
- objEditor.ctrlPanel.remove(resetButton);
158
- objEditor.ctrlPanel.remove(stepButton);
159
-// objEditor.ctrlPanel.remove(stepAllButton);
160
-// objEditor.ctrlPanel.remove(resetAllButton);
161
- objEditor.ctrlPanel.remove(link2masterCB);
162
- //objEditor.ctrlPanel.remove(flipVCB);
163
- //objEditor.ctrlPanel.remove(texresMenu);
164
- objEditor.ctrlPanel.remove(slowerButton);
165
- objEditor.ctrlPanel.remove(fasterButton);
166
- objEditor.ctrlPanel.remove(remarkButton);
151
+// objEditor.ctrlPanel.remove(liveCB);
152
+// objEditor.ctrlPanel.remove(hideCB);
153
+// objEditor.ctrlPanel.remove(markCB);
154
+//
155
+// objEditor.ctrlPanel.remove(randomCB);
156
+// objEditor.ctrlPanel.remove(speedupCB);
157
+// objEditor.ctrlPanel.remove(rewindCB);
158
+//
159
+// objEditor.ctrlPanel.remove(resetButton);
160
+// objEditor.ctrlPanel.remove(stepButton);
161
+//// objEditor.ctrlPanel.remove(stepAllButton);
162
+//// objEditor.ctrlPanel.remove(resetAllButton);
163
+// objEditor.ctrlPanel.remove(link2masterCB);
164
+// //objEditor.ctrlPanel.remove(flipVCB);
165
+// //objEditor.ctrlPanel.remove(texresMenu);
166
+// objEditor.ctrlPanel.remove(slowerButton);
167
+// objEditor.ctrlPanel.remove(fasterButton);
168
+// objEditor.ctrlPanel.remove(remarkButton);
167169
168
- Remove(normalpushField);
170
+ objEditor.ctrlPanel.remove(setupPanel);
171
+ objEditor.ctrlPanel.remove(commandsPanel);
172
+ objEditor.ctrlPanel.remove(pushPanel);
173
+ //objEditor.ctrlPanel.remove(fillPanel);
174
+
175
+ //Remove(normalpushField);
169176 }
170177
171178 public ObjEditor GetEditor()
....@@ -269,24 +276,40 @@
269276 void SetupMenu()
270277 {
271278 frame.setMenuBar(menuBar = new MenuBar());
272
- menuBar.add(windowMenu = new Menu("File"));
273
- windowMenu.add(loadItem = new MenuItem("Load..."));
274
- windowMenu.add("-");
275
- windowMenu.add(saveItem = new MenuItem("Save"));
276
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
279
+ menuBar.add(fileMenu = new Menu("File"));
280
+ fileMenu.add(newItem = new MenuItem("New"));
281
+ fileMenu.add(loadItem = new MenuItem("Open..."));
282
+
283
+ //oe.menuBar.add(menu = new Menu("Include"));
284
+ Menu menu = new Menu("Import");
285
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
286
+ importOBJItem.addActionListener(this);
287
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
288
+ import3DSItem.addActionListener(this);
289
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
290
+ importVRMLX3DItem.addActionListener(this);
291
+ menu.add("-");
292
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
293
+ importGFDItem.addActionListener(this);
294
+ fileMenu.add(menu);
295
+ fileMenu.add("-");
296
+
297
+ fileMenu.add(saveItem = new MenuItem("Save"));
298
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
277299 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
278
- windowMenu.add("-");
279
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
280
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
281
- windowMenu.add("-");
300
+ fileMenu.add("-");
301
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
302
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
303
+ fileMenu.add("-");
282304 if (client.parent != null)
283305 {
284
- windowMenu.add(closeItem = new MenuItem("Close"));
306
+ fileMenu.add(closeItem = new MenuItem("Close"));
285307 } else
286308 {
287
- windowMenu.add(closeItem = new MenuItem("Exit"));
309
+ fileMenu.add(closeItem = new MenuItem("Exit"));
288310 }
289311
312
+ newItem.addActionListener(this);
290313 loadItem.addActionListener(this);
291314 saveItem.addActionListener(this);
292315 saveAsItem.addActionListener(this);
....@@ -295,79 +318,26 @@
295318 //povItem.addActionListener(this);
296319 closeItem.addActionListener(this);
297320
298
- menuBar.add(cameraMenu = new Menu("View"));
299
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
300
- //zBufferItem.addActionListener(this);
301
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
302
- //normalLensItem.addActionListener(this);
303
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
304
- revertCameraItem.addActionListener(this);
305
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
306
- toggleTimelineItem.addItemListener(this);
307
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
308
- toggleFullScreenItem.addItemListener(this);
309
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
310
- cameraMenu.add("-");
311
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
312
- toggleTextureItem.addItemListener(this);
313
- toggleTextureItem.setState(CameraPane.textureon);
314
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
315
- toggleLiveItem.addItemListener(this);
316
- toggleLiveItem.setState(Globals.isLIVE());
317
- cameraMenu.add(stepItem = new MenuItem("Step"));
318
- stepItem.addActionListener(this);
319
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
320
-// toggleDLItem.addItemListener(this);
321
-// toggleDLItem.setState(false);
322
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
323
- toggleRenderItem.addItemListener(this);
324
- toggleRenderItem.setState(!CameraPane.frozen);
325
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
326
- toggleDebugItem.addItemListener(this);
327
- toggleDebugItem.setState(CameraPane.DEBUG);
328
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
329
- toggleFrustumItem.addItemListener(this);
330
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
331
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
332
- toggleFootContactItem.addItemListener(this);
333
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
334
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
335
- toggleRandomItem.addItemListener(this);
336
- toggleRandomItem.setState(CameraPane.RANDOM);
337
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
338
- toggleHandleItem.addItemListener(this);
339
- toggleHandleItem.setState(CameraPane.HANDLES);
340
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
341
- togglePaintItem.addItemListener(this);
342
- togglePaintItem.setState(CameraPane.PAINTMODE);
343
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
344
-// toggleRootItem.addItemListener(this);
345
-// toggleRootItem.setState(false);
346
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
347
-// animationItem.addItemListener(this);
348
-// animationItem.setState(CameraPane.ANIMATION);
349
- cameraMenu.add("-");
350
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
351
- editCameraItem.addActionListener(this);
352
-
353321 objectPanel = new JTabbedPane();
354322 toolbarPanel = new JPanel();
355323 toolbarPanel.setName("Toolbar");
356
- treePanel = new JPanel();
324
+ treePanel = new cGridBag();
357325 treePanel.setName("Tree");
358
- ctrlPanel = new cGridBag(); // new GridBagLayout());
326
+ ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
359327 ctrlPanel.setName("Edit");
360328 materialPanel = new cGridBag().setVertical(true);
361329 materialPanel.setName("Material");
362330 /*JTextPane*/
363331 infoarea = createTextPane();
332
+ doc = infoarea.getStyledDocument();
333
+
364334 infoarea.setEditable(true);
365335 SetText();
366336 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
367337 // infoarea.setOpaque(false);
368338 // //infoarea.setForeground(textcolor);
369
- infoarea.setLineWrap(true);
370
- infoarea.setWrapStyleWord(true);
339
+// TEXTAREA infoarea.setLineWrap(true);
340
+// TEXTAREA infoarea.setWrapStyleWord(true);
371341 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
372342 infoPanel.setPreferredSize(new Dimension(50, 200));
373343 infoPanel.setName("Info");
....@@ -378,15 +348,15 @@
378348 mainPanel.setName("Main");
379349 mainPanel.setContinuousLayout(true);
380350 mainPanel.setOneTouchExpandable(true);
381
- mainPanel.setDividerLocation(1.0);
382351 mainPanel.setDividerSize(9);
383
- mainPanel.setResizeWeight(0);
352
+ mainPanel.setDividerLocation(0.5); //1.0);
353
+ mainPanel.setResizeWeight(0.5);
384354
385355 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
386356 //mainPanel.setLayout(new GridBagLayout());
387357 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
388
- treePanel.setLayout(new GridBagLayout());
389
- ctrlPanel.setLayout(new GridBagLayout());
358
+// treePanel.setLayout(new GridBagLayout());
359
+ //ctrlPanel.setLayout(new GridBagLayout());
390360 //materialPanel.setLayout(new GridBagLayout());
391361
392362 aConstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
....@@ -426,7 +396,7 @@
426396 static String newline = "\n";
427397 protected static final String buttonString = "JButton";
428398 StyledDocument doc;
429
- JTextArea infoarea;
399
+ JTextPane infoarea;
430400
431401 void ClearInfo()
432402 {
....@@ -449,10 +419,10 @@
449419 e.printStackTrace();
450420 }
451421
452
- String selection = infoarea.getText();
453
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
454
- java.awt.datatransfer.Clipboard clipboard =
455
- Toolkit.getDefaultToolkit().getSystemClipboard();
422
+// String selection = infoarea.getText();
423
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
424
+// java.awt.datatransfer.Clipboard clipboard =
425
+// Toolkit.getDefaultToolkit().getSystemClipboard();
456426 //clipboard.setContents(data, data);
457427 }
458428
....@@ -475,13 +445,13 @@
475445 //SendInfo("Name:", "bold");
476446 if (sel.GetTextures() != null || debug)
477447 {
478
- si.SendInfo(sel.toString(), "bold");
448
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
479449 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
480450 if (sel.Size() > 0)
481451 {
482452 si.SendInfo("#children = " + sel.Size(), "regular");
483453 }
484
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
454
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
485455 if (debug)
486456 {
487457 try
....@@ -493,7 +463,10 @@
493463 }
494464
495465 if (full)
496
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
466
+ {
467
+ si.SendInfo(" BBox min: " + minima, "regular");
468
+ si.SendInfo(" BBox max: " + maxima, "regular");
469
+ }
497470
498471 if (sel.bRep != null)
499472 {
....@@ -520,7 +493,7 @@
520493 }
521494 if (sel.support != null)
522495 {
523
- si.SendInfo(" support: " + sel.support, "regular");
496
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
524497 }
525498 if (sel.scriptnode != null)
526499 {
....@@ -591,6 +564,9 @@
591564 {
592565 CameraPane.pointflow = (PointFlow) sel;
593566 }
567
+
568
+ si.SendInfo("_____________________", "regular");
569
+ si.SendInfo("", "regular");
594570 }
595571 }
596572
....@@ -622,52 +598,52 @@
622598 cameraView.ToggleFullScreen();
623599 }
624600
625
- private JTextArea createTextPane()
601
+ private JTextPane createTextPane()
626602 {
627
- String[] initString =
628
- {
629
- "This is an editable JTextPane, ", //regular
630
- "another ", //italic
631
- "styled ", //bold
632
- "text ", //small
633
- "component, ", //large
634
- "which supports embedded components..." + newline,//regular
635
- " " + newline, //button
636
- "...and embedded icons..." + newline, //regular
637
- " ", //icon
638
- newline + "JTextPane is a subclass of JEditorPane that "
639
- + "uses a StyledEditorKit and StyledDocument, and provides "
640
- + "cover methods for interacting with those objects."
641
- };
603
+// TEXTAREA String[] initString =
604
+// {
605
+// "This is an editable JTextPane, ", //regular
606
+// "another ", //italic
607
+// "styled ", //bold
608
+// "text ", //small
609
+// "component, ", //large
610
+// "which supports embedded components..." + newline,//regular
611
+// " " + newline, //button
612
+// "...and embedded icons..." + newline, //regular
613
+// " ", //icon
614
+// newline + "JTextPane is a subclass of JEditorPane that "
615
+// + "uses a StyledEditorKit and StyledDocument, and provides "
616
+// + "cover methods for interacting with those objects."
617
+// };
618
+//
619
+// String[] initStyles =
620
+// {
621
+// "regular", "italic", "bold", "small", "large",
622
+// "regular", "button", "regular", "icon",
623
+// "regular"
624
+// };
625
+//
626
+// JTextPane textPane = new JTextPane();
627
+// textPane.setEditable(true);
628
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
629
+// addStylesToDocument(doc);
630
+//
631
+// try
632
+// {
633
+// for (int j = 0; j < 2; j++)
634
+// {
635
+// for (int i = 0; i < initString.length; i++)
636
+// {
637
+// doc.insertString(doc.getLength(), initString[i],
638
+// doc.getStyle(initStyles[i]));
639
+// }
640
+// }
641
+// } catch (BadLocationException ble)
642
+// {
643
+// System.err.println("Couldn't insert initial text into text pane.");
644
+// }
642645
643
- String[] initStyles =
644
- {
645
- "regular", "italic", "bold", "small", "large",
646
- "regular", "button", "regular", "icon",
647
- "regular"
648
- };
649
-
650
- JTextPane textPane = new JTextPane();
651
- textPane.setEditable(true);
652
- /*StyledDocument*/ doc = textPane.getStyledDocument();
653
- addStylesToDocument(doc);
654
-
655
- try
656
- {
657
- for (int j = 0; j < 2; j++)
658
- {
659
- for (int i = 0; i < initString.length; i++)
660
- {
661
- doc.insertString(doc.getLength(), initString[i],
662
- doc.getStyle(initStyles[i]));
663
- }
664
- }
665
- } catch (BadLocationException ble)
666
- {
667
- System.err.println("Couldn't insert initial text into text pane.");
668
- }
669
-
670
- return new JTextArea(); // textPane;
646
+ return new JTextPane(); // textPane;
671647 }
672648
673649 protected void addStylesToDocument(StyledDocument doc)
....@@ -720,7 +696,7 @@
720696 protected static ImageIcon createImageIcon(String path,
721697 String description)
722698 {
723
- java.net.URL imgURL = GrafreeD.class.getResource(path);
699
+ java.net.URL imgURL = Grafreed.class.getResource(path);
724700 if (imgURL != null)
725701 {
726702 return new ImageIcon(imgURL, description);
....@@ -752,6 +728,7 @@
752728 // NumberSlider vDivsField;
753729 // JCheckBox endcaps;
754730 JCheckBox liveCB;
731
+ JCheckBox selectCB;
755732 JCheckBox hideCB;
756733 JCheckBox link2masterCB;
757734 JCheckBox markCB;
....@@ -767,54 +744,44 @@
767744 JButton slowerButton;
768745 JButton fasterButton;
769746 JButton remarkButton;
747
+
748
+ cGridBag namePanel;
749
+ cGridBag setupPanel;
750
+ cGridBag commandsPanel;
751
+ cGridBag pushPanel;
752
+ cGridBag fillPanel;
770753
771
- JCheckBox AddCheckBox(ObjEditor oe, String label, boolean on)
754
+ JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
772755 {
773756 JCheckBox cb;
774757
775
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
776
- oe.aConstraints.gridwidth = 1; // 3;
777
-// oe.aConstraints.weightx = 1;
778
-// oe.aConstraints.anchor = GridBagConstraints.WEST;
779
- oe.ctrlPanel.add(cb = new JCheckBox(label, on), oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
758
+ panel.add(cb = new JCheckBox(label, on)); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
780759 cb.addItemListener(this);
781
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
782
- oe.aConstraints.gridwidth = 1;
783
- oe.aConstraints.gridx += 1;
784760
785761 return cb;
786762 }
787763
788
- cButton AddButton(ObjEditor oe, String label)
764
+ cButton AddButton(cGridBag panel, String label)
789765 {
790766 cButton cb;
791767
792
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
793
- oe.aConstraints.gridwidth = 1;
794
-// oe.aConstraints.weightx = 1;
795
-// oe.aConstraints.anchor = GridBagConstraints.WEST;
796
- oe.ctrlPanel.add(cb = new cButton(label), oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
768
+ panel.add(cb = new cButton(label)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
797769 cb.addActionListener(this);
798
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
799
- oe.aConstraints.gridwidth = 1;
800
- oe.aConstraints.gridx += 1;
801770
802771 return cb;
803772 }
804773
805
- JComboBox AddCombo(ObjEditor oe, java.util.Vector list, int item)
774
+ JComboBox AddCombo(cGridBag panel, java.util.Vector list, int item)
806775 {
807776 JComboBox combo;
808777
809
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
810
- oe.ctrlPanel.add(combo = new JComboBox(new cListModel(list, item)), oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
811
- oe.aConstraints.gridx += 1;
778
+ panel.add(combo = new JComboBox(new cListModel(list, item))); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
812779 combo.addActionListener(this);
813780
814781 return combo;
815782 }
816783
817
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, double min, double max, double current, double pow)
784
+ cGridBag AddSlider(cGridBag panel, String label, double min, double max, double current, double pow)
818785 {
819786 cGridBag control = new cGridBag();
820787
....@@ -826,12 +793,12 @@
826793 control.add(combo = new cNumberSlider(this, min, max, pow)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
827794 combo.setFloat(current);
828795
829
- ctrlPanel.add(control);
796
+ panel.add(control);
830797
831
- return combo;
798
+ return control;
832799 }
833800
834
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, int min, int max, int current)
801
+ cGridBag AddSlider(cGridBag panel, String label, int min, int max, int current)
835802 {
836803 cGridBag control = new cGridBag();
837804
....@@ -839,25 +806,21 @@
839806
840807 JLabel jlabel = new JLabel(label);
841808 jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
842
- ctrlPanel.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
843
- ctrlPanel.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
809
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
810
+ control.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
844811 combo.setInteger(current);
845812
846
- ctrlPanel.add(control);
813
+ panel.add(control);
847814
848
- return combo;
815
+ return control;
849816 }
850817
851818 JTextArea AddText(cGridBag ctrlPanel, String name)
852819 {
853820 JTextArea text;
854821
855
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
856
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
857822 ctrlPanel.add(text = new JTextArea(name)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
858823 text.addCaretListener(this);
859
- aConstraints.gridx += 1;
860
- aConstraints.gridwidth = 1;
861824
862825 return text;
863826 }
....@@ -896,7 +859,7 @@
896859
897860 /*
898861 */
899
- void Return() // ObjEditor oe)
862
+ void Return0() // ObjEditor oe)
900863 {
901864 aConstraints.gridy += 1;
902865 aConstraints.gridx = 0;
....@@ -951,37 +914,72 @@
951914
952915 void SetupUI2(ObjEditor oe)
953916 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
958
- SetupName(oe);
917
+ //SetupName(oe);
918
+
919
+ namePanel = new cGridBag();
920
+
921
+ nameField = AddText(namePanel, copy.GetName());
922
+ namePanel.add(nameField);
923
+ oe.ctrlPanel.add(namePanel);
924
+
925
+ oe.ctrlPanel.Return();
959926
960927 if (!GroupEditor.allparams)
961928 return;
962929
963
- liveCB = AddCheckBox(oe, "Live", copy.live);
964
- link2masterCB = AddCheckBox(oe, "Supp", copy.link2master);
965
- hideCB = AddCheckBox(oe, "Hide", copy.hide);
930
+ setupPanel = new cGridBag().setVertical(false);
931
+
932
+ liveCB = AddCheckBox(setupPanel, "Live", copy.live);
933
+ liveCB.setToolTipText("Animate object");
934
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
935
+ selectCB.setToolTipText("Make object selectable");
966936 // Return();
967
- markCB = AddCheckBox(oe, "Mark", copy.marked);
968
- rewindCB = AddCheckBox(oe, "Rew", copy.rewind);
969
- randomCB = AddCheckBox(oe, "Rand", copy.random);
970
- Return();
971
- resetButton = AddButton(oe, "Reset");
972
- stepButton = AddButton(oe, "Step");
937
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
938
+ hideCB.setToolTipText("Hide object");
939
+ markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
940
+ markCB.setToolTipText("Set the animation target transform");
941
+
942
+ rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
943
+ rewindCB.setToolTipText("Rewind animation");
944
+
945
+ randomCB = AddCheckBox(setupPanel, "Random", copy.random);
946
+ randomCB.setToolTipText("Option for switch node");
947
+
948
+ if (Globals.ADVANCED)
949
+ {
950
+ link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
951
+ link2masterCB.setToolTipText("Attach to support");
952
+ speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
953
+ speedupCB.setToolTipText("Option motion capture");
954
+ }
955
+
956
+ oe.ctrlPanel.add(setupPanel);
957
+ oe.ctrlPanel.Return();
958
+
959
+ commandsPanel = new cGridBag().setVertical(false);
960
+
961
+ resetButton = AddButton(commandsPanel, "Reset");
962
+ resetButton.setToolTipText("Jump to frame zero");
963
+ stepButton = AddButton(commandsPanel, "Step");
964
+ stepButton.setToolTipText("Step one frame");
973965 // resetAllButton = AddButton(oe, "Reset All");
974966 // stepAllButton = AddButton(oe, "Step All");
975
- speedupCB = AddCheckBox(oe, "Speed", copy.speedup);
976967 // Return();
977
- slowerButton = AddButton(oe, "Slow");
978
- fasterButton = AddButton(oe, "Fast");
979
- remarkButton = AddButton(oe, "Rem");
968
+ slowerButton = AddButton(commandsPanel, "Slow");
969
+ slowerButton.setToolTipText("Decrease animation speed");
970
+ fasterButton = AddButton(commandsPanel, "Fast");
971
+ fasterButton.setToolTipText("Increase animation speed");
972
+ remarkButton = AddButton(commandsPanel, "Remark");
973
+ remarkButton.setToolTipText("Set the current transform as the target");
980974
981
- //Return();
975
+ oe.ctrlPanel.add(commandsPanel);
976
+ oe.ctrlPanel.Return();
982977
983
- //normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1);
978
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
979
+ normalpushField = (cNumberSlider)pushPanel.getComponent(1);
984980 //Return();
981
+
982
+ oe.ctrlPanel.Return();
985983
986984 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
987985 // ObjEditor.aConstraints.gridx += 1;
....@@ -1076,7 +1074,7 @@
10761074 oe.aConstraints.gridwidth = 1;
10771075 /**/
10781076 nameField = AddText(oe.ctrlPanel, copy.GetName());
1079
- Return();
1077
+ oe.ctrlPanel.Return();
10801078
10811079 //ctrlPanel.add(textureButton = new Button("Texture..."));
10821080 //textureButton.setEnabled(false);
....@@ -1253,10 +1251,11 @@
12531251 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12541252 //tmp.setName("Edit");
12551253 objectPanel.add(materialPanel);
1256
- JPanel north = new JPanel(new BorderLayout());
1257
- north.setName("Edit");
1258
- north.add(ctrlPanel, BorderLayout.NORTH);
1259
- objectPanel.add(north);
1254
+// JPanel north = new JPanel(new BorderLayout());
1255
+// north.setName("Edit");
1256
+// north.add(ctrlPanel, BorderLayout.NORTH);
1257
+// objectPanel.add(north);
1258
+ objectPanel.add(ctrlPanel);
12601259 objectPanel.add(infoPanel);
12611260
12621261 /*
....@@ -1278,7 +1277,7 @@
12781277 scrollpane.addMouseWheelListener(this); // Default not fast enough
12791278
12801279 /*JTabbedPane*/ scenePanel = new cGridBag();
1281
- scenePanel.preferredWidth = 7;
1280
+ scenePanel.preferredWidth = 6;
12821281
12831282 JTabbedPane tabbedPane = new JTabbedPane();
12841283 tabbedPane.add(scrollpane);
....@@ -1384,8 +1383,8 @@
13841383
13851384 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13861385
1387
- frame.setSize(1024, 768);
1388
- frame.show();
1386
+ frame.setSize(1280, 860);
1387
+ frame.setVisible(true);
13891388
13901389 gridPanel.setDividerLocation(1.0);
13911390
....@@ -1415,7 +1414,7 @@
14151414 ctrlPanel.removeAll();
14161415 }
14171416
1418
- void SetupMaterial(cGridBag ctrlPanel)
1417
+ void SetupMaterial(cGridBag panel)
14191418 {
14201419 /*
14211420 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
....@@ -1424,18 +1423,26 @@
14241423
14251424 cGridBag editBar = new cGridBag().setVertical(false);
14261425
1427
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
1426
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1427
+ createMaterialButton.setToolTipText("Create material");
14281428
14291429 /*
14301430 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14311431 */
14321432
1433
- editBar.add(clearMaterialButton = new cButton("Clear")); // , aConstraints);
1434
- editBar.add(resetSlidersButton = new cButton("Reset")); // , aConstraints);
1435
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1436
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1433
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1434
+ clearMaterialButton.setToolTipText("Clear material");
1435
+
1436
+ if (Globals.ADVANCED)
1437
+ {
1438
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1439
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1440
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1441
+ }
14371442
1438
- ctrlPanel.add(editBar);
1443
+ editBar.preferredHeight = 15;
1444
+
1445
+ panel.add(editBar);
14391446
14401447 /**/
14411448 //aConstraints.weighty = 0;
....@@ -1484,9 +1491,9 @@
14841491 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
14851492 colorSection.add(shadowbias);
14861493
1487
- ctrlPanel.add(new JSeparator());
1494
+ panel.add(new JSeparator());
14881495
1489
- ctrlPanel.add(colorSection);
1496
+ panel.add(colorSection);
14901497
14911498 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14921499
....@@ -1534,9 +1541,9 @@
15341541 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15351542 diffuseSection.add(fakedepth);
15361543
1537
- ctrlPanel.add(new JSeparator());
1544
+ panel.add(new JSeparator());
15381545
1539
- ctrlPanel.add(diffuseSection);
1546
+ panel.add(diffuseSection);
15401547
15411548 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15421549
....@@ -1572,7 +1579,7 @@
15721579 velvet.add(velvetField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15731580 specularSection.add(velvet);
15741581
1575
- shiftField = AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1);
1582
+ shiftField = (cNumberSlider)AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1).getComponent(1);
15761583 //Return();
15771584 // ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
15781585 // shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
....@@ -1585,9 +1592,9 @@
15851592 // aConstraints.gridwidth = 1;
15861593
15871594
1588
- ctrlPanel.add(new JSeparator());
1595
+ panel.add(new JSeparator());
15891596
1590
- ctrlPanel.add(specularSection);
1597
+ panel.add(specularSection);
15911598
15921599 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15931600
....@@ -1617,9 +1624,9 @@
16171624 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16181625 globalSection.add(opacity);
16191626
1620
- ctrlPanel.add(new JSeparator());
1627
+ panel.add(new JSeparator());
16211628
1622
- ctrlPanel.add(globalSection);
1629
+ panel.add(globalSection);
16231630
16241631 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16251632
....@@ -1661,9 +1668,9 @@
16611668 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16621669 textureSection.add(opacityPower);
16631670
1664
- ctrlPanel.add(new JSeparator());
1671
+ panel.add(new JSeparator());
16651672
1666
- ctrlPanel.add(textureSection);
1673
+ panel.add(textureSection);
16671674
16681675 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16691676
....@@ -1700,12 +1707,15 @@
17001707 opacityPowerField.addChangeListener(this);
17011708 /**/
17021709
1703
- resetSlidersButton.addActionListener(this);
17041710 clearMaterialButton.addActionListener(this);
17051711 createMaterialButton.addActionListener(this);
1706
-
1707
- propagateToggle.addItemListener(this);
1708
- multiplyToggle.addItemListener(this);
1712
+
1713
+ if (Globals.ADVANCED)
1714
+ {
1715
+ resetSlidersButton.addActionListener(this);
1716
+ propagateToggle.addItemListener(this);
1717
+ multiplyToggle.addItemListener(this);
1718
+ }
17091719 }
17101720
17111721 void DropFile(java.io.File[] files, boolean textures)
....@@ -1876,7 +1886,7 @@
18761886
18771887 //? flashIt = false;
18781888 CameraPane pane = (CameraPane) cameraView;
1879
- pane.clickStart(location.x, location.y, 0);
1889
+ pane.clickStart(location.x, location.y, 0, 0);
18801890 pane.clickEnd(location.x, location.y, 0, true);
18811891
18821892 if (group.selection.size() == 1)
....@@ -1925,6 +1935,7 @@
19251935 e2.printStackTrace();
19261936 }
19271937 }
1938
+
19281939 LoadJMEThread loadThread;
19291940
19301941 class LoadJMEThread extends Thread
....@@ -1982,6 +1993,7 @@
19821993 //LoadFile0(filename, converter);
19831994 }
19841995 }
1996
+
19851997 LoadOBJThread loadObjThread;
19861998
19871999 class LoadOBJThread extends Thread
....@@ -2060,19 +2072,19 @@
20602072
20612073 void LoadObjFile(String fullname)
20622074 {
2063
- /*
2075
+ System.out.println("Loading " + fullname);
2076
+ /**/
20642077 //lastFilename = fullname;
20652078 if(loadObjThread == null)
20662079 {
2067
- loadObjThread = new LoadOBJThread();
2068
- loadObjThread.start();
2080
+ loadObjThread = new LoadOBJThread();
2081
+ loadObjThread.start();
20692082 }
20702083
20712084 loadObjThread.add(fullname);
2072
- */
2085
+ /**/
20732086
2074
- System.out.println("Loading " + fullname);
2075
- makeSomething(new FileObject(fullname, true), true);
2087
+ //makeSomething(new FileObject(fullname, true), true);
20762088 }
20772089
20782090 void LoadGFDFile(String fullname)
....@@ -2333,11 +2345,11 @@
23332345
23342346 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23352347 {
2336
- if (GrafreeD.standAlone)
2348
+ if (Grafreed.standAlone)
23372349 {
23382350 /**/
23392351 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2340
- browser.show();
2352
+ browser.setVisible(true);
23412353 String filename = browser.getFile();
23422354 if (filename != null && filename.length() > 0)
23432355 {
....@@ -2482,6 +2494,7 @@
24822494 }
24832495 if (input == null)
24842496 {
2497
+ new Exception().printStackTrace();
24852498 System.exit(0);
24862499 }
24872500
....@@ -2696,7 +2709,8 @@
26962709 return;
26972710 }
26982711
2699
- multiplyToggle.setSelected(mat.multiply);
2712
+ if (multiplyToggle != null)
2713
+ multiplyToggle.setSelected(mat.multiply);
27002714
27012715 assert (object.projectedVertices != null);
27022716
....@@ -2911,9 +2925,9 @@
29112925 frame.validate();
29122926
29132927 return;
2914
- } else if (event.getSource() == toggleRandomItem)
2928
+ } else if (event.getSource() == toggleSwitchItem)
29152929 {
2916
- cameraView.ToggleRandom();
2930
+ cameraView.ToggleSwitch();
29172931 cameraView.repaint();
29182932 return;
29192933 } else if (event.getSource() == toggleHandleItem)
....@@ -2942,6 +2956,10 @@
29422956 {
29432957 copy.live ^= true;
29442958 return;
2959
+ } else if (event.getSource() == selectCB)
2960
+ {
2961
+ copy.dontselect ^= true;
2962
+ return;
29452963 } else if (event.getSource() == hideCB)
29462964 {
29472965 copy.hide ^= true;
....@@ -2956,6 +2974,7 @@
29562974 if (event.getSource() == randomCB)
29572975 {
29582976 copy.random ^= true;
2977
+ objEditor.refreshContents();
29592978 return;
29602979 }
29612980 if (event.getSource() == speedupCB)
....@@ -2979,8 +2998,9 @@
29792998
29802999 public void actionPerformed(ActionEvent event)
29813000 {
3001
+ Object source = event.getSource();
29823002 // SCRIPT DIALOG
2983
- if (event.getSource() == okbutton)
3003
+ if (source == okbutton)
29843004 {
29853005 textpanel.setVisible(false);
29863006 textpanel.remove(textarea);
....@@ -2992,7 +3012,7 @@
29923012 textarea = null;
29933013 textpanel = null;
29943014 }
2995
- if (event.getSource() == cancelbutton)
3015
+ if (source == cancelbutton)
29963016 {
29973017 textpanel.setVisible(false);
29983018 textpanel.remove(textarea);
....@@ -3004,50 +3024,50 @@
30043024 //applySelf();
30053025 //client.refreshEditWindow();
30063026 //refreshContents();
3007
- if (event.getSource() == nameField)
3027
+ if (source == nameField)
30083028 {
30093029 //System.out.println("ObjEditor " + event);
30103030 applySelf0(true);
30113031 //parent.applySelf();
30123032 objEditor.refreshContents();
3013
- } else if (event.getSource() == resetButton)
3033
+ } else if (source == resetButton)
30143034 {
30153035 CameraPane.fullreset = true;
30163036 copy.Reset(); // ResetMeshes();
30173037 copy.Touch();
30183038 objEditor.refreshContents();
3019
- } else if (event.getSource() == stepItem)
3039
+ } else if (source == stepItem)
30203040 {
30213041 //cameraView.ONESTEP = true;
30223042 Globals.ONESTEP = true;
30233043 cameraView.repaint();
30243044 return;
3025
- } else if (event.getSource() == stepButton)
3045
+ } else if (source == stepButton)
30263046 {
30273047 copy.Step();
30283048 copy.Touch();
30293049 objEditor.refreshContents();
3030
- } else if (event.getSource() == slowerButton)
3050
+ } else if (source == slowerButton)
30313051 {
30323052 copy.Slower();
30333053 copy.Touch();
30343054 objEditor.refreshContents();
3035
- } else if (event.getSource() == fasterButton)
3055
+ } else if (source == fasterButton)
30363056 {
30373057 copy.Faster();
30383058 copy.Touch();
30393059 objEditor.refreshContents();
3040
- } else if (event.getSource() == remarkButton)
3060
+ } else if (source == remarkButton)
30413061 {
30423062 copy.Remark();
30433063 copy.Touch();
30443064 objEditor.refreshContents();
3045
- } else if (event.getSource() == stepAllButton)
3065
+ } else if (source == stepAllButton)
30463066 {
30473067 copy.StepAll();
30483068 copy.Touch();
30493069 objEditor.refreshContents();
3050
- } else if (event.getSource() == resetAllButton)
3070
+ } else if (source == resetAllButton)
30513071 {
30523072 //CameraPane.fullreset = true;
30533073 copy.ResetAll(); // ResetMeshes();
....@@ -3080,53 +3100,75 @@
30803100 // Close();
30813101 // }
30823102 // else
3083
- if (event.getSource() == resetSlidersButton)
3103
+ if (source == resetSlidersButton)
30843104 {
30853105 ResetSliders();
3086
- } else if (event.getSource() == clearMaterialButton)
3106
+ } else if (source == clearMaterialButton)
30873107 {
30883108 ClearMaterial();
3089
- } else if (event.getSource() == createMaterialButton)
3109
+ } else if (source == createMaterialButton)
30903110 {
30913111 CreateMaterial();
3092
- } else if (event.getSource() == clearPanelButton)
3112
+ } else if (source == clearPanelButton)
30933113 {
30943114 copy.ClearUI();
30953115 refreshContents(true);
3096
- } /*
3097
- }
3098
-
3099
- public boolean action(Event event, Object arg)
3100
- {
3101
- */ else if (event.getSource() == closeItem)
3116
+ } else if (source == importGFDItem)
3117
+ {
3118
+ ImportGFD();
3119
+ } else
3120
+ if (source == importVRMLX3DItem)
3121
+ {
3122
+ ImportVRMLX3D();
3123
+ } else
3124
+ if (source == import3DSItem)
3125
+ {
3126
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3127
+ } else
3128
+ if (source == importOBJItem)
3129
+ {
3130
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3131
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3132
+ browser.setVisible(true);
3133
+ String filename = browser.getFile();
3134
+ if (filename != null && filename.length() > 0)
3135
+ {
3136
+ String fullname = browser.getDirectory() + filename;
3137
+ makeSomething(ReadOBJ(fullname), true);
3138
+ }
3139
+ } else
3140
+ if (source == closeItem)
31023141 {
31033142 Close();
31043143 //return true;
3105
- } else if (event.getSource() == loadItem)
3144
+ } else if (source == loadItem)
31063145 {
31073146 load();
31083147 //return true;
3109
- } else if (event.getSource() == saveItem)
3148
+ } else if (source == newItem)
3149
+ {
3150
+ New();
3151
+ } else if (source == saveItem)
31103152 {
31113153 save();
31123154 //return true;
3113
- } else if (event.getSource() == saveAsItem)
3155
+ } else if (source == saveAsItem)
31143156 {
31153157 saveAs();
31163158 //return true;
3117
- } else if (event.getSource() == reexportItem)
3159
+ } else if (source == reexportItem)
31183160 {
31193161 reexport();
31203162 //return true;
3121
- } else if (event.getSource() == exportAsItem)
3163
+ } else if (source == exportAsItem)
31223164 {
31233165 export();
31243166 //return true;
3125
- } else if (event.getSource() == povItem)
3167
+ } else if (source == povItem)
31263168 {
31273169 generatePOV();
31283170 //return true;
3129
- } else if (event.getSource() == zBufferItem)
3171
+ } else if (source == zBufferItem)
31303172 {
31313173 try
31323174 {
....@@ -3148,21 +3190,8 @@
31483190 cameraView.repaint();
31493191 //return true;
31503192 }
3151
- */ else if (event.getSource() == editCameraItem)
3152
- {
3153
- cameraView.ProtectCamera();
3154
- cameraView.repaint();
3155
- return;
3156
- } else if (event.getSource() == revertCameraItem)
3157
- {
3158
- cameraView.RevertCamera();
3159
- cameraView.repaint();
3160
- return;
3161
-// } else if (event.getSource() == textureButton)
3162
-// {
3163
-// return; // true;
3164
- } else // combos...
3165
- if (event.getSource() == texresMenu)
3193
+ */ else // combos...
3194
+ if (source == texresMenu)
31663195 {
31673196 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31683197 copy.texres = texresMenu.getSelectedIndex();
....@@ -3174,12 +3203,268 @@
31743203 }
31753204 }
31763205
3206
+ void New()
3207
+ {
3208
+ while (copy.Size() > 1)
3209
+ {
3210
+ copy.remove(1);
3211
+ }
3212
+
3213
+ ResetModel();
3214
+ objEditor.refreshContents();
3215
+ }
3216
+
3217
+ static public byte[] Compress(Object3D o)
3218
+ {
3219
+ try
3220
+ {
3221
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3222
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3223
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3224
+
3225
+ Object3D parent = o.parent;
3226
+ o.parent = null;
3227
+
3228
+ out.writeObject(o);
3229
+
3230
+ o.parent = parent;
3231
+
3232
+ out.flush();
3233
+
3234
+ zstream.close();
3235
+ out.close();
3236
+
3237
+ return baos.toByteArray();
3238
+ } catch (Exception e)
3239
+ {
3240
+ System.err.println(e);
3241
+ return null;
3242
+ }
3243
+ }
3244
+
3245
+ static public Object Uncompress(byte[] bytes)
3246
+ {
3247
+ System.out.println("#bytes = " + bytes.length);
3248
+ try
3249
+ {
3250
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3251
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3252
+ ObjectInputStream in = new ObjectInputStream(istream);
3253
+ Object obj = in.readObject();
3254
+ in.close();
3255
+
3256
+ return obj;
3257
+ } catch (Exception e)
3258
+ {
3259
+ System.err.println(e);
3260
+ return null;
3261
+ }
3262
+ }
3263
+
3264
+ static public Object clone(Object o)
3265
+ {
3266
+ try
3267
+ {
3268
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3269
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3270
+
3271
+ out.writeObject(o);
3272
+
3273
+ out.flush();
3274
+ out.close();
3275
+
3276
+ byte[] bytes = baos.toByteArray();
3277
+
3278
+ System.out.println("clone = " + bytes.length);
3279
+
3280
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3281
+ ObjectInputStream in = new ObjectInputStream(bais);
3282
+ Object obj = in.readObject();
3283
+ in.close();
3284
+
3285
+ return obj;
3286
+ } catch (Exception e)
3287
+ {
3288
+ System.err.println(e);
3289
+ return null;
3290
+ }
3291
+ }
3292
+
3293
+ cRadio GetCurrentTab()
3294
+ {
3295
+ cRadio ab;
3296
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3297
+ {
3298
+ ab = (cRadio)e.nextElement();
3299
+ if(ab.GetObject() == copy)
3300
+ {
3301
+ return ab;
3302
+ }
3303
+ }
3304
+
3305
+ return null;
3306
+ }
3307
+
3308
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3309
+
3310
+ public void Save()
3311
+ {
3312
+ cRadio tab = GetCurrentTab();
3313
+
3314
+ boolean temp = CameraPane.SWITCH;
3315
+ CameraPane.SWITCH = false;
3316
+
3317
+ copy.ExtractBigData(hashtable);
3318
+
3319
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3320
+ tab.graphs[tab.undoindex++] = Compress(copy);
3321
+
3322
+ copy.RestoreBigData(hashtable);
3323
+
3324
+ CameraPane.SWITCH = temp;
3325
+
3326
+ //assert(hashtable.isEmpty());
3327
+
3328
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3329
+ {
3330
+ tab.graphs[i] = null;
3331
+ }
3332
+
3333
+ // test save
3334
+ if (false)
3335
+ {
3336
+ try
3337
+ {
3338
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3339
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3340
+
3341
+ p.writeObject(copy);
3342
+
3343
+ p.flush();
3344
+
3345
+ ostream.close();
3346
+ } catch (Exception e)
3347
+ {
3348
+ e.printStackTrace();
3349
+ }
3350
+ }
3351
+ }
3352
+
3353
+ void CopyChanged(Object3D obj)
3354
+ {
3355
+ boolean temp = CameraPane.SWITCH;
3356
+ CameraPane.SWITCH = false;
3357
+
3358
+ copy.ExtractBigData(hashtable);
3359
+
3360
+ copy.clear();
3361
+
3362
+ for (int i=0; i<obj.Size(); i++)
3363
+ {
3364
+ copy.add(obj.get(i));
3365
+ }
3366
+
3367
+ copy.RestoreBigData(hashtable);
3368
+
3369
+ CameraPane.SWITCH = temp;
3370
+
3371
+ //assert(hashtable.isEmpty());
3372
+
3373
+ copy.Touch();
3374
+
3375
+ ResetModel();
3376
+ copy.HardTouch(); // recompile?
3377
+
3378
+ cRadio ab;
3379
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3380
+ {
3381
+ ab = (cRadio)e.nextElement();
3382
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3383
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3384
+ if (test != null)
3385
+ {
3386
+ test.editWindow = ab.object.editWindow;
3387
+ ab.object = test;
3388
+ }
3389
+ }
3390
+
3391
+ refreshContents();
3392
+ }
3393
+
3394
+ public void Undo()
3395
+ {
3396
+ cRadio tab = GetCurrentTab();
3397
+
3398
+ if (tab.undoindex == 0)
3399
+ {
3400
+ java.awt.Toolkit.getDefaultToolkit().beep();
3401
+ return;
3402
+ }
3403
+
3404
+ if (tab.graphs[tab.undoindex] == null)
3405
+ {
3406
+ Save();
3407
+ tab.undoindex -= 1;
3408
+ }
3409
+
3410
+ tab.undoindex -= 1;
3411
+
3412
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3413
+ }
3414
+
3415
+ public void Redo()
3416
+ {
3417
+ cRadio tab = GetCurrentTab();
3418
+
3419
+ if (tab.graphs[tab.undoindex + 1] == null)
3420
+ {
3421
+ java.awt.Toolkit.getDefaultToolkit().beep();
3422
+ return;
3423
+ }
3424
+
3425
+ tab.undoindex += 1;
3426
+
3427
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3428
+ }
3429
+
3430
+ void ImportGFD()
3431
+ {
3432
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3433
+ browser.show();
3434
+ String filename = browser.getFile();
3435
+ if (filename != null && filename.length() > 0)
3436
+ {
3437
+ String fullname = browser.getDirectory() + filename;
3438
+
3439
+ //Object3D readobj =
3440
+ objEditor.ReadGFD(fullname, objEditor);
3441
+ //makeSomething(readobj);
3442
+ }
3443
+ }
3444
+
3445
+ void ImportVRMLX3D()
3446
+ {
3447
+ if (Grafreed.standAlone)
3448
+ {
3449
+ /**/
3450
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3451
+ browser.show();
3452
+ String filename = browser.getFile();
3453
+ if (filename != null && filename.length() > 0)
3454
+ {
3455
+ String fullname = browser.getDirectory() + filename;
3456
+ LoadVRMLX3D(fullname);
3457
+ }
3458
+ /**/
3459
+ }
3460
+ }
3461
+
31773462 void ToggleAnimation()
31783463 {
31793464 if (!Globals.ANIMATION)
31803465 {
31813466 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3182
- browser.show();
3467
+ browser.setVisible(true);
31833468 String filename = browser.getFile();
31843469 if (filename != null && filename.length() > 0)
31853470 {
....@@ -3189,8 +3474,8 @@
31893474
31903475 Globals.ANIMATION ^= true;
31913476
3192
- GrafreeD.wav.cursor = 0;
3193
- GrafreeD.wav.loop = 0;
3477
+ Grafreed.wav.cursor = 0;
3478
+ Grafreed.wav.loop = 0;
31943479 }
31953480 } else
31963481 {
....@@ -3240,7 +3525,7 @@
32403525 void CreateMaterial()
32413526 {
32423527 //copy.ClearMaterial(); // PATCH
3243
- copy.CreateMaterialS(multiplyToggle.isSelected());
3528
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32443529 if (copy.selection.size() > 0)
32453530 //SetMaterial(copy);
32463531 {
....@@ -3299,11 +3584,11 @@
32993584 {
33003585 copy.ResetBlockLoop(); // temporary problem
33013586
3302
- boolean random = CameraPane.RANDOM;
3303
- CameraPane.RANDOM = false; // parse everything
3587
+ boolean random = CameraPane.SWITCH;
3588
+ CameraPane.SWITCH = false; // parse everything
33043589 copy.ResetDisplayList();
33053590 copy.HardTouch();
3306
- CameraPane.RANDOM = random;
3591
+ CameraPane.SWITCH = random;
33073592 }
33083593
33093594 // public void applySelf()
....@@ -3377,6 +3662,36 @@
33773662 {
33783663 //System.out.println("Propagate = " + propagate);
33793664 copy.UpdateMaterial(anchor, current, propagate);
3665
+
3666
+ if (copy.material != null)
3667
+ {
3668
+ cMaterial mat = copy.material;
3669
+
3670
+ colorField.SetToolTipValue((mat.color));
3671
+ modulationField.SetToolTipValue((mat.modulation));
3672
+ metalnessField.SetToolTipValue((mat.metalness));
3673
+ diffuseField.SetToolTipValue((mat.diffuse));
3674
+ specularField.SetToolTipValue((mat.specular));
3675
+ shininessField.SetToolTipValue((mat.shininess));
3676
+ shiftField.SetToolTipValue((mat.shift));
3677
+ ambientField.SetToolTipValue((mat.ambient));
3678
+ lightareaField.SetToolTipValue((mat.lightarea));
3679
+ diffusenessField.SetToolTipValue((mat.factor));
3680
+ velvetField.SetToolTipValue((mat.velvet));
3681
+ sheenField.SetToolTipValue((mat.sheen));
3682
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3683
+ backlitField.SetToolTipValue((mat.bump));
3684
+ anisoField.SetToolTipValue((mat.aniso));
3685
+ anisoVField.SetToolTipValue((mat.anisoV));
3686
+ cameraField.SetToolTipValue((mat.cameralight));
3687
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3688
+ shadowField.SetToolTipValue((mat.shadow));
3689
+ textureField.SetToolTipValue((mat.texture));
3690
+ opacityField.SetToolTipValue((mat.opacity));
3691
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3692
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3693
+ }
3694
+
33803695 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33813696 {
33823697 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3421,6 +3736,7 @@
34213736 || e.getSource() == apertureField
34223737 || e.getSource() == shadowblurField)
34233738 {
3739
+ new Exception().printStackTrace();
34243740 System.exit(0);
34253741 cameraView.options1[0] = (float) focusField.getFloat() * 10;
34263742 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3491,7 +3807,7 @@
34913807 }
34923808
34933809 if (normalpushField != null)
3494
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3810
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
34953811 }
34963812
34973813 void SnapObject()
....@@ -3755,6 +4071,7 @@
37554071
37564072 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37574073 {
4074
+ Save();
37584075 //Tween.set(thing, 0).target(1).start(tweenManager);
37594076 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37604077 // if (thing instanceof GenericJointDemo)
....@@ -3958,6 +4275,7 @@
39584275 }
39594276 }
39604277 }
4278
+
39614279 LoadGFDThread loadGFDThread;
39624280
39634281 void ReadGFD(String fullname, iCallBack cb)
....@@ -3977,8 +4295,10 @@
39774295
39784296 try
39794297 {
4298
+ // Try compressed version first.
39804299 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3981
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4300
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4301
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39824302
39834303 readobj = (Object3D) p.readObject();
39844304 istream.close();
....@@ -3986,7 +4306,20 @@
39864306 readobj.ResetDisplayList();
39874307 } catch (Exception e)
39884308 {
3989
- e.printStackTrace();
4309
+ //e.printStackTrace();
4310
+ try
4311
+ {
4312
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4313
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4314
+
4315
+ readobj = (Object3D) p.readObject();
4316
+ istream.close();
4317
+
4318
+ readobj.ResetDisplayList();
4319
+ } catch (Exception e2)
4320
+ {
4321
+ e2.printStackTrace();
4322
+ }
39904323 }
39914324 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
39924325 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4032,6 +4365,12 @@
40324365
40334366 void LoadIt(Object obj)
40344367 {
4368
+ if (obj == null)
4369
+ {
4370
+ // Invalid file
4371
+ return;
4372
+ }
4373
+
40354374 System.out.println("Loaded " + obj);
40364375 //new Exception().printStackTrace();
40374376 Object3D readobj = (Object3D) obj;
....@@ -4041,6 +4380,7 @@
40414380
40424381 if (readobj != null)
40434382 {
4383
+ Save();
40444384 try
40454385 {
40464386 //readobj.deepCopySelf(copy);
....@@ -4103,7 +4443,7 @@
41034443
41044444 void load() // throws ClassNotFoundException
41054445 {
4106
- if (GrafreeD.standAlone)
4446
+ if (Grafreed.standAlone)
41074447 {
41084448 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41094449 browser.show();
....@@ -4190,11 +4530,13 @@
41904530 try
41914531 {
41924532 FileOutputStream ostream = new FileOutputStream(lastname);
4193
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4533
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4534
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
41944535
41954536 p.writeObject(copy);
41964537 p.flush();
41974538
4539
+ zstream.close();
41984540 ostream.close();
41994541
42004542 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4204,11 +4546,12 @@
42044546 {
42054547 }
42064548 }
4549
+
42074550 String lastname;
42084551
42094552 void saveAs()
42104553 {
4211
- if (GrafreeD.standAlone)
4554
+ if (Grafreed.standAlone)
42124555 {
42134556 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42144557 browser.setVisible(true);
....@@ -4313,13 +4656,13 @@
43134656 try
43144657 {
43154658 FileOutputStream ostream = new FileOutputStream(filename);
4316
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4317
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4659
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4660
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43184661
43194662 Object3D objectparent = obj.parent;
43204663 obj.parent = null;
43214664
4322
- Object3D object = (Object3D) GrafreeD.clone(obj);
4665
+ Object3D object = (Object3D) Grafreed.clone(obj);
43234666
43244667 obj.parent = objectparent;
43254668
....@@ -4331,8 +4674,8 @@
43314674 p.writeObject(object);
43324675 p.flush();
43334676
4677
+ zstream.close();
43344678 ostream.close();
4335
- // zstream.close();
43364679
43374680 // group.selection.get(0).parent = parent;
43384681 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4353,7 +4696,7 @@
43534696 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43544697 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43554698 copy.generatePOV(buffer);
4356
- if (GrafreeD.standAlone)
4699
+ if (Grafreed.standAlone)
43574700 {
43584701 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43594702 browser.show();
....@@ -4379,7 +4722,8 @@
43794722 Object3D client;
43804723 Object3D copy;
43814724 MenuBar menuBar;
4382
- Menu windowMenu;
4725
+ Menu fileMenu;
4726
+ MenuItem newItem;
43834727 MenuItem loadItem;
43844728 MenuItem saveItem;
43854729 MenuItem saveAsItem;
....@@ -4387,13 +4731,11 @@
43874731 MenuItem reexportItem;
43884732 MenuItem povItem;
43894733 MenuItem closeItem;
4390
- Menu cameraMenu;
4734
+
43914735 CheckboxMenuItem zBufferItem;
43924736 //MenuItem normalLensItem;
4393
- MenuItem editCameraItem;
4394
- MenuItem revertCameraItem;
4395
- CheckboxMenuItem toggleLiveItem;
43964737 MenuItem stepItem;
4738
+ CheckboxMenuItem toggleLiveItem;
43974739 CheckboxMenuItem toggleFullScreenItem;
43984740 CheckboxMenuItem toggleTimelineItem;
43994741 CheckboxMenuItem toggleRenderItem;
....@@ -4402,7 +4744,7 @@
44024744 CheckboxMenuItem toggleFootContactItem;
44034745 CheckboxMenuItem toggleDLItem;
44044746 CheckboxMenuItem toggleTextureItem;
4405
- CheckboxMenuItem toggleRandomItem;
4747
+ CheckboxMenuItem toggleSwitchItem;
44064748 CheckboxMenuItem toggleRootItem;
44074749 CheckboxMenuItem animationItem;
44084750 CheckboxMenuItem toggleHandleItem;
....@@ -4410,7 +4752,7 @@
44104752 JSplitPane mainPanel;
44114753 JScrollPane scrollpane;
44124754 JPanel toolbarPanel;
4413
- JPanel treePanel;
4755
+ cGridBag treePanel;
44144756 JPanel radioPanel;
44154757 ButtonGroup buttonGroup;
44164758 cGridBag ctrlPanel;
....@@ -4539,4 +4881,9 @@
45394881 //ObjectUI parent;
45404882
45414883 cNumberSlider normalpushField;
4884
+
4885
+ private MenuItem importGFDItem;
4886
+ private MenuItem importVRMLX3DItem;
4887
+ private MenuItem import3DSItem;
4888
+ private MenuItem importOBJItem;
45424889 }