Normand Briere
2019-06-16 372b7fd481a476cd659713a4a01bf28bf6760cbe
ObjEditor.java
....@@ -138,34 +138,41 @@
138138 public void closeUI()
139139 {
140140 //new Exception().printStackTrace();
141
- System.out.println("this = " + this);
142
- System.out.println("objEditor = " + objEditor);
141
+// System.out.println("this = " + this);
142
+// System.out.println("objEditor = " + objEditor);
143143 //nameField.removeActionListener(this);
144
- objEditor.ctrlPanel.remove(nameField);
144
+// objEditor.ctrlPanel.remove(nameField);
145
+
146
+ objEditor.ctrlPanel.remove(namePanel);
145147
146148 if (!GroupEditor.allparams)
147149 return;
148150
149
- objEditor.ctrlPanel.remove(liveCB);
150
- objEditor.ctrlPanel.remove(hideCB);
151
- objEditor.ctrlPanel.remove(markCB);
152
-
153
- objEditor.ctrlPanel.remove(randomCB);
154
- objEditor.ctrlPanel.remove(speedupCB);
155
- objEditor.ctrlPanel.remove(rewindCB);
156
-
157
- objEditor.ctrlPanel.remove(resetButton);
158
- objEditor.ctrlPanel.remove(stepButton);
159
-// objEditor.ctrlPanel.remove(stepAllButton);
160
-// objEditor.ctrlPanel.remove(resetAllButton);
161
- objEditor.ctrlPanel.remove(link2masterCB);
162
- //objEditor.ctrlPanel.remove(flipVCB);
163
- //objEditor.ctrlPanel.remove(texresMenu);
164
- objEditor.ctrlPanel.remove(slowerButton);
165
- objEditor.ctrlPanel.remove(fasterButton);
166
- objEditor.ctrlPanel.remove(remarkButton);
151
+// objEditor.ctrlPanel.remove(liveCB);
152
+// objEditor.ctrlPanel.remove(hideCB);
153
+// objEditor.ctrlPanel.remove(markCB);
154
+//
155
+// objEditor.ctrlPanel.remove(randomCB);
156
+// objEditor.ctrlPanel.remove(speedupCB);
157
+// objEditor.ctrlPanel.remove(rewindCB);
158
+//
159
+// objEditor.ctrlPanel.remove(resetButton);
160
+// objEditor.ctrlPanel.remove(stepButton);
161
+//// objEditor.ctrlPanel.remove(stepAllButton);
162
+//// objEditor.ctrlPanel.remove(resetAllButton);
163
+// objEditor.ctrlPanel.remove(link2masterCB);
164
+// //objEditor.ctrlPanel.remove(flipVCB);
165
+// //objEditor.ctrlPanel.remove(texresMenu);
166
+// objEditor.ctrlPanel.remove(slowerButton);
167
+// objEditor.ctrlPanel.remove(fasterButton);
168
+// objEditor.ctrlPanel.remove(remarkButton);
167169
168
- Remove(normalpushField);
170
+ objEditor.ctrlPanel.remove(setupPanel);
171
+ objEditor.ctrlPanel.remove(commandsPanel);
172
+ objEditor.ctrlPanel.remove(pushPanel);
173
+ //objEditor.ctrlPanel.remove(fillPanel);
174
+
175
+ //Remove(normalpushField);
169176 }
170177
171178 public ObjEditor GetEditor()
....@@ -269,24 +276,40 @@
269276 void SetupMenu()
270277 {
271278 frame.setMenuBar(menuBar = new MenuBar());
272
- menuBar.add(windowMenu = new Menu("File"));
273
- windowMenu.add(loadItem = new MenuItem("Load..."));
274
- windowMenu.add("-");
275
- windowMenu.add(saveItem = new MenuItem("Save"));
276
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
279
+ menuBar.add(fileMenu = new Menu("File"));
280
+ fileMenu.add(newItem = new MenuItem("New"));
281
+ fileMenu.add(loadItem = new MenuItem("Open..."));
282
+
283
+ //oe.menuBar.add(menu = new Menu("Include"));
284
+ Menu menu = new Menu("Import");
285
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
286
+ importOBJItem.addActionListener(this);
287
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
288
+ import3DSItem.addActionListener(this);
289
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
290
+ importVRMLX3DItem.addActionListener(this);
291
+ menu.add("-");
292
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
293
+ importGFDItem.addActionListener(this);
294
+ fileMenu.add(menu);
295
+ fileMenu.add("-");
296
+
297
+ fileMenu.add(saveItem = new MenuItem("Save"));
298
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
277299 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
278
- windowMenu.add("-");
279
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
280
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
281
- windowMenu.add("-");
300
+ fileMenu.add("-");
301
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
302
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
303
+ fileMenu.add("-");
282304 if (client.parent != null)
283305 {
284
- windowMenu.add(closeItem = new MenuItem("Close"));
306
+ fileMenu.add(closeItem = new MenuItem("Close"));
285307 } else
286308 {
287
- windowMenu.add(closeItem = new MenuItem("Exit"));
309
+ fileMenu.add(closeItem = new MenuItem("Exit"));
288310 }
289311
312
+ newItem.addActionListener(this);
290313 loadItem.addActionListener(this);
291314 saveItem.addActionListener(this);
292315 saveAsItem.addActionListener(this);
....@@ -295,79 +318,26 @@
295318 //povItem.addActionListener(this);
296319 closeItem.addActionListener(this);
297320
298
- menuBar.add(cameraMenu = new Menu("View"));
299
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
300
- //zBufferItem.addActionListener(this);
301
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
302
- //normalLensItem.addActionListener(this);
303
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
304
- revertCameraItem.addActionListener(this);
305
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
306
- toggleTimelineItem.addItemListener(this);
307
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
308
- toggleFullScreenItem.addItemListener(this);
309
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
310
- cameraMenu.add("-");
311
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
312
- toggleTextureItem.addItemListener(this);
313
- toggleTextureItem.setState(CameraPane.textureon);
314
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
315
- toggleLiveItem.addItemListener(this);
316
- toggleLiveItem.setState(Globals.isLIVE());
317
- cameraMenu.add(stepItem = new MenuItem("Step"));
318
- stepItem.addActionListener(this);
319
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
320
-// toggleDLItem.addItemListener(this);
321
-// toggleDLItem.setState(false);
322
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
323
- toggleRenderItem.addItemListener(this);
324
- toggleRenderItem.setState(!CameraPane.frozen);
325
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
326
- toggleDebugItem.addItemListener(this);
327
- toggleDebugItem.setState(CameraPane.DEBUG);
328
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
329
- toggleFrustumItem.addItemListener(this);
330
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
331
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
332
- toggleFootContactItem.addItemListener(this);
333
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
334
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
335
- toggleRandomItem.addItemListener(this);
336
- toggleRandomItem.setState(CameraPane.RANDOM);
337
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
338
- toggleHandleItem.addItemListener(this);
339
- toggleHandleItem.setState(CameraPane.HANDLES);
340
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
341
- togglePaintItem.addItemListener(this);
342
- togglePaintItem.setState(CameraPane.PAINTMODE);
343
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
344
-// toggleRootItem.addItemListener(this);
345
-// toggleRootItem.setState(false);
346
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
347
-// animationItem.addItemListener(this);
348
-// animationItem.setState(CameraPane.ANIMATION);
349
- cameraMenu.add("-");
350
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
351
- editCameraItem.addActionListener(this);
352
-
353321 objectPanel = new JTabbedPane();
354322 toolbarPanel = new JPanel();
355323 toolbarPanel.setName("Toolbar");
356
- treePanel = new JPanel();
324
+ treePanel = new cGridBag();
357325 treePanel.setName("Tree");
358
- ctrlPanel = new cGridBag(); // new GridBagLayout());
326
+ ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
359327 ctrlPanel.setName("Edit");
360328 materialPanel = new cGridBag().setVertical(true);
361329 materialPanel.setName("Material");
362330 /*JTextPane*/
363331 infoarea = createTextPane();
332
+ doc = infoarea.getStyledDocument();
333
+
364334 infoarea.setEditable(true);
365335 SetText();
366336 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
367337 // infoarea.setOpaque(false);
368338 // //infoarea.setForeground(textcolor);
369
- infoarea.setLineWrap(true);
370
- infoarea.setWrapStyleWord(true);
339
+// TEXTAREA infoarea.setLineWrap(true);
340
+// TEXTAREA infoarea.setWrapStyleWord(true);
371341 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
372342 infoPanel.setPreferredSize(new Dimension(50, 200));
373343 infoPanel.setName("Info");
....@@ -378,15 +348,15 @@
378348 mainPanel.setName("Main");
379349 mainPanel.setContinuousLayout(true);
380350 mainPanel.setOneTouchExpandable(true);
381
- mainPanel.setDividerLocation(1.0);
382351 mainPanel.setDividerSize(9);
383
- mainPanel.setResizeWeight(0);
352
+ mainPanel.setDividerLocation(0.5); //1.0);
353
+ mainPanel.setResizeWeight(0.5);
384354
385355 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
386356 //mainPanel.setLayout(new GridBagLayout());
387357 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
388
- treePanel.setLayout(new GridBagLayout());
389
- ctrlPanel.setLayout(new GridBagLayout());
358
+// treePanel.setLayout(new GridBagLayout());
359
+ //ctrlPanel.setLayout(new GridBagLayout());
390360 //materialPanel.setLayout(new GridBagLayout());
391361
392362 aConstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
....@@ -426,7 +396,7 @@
426396 static String newline = "\n";
427397 protected static final String buttonString = "JButton";
428398 StyledDocument doc;
429
- JTextArea infoarea;
399
+ JTextPane infoarea;
430400
431401 void ClearInfo()
432402 {
....@@ -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
....@@ -2074,19 +2072,19 @@
20742072
20752073 void LoadObjFile(String fullname)
20762074 {
2077
- /*
2075
+ System.out.println("Loading " + fullname);
2076
+ /**/
20782077 //lastFilename = fullname;
20792078 if(loadObjThread == null)
20802079 {
2081
- loadObjThread = new LoadOBJThread();
2082
- loadObjThread.start();
2080
+ loadObjThread = new LoadOBJThread();
2081
+ loadObjThread.start();
20832082 }
20842083
20852084 loadObjThread.add(fullname);
2086
- */
2085
+ /**/
20872086
2088
- System.out.println("Loading " + fullname);
2089
- makeSomething(new FileObject(fullname, true), true);
2087
+ //makeSomething(new FileObject(fullname, true), true);
20902088 }
20912089
20922090 void LoadGFDFile(String fullname)
....@@ -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,9 +2925,9 @@
29252925 frame.validate();
29262926
29272927 return;
2928
- } else if (event.getSource() == toggleRandomItem)
2928
+ } else if (event.getSource() == toggleSwitchItem)
29292929 {
2930
- cameraView.ToggleRandom();
2930
+ cameraView.ToggleSwitch();
29312931 cameraView.repaint();
29322932 return;
29332933 } else if (event.getSource() == toggleHandleItem)
....@@ -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,268 @@
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 byte[] Compress(Object3D o)
3218
+ {
3219
+ try
3220
+ {
3221
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3222
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3223
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3224
+
3225
+ Object3D parent = o.parent;
3226
+ o.parent = null;
3227
+
3228
+ out.writeObject(o);
3229
+
3230
+ o.parent = parent;
3231
+
3232
+ out.flush();
3233
+
3234
+ zstream.close();
3235
+ out.close();
3236
+
3237
+ return baos.toByteArray();
3238
+ } catch (Exception e)
3239
+ {
3240
+ System.err.println(e);
3241
+ return null;
3242
+ }
3243
+ }
3244
+
3245
+ static public Object Uncompress(byte[] bytes)
3246
+ {
3247
+ System.out.println("#bytes = " + bytes.length);
3248
+ try
3249
+ {
3250
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3251
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3252
+ ObjectInputStream in = new ObjectInputStream(istream);
3253
+ Object obj = in.readObject();
3254
+ in.close();
3255
+
3256
+ return obj;
3257
+ } catch (Exception e)
3258
+ {
3259
+ System.err.println(e);
3260
+ return null;
3261
+ }
3262
+ }
3263
+
3264
+ static public Object clone(Object o)
3265
+ {
3266
+ try
3267
+ {
3268
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3269
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3270
+
3271
+ out.writeObject(o);
3272
+
3273
+ out.flush();
3274
+ out.close();
3275
+
3276
+ byte[] bytes = baos.toByteArray();
3277
+
3278
+ System.out.println("clone = " + bytes.length);
3279
+
3280
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3281
+ ObjectInputStream in = new ObjectInputStream(bais);
3282
+ Object obj = in.readObject();
3283
+ in.close();
3284
+
3285
+ return obj;
3286
+ } catch (Exception e)
3287
+ {
3288
+ System.err.println(e);
3289
+ return null;
3290
+ }
3291
+ }
3292
+
3293
+ cRadio GetCurrentTab()
3294
+ {
3295
+ cRadio ab;
3296
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3297
+ {
3298
+ ab = (cRadio)e.nextElement();
3299
+ if(ab.GetObject() == copy)
3300
+ {
3301
+ return ab;
3302
+ }
3303
+ }
3304
+
3305
+ return null;
3306
+ }
3307
+
3308
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3309
+
3310
+ public void Save()
3311
+ {
3312
+ cRadio tab = GetCurrentTab();
3313
+
3314
+ boolean temp = CameraPane.SWITCH;
3315
+ CameraPane.SWITCH = false;
3316
+
3317
+ copy.ExtractBigData(hashtable);
3318
+
3319
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3320
+ tab.graphs[tab.undoindex++] = Compress(copy);
3321
+
3322
+ copy.RestoreBigData(hashtable);
3323
+
3324
+ CameraPane.SWITCH = temp;
3325
+
3326
+ //assert(hashtable.isEmpty());
3327
+
3328
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3329
+ {
3330
+ tab.graphs[i] = null;
3331
+ }
3332
+
3333
+ // test save
3334
+ if (false)
3335
+ {
3336
+ try
3337
+ {
3338
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3339
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3340
+
3341
+ p.writeObject(copy);
3342
+
3343
+ p.flush();
3344
+
3345
+ ostream.close();
3346
+ } catch (Exception e)
3347
+ {
3348
+ e.printStackTrace();
3349
+ }
3350
+ }
3351
+ }
3352
+
3353
+ void CopyChanged(Object3D obj)
3354
+ {
3355
+ boolean temp = CameraPane.SWITCH;
3356
+ CameraPane.SWITCH = false;
3357
+
3358
+ copy.ExtractBigData(hashtable);
3359
+
3360
+ copy.clear();
3361
+
3362
+ for (int i=0; i<obj.Size(); i++)
3363
+ {
3364
+ copy.add(obj.get(i));
3365
+ }
3366
+
3367
+ copy.RestoreBigData(hashtable);
3368
+
3369
+ CameraPane.SWITCH = temp;
3370
+
3371
+ //assert(hashtable.isEmpty());
3372
+
3373
+ copy.Touch();
3374
+
3375
+ ResetModel();
3376
+ copy.HardTouch(); // recompile?
3377
+
3378
+ cRadio ab;
3379
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3380
+ {
3381
+ ab = (cRadio)e.nextElement();
3382
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3383
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3384
+ if (test != null)
3385
+ {
3386
+ test.editWindow = ab.object.editWindow;
3387
+ ab.object = test;
3388
+ }
3389
+ }
3390
+
3391
+ refreshContents();
3392
+ }
3393
+
3394
+ public void Undo()
3395
+ {
3396
+ cRadio tab = GetCurrentTab();
3397
+
3398
+ if (tab.undoindex == 0)
3399
+ {
3400
+ java.awt.Toolkit.getDefaultToolkit().beep();
3401
+ return;
3402
+ }
3403
+
3404
+ if (tab.graphs[tab.undoindex] == null)
3405
+ {
3406
+ Save();
3407
+ tab.undoindex -= 1;
3408
+ }
3409
+
3410
+ tab.undoindex -= 1;
3411
+
3412
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3413
+ }
3414
+
3415
+ public void Redo()
3416
+ {
3417
+ cRadio tab = GetCurrentTab();
3418
+
3419
+ if (tab.graphs[tab.undoindex + 1] == null)
3420
+ {
3421
+ java.awt.Toolkit.getDefaultToolkit().beep();
3422
+ return;
3423
+ }
3424
+
3425
+ tab.undoindex += 1;
3426
+
3427
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3428
+ }
3429
+
3430
+ void ImportGFD()
3431
+ {
3432
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3433
+ browser.show();
3434
+ String filename = browser.getFile();
3435
+ if (filename != null && filename.length() > 0)
3436
+ {
3437
+ String fullname = browser.getDirectory() + filename;
3438
+
3439
+ //Object3D readobj =
3440
+ objEditor.ReadGFD(fullname, objEditor);
3441
+ //makeSomething(readobj);
3442
+ }
3443
+ }
3444
+
3445
+ void ImportVRMLX3D()
3446
+ {
3447
+ if (Grafreed.standAlone)
3448
+ {
3449
+ /**/
3450
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3451
+ browser.show();
3452
+ String filename = browser.getFile();
3453
+ if (filename != null && filename.length() > 0)
3454
+ {
3455
+ String fullname = browser.getDirectory() + filename;
3456
+ LoadVRMLX3D(fullname);
3457
+ }
3458
+ /**/
3459
+ }
3460
+ }
3461
+
31913462 void ToggleAnimation()
31923463 {
31933464 if (!Globals.ANIMATION)
31943465 {
31953466 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3196
- browser.show();
3467
+ browser.setVisible(true);
31973468 String filename = browser.getFile();
31983469 if (filename != null && filename.length() > 0)
31993470 {
....@@ -3203,8 +3474,8 @@
32033474
32043475 Globals.ANIMATION ^= true;
32053476
3206
- GrafreeD.wav.cursor = 0;
3207
- GrafreeD.wav.loop = 0;
3477
+ Grafreed.wav.cursor = 0;
3478
+ Grafreed.wav.loop = 0;
32083479 }
32093480 } else
32103481 {
....@@ -3254,7 +3525,7 @@
32543525 void CreateMaterial()
32553526 {
32563527 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
3528
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32583529 if (copy.selection.size() > 0)
32593530 //SetMaterial(copy);
32603531 {
....@@ -3313,11 +3584,11 @@
33133584 {
33143585 copy.ResetBlockLoop(); // temporary problem
33153586
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
3587
+ boolean random = CameraPane.SWITCH;
3588
+ CameraPane.SWITCH = false; // parse everything
33183589 copy.ResetDisplayList();
33193590 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
3591
+ CameraPane.SWITCH = random;
33213592 }
33223593
33233594 // public void applySelf()
....@@ -3391,6 +3662,36 @@
33913662 {
33923663 //System.out.println("Propagate = " + propagate);
33933664 copy.UpdateMaterial(anchor, current, propagate);
3665
+
3666
+ if (copy.material != null)
3667
+ {
3668
+ cMaterial mat = copy.material;
3669
+
3670
+ colorField.SetToolTipValue((mat.color));
3671
+ modulationField.SetToolTipValue((mat.modulation));
3672
+ metalnessField.SetToolTipValue((mat.metalness));
3673
+ diffuseField.SetToolTipValue((mat.diffuse));
3674
+ specularField.SetToolTipValue((mat.specular));
3675
+ shininessField.SetToolTipValue((mat.shininess));
3676
+ shiftField.SetToolTipValue((mat.shift));
3677
+ ambientField.SetToolTipValue((mat.ambient));
3678
+ lightareaField.SetToolTipValue((mat.lightarea));
3679
+ diffusenessField.SetToolTipValue((mat.factor));
3680
+ velvetField.SetToolTipValue((mat.velvet));
3681
+ sheenField.SetToolTipValue((mat.sheen));
3682
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3683
+ backlitField.SetToolTipValue((mat.bump));
3684
+ anisoField.SetToolTipValue((mat.aniso));
3685
+ anisoVField.SetToolTipValue((mat.anisoV));
3686
+ cameraField.SetToolTipValue((mat.cameralight));
3687
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3688
+ shadowField.SetToolTipValue((mat.shadow));
3689
+ textureField.SetToolTipValue((mat.texture));
3690
+ opacityField.SetToolTipValue((mat.opacity));
3691
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3692
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3693
+ }
3694
+
33943695 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33953696 {
33963697 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3435,6 +3736,7 @@
34353736 || e.getSource() == apertureField
34363737 || e.getSource() == shadowblurField)
34373738 {
3739
+ new Exception().printStackTrace();
34383740 System.exit(0);
34393741 cameraView.options1[0] = (float) focusField.getFloat() * 10;
34403742 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3505,7 +3807,7 @@
35053807 }
35063808
35073809 if (normalpushField != null)
3508
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3810
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35093811 }
35103812
35113813 void SnapObject()
....@@ -3769,6 +4071,7 @@
37694071
37704072 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37714073 {
4074
+ Save();
37724075 //Tween.set(thing, 0).target(1).start(tweenManager);
37734076 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37744077 // if (thing instanceof GenericJointDemo)
....@@ -3972,6 +4275,7 @@
39724275 }
39734276 }
39744277 }
4278
+
39754279 LoadGFDThread loadGFDThread;
39764280
39774281 void ReadGFD(String fullname, iCallBack cb)
....@@ -3992,7 +4296,8 @@
39924296 try
39934297 {
39944298 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3995
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4299
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4300
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39964301
39974302 readobj = (Object3D) p.readObject();
39984303 istream.close();
....@@ -4000,7 +4305,20 @@
40004305 readobj.ResetDisplayList();
40014306 } catch (Exception e)
40024307 {
4003
- e.printStackTrace();
4308
+ //e.printStackTrace();
4309
+ try
4310
+ {
4311
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4312
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4313
+
4314
+ readobj = (Object3D) p.readObject();
4315
+ istream.close();
4316
+
4317
+ readobj.ResetDisplayList();
4318
+ } catch (Exception e2)
4319
+ {
4320
+ e2.printStackTrace();
4321
+ }
40044322 }
40054323 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40064324 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4055,6 +4373,7 @@
40554373
40564374 if (readobj != null)
40574375 {
4376
+ Save();
40584377 try
40594378 {
40604379 //readobj.deepCopySelf(copy);
....@@ -4117,7 +4436,7 @@
41174436
41184437 void load() // throws ClassNotFoundException
41194438 {
4120
- if (GrafreeD.standAlone)
4439
+ if (Grafreed.standAlone)
41214440 {
41224441 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41234442 browser.show();
....@@ -4204,11 +4523,13 @@
42044523 try
42054524 {
42064525 FileOutputStream ostream = new FileOutputStream(lastname);
4207
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4526
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4527
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42084528
42094529 p.writeObject(copy);
42104530 p.flush();
42114531
4532
+ zstream.close();
42124533 ostream.close();
42134534
42144535 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4218,11 +4539,12 @@
42184539 {
42194540 }
42204541 }
4542
+
42214543 String lastname;
42224544
42234545 void saveAs()
42244546 {
4225
- if (GrafreeD.standAlone)
4547
+ if (Grafreed.standAlone)
42264548 {
42274549 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42284550 browser.setVisible(true);
....@@ -4327,13 +4649,13 @@
43274649 try
43284650 {
43294651 FileOutputStream ostream = new FileOutputStream(filename);
4330
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4331
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4652
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4653
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43324654
43334655 Object3D objectparent = obj.parent;
43344656 obj.parent = null;
43354657
4336
- Object3D object = (Object3D) GrafreeD.clone(obj);
4658
+ Object3D object = (Object3D) Grafreed.clone(obj);
43374659
43384660 obj.parent = objectparent;
43394661
....@@ -4345,8 +4667,8 @@
43454667 p.writeObject(object);
43464668 p.flush();
43474669
4670
+ zstream.close();
43484671 ostream.close();
4349
- // zstream.close();
43504672
43514673 // group.selection.get(0).parent = parent;
43524674 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4367,7 +4689,7 @@
43674689 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43684690 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43694691 copy.generatePOV(buffer);
4370
- if (GrafreeD.standAlone)
4692
+ if (Grafreed.standAlone)
43714693 {
43724694 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43734695 browser.show();
....@@ -4393,7 +4715,8 @@
43934715 Object3D client;
43944716 Object3D copy;
43954717 MenuBar menuBar;
4396
- Menu windowMenu;
4718
+ Menu fileMenu;
4719
+ MenuItem newItem;
43974720 MenuItem loadItem;
43984721 MenuItem saveItem;
43994722 MenuItem saveAsItem;
....@@ -4401,13 +4724,11 @@
44014724 MenuItem reexportItem;
44024725 MenuItem povItem;
44034726 MenuItem closeItem;
4404
- Menu cameraMenu;
4727
+
44054728 CheckboxMenuItem zBufferItem;
44064729 //MenuItem normalLensItem;
4407
- MenuItem editCameraItem;
4408
- MenuItem revertCameraItem;
4409
- CheckboxMenuItem toggleLiveItem;
44104730 MenuItem stepItem;
4731
+ CheckboxMenuItem toggleLiveItem;
44114732 CheckboxMenuItem toggleFullScreenItem;
44124733 CheckboxMenuItem toggleTimelineItem;
44134734 CheckboxMenuItem toggleRenderItem;
....@@ -4416,7 +4737,7 @@
44164737 CheckboxMenuItem toggleFootContactItem;
44174738 CheckboxMenuItem toggleDLItem;
44184739 CheckboxMenuItem toggleTextureItem;
4419
- CheckboxMenuItem toggleRandomItem;
4740
+ CheckboxMenuItem toggleSwitchItem;
44204741 CheckboxMenuItem toggleRootItem;
44214742 CheckboxMenuItem animationItem;
44224743 CheckboxMenuItem toggleHandleItem;
....@@ -4424,7 +4745,7 @@
44244745 JSplitPane mainPanel;
44254746 JScrollPane scrollpane;
44264747 JPanel toolbarPanel;
4427
- JPanel treePanel;
4748
+ cGridBag treePanel;
44284749 JPanel radioPanel;
44294750 ButtonGroup buttonGroup;
44304751 cGridBag ctrlPanel;
....@@ -4553,4 +4874,9 @@
45534874 //ObjectUI parent;
45544875
45554876 cNumberSlider normalpushField;
4877
+
4878
+ private MenuItem importGFDItem;
4879
+ private MenuItem importVRMLX3DItem;
4880
+ private MenuItem import3DSItem;
4881
+ private MenuItem importOBJItem;
45564882 }