Normand Briere
2019-06-11 1d909ffa0c2beb51d453b53b845c4f3a749ca5f0
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);
984
- Return();
978
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
979
+ normalpushField = (cNumberSlider)pushPanel.getComponent(1);
980
+ //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;
....@@ -1445,17 +1452,13 @@
14451452 //aConstraints.gridx += 1;
14461453 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14471454
1448
- JPanel colorPanel = new JPanel(new BorderLayout());
1449
- colorPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1450
-
14511455 cGridBag colorSection = new cGridBag().setVertical(true);
1452
-
1453
- colorPanel.add(colorSection);
14541456
14551457 cGridBag color = new cGridBag();
14561458 color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
14571459 colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14581460 color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1461
+ //colorField.preferredWidth = 200;
14591462 colorSection.add(color);
14601463
14611464 cGridBag modulation = new cGridBag();
....@@ -1488,16 +1491,13 @@
14881491 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
14891492 colorSection.add(shadowbias);
14901493
1491
- ctrlPanel.add(colorPanel);
1494
+ panel.add(new JSeparator());
1495
+
1496
+ panel.add(colorSection);
14921497
14931498 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14941499
1495
- JPanel diffusePanel = new JPanel(new BorderLayout());
1496
- diffusePanel.setBorder(BorderFactory.createLineBorder(Color.black));
1497
-
14981500 cGridBag diffuseSection = new cGridBag().setVertical(true);
1499
-
1500
- diffusePanel.add(diffuseSection);
15011501
15021502 cGridBag diffuse = new cGridBag();
15031503 diffuse.add(diffuseLabel = new JLabel("Diffuse")); // , aConstraints);
....@@ -1541,16 +1541,13 @@
15411541 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15421542 diffuseSection.add(fakedepth);
15431543
1544
- ctrlPanel.add(diffusePanel);
1544
+ panel.add(new JSeparator());
1545
+
1546
+ panel.add(diffuseSection);
15451547
15461548 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15471549
1548
- JPanel specularPanel = new JPanel(new BorderLayout());
1549
- specularPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1550
-
15511550 cGridBag specularSection = new cGridBag().setVertical(true);
1552
-
1553
- specularPanel.add(specularSection);
15541551
15551552 cGridBag specular = new cGridBag();
15561553 specular.add(specularLabel = new JLabel("Specular")); // , aConstraints);
....@@ -1582,7 +1579,7 @@
15821579 velvet.add(velvetField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15831580 specularSection.add(velvet);
15841581
1585
- 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);
15861583 //Return();
15871584 // ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
15881585 // shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
....@@ -1595,16 +1592,13 @@
15951592 // aConstraints.gridwidth = 1;
15961593
15971594
1598
- ctrlPanel.add(specularPanel);
1595
+ panel.add(new JSeparator());
1596
+
1597
+ panel.add(specularSection);
15991598
16001599 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16011600
1602
- JPanel globalPanel = new JPanel(new BorderLayout());
1603
- globalPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1604
-
16051601 cGridBag globalSection = new cGridBag().setVertical(true);
1606
-
1607
- globalPanel.add(globalSection);
16081602
16091603 cGridBag camera = new cGridBag();
16101604 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
....@@ -1630,16 +1624,13 @@
16301624 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16311625 globalSection.add(opacity);
16321626
1633
- ctrlPanel.add(globalPanel);
1627
+ panel.add(new JSeparator());
1628
+
1629
+ panel.add(globalSection);
16341630
16351631 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16361632
1637
- JPanel texturePanel = new JPanel(new BorderLayout());
1638
- texturePanel.setBorder(BorderFactory.createLineBorder(Color.black));
1639
-
16401633 cGridBag textureSection = new cGridBag().setVertical(true);
1641
-
1642
- texturePanel.add(textureSection);
16431634
16441635 cGridBag bump = new cGridBag();
16451636 bump.add(bumpLabel = new JLabel("Bump")); // , aConstraints);
....@@ -1677,7 +1668,9 @@
16771668 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16781669 textureSection.add(opacityPower);
16791670
1680
- ctrlPanel.add(texturePanel);
1671
+ panel.add(new JSeparator());
1672
+
1673
+ panel.add(textureSection);
16811674
16821675 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16831676
....@@ -1714,12 +1707,15 @@
17141707 opacityPowerField.addChangeListener(this);
17151708 /**/
17161709
1717
- resetSlidersButton.addActionListener(this);
17181710 clearMaterialButton.addActionListener(this);
17191711 createMaterialButton.addActionListener(this);
1720
-
1721
- propagateToggle.addItemListener(this);
1722
- multiplyToggle.addItemListener(this);
1712
+
1713
+ if (Globals.ADVANCED)
1714
+ {
1715
+ resetSlidersButton.addActionListener(this);
1716
+ propagateToggle.addItemListener(this);
1717
+ multiplyToggle.addItemListener(this);
1718
+ }
17231719 }
17241720
17251721 void DropFile(java.io.File[] files, boolean textures)
....@@ -1890,7 +1886,7 @@
18901886
18911887 //? flashIt = false;
18921888 CameraPane pane = (CameraPane) cameraView;
1893
- pane.clickStart(location.x, location.y, 0);
1889
+ pane.clickStart(location.x, location.y, 0, 0);
18941890 pane.clickEnd(location.x, location.y, 0, true);
18951891
18961892 if (group.selection.size() == 1)
....@@ -1939,6 +1935,7 @@
19391935 e2.printStackTrace();
19401936 }
19411937 }
1938
+
19421939 LoadJMEThread loadThread;
19431940
19441941 class LoadJMEThread extends Thread
....@@ -1996,6 +1993,7 @@
19961993 //LoadFile0(filename, converter);
19971994 }
19981995 }
1996
+
19991997 LoadOBJThread loadObjThread;
20001998
20011999 class LoadOBJThread extends Thread
....@@ -2347,11 +2345,11 @@
23472345
23482346 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23492347 {
2350
- if (GrafreeD.standAlone)
2348
+ if (Grafreed.standAlone)
23512349 {
23522350 /**/
23532351 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2354
- browser.show();
2352
+ browser.setVisible(true);
23552353 String filename = browser.getFile();
23562354 if (filename != null && filename.length() > 0)
23572355 {
....@@ -2496,6 +2494,7 @@
24962494 }
24972495 if (input == null)
24982496 {
2497
+ new Exception().printStackTrace();
24992498 System.exit(0);
25002499 }
25012500
....@@ -2710,7 +2709,8 @@
27102709 return;
27112710 }
27122711
2713
- multiplyToggle.setSelected(mat.multiply);
2712
+ if (multiplyToggle != null)
2713
+ multiplyToggle.setSelected(mat.multiply);
27142714
27152715 assert (object.projectedVertices != null);
27162716
....@@ -2925,7 +2925,7 @@
29252925 frame.validate();
29262926
29272927 return;
2928
- } else if (event.getSource() == toggleRandomItem)
2928
+ } else if (event.getSource() == toggleSwitchItem)
29292929 {
29302930 cameraView.ToggleRandom();
29312931 cameraView.repaint();
....@@ -2956,6 +2956,10 @@
29562956 {
29572957 copy.live ^= true;
29582958 return;
2959
+ } else if (event.getSource() == selectCB)
2960
+ {
2961
+ copy.dontselect ^= true;
2962
+ return;
29592963 } else if (event.getSource() == hideCB)
29602964 {
29612965 copy.hide ^= true;
....@@ -2970,6 +2974,7 @@
29702974 if (event.getSource() == randomCB)
29712975 {
29722976 copy.random ^= true;
2977
+ objEditor.refreshContents();
29732978 return;
29742979 }
29752980 if (event.getSource() == speedupCB)
....@@ -2993,8 +2998,9 @@
29932998
29942999 public void actionPerformed(ActionEvent event)
29953000 {
3001
+ Object source = event.getSource();
29963002 // SCRIPT DIALOG
2997
- if (event.getSource() == okbutton)
3003
+ if (source == okbutton)
29983004 {
29993005 textpanel.setVisible(false);
30003006 textpanel.remove(textarea);
....@@ -3006,7 +3012,7 @@
30063012 textarea = null;
30073013 textpanel = null;
30083014 }
3009
- if (event.getSource() == cancelbutton)
3015
+ if (source == cancelbutton)
30103016 {
30113017 textpanel.setVisible(false);
30123018 textpanel.remove(textarea);
....@@ -3018,50 +3024,50 @@
30183024 //applySelf();
30193025 //client.refreshEditWindow();
30203026 //refreshContents();
3021
- if (event.getSource() == nameField)
3027
+ if (source == nameField)
30223028 {
30233029 //System.out.println("ObjEditor " + event);
30243030 applySelf0(true);
30253031 //parent.applySelf();
30263032 objEditor.refreshContents();
3027
- } else if (event.getSource() == resetButton)
3033
+ } else if (source == resetButton)
30283034 {
30293035 CameraPane.fullreset = true;
30303036 copy.Reset(); // ResetMeshes();
30313037 copy.Touch();
30323038 objEditor.refreshContents();
3033
- } else if (event.getSource() == stepItem)
3039
+ } else if (source == stepItem)
30343040 {
30353041 //cameraView.ONESTEP = true;
30363042 Globals.ONESTEP = true;
30373043 cameraView.repaint();
30383044 return;
3039
- } else if (event.getSource() == stepButton)
3045
+ } else if (source == stepButton)
30403046 {
30413047 copy.Step();
30423048 copy.Touch();
30433049 objEditor.refreshContents();
3044
- } else if (event.getSource() == slowerButton)
3050
+ } else if (source == slowerButton)
30453051 {
30463052 copy.Slower();
30473053 copy.Touch();
30483054 objEditor.refreshContents();
3049
- } else if (event.getSource() == fasterButton)
3055
+ } else if (source == fasterButton)
30503056 {
30513057 copy.Faster();
30523058 copy.Touch();
30533059 objEditor.refreshContents();
3054
- } else if (event.getSource() == remarkButton)
3060
+ } else if (source == remarkButton)
30553061 {
30563062 copy.Remark();
30573063 copy.Touch();
30583064 objEditor.refreshContents();
3059
- } else if (event.getSource() == stepAllButton)
3065
+ } else if (source == stepAllButton)
30603066 {
30613067 copy.StepAll();
30623068 copy.Touch();
30633069 objEditor.refreshContents();
3064
- } else if (event.getSource() == resetAllButton)
3070
+ } else if (source == resetAllButton)
30653071 {
30663072 //CameraPane.fullreset = true;
30673073 copy.ResetAll(); // ResetMeshes();
....@@ -3094,53 +3100,75 @@
30943100 // Close();
30953101 // }
30963102 // else
3097
- if (event.getSource() == resetSlidersButton)
3103
+ if (source == resetSlidersButton)
30983104 {
30993105 ResetSliders();
3100
- } else if (event.getSource() == clearMaterialButton)
3106
+ } else if (source == clearMaterialButton)
31013107 {
31023108 ClearMaterial();
3103
- } else if (event.getSource() == createMaterialButton)
3109
+ } else if (source == createMaterialButton)
31043110 {
31053111 CreateMaterial();
3106
- } else if (event.getSource() == clearPanelButton)
3112
+ } else if (source == clearPanelButton)
31073113 {
31083114 copy.ClearUI();
31093115 refreshContents(true);
3110
- } /*
3111
- }
3112
-
3113
- public boolean action(Event event, Object arg)
3114
- {
3115
- */ 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)
31163141 {
31173142 Close();
31183143 //return true;
3119
- } else if (event.getSource() == loadItem)
3144
+ } else if (source == loadItem)
31203145 {
31213146 load();
31223147 //return true;
3123
- } else if (event.getSource() == saveItem)
3148
+ } else if (source == newItem)
3149
+ {
3150
+ New();
3151
+ } else if (source == saveItem)
31243152 {
31253153 save();
31263154 //return true;
3127
- } else if (event.getSource() == saveAsItem)
3155
+ } else if (source == saveAsItem)
31283156 {
31293157 saveAs();
31303158 //return true;
3131
- } else if (event.getSource() == reexportItem)
3159
+ } else if (source == reexportItem)
31323160 {
31333161 reexport();
31343162 //return true;
3135
- } else if (event.getSource() == exportAsItem)
3163
+ } else if (source == exportAsItem)
31363164 {
31373165 export();
31383166 //return true;
3139
- } else if (event.getSource() == povItem)
3167
+ } else if (source == povItem)
31403168 {
31413169 generatePOV();
31423170 //return true;
3143
- } else if (event.getSource() == zBufferItem)
3171
+ } else if (source == zBufferItem)
31443172 {
31453173 try
31463174 {
....@@ -3162,21 +3190,8 @@
31623190 cameraView.repaint();
31633191 //return true;
31643192 }
3165
- */ else if (event.getSource() == editCameraItem)
3166
- {
3167
- cameraView.ProtectCamera();
3168
- cameraView.repaint();
3169
- return;
3170
- } else if (event.getSource() == revertCameraItem)
3171
- {
3172
- cameraView.RevertCamera();
3173
- cameraView.repaint();
3174
- return;
3175
-// } else if (event.getSource() == textureButton)
3176
-// {
3177
-// return; // true;
3178
- } else // combos...
3179
- if (event.getSource() == texresMenu)
3193
+ */ else // combos...
3194
+ if (source == texresMenu)
31803195 {
31813196 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31823197 copy.texres = texresMenu.getSelectedIndex();
....@@ -3188,12 +3203,190 @@
31883203 }
31893204 }
31903205
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 Object clone(Object o)
3218
+ {
3219
+ try
3220
+ {
3221
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3222
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3223
+
3224
+ out.writeObject(o);
3225
+
3226
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
3227
+ ObjectInputStream in = new ObjectInputStream(bais);
3228
+ Object obj = in.readObject();
3229
+ in.close();
3230
+ out.close();
3231
+ return obj;
3232
+ } catch (Exception e)
3233
+ {
3234
+ System.err.println(e);
3235
+ return null;
3236
+ }
3237
+ }
3238
+
3239
+ cRadio GetCurrentTab()
3240
+ {
3241
+ cRadio ab;
3242
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3243
+ {
3244
+ ab = (cRadio)e.nextElement();
3245
+ if(ab.GetObject() == copy)
3246
+ {
3247
+ return ab;
3248
+ }
3249
+ }
3250
+
3251
+ return null;
3252
+ }
3253
+
3254
+ public void Save()
3255
+ {
3256
+ cRadio tab = GetCurrentTab();
3257
+
3258
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3259
+ tab.graphs[tab.undoindex++] = (Object3D)clone(copy);
3260
+
3261
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3262
+ {
3263
+ tab.graphs[i] = null;
3264
+ }
3265
+
3266
+ // test save
3267
+ if (false)
3268
+ {
3269
+ try
3270
+ {
3271
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3272
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3273
+
3274
+ p.writeObject(copy);
3275
+
3276
+ p.flush();
3277
+
3278
+ ostream.close();
3279
+ } catch (Exception e)
3280
+ {
3281
+ e.printStackTrace();
3282
+ }
3283
+ }
3284
+ }
3285
+
3286
+ void CopyChanged(Object3D obj)
3287
+ {
3288
+ copy.clear();
3289
+
3290
+ for (int i=0; i<obj.Size(); i++)
3291
+ {
3292
+ copy.add(obj.get(i));
3293
+ }
3294
+
3295
+ copy.Touch();
3296
+
3297
+ ResetModel();
3298
+ copy.HardTouch(); // recompile?
3299
+
3300
+ cRadio ab;
3301
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3302
+ {
3303
+ ab = (cRadio)e.nextElement();
3304
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3305
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3306
+ if (test != null)
3307
+ {
3308
+ test.editWindow = ab.object.editWindow;
3309
+ ab.object = test;
3310
+ }
3311
+ }
3312
+
3313
+ refreshContents();
3314
+ }
3315
+
3316
+ public void Undo()
3317
+ {
3318
+ cRadio tab = GetCurrentTab();
3319
+
3320
+ if (tab.undoindex == 0)
3321
+ {
3322
+ java.awt.Toolkit.getDefaultToolkit().beep();
3323
+ return;
3324
+ }
3325
+
3326
+ if (tab.graphs[tab.undoindex] == null)
3327
+ {
3328
+ Save();
3329
+ tab.undoindex -= 1;
3330
+ }
3331
+
3332
+ tab.undoindex -= 1;
3333
+
3334
+ CopyChanged(tab.graphs[tab.undoindex]);
3335
+ }
3336
+
3337
+ public void Redo()
3338
+ {
3339
+ cRadio tab = GetCurrentTab();
3340
+
3341
+ if (tab.graphs[tab.undoindex + 1] == null)
3342
+ {
3343
+ java.awt.Toolkit.getDefaultToolkit().beep();
3344
+ return;
3345
+ }
3346
+
3347
+ tab.undoindex += 1;
3348
+
3349
+ CopyChanged(tab.graphs[tab.undoindex]);
3350
+ }
3351
+
3352
+ void ImportGFD()
3353
+ {
3354
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3355
+ browser.show();
3356
+ String filename = browser.getFile();
3357
+ if (filename != null && filename.length() > 0)
3358
+ {
3359
+ String fullname = browser.getDirectory() + filename;
3360
+
3361
+ //Object3D readobj =
3362
+ objEditor.ReadGFD(fullname, objEditor);
3363
+ //makeSomething(readobj);
3364
+ }
3365
+ }
3366
+
3367
+ void ImportVRMLX3D()
3368
+ {
3369
+ if (Grafreed.standAlone)
3370
+ {
3371
+ /**/
3372
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3373
+ browser.show();
3374
+ String filename = browser.getFile();
3375
+ if (filename != null && filename.length() > 0)
3376
+ {
3377
+ String fullname = browser.getDirectory() + filename;
3378
+ LoadVRMLX3D(fullname);
3379
+ }
3380
+ /**/
3381
+ }
3382
+ }
3383
+
31913384 void ToggleAnimation()
31923385 {
31933386 if (!Globals.ANIMATION)
31943387 {
31953388 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3196
- browser.show();
3389
+ browser.setVisible(true);
31973390 String filename = browser.getFile();
31983391 if (filename != null && filename.length() > 0)
31993392 {
....@@ -3203,8 +3396,8 @@
32033396
32043397 Globals.ANIMATION ^= true;
32053398
3206
- GrafreeD.wav.cursor = 0;
3207
- GrafreeD.wav.loop = 0;
3399
+ Grafreed.wav.cursor = 0;
3400
+ Grafreed.wav.loop = 0;
32083401 }
32093402 } else
32103403 {
....@@ -3254,7 +3447,7 @@
32543447 void CreateMaterial()
32553448 {
32563449 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
3450
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32583451 if (copy.selection.size() > 0)
32593452 //SetMaterial(copy);
32603453 {
....@@ -3313,11 +3506,11 @@
33133506 {
33143507 copy.ResetBlockLoop(); // temporary problem
33153508
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
3509
+ boolean random = CameraPane.SWITCH;
3510
+ CameraPane.SWITCH = false; // parse everything
33183511 copy.ResetDisplayList();
33193512 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
3513
+ CameraPane.SWITCH = random;
33213514 }
33223515
33233516 // public void applySelf()
....@@ -3391,6 +3584,36 @@
33913584 {
33923585 //System.out.println("Propagate = " + propagate);
33933586 copy.UpdateMaterial(anchor, current, propagate);
3587
+
3588
+ if (copy.material != null)
3589
+ {
3590
+ cMaterial mat = copy.material;
3591
+
3592
+ colorField.SetToolTipValue((mat.color));
3593
+ modulationField.SetToolTipValue((mat.modulation));
3594
+ metalnessField.SetToolTipValue((mat.metalness));
3595
+ diffuseField.SetToolTipValue((mat.diffuse));
3596
+ specularField.SetToolTipValue((mat.specular));
3597
+ shininessField.SetToolTipValue((mat.shininess));
3598
+ shiftField.SetToolTipValue((mat.shift));
3599
+ ambientField.SetToolTipValue((mat.ambient));
3600
+ lightareaField.SetToolTipValue((mat.lightarea));
3601
+ diffusenessField.SetToolTipValue((mat.factor));
3602
+ velvetField.SetToolTipValue((mat.velvet));
3603
+ sheenField.SetToolTipValue((mat.sheen));
3604
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3605
+ backlitField.SetToolTipValue((mat.bump));
3606
+ anisoField.SetToolTipValue((mat.aniso));
3607
+ anisoVField.SetToolTipValue((mat.anisoV));
3608
+ cameraField.SetToolTipValue((mat.cameralight));
3609
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3610
+ shadowField.SetToolTipValue((mat.shadow));
3611
+ textureField.SetToolTipValue((mat.texture));
3612
+ opacityField.SetToolTipValue((mat.opacity));
3613
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3614
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3615
+ }
3616
+
33943617 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33953618 {
33963619 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3435,6 +3658,7 @@
34353658 || e.getSource() == apertureField
34363659 || e.getSource() == shadowblurField)
34373660 {
3661
+ new Exception().printStackTrace();
34383662 System.exit(0);
34393663 cameraView.options1[0] = (float) focusField.getFloat() * 10;
34403664 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3505,7 +3729,7 @@
35053729 }
35063730
35073731 if (normalpushField != null)
3508
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3732
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35093733 }
35103734
35113735 void SnapObject()
....@@ -3769,6 +3993,7 @@
37693993
37703994 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37713995 {
3996
+ Save();
37723997 //Tween.set(thing, 0).target(1).start(tweenManager);
37733998 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37743999 // if (thing instanceof GenericJointDemo)
....@@ -3972,6 +4197,7 @@
39724197 }
39734198 }
39744199 }
4200
+
39754201 LoadGFDThread loadGFDThread;
39764202
39774203 void ReadGFD(String fullname, iCallBack cb)
....@@ -3992,7 +4218,8 @@
39924218 try
39934219 {
39944220 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3995
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4221
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4222
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39964223
39974224 readobj = (Object3D) p.readObject();
39984225 istream.close();
....@@ -4000,7 +4227,20 @@
40004227 readobj.ResetDisplayList();
40014228 } catch (Exception e)
40024229 {
4003
- e.printStackTrace();
4230
+ //e.printStackTrace();
4231
+ try
4232
+ {
4233
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4234
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4235
+
4236
+ readobj = (Object3D) p.readObject();
4237
+ istream.close();
4238
+
4239
+ readobj.ResetDisplayList();
4240
+ } catch (Exception e2)
4241
+ {
4242
+ e2.printStackTrace();
4243
+ }
40044244 }
40054245 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40064246 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4117,7 +4357,7 @@
41174357
41184358 void load() // throws ClassNotFoundException
41194359 {
4120
- if (GrafreeD.standAlone)
4360
+ if (Grafreed.standAlone)
41214361 {
41224362 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41234363 browser.show();
....@@ -4204,11 +4444,13 @@
42044444 try
42054445 {
42064446 FileOutputStream ostream = new FileOutputStream(lastname);
4207
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4447
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4448
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42084449
42094450 p.writeObject(copy);
42104451 p.flush();
42114452
4453
+ zstream.close();
42124454 ostream.close();
42134455
42144456 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4218,11 +4460,12 @@
42184460 {
42194461 }
42204462 }
4463
+
42214464 String lastname;
42224465
42234466 void saveAs()
42244467 {
4225
- if (GrafreeD.standAlone)
4468
+ if (Grafreed.standAlone)
42264469 {
42274470 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42284471 browser.setVisible(true);
....@@ -4327,13 +4570,13 @@
43274570 try
43284571 {
43294572 FileOutputStream ostream = new FileOutputStream(filename);
4330
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4331
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4573
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4574
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43324575
43334576 Object3D objectparent = obj.parent;
43344577 obj.parent = null;
43354578
4336
- Object3D object = (Object3D) GrafreeD.clone(obj);
4579
+ Object3D object = (Object3D) Grafreed.clone(obj);
43374580
43384581 obj.parent = objectparent;
43394582
....@@ -4345,8 +4588,8 @@
43454588 p.writeObject(object);
43464589 p.flush();
43474590
4591
+ zstream.close();
43484592 ostream.close();
4349
- // zstream.close();
43504593
43514594 // group.selection.get(0).parent = parent;
43524595 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4367,7 +4610,7 @@
43674610 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43684611 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43694612 copy.generatePOV(buffer);
4370
- if (GrafreeD.standAlone)
4613
+ if (Grafreed.standAlone)
43714614 {
43724615 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43734616 browser.show();
....@@ -4393,7 +4636,8 @@
43934636 Object3D client;
43944637 Object3D copy;
43954638 MenuBar menuBar;
4396
- Menu windowMenu;
4639
+ Menu fileMenu;
4640
+ MenuItem newItem;
43974641 MenuItem loadItem;
43984642 MenuItem saveItem;
43994643 MenuItem saveAsItem;
....@@ -4401,13 +4645,11 @@
44014645 MenuItem reexportItem;
44024646 MenuItem povItem;
44034647 MenuItem closeItem;
4404
- Menu cameraMenu;
4648
+
44054649 CheckboxMenuItem zBufferItem;
44064650 //MenuItem normalLensItem;
4407
- MenuItem editCameraItem;
4408
- MenuItem revertCameraItem;
4409
- CheckboxMenuItem toggleLiveItem;
44104651 MenuItem stepItem;
4652
+ CheckboxMenuItem toggleLiveItem;
44114653 CheckboxMenuItem toggleFullScreenItem;
44124654 CheckboxMenuItem toggleTimelineItem;
44134655 CheckboxMenuItem toggleRenderItem;
....@@ -4416,7 +4658,7 @@
44164658 CheckboxMenuItem toggleFootContactItem;
44174659 CheckboxMenuItem toggleDLItem;
44184660 CheckboxMenuItem toggleTextureItem;
4419
- CheckboxMenuItem toggleRandomItem;
4661
+ CheckboxMenuItem toggleSwitchItem;
44204662 CheckboxMenuItem toggleRootItem;
44214663 CheckboxMenuItem animationItem;
44224664 CheckboxMenuItem toggleHandleItem;
....@@ -4424,7 +4666,7 @@
44244666 JSplitPane mainPanel;
44254667 JScrollPane scrollpane;
44264668 JPanel toolbarPanel;
4427
- JPanel treePanel;
4669
+ cGridBag treePanel;
44284670 JPanel radioPanel;
44294671 ButtonGroup buttonGroup;
44304672 cGridBag ctrlPanel;
....@@ -4553,4 +4795,9 @@
45534795 //ObjectUI parent;
45544796
45554797 cNumberSlider normalpushField;
4798
+
4799
+ private MenuItem importGFDItem;
4800
+ private MenuItem importVRMLX3DItem;
4801
+ private MenuItem import3DSItem;
4802
+ private MenuItem importOBJItem;
45564803 }