Normand Briere
2019-06-11 4113164b3be1e50251ac40d6fd65660f0a6c2e63
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("Load..."));
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 {
....@@ -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
....@@ -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,253 @@
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(Object 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
+ out.writeObject(o);
3226
+
3227
+ out.flush();
3228
+
3229
+ zstream.close();
3230
+ out.close();
3231
+
3232
+ return baos.toByteArray();
3233
+ } catch (Exception e)
3234
+ {
3235
+ System.err.println(e);
3236
+ return null;
3237
+ }
3238
+ }
3239
+
3240
+ static public Object Uncompress(byte[] bytes)
3241
+ {
3242
+ System.out.println("#bytes = " + bytes.length);
3243
+ try
3244
+ {
3245
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3246
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3247
+ ObjectInputStream in = new ObjectInputStream(istream);
3248
+ Object obj = in.readObject();
3249
+ in.close();
3250
+
3251
+ return obj;
3252
+ } catch (Exception e)
3253
+ {
3254
+ System.err.println(e);
3255
+ return null;
3256
+ }
3257
+ }
3258
+
3259
+ static public Object clone(Object o)
3260
+ {
3261
+ try
3262
+ {
3263
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3264
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3265
+
3266
+ out.writeObject(o);
3267
+
3268
+ out.flush();
3269
+ out.close();
3270
+
3271
+ byte[] bytes = baos.toByteArray();
3272
+
3273
+ System.out.println("clone = " + bytes.length);
3274
+
3275
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3276
+ ObjectInputStream in = new ObjectInputStream(bais);
3277
+ Object obj = in.readObject();
3278
+ in.close();
3279
+
3280
+ return obj;
3281
+ } catch (Exception e)
3282
+ {
3283
+ System.err.println(e);
3284
+ return null;
3285
+ }
3286
+ }
3287
+
3288
+ cRadio GetCurrentTab()
3289
+ {
3290
+ cRadio ab;
3291
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3292
+ {
3293
+ ab = (cRadio)e.nextElement();
3294
+ if(ab.GetObject() == copy)
3295
+ {
3296
+ return ab;
3297
+ }
3298
+ }
3299
+
3300
+ return null;
3301
+ }
3302
+
3303
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3304
+
3305
+ public void Save()
3306
+ {
3307
+ cRadio tab = GetCurrentTab();
3308
+
3309
+ copy.ExtractBigData(hashtable);
3310
+
3311
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3312
+ tab.graphs[tab.undoindex++] = Compress(copy);
3313
+
3314
+ copy.RestoreBigData(hashtable);
3315
+
3316
+ //assert(hashtable.isEmpty());
3317
+
3318
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3319
+ {
3320
+ tab.graphs[i] = null;
3321
+ }
3322
+
3323
+ // test save
3324
+ if (false)
3325
+ {
3326
+ try
3327
+ {
3328
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3329
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3330
+
3331
+ p.writeObject(copy);
3332
+
3333
+ p.flush();
3334
+
3335
+ ostream.close();
3336
+ } catch (Exception e)
3337
+ {
3338
+ e.printStackTrace();
3339
+ }
3340
+ }
3341
+ }
3342
+
3343
+ void CopyChanged(Object3D obj)
3344
+ {
3345
+ copy.ExtractBigData(hashtable);
3346
+
3347
+ copy.clear();
3348
+
3349
+ for (int i=0; i<obj.Size(); i++)
3350
+ {
3351
+ copy.add(obj.get(i));
3352
+ }
3353
+
3354
+ copy.RestoreBigData(hashtable);
3355
+
3356
+ //assert(hashtable.isEmpty());
3357
+
3358
+ copy.Touch();
3359
+
3360
+ ResetModel();
3361
+ copy.HardTouch(); // recompile?
3362
+
3363
+ cRadio ab;
3364
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3365
+ {
3366
+ ab = (cRadio)e.nextElement();
3367
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3368
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3369
+ if (test != null)
3370
+ {
3371
+ test.editWindow = ab.object.editWindow;
3372
+ ab.object = test;
3373
+ }
3374
+ }
3375
+
3376
+ refreshContents();
3377
+ }
3378
+
3379
+ public void Undo()
3380
+ {
3381
+ cRadio tab = GetCurrentTab();
3382
+
3383
+ if (tab.undoindex == 0)
3384
+ {
3385
+ java.awt.Toolkit.getDefaultToolkit().beep();
3386
+ return;
3387
+ }
3388
+
3389
+ if (tab.graphs[tab.undoindex] == null)
3390
+ {
3391
+ Save();
3392
+ tab.undoindex -= 1;
3393
+ }
3394
+
3395
+ tab.undoindex -= 1;
3396
+
3397
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3398
+ }
3399
+
3400
+ public void Redo()
3401
+ {
3402
+ cRadio tab = GetCurrentTab();
3403
+
3404
+ if (tab.graphs[tab.undoindex + 1] == null)
3405
+ {
3406
+ java.awt.Toolkit.getDefaultToolkit().beep();
3407
+ return;
3408
+ }
3409
+
3410
+ tab.undoindex += 1;
3411
+
3412
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3413
+ }
3414
+
3415
+ void ImportGFD()
3416
+ {
3417
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3418
+ browser.show();
3419
+ String filename = browser.getFile();
3420
+ if (filename != null && filename.length() > 0)
3421
+ {
3422
+ String fullname = browser.getDirectory() + filename;
3423
+
3424
+ //Object3D readobj =
3425
+ objEditor.ReadGFD(fullname, objEditor);
3426
+ //makeSomething(readobj);
3427
+ }
3428
+ }
3429
+
3430
+ void ImportVRMLX3D()
3431
+ {
3432
+ if (Grafreed.standAlone)
3433
+ {
3434
+ /**/
3435
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3436
+ browser.show();
3437
+ String filename = browser.getFile();
3438
+ if (filename != null && filename.length() > 0)
3439
+ {
3440
+ String fullname = browser.getDirectory() + filename;
3441
+ LoadVRMLX3D(fullname);
3442
+ }
3443
+ /**/
3444
+ }
3445
+ }
3446
+
31773447 void ToggleAnimation()
31783448 {
31793449 if (!Globals.ANIMATION)
31803450 {
31813451 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3182
- browser.show();
3452
+ browser.setVisible(true);
31833453 String filename = browser.getFile();
31843454 if (filename != null && filename.length() > 0)
31853455 {
....@@ -3189,8 +3459,8 @@
31893459
31903460 Globals.ANIMATION ^= true;
31913461
3192
- GrafreeD.wav.cursor = 0;
3193
- GrafreeD.wav.loop = 0;
3462
+ Grafreed.wav.cursor = 0;
3463
+ Grafreed.wav.loop = 0;
31943464 }
31953465 } else
31963466 {
....@@ -3240,7 +3510,7 @@
32403510 void CreateMaterial()
32413511 {
32423512 //copy.ClearMaterial(); // PATCH
3243
- copy.CreateMaterialS(multiplyToggle.isSelected());
3513
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32443514 if (copy.selection.size() > 0)
32453515 //SetMaterial(copy);
32463516 {
....@@ -3299,11 +3569,11 @@
32993569 {
33003570 copy.ResetBlockLoop(); // temporary problem
33013571
3302
- boolean random = CameraPane.RANDOM;
3303
- CameraPane.RANDOM = false; // parse everything
3572
+ boolean random = CameraPane.SWITCH;
3573
+ CameraPane.SWITCH = false; // parse everything
33043574 copy.ResetDisplayList();
33053575 copy.HardTouch();
3306
- CameraPane.RANDOM = random;
3576
+ CameraPane.SWITCH = random;
33073577 }
33083578
33093579 // public void applySelf()
....@@ -3377,6 +3647,36 @@
33773647 {
33783648 //System.out.println("Propagate = " + propagate);
33793649 copy.UpdateMaterial(anchor, current, propagate);
3650
+
3651
+ if (copy.material != null)
3652
+ {
3653
+ cMaterial mat = copy.material;
3654
+
3655
+ colorField.SetToolTipValue((mat.color));
3656
+ modulationField.SetToolTipValue((mat.modulation));
3657
+ metalnessField.SetToolTipValue((mat.metalness));
3658
+ diffuseField.SetToolTipValue((mat.diffuse));
3659
+ specularField.SetToolTipValue((mat.specular));
3660
+ shininessField.SetToolTipValue((mat.shininess));
3661
+ shiftField.SetToolTipValue((mat.shift));
3662
+ ambientField.SetToolTipValue((mat.ambient));
3663
+ lightareaField.SetToolTipValue((mat.lightarea));
3664
+ diffusenessField.SetToolTipValue((mat.factor));
3665
+ velvetField.SetToolTipValue((mat.velvet));
3666
+ sheenField.SetToolTipValue((mat.sheen));
3667
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3668
+ backlitField.SetToolTipValue((mat.bump));
3669
+ anisoField.SetToolTipValue((mat.aniso));
3670
+ anisoVField.SetToolTipValue((mat.anisoV));
3671
+ cameraField.SetToolTipValue((mat.cameralight));
3672
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3673
+ shadowField.SetToolTipValue((mat.shadow));
3674
+ textureField.SetToolTipValue((mat.texture));
3675
+ opacityField.SetToolTipValue((mat.opacity));
3676
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3677
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3678
+ }
3679
+
33803680 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33813681 {
33823682 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3421,6 +3721,7 @@
34213721 || e.getSource() == apertureField
34223722 || e.getSource() == shadowblurField)
34233723 {
3724
+ new Exception().printStackTrace();
34243725 System.exit(0);
34253726 cameraView.options1[0] = (float) focusField.getFloat() * 10;
34263727 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3491,7 +3792,7 @@
34913792 }
34923793
34933794 if (normalpushField != null)
3494
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3795
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
34953796 }
34963797
34973798 void SnapObject()
....@@ -3755,6 +4056,7 @@
37554056
37564057 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37574058 {
4059
+ Save();
37584060 //Tween.set(thing, 0).target(1).start(tweenManager);
37594061 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37604062 // if (thing instanceof GenericJointDemo)
....@@ -3958,6 +4260,7 @@
39584260 }
39594261 }
39604262 }
4263
+
39614264 LoadGFDThread loadGFDThread;
39624265
39634266 void ReadGFD(String fullname, iCallBack cb)
....@@ -3978,7 +4281,8 @@
39784281 try
39794282 {
39804283 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3981
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4284
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4285
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39824286
39834287 readobj = (Object3D) p.readObject();
39844288 istream.close();
....@@ -3986,7 +4290,20 @@
39864290 readobj.ResetDisplayList();
39874291 } catch (Exception e)
39884292 {
3989
- e.printStackTrace();
4293
+ //e.printStackTrace();
4294
+ try
4295
+ {
4296
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4297
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4298
+
4299
+ readobj = (Object3D) p.readObject();
4300
+ istream.close();
4301
+
4302
+ readobj.ResetDisplayList();
4303
+ } catch (Exception e2)
4304
+ {
4305
+ e2.printStackTrace();
4306
+ }
39904307 }
39914308 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
39924309 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4041,6 +4358,7 @@
40414358
40424359 if (readobj != null)
40434360 {
4361
+ Save();
40444362 try
40454363 {
40464364 //readobj.deepCopySelf(copy);
....@@ -4103,7 +4421,7 @@
41034421
41044422 void load() // throws ClassNotFoundException
41054423 {
4106
- if (GrafreeD.standAlone)
4424
+ if (Grafreed.standAlone)
41074425 {
41084426 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41094427 browser.show();
....@@ -4190,11 +4508,13 @@
41904508 try
41914509 {
41924510 FileOutputStream ostream = new FileOutputStream(lastname);
4193
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4511
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4512
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
41944513
41954514 p.writeObject(copy);
41964515 p.flush();
41974516
4517
+ zstream.close();
41984518 ostream.close();
41994519
42004520 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4204,11 +4524,12 @@
42044524 {
42054525 }
42064526 }
4527
+
42074528 String lastname;
42084529
42094530 void saveAs()
42104531 {
4211
- if (GrafreeD.standAlone)
4532
+ if (Grafreed.standAlone)
42124533 {
42134534 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42144535 browser.setVisible(true);
....@@ -4313,13 +4634,13 @@
43134634 try
43144635 {
43154636 FileOutputStream ostream = new FileOutputStream(filename);
4316
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4317
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4637
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4638
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43184639
43194640 Object3D objectparent = obj.parent;
43204641 obj.parent = null;
43214642
4322
- Object3D object = (Object3D) GrafreeD.clone(obj);
4643
+ Object3D object = (Object3D) Grafreed.clone(obj);
43234644
43244645 obj.parent = objectparent;
43254646
....@@ -4331,8 +4652,8 @@
43314652 p.writeObject(object);
43324653 p.flush();
43334654
4655
+ zstream.close();
43344656 ostream.close();
4335
- // zstream.close();
43364657
43374658 // group.selection.get(0).parent = parent;
43384659 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4353,7 +4674,7 @@
43534674 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43544675 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43554676 copy.generatePOV(buffer);
4356
- if (GrafreeD.standAlone)
4677
+ if (Grafreed.standAlone)
43574678 {
43584679 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43594680 browser.show();
....@@ -4379,7 +4700,8 @@
43794700 Object3D client;
43804701 Object3D copy;
43814702 MenuBar menuBar;
4382
- Menu windowMenu;
4703
+ Menu fileMenu;
4704
+ MenuItem newItem;
43834705 MenuItem loadItem;
43844706 MenuItem saveItem;
43854707 MenuItem saveAsItem;
....@@ -4387,13 +4709,11 @@
43874709 MenuItem reexportItem;
43884710 MenuItem povItem;
43894711 MenuItem closeItem;
4390
- Menu cameraMenu;
4712
+
43914713 CheckboxMenuItem zBufferItem;
43924714 //MenuItem normalLensItem;
4393
- MenuItem editCameraItem;
4394
- MenuItem revertCameraItem;
4395
- CheckboxMenuItem toggleLiveItem;
43964715 MenuItem stepItem;
4716
+ CheckboxMenuItem toggleLiveItem;
43974717 CheckboxMenuItem toggleFullScreenItem;
43984718 CheckboxMenuItem toggleTimelineItem;
43994719 CheckboxMenuItem toggleRenderItem;
....@@ -4402,7 +4722,7 @@
44024722 CheckboxMenuItem toggleFootContactItem;
44034723 CheckboxMenuItem toggleDLItem;
44044724 CheckboxMenuItem toggleTextureItem;
4405
- CheckboxMenuItem toggleRandomItem;
4725
+ CheckboxMenuItem toggleSwitchItem;
44064726 CheckboxMenuItem toggleRootItem;
44074727 CheckboxMenuItem animationItem;
44084728 CheckboxMenuItem toggleHandleItem;
....@@ -4410,7 +4730,7 @@
44104730 JSplitPane mainPanel;
44114731 JScrollPane scrollpane;
44124732 JPanel toolbarPanel;
4413
- JPanel treePanel;
4733
+ cGridBag treePanel;
44144734 JPanel radioPanel;
44154735 ButtonGroup buttonGroup;
44164736 cGridBag ctrlPanel;
....@@ -4539,4 +4859,9 @@
45394859 //ObjectUI parent;
45404860
45414861 cNumberSlider normalpushField;
4862
+
4863
+ private MenuItem importGFDItem;
4864
+ private MenuItem importVRMLX3DItem;
4865
+ private MenuItem import3DSItem;
4866
+ private MenuItem importOBJItem;
45424867 }