Normand Briere
2019-06-21 15123b19e7bc8da2869429b07f0fbaa0598e945e
ObjEditor.java
....@@ -138,34 +138,42 @@
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(setupPanel2);
172
+ objEditor.ctrlPanel.remove(commandsPanel);
173
+ objEditor.ctrlPanel.remove(pushPanel);
174
+ //objEditor.ctrlPanel.remove(fillPanel);
175
+
176
+ //Remove(normalpushField);
169177 }
170178
171179 public ObjEditor GetEditor()
....@@ -269,24 +277,40 @@
269277 void SetupMenu()
270278 {
271279 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..."));
280
+ menuBar.add(fileMenu = new Menu("File"));
281
+ fileMenu.add(newItem = new MenuItem("New"));
282
+ fileMenu.add(loadItem = new MenuItem("Open..."));
283
+
284
+ //oe.menuBar.add(menu = new Menu("Include"));
285
+ Menu menu = new Menu("Import");
286
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
287
+ importOBJItem.addActionListener(this);
288
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
289
+ import3DSItem.addActionListener(this);
290
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
291
+ importVRMLX3DItem.addActionListener(this);
292
+ menu.add("-");
293
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
294
+ importGFDItem.addActionListener(this);
295
+ fileMenu.add(menu);
296
+ fileMenu.add("-");
297
+
298
+ fileMenu.add(saveItem = new MenuItem("Save"));
299
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
277300 //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("-");
301
+ fileMenu.add("-");
302
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
303
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
304
+ fileMenu.add("-");
282305 if (client.parent != null)
283306 {
284
- windowMenu.add(closeItem = new MenuItem("Close"));
307
+ fileMenu.add(closeItem = new MenuItem("Close"));
285308 } else
286309 {
287
- windowMenu.add(closeItem = new MenuItem("Exit"));
310
+ fileMenu.add(closeItem = new MenuItem("Exit"));
288311 }
289312
313
+ newItem.addActionListener(this);
290314 loadItem.addActionListener(this);
291315 saveItem.addActionListener(this);
292316 saveAsItem.addActionListener(this);
....@@ -295,79 +319,26 @@
295319 //povItem.addActionListener(this);
296320 closeItem.addActionListener(this);
297321
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
-
353322 objectPanel = new JTabbedPane();
354323 toolbarPanel = new JPanel();
355324 toolbarPanel.setName("Toolbar");
356
- treePanel = new JPanel();
325
+ treePanel = new cGridBag();
357326 treePanel.setName("Tree");
358
- ctrlPanel = new cGridBag(); // new GridBagLayout());
327
+ ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
359328 ctrlPanel.setName("Edit");
360329 materialPanel = new cGridBag().setVertical(true);
361330 materialPanel.setName("Material");
362331 /*JTextPane*/
363332 infoarea = createTextPane();
333
+ doc = infoarea.getStyledDocument();
334
+
364335 infoarea.setEditable(true);
365336 SetText();
366337 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
367338 // infoarea.setOpaque(false);
368339 // //infoarea.setForeground(textcolor);
369
- infoarea.setLineWrap(true);
370
- infoarea.setWrapStyleWord(true);
340
+// TEXTAREA infoarea.setLineWrap(true);
341
+// TEXTAREA infoarea.setWrapStyleWord(true);
371342 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
372343 infoPanel.setPreferredSize(new Dimension(50, 200));
373344 infoPanel.setName("Info");
....@@ -378,15 +349,15 @@
378349 mainPanel.setName("Main");
379350 mainPanel.setContinuousLayout(true);
380351 mainPanel.setOneTouchExpandable(true);
381
- mainPanel.setDividerLocation(1.0);
382352 mainPanel.setDividerSize(9);
383
- mainPanel.setResizeWeight(0);
353
+ mainPanel.setDividerLocation(0.5); //1.0);
354
+ mainPanel.setResizeWeight(0.5);
384355
385356 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
386357 //mainPanel.setLayout(new GridBagLayout());
387358 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
388
- treePanel.setLayout(new GridBagLayout());
389
- ctrlPanel.setLayout(new GridBagLayout());
359
+// treePanel.setLayout(new GridBagLayout());
360
+ //ctrlPanel.setLayout(new GridBagLayout());
390361 //materialPanel.setLayout(new GridBagLayout());
391362
392363 aConstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
....@@ -426,7 +397,7 @@
426397 static String newline = "\n";
427398 protected static final String buttonString = "JButton";
428399 StyledDocument doc;
429
- JTextArea infoarea;
400
+ JTextPane infoarea;
430401
431402 void ClearInfo()
432403 {
....@@ -449,10 +420,10 @@
449420 e.printStackTrace();
450421 }
451422
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();
423
+// String selection = infoarea.getText();
424
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
425
+// java.awt.datatransfer.Clipboard clipboard =
426
+// Toolkit.getDefaultToolkit().getSystemClipboard();
456427 //clipboard.setContents(data, data);
457428 }
458429
....@@ -475,13 +446,13 @@
475446 //SendInfo("Name:", "bold");
476447 if (sel.GetTextures() != null || debug)
477448 {
478
- si.SendInfo(sel.toString(), "bold");
449
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
479450 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
480451 if (sel.Size() > 0)
481452 {
482453 si.SendInfo("#children = " + sel.Size(), "regular");
483454 }
484
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
455
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
485456 if (debug)
486457 {
487458 try
....@@ -493,7 +464,10 @@
493464 }
494465
495466 if (full)
496
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
467
+ {
468
+ si.SendInfo(" BBox min: " + minima, "regular");
469
+ si.SendInfo(" BBox max: " + maxima, "regular");
470
+ }
497471
498472 if (sel.bRep != null)
499473 {
....@@ -520,7 +494,7 @@
520494 }
521495 if (sel.support != null)
522496 {
523
- si.SendInfo(" support: " + sel.support, "regular");
497
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
524498 }
525499 if (sel.scriptnode != null)
526500 {
....@@ -591,6 +565,9 @@
591565 {
592566 CameraPane.pointflow = (PointFlow) sel;
593567 }
568
+
569
+ si.SendInfo("_____________________", "regular");
570
+ si.SendInfo("", "regular");
594571 }
595572 }
596573
....@@ -622,52 +599,52 @@
622599 cameraView.ToggleFullScreen();
623600 }
624601
625
- private JTextArea createTextPane()
602
+ private JTextPane createTextPane()
626603 {
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
- };
604
+// TEXTAREA String[] initString =
605
+// {
606
+// "This is an editable JTextPane, ", //regular
607
+// "another ", //italic
608
+// "styled ", //bold
609
+// "text ", //small
610
+// "component, ", //large
611
+// "which supports embedded components..." + newline,//regular
612
+// " " + newline, //button
613
+// "...and embedded icons..." + newline, //regular
614
+// " ", //icon
615
+// newline + "JTextPane is a subclass of JEditorPane that "
616
+// + "uses a StyledEditorKit and StyledDocument, and provides "
617
+// + "cover methods for interacting with those objects."
618
+// };
619
+//
620
+// String[] initStyles =
621
+// {
622
+// "regular", "italic", "bold", "small", "large",
623
+// "regular", "button", "regular", "icon",
624
+// "regular"
625
+// };
626
+//
627
+// JTextPane textPane = new JTextPane();
628
+// textPane.setEditable(true);
629
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
630
+// addStylesToDocument(doc);
631
+//
632
+// try
633
+// {
634
+// for (int j = 0; j < 2; j++)
635
+// {
636
+// for (int i = 0; i < initString.length; i++)
637
+// {
638
+// doc.insertString(doc.getLength(), initString[i],
639
+// doc.getStyle(initStyles[i]));
640
+// }
641
+// }
642
+// } catch (BadLocationException ble)
643
+// {
644
+// System.err.println("Couldn't insert initial text into text pane.");
645
+// }
642646
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;
647
+ return new JTextPane(); // textPane;
671648 }
672649
673650 protected void addStylesToDocument(StyledDocument doc)
....@@ -720,7 +697,7 @@
720697 protected static ImageIcon createImageIcon(String path,
721698 String description)
722699 {
723
- java.net.URL imgURL = GrafreeD.class.getResource(path);
700
+ java.net.URL imgURL = Grafreed.class.getResource(path);
724701 if (imgURL != null)
725702 {
726703 return new ImageIcon(imgURL, description);
....@@ -752,6 +729,7 @@
752729 // NumberSlider vDivsField;
753730 // JCheckBox endcaps;
754731 JCheckBox liveCB;
732
+ JCheckBox selectCB;
755733 JCheckBox hideCB;
756734 JCheckBox link2masterCB;
757735 JCheckBox markCB;
....@@ -767,54 +745,45 @@
767745 JButton slowerButton;
768746 JButton fasterButton;
769747 JButton remarkButton;
748
+
749
+ cGridBag namePanel;
750
+ cGridBag setupPanel;
751
+ cGridBag setupPanel2;
752
+ cGridBag commandsPanel;
753
+ cGridBag pushPanel;
754
+ cGridBag fillPanel;
770755
771
- JCheckBox AddCheckBox(ObjEditor oe, String label, boolean on)
756
+ JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
772757 {
773758 JCheckBox cb;
774759
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);
760
+ panel.add(cb = new JCheckBox(label, on)); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
780761 cb.addItemListener(this);
781
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
782
- oe.aConstraints.gridwidth = 1;
783
- oe.aConstraints.gridx += 1;
784762
785763 return cb;
786764 }
787765
788
- cButton AddButton(ObjEditor oe, String label)
766
+ cButton AddButton(cGridBag panel, String label)
789767 {
790768 cButton cb;
791769
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);
770
+ panel.add(cb = new cButton(label)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
797771 cb.addActionListener(this);
798
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
799
- oe.aConstraints.gridwidth = 1;
800
- oe.aConstraints.gridx += 1;
801772
802773 return cb;
803774 }
804775
805
- JComboBox AddCombo(ObjEditor oe, java.util.Vector list, int item)
776
+ JComboBox AddCombo(cGridBag panel, java.util.Vector list, int item)
806777 {
807778 JComboBox combo;
808779
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;
780
+ panel.add(combo = new JComboBox(new cListModel(list, item))); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
812781 combo.addActionListener(this);
813782
814783 return combo;
815784 }
816785
817
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, double min, double max, double current, double pow)
786
+ cGridBag AddSlider(cGridBag panel, String label, double min, double max, double current, double pow)
818787 {
819788 cGridBag control = new cGridBag();
820789
....@@ -826,12 +795,12 @@
826795 control.add(combo = new cNumberSlider(this, min, max, pow)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
827796 combo.setFloat(current);
828797
829
- ctrlPanel.add(control);
798
+ panel.add(control);
830799
831
- return combo;
800
+ return control;
832801 }
833802
834
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, int min, int max, int current)
803
+ cGridBag AddSlider(cGridBag panel, String label, int min, int max, int current)
835804 {
836805 cGridBag control = new cGridBag();
837806
....@@ -839,25 +808,21 @@
839808
840809 JLabel jlabel = new JLabel(label);
841810 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);
811
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
812
+ control.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
844813 combo.setInteger(current);
845814
846
- ctrlPanel.add(control);
815
+ panel.add(control);
847816
848
- return combo;
817
+ return control;
849818 }
850819
851820 JTextArea AddText(cGridBag ctrlPanel, String name)
852821 {
853822 JTextArea text;
854823
855
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
856
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
857824 ctrlPanel.add(text = new JTextArea(name)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
858825 text.addCaretListener(this);
859
- aConstraints.gridx += 1;
860
- aConstraints.gridwidth = 1;
861826
862827 return text;
863828 }
....@@ -896,7 +861,7 @@
896861
897862 /*
898863 */
899
- void Return() // ObjEditor oe)
864
+ void Return0() // ObjEditor oe)
900865 {
901866 aConstraints.gridy += 1;
902867 aConstraints.gridx = 0;
....@@ -951,37 +916,76 @@
951916
952917 void SetupUI2(ObjEditor oe)
953918 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
958
- SetupName(oe);
919
+ //SetupName(oe);
920
+
921
+ namePanel = new cGridBag();
922
+
923
+ nameField = AddText(namePanel, copy.GetName());
924
+ namePanel.add(nameField);
925
+ oe.ctrlPanel.add(namePanel);
926
+
927
+ oe.ctrlPanel.Return();
959928
960929 if (!GroupEditor.allparams)
961930 return;
962931
963
- liveCB = AddCheckBox(oe, "Live", copy.live);
964
- link2masterCB = AddCheckBox(oe, "Supp", copy.link2master);
965
- hideCB = AddCheckBox(oe, "Hide", copy.hide);
932
+ setupPanel = new cGridBag().setVertical(false);
933
+
934
+ liveCB = AddCheckBox(setupPanel, "Live", copy.live);
935
+ liveCB.setToolTipText("Animate object");
936
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
937
+ selectCB.setToolTipText("Make object selectable");
966938 // 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");
939
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
940
+ hideCB.setToolTipText("Hide object");
941
+ markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
942
+ markCB.setToolTipText("Set the animation target transform");
943
+
944
+ setupPanel2 = new cGridBag().setVertical(false);
945
+
946
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
947
+ rewindCB.setToolTipText("Rewind animation");
948
+
949
+ randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
950
+ randomCB.setToolTipText("Rewind or Go back and forth randomly");
951
+
952
+ if (Globals.ADVANCED)
953
+ {
954
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
955
+ link2masterCB.setToolTipText("Attach to support");
956
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
957
+ speedupCB.setToolTipText("Option motion capture");
958
+ }
959
+
960
+ oe.ctrlPanel.add(setupPanel);
961
+ oe.ctrlPanel.Return();
962
+ oe.ctrlPanel.add(setupPanel2);
963
+ oe.ctrlPanel.Return();
964
+
965
+ commandsPanel = new cGridBag().setVertical(false);
966
+
967
+ resetButton = AddButton(commandsPanel, "Reset");
968
+ resetButton.setToolTipText("Jump to frame zero");
969
+ stepButton = AddButton(commandsPanel, "Step");
970
+ stepButton.setToolTipText("Step one frame");
973971 // resetAllButton = AddButton(oe, "Reset All");
974972 // stepAllButton = AddButton(oe, "Step All");
975
- speedupCB = AddCheckBox(oe, "Speed", copy.speedup);
976973 // Return();
977
- slowerButton = AddButton(oe, "Slow");
978
- fasterButton = AddButton(oe, "Fast");
979
- remarkButton = AddButton(oe, "Rem");
974
+ slowerButton = AddButton(commandsPanel, "Slow");
975
+ slowerButton.setToolTipText("Decrease animation speed");
976
+ fasterButton = AddButton(commandsPanel, "Fast");
977
+ fasterButton.setToolTipText("Increase animation speed");
978
+ remarkButton = AddButton(commandsPanel, "Remark");
979
+ remarkButton.setToolTipText("Set the current transform as the target");
980980
981
- //Return();
981
+ oe.ctrlPanel.add(commandsPanel);
982
+ oe.ctrlPanel.Return();
982983
983
- //normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1);
984
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
985
+ normalpushField = (cNumberSlider)pushPanel.getComponent(1);
984986 //Return();
987
+
988
+ oe.ctrlPanel.Return();
985989
986990 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
987991 // ObjEditor.aConstraints.gridx += 1;
....@@ -1076,7 +1080,7 @@
10761080 oe.aConstraints.gridwidth = 1;
10771081 /**/
10781082 nameField = AddText(oe.ctrlPanel, copy.GetName());
1079
- Return();
1083
+ oe.ctrlPanel.Return();
10801084
10811085 //ctrlPanel.add(textureButton = new Button("Texture..."));
10821086 //textureButton.setEnabled(false);
....@@ -1253,10 +1257,11 @@
12531257 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12541258 //tmp.setName("Edit");
12551259 objectPanel.add(materialPanel);
1256
- JPanel north = new JPanel(new BorderLayout());
1257
- north.setName("Edit");
1258
- north.add(ctrlPanel, BorderLayout.NORTH);
1259
- objectPanel.add(north);
1260
+// JPanel north = new JPanel(new BorderLayout());
1261
+// north.setName("Edit");
1262
+// north.add(ctrlPanel, BorderLayout.NORTH);
1263
+// objectPanel.add(north);
1264
+ objectPanel.add(ctrlPanel);
12601265 objectPanel.add(infoPanel);
12611266
12621267 /*
....@@ -1278,7 +1283,7 @@
12781283 scrollpane.addMouseWheelListener(this); // Default not fast enough
12791284
12801285 /*JTabbedPane*/ scenePanel = new cGridBag();
1281
- scenePanel.preferredWidth = 7;
1286
+ scenePanel.preferredWidth = 6;
12821287
12831288 JTabbedPane tabbedPane = new JTabbedPane();
12841289 tabbedPane.add(scrollpane);
....@@ -1384,8 +1389,8 @@
13841389
13851390 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13861391
1387
- frame.setSize(1024, 768);
1388
- frame.show();
1392
+ frame.setSize(1280, 860);
1393
+ frame.setVisible(true);
13891394
13901395 gridPanel.setDividerLocation(1.0);
13911396
....@@ -1415,7 +1420,7 @@
14151420 ctrlPanel.removeAll();
14161421 }
14171422
1418
- void SetupMaterial(cGridBag ctrlPanel)
1423
+ void SetupMaterial(cGridBag panel)
14191424 {
14201425 /*
14211426 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
....@@ -1424,18 +1429,26 @@
14241429
14251430 cGridBag editBar = new cGridBag().setVertical(false);
14261431
1427
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
1432
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1433
+ createMaterialButton.setToolTipText("Create material");
14281434
14291435 /*
14301436 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14311437 */
14321438
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);
1439
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1440
+ clearMaterialButton.setToolTipText("Clear material");
1441
+
1442
+ if (Globals.ADVANCED)
1443
+ {
1444
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1445
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1446
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1447
+ }
14371448
1438
- ctrlPanel.add(editBar);
1449
+ editBar.preferredHeight = 15;
1450
+
1451
+ panel.add(editBar);
14391452
14401453 /**/
14411454 //aConstraints.weighty = 0;
....@@ -1484,9 +1497,9 @@
14841497 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
14851498 colorSection.add(shadowbias);
14861499
1487
- ctrlPanel.add(new JSeparator());
1500
+ panel.add(new JSeparator());
14881501
1489
- ctrlPanel.add(colorSection);
1502
+ panel.add(colorSection);
14901503
14911504 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14921505
....@@ -1534,9 +1547,9 @@
15341547 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15351548 diffuseSection.add(fakedepth);
15361549
1537
- ctrlPanel.add(new JSeparator());
1550
+ panel.add(new JSeparator());
15381551
1539
- ctrlPanel.add(diffuseSection);
1552
+ panel.add(diffuseSection);
15401553
15411554 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15421555
....@@ -1572,7 +1585,7 @@
15721585 velvet.add(velvetField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15731586 specularSection.add(velvet);
15741587
1575
- shiftField = AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1);
1588
+ shiftField = (cNumberSlider)AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1).getComponent(1);
15761589 //Return();
15771590 // ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
15781591 // shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
....@@ -1585,9 +1598,9 @@
15851598 // aConstraints.gridwidth = 1;
15861599
15871600
1588
- ctrlPanel.add(new JSeparator());
1601
+ panel.add(new JSeparator());
15891602
1590
- ctrlPanel.add(specularSection);
1603
+ panel.add(specularSection);
15911604
15921605 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15931606
....@@ -1617,9 +1630,9 @@
16171630 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16181631 globalSection.add(opacity);
16191632
1620
- ctrlPanel.add(new JSeparator());
1633
+ panel.add(new JSeparator());
16211634
1622
- ctrlPanel.add(globalSection);
1635
+ panel.add(globalSection);
16231636
16241637 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16251638
....@@ -1661,9 +1674,9 @@
16611674 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16621675 textureSection.add(opacityPower);
16631676
1664
- ctrlPanel.add(new JSeparator());
1677
+ panel.add(new JSeparator());
16651678
1666
- ctrlPanel.add(textureSection);
1679
+ panel.add(textureSection);
16671680
16681681 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16691682
....@@ -1700,12 +1713,15 @@
17001713 opacityPowerField.addChangeListener(this);
17011714 /**/
17021715
1703
- resetSlidersButton.addActionListener(this);
17041716 clearMaterialButton.addActionListener(this);
17051717 createMaterialButton.addActionListener(this);
1706
-
1707
- propagateToggle.addItemListener(this);
1708
- multiplyToggle.addItemListener(this);
1718
+
1719
+ if (Globals.ADVANCED)
1720
+ {
1721
+ resetSlidersButton.addActionListener(this);
1722
+ propagateToggle.addItemListener(this);
1723
+ multiplyToggle.addItemListener(this);
1724
+ }
17091725 }
17101726
17111727 void DropFile(java.io.File[] files, boolean textures)
....@@ -1876,7 +1892,7 @@
18761892
18771893 //? flashIt = false;
18781894 CameraPane pane = (CameraPane) cameraView;
1879
- pane.clickStart(location.x, location.y, 0);
1895
+ pane.clickStart(location.x, location.y, 0, 0);
18801896 pane.clickEnd(location.x, location.y, 0, true);
18811897
18821898 if (group.selection.size() == 1)
....@@ -1925,6 +1941,7 @@
19251941 e2.printStackTrace();
19261942 }
19271943 }
1944
+
19281945 LoadJMEThread loadThread;
19291946
19301947 class LoadJMEThread extends Thread
....@@ -1982,6 +1999,7 @@
19821999 //LoadFile0(filename, converter);
19832000 }
19842001 }
2002
+
19852003 LoadOBJThread loadObjThread;
19862004
19872005 class LoadOBJThread extends Thread
....@@ -2060,19 +2078,19 @@
20602078
20612079 void LoadObjFile(String fullname)
20622080 {
2063
- /*
2081
+ System.out.println("Loading " + fullname);
2082
+ /**/
20642083 //lastFilename = fullname;
20652084 if(loadObjThread == null)
20662085 {
2067
- loadObjThread = new LoadOBJThread();
2068
- loadObjThread.start();
2086
+ loadObjThread = new LoadOBJThread();
2087
+ loadObjThread.start();
20692088 }
20702089
20712090 loadObjThread.add(fullname);
2072
- */
2091
+ /**/
20732092
2074
- System.out.println("Loading " + fullname);
2075
- makeSomething(new FileObject(fullname, true), true);
2093
+ //makeSomething(new FileObject(fullname, true), true);
20762094 }
20772095
20782096 void LoadGFDFile(String fullname)
....@@ -2333,11 +2351,11 @@
23332351
23342352 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23352353 {
2336
- if (GrafreeD.standAlone)
2354
+ if (Grafreed.standAlone)
23372355 {
23382356 /**/
23392357 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2340
- browser.show();
2358
+ browser.setVisible(true);
23412359 String filename = browser.getFile();
23422360 if (filename != null && filename.length() > 0)
23432361 {
....@@ -2482,6 +2500,7 @@
24822500 }
24832501 if (input == null)
24842502 {
2503
+ new Exception().printStackTrace();
24852504 System.exit(0);
24862505 }
24872506
....@@ -2696,7 +2715,8 @@
26962715 return;
26972716 }
26982717
2699
- multiplyToggle.setSelected(mat.multiply);
2718
+ if (multiplyToggle != null)
2719
+ multiplyToggle.setSelected(mat.multiply);
27002720
27012721 assert (object.projectedVertices != null);
27022722
....@@ -2911,9 +2931,9 @@
29112931 frame.validate();
29122932
29132933 return;
2914
- } else if (event.getSource() == toggleRandomItem)
2934
+ } else if (event.getSource() == toggleSwitchItem)
29152935 {
2916
- cameraView.ToggleRandom();
2936
+ cameraView.ToggleSwitch();
29172937 cameraView.repaint();
29182938 return;
29192939 } else if (event.getSource() == toggleHandleItem)
....@@ -2942,6 +2962,10 @@
29422962 {
29432963 copy.live ^= true;
29442964 return;
2965
+ } else if (event.getSource() == selectCB)
2966
+ {
2967
+ copy.dontselect ^= true;
2968
+ return;
29452969 } else if (event.getSource() == hideCB)
29462970 {
29472971 copy.hide ^= true;
....@@ -2956,6 +2980,7 @@
29562980 if (event.getSource() == randomCB)
29572981 {
29582982 copy.random ^= true;
2983
+ objEditor.refreshContents();
29592984 return;
29602985 }
29612986 if (event.getSource() == speedupCB)
....@@ -2979,8 +3004,9 @@
29793004
29803005 public void actionPerformed(ActionEvent event)
29813006 {
3007
+ Object source = event.getSource();
29823008 // SCRIPT DIALOG
2983
- if (event.getSource() == okbutton)
3009
+ if (source == okbutton)
29843010 {
29853011 textpanel.setVisible(false);
29863012 textpanel.remove(textarea);
....@@ -2992,7 +3018,7 @@
29923018 textarea = null;
29933019 textpanel = null;
29943020 }
2995
- if (event.getSource() == cancelbutton)
3021
+ if (source == cancelbutton)
29963022 {
29973023 textpanel.setVisible(false);
29983024 textpanel.remove(textarea);
....@@ -3004,50 +3030,50 @@
30043030 //applySelf();
30053031 //client.refreshEditWindow();
30063032 //refreshContents();
3007
- if (event.getSource() == nameField)
3033
+ if (source == nameField)
30083034 {
30093035 //System.out.println("ObjEditor " + event);
30103036 applySelf0(true);
30113037 //parent.applySelf();
30123038 objEditor.refreshContents();
3013
- } else if (event.getSource() == resetButton)
3039
+ } else if (source == resetButton)
30143040 {
30153041 CameraPane.fullreset = true;
30163042 copy.Reset(); // ResetMeshes();
30173043 copy.Touch();
30183044 objEditor.refreshContents();
3019
- } else if (event.getSource() == stepItem)
3045
+ } else if (source == stepItem)
30203046 {
30213047 //cameraView.ONESTEP = true;
30223048 Globals.ONESTEP = true;
30233049 cameraView.repaint();
30243050 return;
3025
- } else if (event.getSource() == stepButton)
3051
+ } else if (source == stepButton)
30263052 {
30273053 copy.Step();
30283054 copy.Touch();
30293055 objEditor.refreshContents();
3030
- } else if (event.getSource() == slowerButton)
3056
+ } else if (source == slowerButton)
30313057 {
30323058 copy.Slower();
30333059 copy.Touch();
30343060 objEditor.refreshContents();
3035
- } else if (event.getSource() == fasterButton)
3061
+ } else if (source == fasterButton)
30363062 {
30373063 copy.Faster();
30383064 copy.Touch();
30393065 objEditor.refreshContents();
3040
- } else if (event.getSource() == remarkButton)
3066
+ } else if (source == remarkButton)
30413067 {
30423068 copy.Remark();
30433069 copy.Touch();
30443070 objEditor.refreshContents();
3045
- } else if (event.getSource() == stepAllButton)
3071
+ } else if (source == stepAllButton)
30463072 {
30473073 copy.StepAll();
30483074 copy.Touch();
30493075 objEditor.refreshContents();
3050
- } else if (event.getSource() == resetAllButton)
3076
+ } else if (source == resetAllButton)
30513077 {
30523078 //CameraPane.fullreset = true;
30533079 copy.ResetAll(); // ResetMeshes();
....@@ -3080,53 +3106,75 @@
30803106 // Close();
30813107 // }
30823108 // else
3083
- if (event.getSource() == resetSlidersButton)
3109
+ if (source == resetSlidersButton)
30843110 {
30853111 ResetSliders();
3086
- } else if (event.getSource() == clearMaterialButton)
3112
+ } else if (source == clearMaterialButton)
30873113 {
30883114 ClearMaterial();
3089
- } else if (event.getSource() == createMaterialButton)
3115
+ } else if (source == createMaterialButton)
30903116 {
30913117 CreateMaterial();
3092
- } else if (event.getSource() == clearPanelButton)
3118
+ } else if (source == clearPanelButton)
30933119 {
30943120 copy.ClearUI();
30953121 refreshContents(true);
3096
- } /*
3097
- }
3098
-
3099
- public boolean action(Event event, Object arg)
3100
- {
3101
- */ else if (event.getSource() == closeItem)
3122
+ } else if (source == importGFDItem)
3123
+ {
3124
+ ImportGFD();
3125
+ } else
3126
+ if (source == importVRMLX3DItem)
3127
+ {
3128
+ ImportVRMLX3D();
3129
+ } else
3130
+ if (source == import3DSItem)
3131
+ {
3132
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3133
+ } else
3134
+ if (source == importOBJItem)
3135
+ {
3136
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3137
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3138
+ browser.setVisible(true);
3139
+ String filename = browser.getFile();
3140
+ if (filename != null && filename.length() > 0)
3141
+ {
3142
+ String fullname = browser.getDirectory() + filename;
3143
+ makeSomething(ReadOBJ(fullname), true);
3144
+ }
3145
+ } else
3146
+ if (source == closeItem)
31023147 {
31033148 Close();
31043149 //return true;
3105
- } else if (event.getSource() == loadItem)
3150
+ } else if (source == loadItem)
31063151 {
31073152 load();
31083153 //return true;
3109
- } else if (event.getSource() == saveItem)
3154
+ } else if (source == newItem)
3155
+ {
3156
+ New();
3157
+ } else if (source == saveItem)
31103158 {
31113159 save();
31123160 //return true;
3113
- } else if (event.getSource() == saveAsItem)
3161
+ } else if (source == saveAsItem)
31143162 {
31153163 saveAs();
31163164 //return true;
3117
- } else if (event.getSource() == reexportItem)
3165
+ } else if (source == reexportItem)
31183166 {
31193167 reexport();
31203168 //return true;
3121
- } else if (event.getSource() == exportAsItem)
3169
+ } else if (source == exportAsItem)
31223170 {
31233171 export();
31243172 //return true;
3125
- } else if (event.getSource() == povItem)
3173
+ } else if (source == povItem)
31263174 {
31273175 generatePOV();
31283176 //return true;
3129
- } else if (event.getSource() == zBufferItem)
3177
+ } else if (source == zBufferItem)
31303178 {
31313179 try
31323180 {
....@@ -3148,21 +3196,8 @@
31483196 cameraView.repaint();
31493197 //return true;
31503198 }
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)
3199
+ */ else // combos...
3200
+ if (source == texresMenu)
31663201 {
31673202 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31683203 copy.texres = texresMenu.getSelectedIndex();
....@@ -3174,12 +3209,268 @@
31743209 }
31753210 }
31763211
3212
+ void New()
3213
+ {
3214
+ while (copy.Size() > 1)
3215
+ {
3216
+ copy.remove(1);
3217
+ }
3218
+
3219
+ ResetModel();
3220
+ objEditor.refreshContents();
3221
+ }
3222
+
3223
+ static public byte[] Compress(Object3D o)
3224
+ {
3225
+ try
3226
+ {
3227
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3228
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3229
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3230
+
3231
+ Object3D parent = o.parent;
3232
+ o.parent = null;
3233
+
3234
+ out.writeObject(o);
3235
+
3236
+ o.parent = parent;
3237
+
3238
+ out.flush();
3239
+
3240
+ zstream.close();
3241
+ out.close();
3242
+
3243
+ return baos.toByteArray();
3244
+ } catch (Exception e)
3245
+ {
3246
+ System.err.println(e);
3247
+ return null;
3248
+ }
3249
+ }
3250
+
3251
+ static public Object Uncompress(byte[] bytes)
3252
+ {
3253
+ System.out.println("#bytes = " + bytes.length);
3254
+ try
3255
+ {
3256
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3257
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3258
+ ObjectInputStream in = new ObjectInputStream(istream);
3259
+ Object obj = in.readObject();
3260
+ in.close();
3261
+
3262
+ return obj;
3263
+ } catch (Exception e)
3264
+ {
3265
+ System.err.println(e);
3266
+ return null;
3267
+ }
3268
+ }
3269
+
3270
+ static public Object clone(Object o)
3271
+ {
3272
+ try
3273
+ {
3274
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3275
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3276
+
3277
+ out.writeObject(o);
3278
+
3279
+ out.flush();
3280
+ out.close();
3281
+
3282
+ byte[] bytes = baos.toByteArray();
3283
+
3284
+ System.out.println("clone = " + bytes.length);
3285
+
3286
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3287
+ ObjectInputStream in = new ObjectInputStream(bais);
3288
+ Object obj = in.readObject();
3289
+ in.close();
3290
+
3291
+ return obj;
3292
+ } catch (Exception e)
3293
+ {
3294
+ System.err.println(e);
3295
+ return null;
3296
+ }
3297
+ }
3298
+
3299
+ cRadio GetCurrentTab()
3300
+ {
3301
+ cRadio ab;
3302
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3303
+ {
3304
+ ab = (cRadio)e.nextElement();
3305
+ if(ab.GetObject() == copy)
3306
+ {
3307
+ return ab;
3308
+ }
3309
+ }
3310
+
3311
+ return null;
3312
+ }
3313
+
3314
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3315
+
3316
+ public void Save()
3317
+ {
3318
+ cRadio tab = GetCurrentTab();
3319
+
3320
+ boolean temp = CameraPane.SWITCH;
3321
+ CameraPane.SWITCH = false;
3322
+
3323
+ copy.ExtractBigData(hashtable);
3324
+
3325
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3326
+ tab.graphs[tab.undoindex++] = Compress(copy);
3327
+
3328
+ copy.RestoreBigData(hashtable);
3329
+
3330
+ CameraPane.SWITCH = temp;
3331
+
3332
+ //assert(hashtable.isEmpty());
3333
+
3334
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3335
+ {
3336
+ tab.graphs[i] = null;
3337
+ }
3338
+
3339
+ // test save
3340
+ if (false)
3341
+ {
3342
+ try
3343
+ {
3344
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3345
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3346
+
3347
+ p.writeObject(copy);
3348
+
3349
+ p.flush();
3350
+
3351
+ ostream.close();
3352
+ } catch (Exception e)
3353
+ {
3354
+ e.printStackTrace();
3355
+ }
3356
+ }
3357
+ }
3358
+
3359
+ void CopyChanged(Object3D obj)
3360
+ {
3361
+ boolean temp = CameraPane.SWITCH;
3362
+ CameraPane.SWITCH = false;
3363
+
3364
+ copy.ExtractBigData(hashtable);
3365
+
3366
+ copy.clear();
3367
+
3368
+ for (int i=0; i<obj.Size(); i++)
3369
+ {
3370
+ copy.add(obj.get(i));
3371
+ }
3372
+
3373
+ copy.RestoreBigData(hashtable);
3374
+
3375
+ CameraPane.SWITCH = temp;
3376
+
3377
+ //assert(hashtable.isEmpty());
3378
+
3379
+ copy.Touch();
3380
+
3381
+ ResetModel();
3382
+ copy.HardTouch(); // recompile?
3383
+
3384
+ cRadio ab;
3385
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3386
+ {
3387
+ ab = (cRadio)e.nextElement();
3388
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3389
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3390
+ if (test != null)
3391
+ {
3392
+ test.editWindow = ab.object.editWindow;
3393
+ ab.object = test;
3394
+ }
3395
+ }
3396
+
3397
+ refreshContents();
3398
+ }
3399
+
3400
+ public void Undo()
3401
+ {
3402
+ cRadio tab = GetCurrentTab();
3403
+
3404
+ if (tab.undoindex == 0)
3405
+ {
3406
+ java.awt.Toolkit.getDefaultToolkit().beep();
3407
+ return;
3408
+ }
3409
+
3410
+ if (tab.graphs[tab.undoindex] == null)
3411
+ {
3412
+ Save();
3413
+ tab.undoindex -= 1;
3414
+ }
3415
+
3416
+ tab.undoindex -= 1;
3417
+
3418
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3419
+ }
3420
+
3421
+ public void Redo()
3422
+ {
3423
+ cRadio tab = GetCurrentTab();
3424
+
3425
+ if (tab.graphs[tab.undoindex + 1] == null)
3426
+ {
3427
+ java.awt.Toolkit.getDefaultToolkit().beep();
3428
+ return;
3429
+ }
3430
+
3431
+ tab.undoindex += 1;
3432
+
3433
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3434
+ }
3435
+
3436
+ void ImportGFD()
3437
+ {
3438
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3439
+ browser.show();
3440
+ String filename = browser.getFile();
3441
+ if (filename != null && filename.length() > 0)
3442
+ {
3443
+ String fullname = browser.getDirectory() + filename;
3444
+
3445
+ //Object3D readobj =
3446
+ objEditor.ReadGFD(fullname, objEditor);
3447
+ //makeSomething(readobj);
3448
+ }
3449
+ }
3450
+
3451
+ void ImportVRMLX3D()
3452
+ {
3453
+ if (Grafreed.standAlone)
3454
+ {
3455
+ /**/
3456
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3457
+ browser.show();
3458
+ String filename = browser.getFile();
3459
+ if (filename != null && filename.length() > 0)
3460
+ {
3461
+ String fullname = browser.getDirectory() + filename;
3462
+ LoadVRMLX3D(fullname);
3463
+ }
3464
+ /**/
3465
+ }
3466
+ }
3467
+
31773468 void ToggleAnimation()
31783469 {
31793470 if (!Globals.ANIMATION)
31803471 {
31813472 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3182
- browser.show();
3473
+ browser.setVisible(true);
31833474 String filename = browser.getFile();
31843475 if (filename != null && filename.length() > 0)
31853476 {
....@@ -3189,8 +3480,8 @@
31893480
31903481 Globals.ANIMATION ^= true;
31913482
3192
- GrafreeD.wav.cursor = 0;
3193
- GrafreeD.wav.loop = 0;
3483
+ Grafreed.wav.cursor = 0;
3484
+ Grafreed.wav.loop = 0;
31943485 }
31953486 } else
31963487 {
....@@ -3240,7 +3531,7 @@
32403531 void CreateMaterial()
32413532 {
32423533 //copy.ClearMaterial(); // PATCH
3243
- copy.CreateMaterialS(multiplyToggle.isSelected());
3534
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32443535 if (copy.selection.size() > 0)
32453536 //SetMaterial(copy);
32463537 {
....@@ -3299,11 +3590,11 @@
32993590 {
33003591 copy.ResetBlockLoop(); // temporary problem
33013592
3302
- boolean random = CameraPane.RANDOM;
3303
- CameraPane.RANDOM = false; // parse everything
3593
+ boolean random = CameraPane.SWITCH;
3594
+ CameraPane.SWITCH = false; // parse everything
33043595 copy.ResetDisplayList();
33053596 copy.HardTouch();
3306
- CameraPane.RANDOM = random;
3597
+ CameraPane.SWITCH = random;
33073598 }
33083599
33093600 // public void applySelf()
....@@ -3377,6 +3668,36 @@
33773668 {
33783669 //System.out.println("Propagate = " + propagate);
33793670 copy.UpdateMaterial(anchor, current, propagate);
3671
+
3672
+ if (copy.material != null)
3673
+ {
3674
+ cMaterial mat = copy.material;
3675
+
3676
+ colorField.SetToolTipValue((mat.color));
3677
+ modulationField.SetToolTipValue((mat.modulation));
3678
+ metalnessField.SetToolTipValue((mat.metalness));
3679
+ diffuseField.SetToolTipValue((mat.diffuse));
3680
+ specularField.SetToolTipValue((mat.specular));
3681
+ shininessField.SetToolTipValue((mat.shininess));
3682
+ shiftField.SetToolTipValue((mat.shift));
3683
+ ambientField.SetToolTipValue((mat.ambient));
3684
+ lightareaField.SetToolTipValue((mat.lightarea));
3685
+ diffusenessField.SetToolTipValue((mat.factor));
3686
+ velvetField.SetToolTipValue((mat.velvet));
3687
+ sheenField.SetToolTipValue((mat.sheen));
3688
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3689
+ backlitField.SetToolTipValue((mat.bump));
3690
+ anisoField.SetToolTipValue((mat.aniso));
3691
+ anisoVField.SetToolTipValue((mat.anisoV));
3692
+ cameraField.SetToolTipValue((mat.cameralight));
3693
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3694
+ shadowField.SetToolTipValue((mat.shadow));
3695
+ textureField.SetToolTipValue((mat.texture));
3696
+ opacityField.SetToolTipValue((mat.opacity));
3697
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3698
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3699
+ }
3700
+
33803701 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33813702 {
33823703 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3421,6 +3742,7 @@
34213742 || e.getSource() == apertureField
34223743 || e.getSource() == shadowblurField)
34233744 {
3745
+ new Exception().printStackTrace();
34243746 System.exit(0);
34253747 cameraView.options1[0] = (float) focusField.getFloat() * 10;
34263748 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3491,7 +3813,7 @@
34913813 }
34923814
34933815 if (normalpushField != null)
3494
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3816
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
34953817 }
34963818
34973819 void SnapObject()
....@@ -3755,6 +4077,7 @@
37554077
37564078 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37574079 {
4080
+ Save();
37584081 //Tween.set(thing, 0).target(1).start(tweenManager);
37594082 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37604083 // if (thing instanceof GenericJointDemo)
....@@ -3958,6 +4281,7 @@
39584281 }
39594282 }
39604283 }
4284
+
39614285 LoadGFDThread loadGFDThread;
39624286
39634287 void ReadGFD(String fullname, iCallBack cb)
....@@ -3977,8 +4301,10 @@
39774301
39784302 try
39794303 {
4304
+ // Try compressed version first.
39804305 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3981
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4306
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4307
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39824308
39834309 readobj = (Object3D) p.readObject();
39844310 istream.close();
....@@ -3986,7 +4312,20 @@
39864312 readobj.ResetDisplayList();
39874313 } catch (Exception e)
39884314 {
3989
- e.printStackTrace();
4315
+ //e.printStackTrace();
4316
+ try
4317
+ {
4318
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4319
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4320
+
4321
+ readobj = (Object3D) p.readObject();
4322
+ istream.close();
4323
+
4324
+ readobj.ResetDisplayList();
4325
+ } catch (Exception e2)
4326
+ {
4327
+ e2.printStackTrace();
4328
+ }
39904329 }
39914330 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
39924331 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4032,6 +4371,12 @@
40324371
40334372 void LoadIt(Object obj)
40344373 {
4374
+ if (obj == null)
4375
+ {
4376
+ // Invalid file
4377
+ return;
4378
+ }
4379
+
40354380 System.out.println("Loaded " + obj);
40364381 //new Exception().printStackTrace();
40374382 Object3D readobj = (Object3D) obj;
....@@ -4041,6 +4386,7 @@
40414386
40424387 if (readobj != null)
40434388 {
4389
+ Save();
40444390 try
40454391 {
40464392 //readobj.deepCopySelf(copy);
....@@ -4103,7 +4449,7 @@
41034449
41044450 void load() // throws ClassNotFoundException
41054451 {
4106
- if (GrafreeD.standAlone)
4452
+ if (Grafreed.standAlone)
41074453 {
41084454 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41094455 browser.show();
....@@ -4190,11 +4536,13 @@
41904536 try
41914537 {
41924538 FileOutputStream ostream = new FileOutputStream(lastname);
4193
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4539
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4540
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
41944541
41954542 p.writeObject(copy);
41964543 p.flush();
41974544
4545
+ zstream.close();
41984546 ostream.close();
41994547
42004548 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4204,11 +4552,12 @@
42044552 {
42054553 }
42064554 }
4555
+
42074556 String lastname;
42084557
42094558 void saveAs()
42104559 {
4211
- if (GrafreeD.standAlone)
4560
+ if (Grafreed.standAlone)
42124561 {
42134562 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42144563 browser.setVisible(true);
....@@ -4313,13 +4662,13 @@
43134662 try
43144663 {
43154664 FileOutputStream ostream = new FileOutputStream(filename);
4316
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4317
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4665
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4666
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43184667
43194668 Object3D objectparent = obj.parent;
43204669 obj.parent = null;
43214670
4322
- Object3D object = (Object3D) GrafreeD.clone(obj);
4671
+ Object3D object = (Object3D) Grafreed.clone(obj);
43234672
43244673 obj.parent = objectparent;
43254674
....@@ -4331,8 +4680,8 @@
43314680 p.writeObject(object);
43324681 p.flush();
43334682
4683
+ zstream.close();
43344684 ostream.close();
4335
- // zstream.close();
43364685
43374686 // group.selection.get(0).parent = parent;
43384687 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4353,7 +4702,7 @@
43534702 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43544703 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43554704 copy.generatePOV(buffer);
4356
- if (GrafreeD.standAlone)
4705
+ if (Grafreed.standAlone)
43574706 {
43584707 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43594708 browser.show();
....@@ -4379,7 +4728,8 @@
43794728 Object3D client;
43804729 Object3D copy;
43814730 MenuBar menuBar;
4382
- Menu windowMenu;
4731
+ Menu fileMenu;
4732
+ MenuItem newItem;
43834733 MenuItem loadItem;
43844734 MenuItem saveItem;
43854735 MenuItem saveAsItem;
....@@ -4387,13 +4737,11 @@
43874737 MenuItem reexportItem;
43884738 MenuItem povItem;
43894739 MenuItem closeItem;
4390
- Menu cameraMenu;
4740
+
43914741 CheckboxMenuItem zBufferItem;
43924742 //MenuItem normalLensItem;
4393
- MenuItem editCameraItem;
4394
- MenuItem revertCameraItem;
4395
- CheckboxMenuItem toggleLiveItem;
43964743 MenuItem stepItem;
4744
+ CheckboxMenuItem toggleLiveItem;
43974745 CheckboxMenuItem toggleFullScreenItem;
43984746 CheckboxMenuItem toggleTimelineItem;
43994747 CheckboxMenuItem toggleRenderItem;
....@@ -4402,7 +4750,7 @@
44024750 CheckboxMenuItem toggleFootContactItem;
44034751 CheckboxMenuItem toggleDLItem;
44044752 CheckboxMenuItem toggleTextureItem;
4405
- CheckboxMenuItem toggleRandomItem;
4753
+ CheckboxMenuItem toggleSwitchItem;
44064754 CheckboxMenuItem toggleRootItem;
44074755 CheckboxMenuItem animationItem;
44084756 CheckboxMenuItem toggleHandleItem;
....@@ -4410,7 +4758,7 @@
44104758 JSplitPane mainPanel;
44114759 JScrollPane scrollpane;
44124760 JPanel toolbarPanel;
4413
- JPanel treePanel;
4761
+ cGridBag treePanel;
44144762 JPanel radioPanel;
44154763 ButtonGroup buttonGroup;
44164764 cGridBag ctrlPanel;
....@@ -4539,4 +4887,9 @@
45394887 //ObjectUI parent;
45404888
45414889 cNumberSlider normalpushField;
4890
+
4891
+ private MenuItem importGFDItem;
4892
+ private MenuItem importVRMLX3DItem;
4893
+ private MenuItem import3DSItem;
4894
+ private MenuItem importOBJItem;
45424895 }