Normand Briere
2019-06-29 a69bb4474a3264a9a7a7f8b8d8154ea771f167c8
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -35,6 +39,67 @@
3539
3640 GroupEditor callee;
3741 JFrame frame;
42
+
43
+ static ObjEditor theFrame;
44
+
45
+ cButton GetButton(String name, boolean border)
46
+ {
47
+ try
48
+ {
49
+ ImageIcon icon = GetIcon(name);
50
+ return new cButton(icon, border);
51
+ }
52
+ catch (Exception e)
53
+ {
54
+ return new cButton(name, border);
55
+ }
56
+ }
57
+
58
+ cToggleButton GetToggleButton(String name, boolean border)
59
+ {
60
+ try
61
+ {
62
+ ImageIcon icon = GetIcon(name);
63
+ return new cToggleButton(icon, border);
64
+ }
65
+ catch (Exception e)
66
+ {
67
+ return new cToggleButton(name, border);
68
+ }
69
+ }
70
+
71
+ cCheckBox GetCheckBox(String name, boolean border)
72
+ {
73
+ try
74
+ {
75
+ ImageIcon icon = GetIcon(name);
76
+ return new cCheckBox(icon, border);
77
+ }
78
+ catch (Exception e)
79
+ {
80
+ return new cCheckBox(name, border);
81
+ }
82
+ }
83
+
84
+ private ImageIcon GetIcon(String name) throws IOException
85
+ {
86
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
+
88
+ if (image.getWidth() != 24 && image.getHeight() != 24)
89
+ {
90
+ BufferedImage resized = new BufferedImage(24, 24, image.getType());
91
+ Graphics2D g = resized.createGraphics();
92
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
93
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
94
+ g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
95
+ g.dispose();
96
+
97
+ image = resized;
98
+ }
99
+
100
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
+ return icon;
102
+ }
38103
39104 // SCRIPT
40105
....@@ -138,34 +203,42 @@
138203 public void closeUI()
139204 {
140205 //new Exception().printStackTrace();
141
- System.out.println("this = " + this);
142
- System.out.println("objEditor = " + objEditor);
206
+// System.out.println("this = " + this);
207
+// System.out.println("objEditor = " + objEditor);
143208 //nameField.removeActionListener(this);
144
- objEditor.ctrlPanel.remove(nameField);
209
+// objEditor.ctrlPanel.remove(nameField);
145210
146
- if (!GroupEditor.allparams)
211
+ objEditor.ctrlPanel.remove(namePanel);
212
+
213
+ if (!allparams)
147214 return;
148215
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);
216
+// objEditor.ctrlPanel.remove(liveCB);
217
+// objEditor.ctrlPanel.remove(hideCB);
218
+// objEditor.ctrlPanel.remove(markCB);
219
+//
220
+// objEditor.ctrlPanel.remove(randomCB);
221
+// objEditor.ctrlPanel.remove(speedupCB);
222
+// objEditor.ctrlPanel.remove(rewindCB);
223
+//
224
+// objEditor.ctrlPanel.remove(resetButton);
225
+// objEditor.ctrlPanel.remove(stepButton);
226
+//// objEditor.ctrlPanel.remove(stepAllButton);
227
+//// objEditor.ctrlPanel.remove(resetAllButton);
228
+// objEditor.ctrlPanel.remove(link2masterCB);
229
+// //objEditor.ctrlPanel.remove(flipVCB);
230
+// //objEditor.ctrlPanel.remove(texresMenu);
231
+// objEditor.ctrlPanel.remove(slowerButton);
232
+// objEditor.ctrlPanel.remove(fasterButton);
233
+// objEditor.ctrlPanel.remove(remarkButton);
167234
168
- Remove(normalpushField);
235
+ objEditor.ctrlPanel.remove(setupPanel);
236
+ objEditor.ctrlPanel.remove(setupPanel2);
237
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
238
+ objEditor.ctrlPanel.remove(pushPanel);
239
+ //objEditor.ctrlPanel.remove(fillPanel);
240
+
241
+ //Remove(normalpushField);
169242 }
170243
171244 public ObjEditor GetEditor()
....@@ -236,6 +309,7 @@
236309 //localCopy.parent = null;
237310
238311 frame = new JFrame();
312
+ frame.setUndecorated(true);
239313 objEditor = this;
240314 this.callee = callee;
241315
....@@ -266,27 +340,48 @@
266340 return frame.action(event, obj);
267341 }
268342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
269348 void SetupMenu()
270349 {
271350 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..."));
351
+ menuBar.add(fileMenu = new Menu("File"));
352
+ fileMenu.add(newItem = new MenuItem("New"));
353
+ fileMenu.add(loadItem = new MenuItem("Open..."));
354
+
355
+ //oe.menuBar.add(menu = new Menu("Include"));
356
+ Menu menu = new Menu("Import");
357
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
358
+ importOBJItem.addActionListener(this);
359
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
360
+ import3DSItem.addActionListener(this);
361
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
362
+ importVRMLX3DItem.addActionListener(this);
363
+ menu.add("-");
364
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
365
+ importGFDItem.addActionListener(this);
366
+ fileMenu.add(menu);
367
+ fileMenu.add("-");
368
+
369
+ fileMenu.add(saveItem = new MenuItem("Save"));
370
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
277371 //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("-");
372
+ fileMenu.add("-");
373
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
374
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
375
+ fileMenu.add("-");
282376 if (client.parent != null)
283377 {
284
- windowMenu.add(closeItem = new MenuItem("Close"));
378
+ fileMenu.add(closeItem = new MenuItem("Close"));
285379 } else
286380 {
287
- windowMenu.add(closeItem = new MenuItem("Exit"));
381
+ fileMenu.add(closeItem = new MenuItem("Exit"));
288382 }
289383
384
+ newItem.addActionListener(this);
290385 loadItem.addActionListener(this);
291386 saveItem.addActionListener(this);
292387 saveAsItem.addActionListener(this);
....@@ -295,81 +390,66 @@
295390 //povItem.addActionListener(this);
296391 closeItem.addActionListener(this);
297392
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
-
353393 objectPanel = new JTabbedPane();
394
+
395
+ ChangeListener changeListener = new ChangeListener()
396
+ {
397
+ public void stateChanged(ChangeEvent changeEvent)
398
+ {
399
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
400
+// {
401
+// if (latestObject != null)
402
+// {
403
+// refreshContents(true);
404
+// SetMaterial(latestObject);
405
+// }
406
+//
407
+// materialFlushed = true;
408
+// }
409
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
410
+// {
411
+// if (listUI.size() == 0)
412
+// EditSelection(false);
413
+// }
414
+
415
+ refreshContents(false); // To refresh Info tab
416
+ }
417
+ };
418
+ objectPanel.addChangeListener(changeListener);
419
+
354420 toolbarPanel = new JPanel();
355421 toolbarPanel.setName("Toolbar");
356
- treePanel = new JPanel();
422
+ treePanel = new cGridBag();
357423 treePanel.setName("Tree");
358
- ctrlPanel = new cGridBag(); // new GridBagLayout());
359
- ctrlPanel.setName("Edit");
424
+
425
+ editPanel = new cGridBag().setVertical(true);
426
+ editPanel.setName("Edit");
427
+
428
+ ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429
+
430
+ editCommandsPanel = new cGridBag();
431
+ editPanel.add(editCommandsPanel);
432
+ editPanel.add(ctrlPanel);
433
+
434
+ toolboxPanel = new cGridBag().setVertical(false);
435
+ toolboxPanel.setName("Toolbox");
436
+
360437 materialPanel = new cGridBag().setVertical(true);
361438 materialPanel.setName("Material");
439
+
362440 /*JTextPane*/
363441 infoarea = createTextPane();
442
+ doc = infoarea.getStyledDocument();
443
+
364444 infoarea.setEditable(true);
365445 SetText();
366446 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
367447 // infoarea.setOpaque(false);
368448 // //infoarea.setForeground(textcolor);
369
- infoarea.setLineWrap(true);
370
- infoarea.setWrapStyleWord(true);
449
+// TEXTAREA infoarea.setLineWrap(true);
450
+// TEXTAREA infoarea.setWrapStyleWord(true);
371451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
372
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ //infoPanel.setPreferredSize(new Dimension(50, 200));
373453 infoPanel.setName("Info");
374454 //infoPanel.setLayout(new BorderLayout());
375455 //infoPanel.add(createTextPane());
....@@ -378,15 +458,22 @@
378458 mainPanel.setName("Main");
379459 mainPanel.setContinuousLayout(true);
380460 mainPanel.setOneTouchExpandable(true);
381
- mainPanel.setDividerLocation(1.0);
382461 mainPanel.setDividerSize(9);
383
- mainPanel.setResizeWeight(0);
384
-
462
+ mainPanel.setDividerLocation(0.5); //1.0);
463
+ mainPanel.setResizeWeight(0.5);
464
+
465
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
466
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
467
+ divider.setDividerSize(15);
468
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
469
+
470
+ mainPanel.setUI(new BasicSplitPaneUI());
471
+
385472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
386473 //mainPanel.setLayout(new GridBagLayout());
387474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
388
- treePanel.setLayout(new GridBagLayout());
389
- ctrlPanel.setLayout(new GridBagLayout());
475
+// treePanel.setLayout(new GridBagLayout());
476
+ //ctrlPanel.setLayout(new GridBagLayout());
390477 //materialPanel.setLayout(new GridBagLayout());
391478
392479 aConstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
....@@ -426,7 +513,7 @@
426513 static String newline = "\n";
427514 protected static final String buttonString = "JButton";
428515 StyledDocument doc;
429
- JTextArea infoarea;
516
+ JTextPane infoarea;
430517
431518 void ClearInfo()
432519 {
....@@ -449,10 +536,10 @@
449536 e.printStackTrace();
450537 }
451538
452
- String selection = infoarea.getText();
453
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
454
- java.awt.datatransfer.Clipboard clipboard =
455
- Toolkit.getDefaultToolkit().getSystemClipboard();
539
+// String selection = infoarea.getText();
540
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
541
+// java.awt.datatransfer.Clipboard clipboard =
542
+// Toolkit.getDefaultToolkit().getSystemClipboard();
456543 //clipboard.setContents(data, data);
457544 }
458545
....@@ -475,13 +562,13 @@
475562 //SendInfo("Name:", "bold");
476563 if (sel.GetTextures() != null || debug)
477564 {
478
- si.SendInfo(sel.toString(), "bold");
565
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
479566 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
480567 if (sel.Size() > 0)
481568 {
482569 si.SendInfo("#children = " + sel.Size(), "regular");
483570 }
484
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
571
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
485572 if (debug)
486573 {
487574 try
....@@ -493,7 +580,10 @@
493580 }
494581
495582 if (full)
496
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
583
+ {
584
+ si.SendInfo(" BBox min: " + minima, "regular");
585
+ si.SendInfo(" BBox max: " + maxima, "regular");
586
+ }
497587
498588 if (sel.bRep != null)
499589 {
....@@ -520,7 +610,7 @@
520610 }
521611 if (sel.support != null)
522612 {
523
- si.SendInfo(" support: " + sel.support, "regular");
613
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
524614 }
525615 if (sel.scriptnode != null)
526616 {
....@@ -591,6 +681,9 @@
591681 {
592682 CameraPane.pointflow = (PointFlow) sel;
593683 }
684
+
685
+ si.SendInfo("_____________________", "regular");
686
+ si.SendInfo("", "regular");
594687 }
595688 }
596689
....@@ -606,68 +699,159 @@
606699 }
607700 }
608701
702
+static GraphicsDevice device = GraphicsEnvironment
703
+ .getLocalGraphicsEnvironment().getScreenDevices()[0];
704
+
705
+ Rectangle keeprect;
706
+ cRadio radio;
707
+
708
+cButton keepButton;
709
+ cButton twoButton; // Full 3D
710
+ cButton sixButton;
711
+ cButton threeButton;
712
+ cButton sevenButton;
713
+ cButton fourButton; // full panel
714
+ cButton oneButton; // full XYZ
715
+ //cButton currentLayout;
716
+
717
+ boolean maximized;
718
+
719
+ cButton fullscreenLayout;
720
+
721
+ void Minimize()
722
+ {
723
+ frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
725
+ }
726
+
727
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
728
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
729
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
730
+ void Maximize()
731
+ {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
737
+ if (maximized)
738
+ {
739
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
740
+ }
741
+ else
742
+ {
743
+ keeprect = frame.getBounds();
744
+ Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
745
+ Dimension rect2 = frame.getToolkit().getScreenSize();
746
+ frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
747
+// frame.setState(Frame.MAXIMIZED_BOTH);
748
+ }
749
+
750
+ maximized ^= true;
751
+
752
+ frame.validate();
753
+ }
754
+
755
+ cButton minButton;
756
+ cButton maxButton;
757
+ cButton fullButton;
758
+
609759 void ToggleFullScreen()
610760 {
611
- if (CameraPane.FULLSCREEN)
761
+ cameraView.ToggleFullScreen();
762
+
763
+ if (!CameraPane.FULLSCREEN)
612764 {
613
- frame.getContentPane().remove(/*"Center",*/bigThree);
614
- framePanel.add(bigThree);
615
- frame.getContentPane().add(/*"Center",*/framePanel);
765
+ device.setFullScreenWindow(null);
766
+ frame.validate();
767
+
768
+ //frame.setVisible(false);
769
+// frame.removeNotify();
770
+// frame.setUndecorated(false);
771
+// frame.addNotify();
772
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
773
+
774
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
775
+// X framePanel.add(bigThree);
776
+// X frame.getContentPane().add(/*"Center",*/framePanel);
777
+ framePanel.setDividerLocation(1);
778
+
779
+ //frame.setVisible(true);
780
+ radio.layout = keepButton;
781
+ //theFrame = null;
782
+ keepButton = null;
783
+ radio.layout.doClick();
784
+
616785 } else
617786 {
618
- frame.getContentPane().remove(/*"Center",*/framePanel);
619
- framePanel.remove(bigThree);
620
- frame.getContentPane().add(/*"Center",*/bigThree);
787
+ keepButton = radio.layout;
788
+ //keeprect = frame.getBounds();
789
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
790
+// frame.getToolkit().getScreenSize().height);
791
+ //frame.setVisible(false);
792
+ device.setFullScreenWindow(frame);
793
+ frame.validate();
794
+// frame.removeNotify();
795
+// frame.setUndecorated(true);
796
+// frame.addNotify();
797
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
798
+// X framePanel.remove(bigThree);
799
+// X frame.getContentPane().add(/*"Center",*/bigThree);
800
+ framePanel.setDividerLocation(0);
801
+
802
+ radio.layout = fullscreenLayout;
803
+ radio.layout.doClick();
804
+ //frame.setVisible(true);
621805 }
622
- cameraView.ToggleFullScreen();
806
+ frame.validate();
623807 }
624808
625
- private JTextArea createTextPane()
809
+ private JTextPane createTextPane()
626810 {
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
- };
811
+// TEXTAREA String[] initString =
812
+// {
813
+// "This is an editable JTextPane, ", //regular
814
+// "another ", //italic
815
+// "styled ", //bold
816
+// "text ", //small
817
+// "component, ", //large
818
+// "which supports embedded components..." + newline,//regular
819
+// " " + newline, //button
820
+// "...and embedded icons..." + newline, //regular
821
+// " ", //icon
822
+// newline + "JTextPane is a subclass of JEditorPane that "
823
+// + "uses a StyledEditorKit and StyledDocument, and provides "
824
+// + "cover methods for interacting with those objects."
825
+// };
826
+//
827
+// String[] initStyles =
828
+// {
829
+// "regular", "italic", "bold", "small", "large",
830
+// "regular", "button", "regular", "icon",
831
+// "regular"
832
+// };
833
+//
834
+// JTextPane textPane = new JTextPane();
835
+// textPane.setEditable(true);
836
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
837
+// addStylesToDocument(doc);
838
+//
839
+// try
840
+// {
841
+// for (int j = 0; j < 2; j++)
842
+// {
843
+// for (int i = 0; i < initString.length; i++)
844
+// {
845
+// doc.insertString(doc.getLength(), initString[i],
846
+// doc.getStyle(initStyles[i]));
847
+// }
848
+// }
849
+// } catch (BadLocationException ble)
850
+// {
851
+// System.err.println("Couldn't insert initial text into text pane.");
852
+// }
642853
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;
854
+ return new JTextPane(); // textPane;
671855 }
672856
673857 protected void addStylesToDocument(StyledDocument doc)
....@@ -720,7 +904,7 @@
720904 protected static ImageIcon createImageIcon(String path,
721905 String description)
722906 {
723
- java.net.URL imgURL = GrafreeD.class.getResource(path);
907
+ java.net.URL imgURL = Grafreed.class.getResource(path);
724908 if (imgURL != null)
725909 {
726910 return new ImageIcon(imgURL, description);
....@@ -752,6 +936,7 @@
752936 // NumberSlider vDivsField;
753937 // JCheckBox endcaps;
754938 JCheckBox liveCB;
939
+ JCheckBox selectCB;
755940 JCheckBox hideCB;
756941 JCheckBox link2masterCB;
757942 JCheckBox markCB;
....@@ -759,7 +944,12 @@
759944 JCheckBox speedupCB;
760945 JCheckBox rewindCB;
761946 JCheckBox flipVCB;
947
+
948
+ cCheckBox toggleTextureCB;
949
+ cCheckBox toggleSwitchCB;
950
+
762951 JComboBox texresMenu;
952
+
763953 JButton resetButton;
764954 JButton stepButton;
765955 JButton stepAllButton;
....@@ -767,54 +957,48 @@
767957 JButton slowerButton;
768958 JButton fasterButton;
769959 JButton remarkButton;
960
+
961
+ cGridBag editPanel;
962
+ cGridBag editCommandsPanel;
963
+
964
+ cGridBag namePanel;
965
+ cGridBag setupPanel;
966
+ cGridBag setupPanel2;
967
+ cGridBag objectCommandsPanel;
968
+ cGridBag pushPanel;
969
+ cGridBag fillPanel;
770970
771
- JCheckBox AddCheckBox(ObjEditor oe, String label, boolean on)
971
+ JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
772972 {
773973 JCheckBox cb;
774974
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);
975
+ panel.add(cb = new JCheckBox(label, on)); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
780976 cb.addItemListener(this);
781
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
782
- oe.aConstraints.gridwidth = 1;
783
- oe.aConstraints.gridx += 1;
784977
785978 return cb;
786979 }
787980
788
- cButton AddButton(ObjEditor oe, String label)
981
+ cButton AddButton(cGridBag panel, String label)
789982 {
790983 cButton cb;
791984
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);
985
+ panel.add(cb = new cButton(label)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
797986 cb.addActionListener(this);
798
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
799
- oe.aConstraints.gridwidth = 1;
800
- oe.aConstraints.gridx += 1;
801987
802988 return cb;
803989 }
804990
805
- JComboBox AddCombo(ObjEditor oe, java.util.Vector list, int item)
991
+ JComboBox AddCombo(cGridBag panel, java.util.Vector list, int item)
806992 {
807993 JComboBox combo;
808994
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;
995
+ panel.add(combo = new JComboBox(new cListModel(list, item))); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
812996 combo.addActionListener(this);
813997
814998 return combo;
815999 }
8161000
817
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, double min, double max, double current, double pow)
1001
+ cGridBag AddSlider(cGridBag panel, String label, double min, double max, double current, double pow)
8181002 {
8191003 cGridBag control = new cGridBag();
8201004
....@@ -826,12 +1010,12 @@
8261010 control.add(combo = new cNumberSlider(this, min, max, pow)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8271011 combo.setFloat(current);
8281012
829
- ctrlPanel.add(control);
1013
+ panel.add(control);
8301014
831
- return combo;
1015
+ return control;
8321016 }
8331017
834
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, int min, int max, int current)
1018
+ cGridBag AddSlider(cGridBag panel, String label, int min, int max, int current)
8351019 {
8361020 cGridBag control = new cGridBag();
8371021
....@@ -839,25 +1023,21 @@
8391023
8401024 JLabel jlabel = new JLabel(label);
8411025 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);
1026
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
1027
+ control.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8441028 combo.setInteger(current);
8451029
846
- ctrlPanel.add(control);
1030
+ panel.add(control);
8471031
848
- return combo;
1032
+ return control;
8491033 }
8501034
8511035 JTextArea AddText(cGridBag ctrlPanel, String name)
8521036 {
8531037 JTextArea text;
8541038
855
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
856
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
8571039 ctrlPanel.add(text = new JTextArea(name)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8581040 text.addCaretListener(this);
859
- aConstraints.gridx += 1;
860
- aConstraints.gridwidth = 1;
8611041
8621042 return text;
8631043 }
....@@ -896,7 +1076,7 @@
8961076
8971077 /*
8981078 */
899
- void Return() // ObjEditor oe)
1079
+ void Return0() // ObjEditor oe)
9001080 {
9011081 aConstraints.gridy += 1;
9021082 aConstraints.gridx = 0;
....@@ -951,37 +1131,76 @@
9511131
9521132 void SetupUI2(ObjEditor oe)
9531133 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
958
- SetupName(oe);
1134
+ //SetupName(oe);
9591135
960
- if (!GroupEditor.allparams)
1136
+ namePanel = new cGridBag();
1137
+
1138
+ nameField = AddText(namePanel, copy.GetName());
1139
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
1140
+ oe.ctrlPanel.add(namePanel);
1141
+
1142
+ oe.ctrlPanel.Return();
1143
+
1144
+ if (!allparams)
9611145 return;
9621146
963
- liveCB = AddCheckBox(oe, "Live", copy.live);
964
- link2masterCB = AddCheckBox(oe, "Supp", copy.link2master);
965
- hideCB = AddCheckBox(oe, "Hide", copy.hide);
1147
+ setupPanel = new cGridBag().setVertical(false);
1148
+
1149
+ liveCB = AddCheckBox(setupPanel, "Live", copy.live);
1150
+ liveCB.setToolTipText("Animate object");
1151
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1152
+ selectCB.setToolTipText("Make object selectable");
9661153 // 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");
1154
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1155
+ hideCB.setToolTipText("Hide object");
1156
+ markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1157
+ markCB.setToolTipText("As animation target transform");
1158
+
1159
+ setupPanel2 = new cGridBag().setVertical(false);
1160
+
1161
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1162
+ rewindCB.setToolTipText("Rewind animation");
1163
+
1164
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1165
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
1166
+
1167
+ if (Globals.ADVANCED)
1168
+ {
1169
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1170
+ link2masterCB.setToolTipText("Attach to support");
1171
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1172
+ speedupCB.setToolTipText("Option motion capture");
1173
+ }
1174
+
1175
+ oe.ctrlPanel.add(setupPanel);
1176
+ oe.ctrlPanel.Return();
1177
+ oe.ctrlPanel.add(setupPanel2);
1178
+ oe.ctrlPanel.Return();
1179
+
1180
+ objectCommandsPanel = new cGridBag().setVertical(false);
1181
+
1182
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1183
+ resetButton.setToolTipText("Jump to frame zero");
1184
+ stepButton = AddButton(objectCommandsPanel, "Step");
1185
+ stepButton.setToolTipText("Step one frame");
9731186 // resetAllButton = AddButton(oe, "Reset All");
9741187 // stepAllButton = AddButton(oe, "Step All");
975
- speedupCB = AddCheckBox(oe, "Speed", copy.speedup);
9761188 // Return();
977
- slowerButton = AddButton(oe, "Slow");
978
- fasterButton = AddButton(oe, "Fast");
979
- remarkButton = AddButton(oe, "Rem");
1189
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1190
+ slowerButton.setToolTipText("Decrease animation speed");
1191
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1192
+ fasterButton.setToolTipText("Increase animation speed");
1193
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1194
+ remarkButton.setToolTipText("Set the current transform as the target");
9801195
981
- Return();
1196
+ oe.ctrlPanel.add(objectCommandsPanel);
1197
+ oe.ctrlPanel.Return();
9821198
983
- normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1);
984
- Return();
1199
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
1200
+ normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1201
+ //Return();
1202
+
1203
+ oe.ctrlPanel.Return();
9851204
9861205 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
9871206 // ObjEditor.aConstraints.gridx += 1;
....@@ -1076,7 +1295,7 @@
10761295 oe.aConstraints.gridwidth = 1;
10771296 /**/
10781297 nameField = AddText(oe.ctrlPanel, copy.GetName());
1079
- Return();
1298
+ oe.ctrlPanel.Return();
10801299
10811300 //ctrlPanel.add(textureButton = new Button("Texture..."));
10821301 //textureButton.setEnabled(false);
....@@ -1180,8 +1399,11 @@
11801399 //worldPanel.setName("World");
11811400 centralPanel = new cGridBag();
11821401 centralPanel.preferredWidth = 20;
1183
- timelinePanel = new JPanel(new BorderLayout());
1184
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1402
+
1403
+ if (Globals.ADVANCED)
1404
+ {
1405
+ timelinePanel = new JPanel(new BorderLayout());
1406
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11851407
11861408 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11871409 cameraPanel.setContinuousLayout(true);
....@@ -1190,7 +1412,10 @@
11901412 // cameraPanel.setDividerSize(9);
11911413 cameraPanel.setResizeWeight(1.0);
11921414
1415
+ }
1416
+
11931417 centralPanel.add(cameraView);
1418
+ centralPanel.setFocusable(true);
11941419 //frame.setJMenuBar(timelineMenubar);
11951420 //centralPanel.add(timelinePanel);
11961421
....@@ -1253,11 +1478,13 @@
12531478 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12541479 //tmp.setName("Edit");
12551480 objectPanel.add(materialPanel);
1256
- JPanel north = new JPanel(new BorderLayout());
1257
- north.setName("Edit");
1258
- north.add(ctrlPanel, BorderLayout.NORTH);
1259
- objectPanel.add(north);
1481
+// JPanel north = new JPanel(new BorderLayout());
1482
+// north.setName("Edit");
1483
+// north.add(ctrlPanel, BorderLayout.NORTH);
1484
+// objectPanel.add(north);
1485
+ objectPanel.add(editPanel);
12601486 objectPanel.add(infoPanel);
1487
+ objectPanel.add(toolboxPanel);
12611488
12621489 /*
12631490 aConstraints.gridx = 0;
....@@ -1266,7 +1493,7 @@
12661493 aConstraints.gridy += 1;
12671494 aConstraints.gridwidth = 1;
12681495 mainPanel.add(objectPanel, aConstraints);
1269
- */
1496
+ */
12701497
12711498 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12721499 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1278,14 +1505,12 @@
12781505 scrollpane.addMouseWheelListener(this); // Default not fast enough
12791506
12801507 /*JTabbedPane*/ scenePanel = new cGridBag();
1281
- scenePanel.preferredWidth = 7;
1508
+ scenePanel.preferredWidth = 6;
12821509
12831510 JTabbedPane tabbedPane = new JTabbedPane();
12841511 tabbedPane.add(scrollpane);
12851512
1286
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1287
-
1288
- optionsPanel = new cGridBag().setVertical(true);
1513
+ optionsPanel = new cGridBag().setVertical(false);
12891514
12901515 optionsPanel.setName("Options");
12911516
....@@ -1293,6 +1518,8 @@
12931518
12941519 tabbedPane.add(optionsPanel);
12951520
1521
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1522
+
12961523 scenePanel.add(tabbedPane);
12971524
12981525 /*
....@@ -1384,9 +1611,13 @@
13841611
13851612 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13861613
1387
- frame.setSize(1024, 768);
1388
- frame.show();
1614
+ frame.setSize(1280, 860);
1615
+
1616
+ frame.validate();
1617
+ frame.setVisible(true);
13891618
1619
+ cameraView.requestFocusInWindow();
1620
+
13901621 gridPanel.setDividerLocation(1.0);
13911622
13921623 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -1415,7 +1646,7 @@
14151646 ctrlPanel.removeAll();
14161647 }
14171648
1418
- void SetupMaterial(cGridBag ctrlPanel)
1649
+ void SetupMaterial(cGridBag panel)
14191650 {
14201651 /*
14211652 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
....@@ -1424,18 +1655,26 @@
14241655
14251656 cGridBag editBar = new cGridBag().setVertical(false);
14261657
1427
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
1658
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1659
+ createMaterialButton.setToolTipText("Create material");
14281660
14291661 /*
14301662 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14311663 */
14321664
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);
1665
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1666
+ clearMaterialButton.setToolTipText("Clear material");
1667
+
1668
+ if (Globals.ADVANCED)
1669
+ {
1670
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1671
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1672
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1673
+ }
14371674
1438
- ctrlPanel.add(editBar);
1675
+ editBar.preferredHeight = 15;
1676
+
1677
+ panel.add(editBar);
14391678
14401679 /**/
14411680 //aConstraints.weighty = 0;
....@@ -1445,17 +1684,13 @@
14451684 //aConstraints.gridx += 1;
14461685 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14471686
1448
- JPanel colorPanel = new JPanel(new BorderLayout());
1449
- colorPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1450
-
14511687 cGridBag colorSection = new cGridBag().setVertical(true);
1452
-
1453
- colorPanel.add(colorSection);
14541688
14551689 cGridBag color = new cGridBag();
14561690 color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
14571691 colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14581692 color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1693
+ //colorField.preferredWidth = 200;
14591694 colorSection.add(color);
14601695
14611696 cGridBag modulation = new cGridBag();
....@@ -1470,34 +1705,13 @@
14701705 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14711706 colorSection.add(texture);
14721707
1473
- cGridBag anisoU = new cGridBag();
1474
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1475
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1476
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1477
- colorSection.add(anisoU);
1478
-
1479
- cGridBag anisoV = new cGridBag();
1480
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1481
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1482
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1483
- colorSection.add(anisoV);
1484
-
1485
- cGridBag shadowbias = new cGridBag();
1486
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1487
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1488
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1489
- colorSection.add(shadowbias);
1490
-
1491
- ctrlPanel.add(colorPanel);
1708
+ panel.add(new JSeparator());
1709
+
1710
+ panel.add(colorSection);
14921711
14931712 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14941713
1495
- JPanel diffusePanel = new JPanel(new BorderLayout());
1496
- diffusePanel.setBorder(BorderFactory.createLineBorder(Color.black));
1497
-
14981714 cGridBag diffuseSection = new cGridBag().setVertical(true);
1499
-
1500
- diffusePanel.add(diffuseSection);
15011715
15021716 cGridBag diffuse = new cGridBag();
15031717 diffuse.add(diffuseLabel = new JLabel("Diffuse")); // , aConstraints);
....@@ -1541,16 +1755,19 @@
15411755 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15421756 diffuseSection.add(fakedepth);
15431757
1544
- ctrlPanel.add(diffusePanel);
1758
+ cGridBag shadowbias = new cGridBag();
1759
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1760
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1761
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1762
+ diffuseSection.add(shadowbias);
1763
+
1764
+ panel.add(new JSeparator());
1765
+
1766
+ panel.add(diffuseSection);
15451767
15461768 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15471769
1548
- JPanel specularPanel = new JPanel(new BorderLayout());
1549
- specularPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1550
-
15511770 cGridBag specularSection = new cGridBag().setVertical(true);
1552
-
1553
- specularPanel.add(specularSection);
15541771
15551772 cGridBag specular = new cGridBag();
15561773 specular.add(specularLabel = new JLabel("Specular")); // , aConstraints);
....@@ -1582,7 +1799,7 @@
15821799 velvet.add(velvetField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15831800 specularSection.add(velvet);
15841801
1585
- shiftField = AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1);
1802
+ shiftField = (cNumberSlider)AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1).getComponent(1);
15861803 //Return();
15871804 // ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
15881805 // shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
....@@ -1594,52 +1811,58 @@
15941811 // aConstraints.gridy += 1;
15951812 // aConstraints.gridwidth = 1;
15961813
1814
+ cGridBag anisoU = new cGridBag();
1815
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1816
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1817
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1818
+ specularSection.add(anisoU);
15971819
1598
- ctrlPanel.add(specularPanel);
1820
+ cGridBag anisoV = new cGridBag();
1821
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1822
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1823
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1824
+ specularSection.add(anisoV);
1825
+
1826
+
1827
+ panel.add(new JSeparator());
1828
+
1829
+ panel.add(specularSection);
15991830
16001831 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16011832
1602
- JPanel globalPanel = new JPanel(new BorderLayout());
1603
- globalPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1604
-
1605
- cGridBag globalSection = new cGridBag().setVertical(true);
1606
-
1607
- globalPanel.add(globalSection);
1833
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16081834
16091835 cGridBag camera = new cGridBag();
16101836 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16111837 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16121838 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(camera);
1839
+ colorSection.add(camera);
16141840
16151841 cGridBag ambient = new cGridBag();
16161842 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16171843 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16181844 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(ambient);
1845
+ colorSection.add(ambient);
16201846
16211847 cGridBag backlit = new cGridBag();
16221848 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16231849 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16241850 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1625
- globalSection.add(backlit);
1851
+ colorSection.add(backlit);
16261852
16271853 cGridBag opacity = new cGridBag();
16281854 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
16291855 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16301856 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1631
- globalSection.add(opacity);
1857
+ colorSection.add(opacity);
16321858
1633
- ctrlPanel.add(globalPanel);
1859
+ //panel.add(new JSeparator());
1860
+
1861
+ //panel.add(globalSection);
16341862
16351863 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16361864
1637
- JPanel texturePanel = new JPanel(new BorderLayout());
1638
- texturePanel.setBorder(BorderFactory.createLineBorder(Color.black));
1639
-
16401865 cGridBag textureSection = new cGridBag().setVertical(true);
1641
-
1642
- texturePanel.add(textureSection);
16431866
16441867 cGridBag bump = new cGridBag();
16451868 bump.add(bumpLabel = new JLabel("Bump")); // , aConstraints);
....@@ -1677,7 +1900,9 @@
16771900 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16781901 textureSection.add(opacityPower);
16791902
1680
- ctrlPanel.add(texturePanel);
1903
+ panel.add(new JSeparator());
1904
+
1905
+ panel.add(textureSection);
16811906
16821907 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16831908
....@@ -1714,12 +1939,15 @@
17141939 opacityPowerField.addChangeListener(this);
17151940 /**/
17161941
1717
- resetSlidersButton.addActionListener(this);
17181942 clearMaterialButton.addActionListener(this);
17191943 createMaterialButton.addActionListener(this);
1720
-
1721
- propagateToggle.addItemListener(this);
1722
- multiplyToggle.addItemListener(this);
1944
+
1945
+ if (Globals.ADVANCED)
1946
+ {
1947
+ resetSlidersButton.addActionListener(this);
1948
+ propagateToggle.addItemListener(this);
1949
+ multiplyToggle.addItemListener(this);
1950
+ }
17231951 }
17241952
17251953 void DropFile(java.io.File[] files, boolean textures)
....@@ -1890,7 +2118,7 @@
18902118
18912119 //? flashIt = false;
18922120 CameraPane pane = (CameraPane) cameraView;
1893
- pane.clickStart(location.x, location.y, 0);
2121
+ pane.clickStart(location.x, location.y, 0, 0);
18942122 pane.clickEnd(location.x, location.y, 0, true);
18952123
18962124 if (group.selection.size() == 1)
....@@ -1939,6 +2167,7 @@
19392167 e2.printStackTrace();
19402168 }
19412169 }
2170
+
19422171 LoadJMEThread loadThread;
19432172
19442173 class LoadJMEThread extends Thread
....@@ -1996,6 +2225,7 @@
19962225 //LoadFile0(filename, converter);
19972226 }
19982227 }
2228
+
19992229 LoadOBJThread loadObjThread;
20002230
20012231 class LoadOBJThread extends Thread
....@@ -2074,19 +2304,19 @@
20742304
20752305 void LoadObjFile(String fullname)
20762306 {
2077
- /*
2307
+ System.out.println("Loading " + fullname);
2308
+ /**/
20782309 //lastFilename = fullname;
20792310 if(loadObjThread == null)
20802311 {
2081
- loadObjThread = new LoadOBJThread();
2082
- loadObjThread.start();
2312
+ loadObjThread = new LoadOBJThread();
2313
+ loadObjThread.start();
20832314 }
20842315
20852316 loadObjThread.add(fullname);
2086
- */
2317
+ /**/
20872318
2088
- System.out.println("Loading " + fullname);
2089
- makeSomething(new FileObject(fullname, true), true);
2319
+ //makeSomething(new FileObject(fullname, true), true);
20902320 }
20912321
20922322 void LoadGFDFile(String fullname)
....@@ -2347,11 +2577,11 @@
23472577
23482578 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23492579 {
2350
- if (GrafreeD.standAlone)
2580
+ if (Grafreed.standAlone)
23512581 {
23522582 /**/
23532583 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2354
- browser.show();
2584
+ browser.setVisible(true);
23552585 String filename = browser.getFile();
23562586 if (filename != null && filename.length() > 0)
23572587 {
....@@ -2496,6 +2726,7 @@
24962726 }
24972727 if (input == null)
24982728 {
2729
+ new Exception().printStackTrace();
24992730 System.exit(0);
25002731 }
25012732
....@@ -2702,6 +2933,8 @@
27022933
27032934 void SetMaterial(Object3D object)
27042935 {
2936
+ latestObject = object;
2937
+
27052938 cMaterial mat = object.material;
27062939
27072940 if (mat == null)
....@@ -2710,7 +2943,8 @@
27102943 return;
27112944 }
27122945
2713
- multiplyToggle.setSelected(mat.multiply);
2946
+ if (multiplyToggle != null)
2947
+ multiplyToggle.setSelected(mat.multiply);
27142948
27152949 assert (object.projectedVertices != null);
27162950
....@@ -2812,12 +3046,17 @@
28123046 // }
28133047
28143048 /**/
2815
- if (deselect)
3049
+ if (deselect || child == null)
28163050 {
28173051 //group.deselectAll();
28183052 //freeze = true;
28193053 GetTree().clearSelection();
28203054 //freeze = false;
3055
+
3056
+ if (child == null)
3057
+ {
3058
+ return;
3059
+ }
28213060 }
28223061
28233062 //group.addSelectee(child);
....@@ -2886,7 +3125,7 @@
28863125 cameraView.ToggleDL();
28873126 cameraView.repaint();
28883127 return;
2889
- } else if (event.getSource() == toggleTextureItem)
3128
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28903129 {
28913130 cameraView.ToggleTexture();
28923131 // june 2013 copy.HardTouch();
....@@ -2925,9 +3164,9 @@
29253164 frame.validate();
29263165
29273166 return;
2928
- } else if (event.getSource() == toggleRandomItem)
3167
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29293168 {
2930
- cameraView.ToggleRandom();
3169
+ cameraView.ToggleSwitch();
29313170 cameraView.repaint();
29323171 return;
29333172 } else if (event.getSource() == toggleHandleItem)
....@@ -2956,6 +3195,10 @@
29563195 {
29573196 copy.live ^= true;
29583197 return;
3198
+ } else if (event.getSource() == selectCB)
3199
+ {
3200
+ copy.dontselect ^= true;
3201
+ return;
29593202 } else if (event.getSource() == hideCB)
29603203 {
29613204 copy.hide ^= true;
....@@ -2970,6 +3213,7 @@
29703213 if (event.getSource() == randomCB)
29713214 {
29723215 copy.random ^= true;
3216
+ objEditor.refreshContents();
29733217 return;
29743218 }
29753219 if (event.getSource() == speedupCB)
....@@ -2993,8 +3237,9 @@
29933237
29943238 public void actionPerformed(ActionEvent event)
29953239 {
3240
+ Object source = event.getSource();
29963241 // SCRIPT DIALOG
2997
- if (event.getSource() == okbutton)
3242
+ if (source == okbutton)
29983243 {
29993244 textpanel.setVisible(false);
30003245 textpanel.remove(textarea);
....@@ -3006,7 +3251,7 @@
30063251 textarea = null;
30073252 textpanel = null;
30083253 }
3009
- if (event.getSource() == cancelbutton)
3254
+ if (source == cancelbutton)
30103255 {
30113256 textpanel.setVisible(false);
30123257 textpanel.remove(textarea);
....@@ -3018,50 +3263,50 @@
30183263 //applySelf();
30193264 //client.refreshEditWindow();
30203265 //refreshContents();
3021
- if (event.getSource() == nameField)
3266
+ if (source == nameField)
30223267 {
30233268 //System.out.println("ObjEditor " + event);
30243269 applySelf0(true);
30253270 //parent.applySelf();
30263271 objEditor.refreshContents();
3027
- } else if (event.getSource() == resetButton)
3272
+ } else if (source == resetButton)
30283273 {
30293274 CameraPane.fullreset = true;
30303275 copy.Reset(); // ResetMeshes();
30313276 copy.Touch();
30323277 objEditor.refreshContents();
3033
- } else if (event.getSource() == stepItem)
3278
+ } else if (source == stepItem)
30343279 {
30353280 //cameraView.ONESTEP = true;
30363281 Globals.ONESTEP = true;
30373282 cameraView.repaint();
30383283 return;
3039
- } else if (event.getSource() == stepButton)
3284
+ } else if (source == stepButton)
30403285 {
30413286 copy.Step();
30423287 copy.Touch();
30433288 objEditor.refreshContents();
3044
- } else if (event.getSource() == slowerButton)
3289
+ } else if (source == slowerButton)
30453290 {
30463291 copy.Slower();
30473292 copy.Touch();
30483293 objEditor.refreshContents();
3049
- } else if (event.getSource() == fasterButton)
3294
+ } else if (source == fasterButton)
30503295 {
30513296 copy.Faster();
30523297 copy.Touch();
30533298 objEditor.refreshContents();
3054
- } else if (event.getSource() == remarkButton)
3299
+ } else if (source == remarkButton)
30553300 {
30563301 copy.Remark();
30573302 copy.Touch();
30583303 objEditor.refreshContents();
3059
- } else if (event.getSource() == stepAllButton)
3304
+ } else if (source == stepAllButton)
30603305 {
30613306 copy.StepAll();
30623307 copy.Touch();
30633308 objEditor.refreshContents();
3064
- } else if (event.getSource() == resetAllButton)
3309
+ } else if (source == resetAllButton)
30653310 {
30663311 //CameraPane.fullreset = true;
30673312 copy.ResetAll(); // ResetMeshes();
....@@ -3094,53 +3339,75 @@
30943339 // Close();
30953340 // }
30963341 // else
3097
- if (event.getSource() == resetSlidersButton)
3342
+ if (source == resetSlidersButton)
30983343 {
30993344 ResetSliders();
3100
- } else if (event.getSource() == clearMaterialButton)
3345
+ } else if (source == clearMaterialButton)
31013346 {
31023347 ClearMaterial();
3103
- } else if (event.getSource() == createMaterialButton)
3348
+ } else if (source == createMaterialButton)
31043349 {
31053350 CreateMaterial();
3106
- } else if (event.getSource() == clearPanelButton)
3351
+ } else if (source == clearPanelButton)
31073352 {
31083353 copy.ClearUI();
31093354 refreshContents(true);
3110
- } /*
3111
- }
3112
-
3113
- public boolean action(Event event, Object arg)
3114
- {
3115
- */ else if (event.getSource() == closeItem)
3355
+ } else if (source == importGFDItem)
3356
+ {
3357
+ ImportGFD();
3358
+ } else
3359
+ if (source == importVRMLX3DItem)
3360
+ {
3361
+ ImportVRMLX3D();
3362
+ } else
3363
+ if (source == import3DSItem)
3364
+ {
3365
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3366
+ } else
3367
+ if (source == importOBJItem)
3368
+ {
3369
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3370
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3371
+ browser.setVisible(true);
3372
+ String filename = browser.getFile();
3373
+ if (filename != null && filename.length() > 0)
3374
+ {
3375
+ String fullname = browser.getDirectory() + filename;
3376
+ makeSomething(ReadOBJ(fullname), true);
3377
+ }
3378
+ } else
3379
+ if (source == closeItem)
31163380 {
31173381 Close();
31183382 //return true;
3119
- } else if (event.getSource() == loadItem)
3383
+ } else if (source == loadItem)
31203384 {
31213385 load();
31223386 //return true;
3123
- } else if (event.getSource() == saveItem)
3387
+ } else if (source == newItem)
3388
+ {
3389
+ New();
3390
+ } else if (source == saveItem)
31243391 {
31253392 save();
31263393 //return true;
3127
- } else if (event.getSource() == saveAsItem)
3394
+ } else if (source == saveAsItem)
31283395 {
31293396 saveAs();
31303397 //return true;
3131
- } else if (event.getSource() == reexportItem)
3398
+ } else if (source == reexportItem)
31323399 {
31333400 reexport();
31343401 //return true;
3135
- } else if (event.getSource() == exportAsItem)
3402
+ } else if (source == exportAsItem)
31363403 {
31373404 export();
31383405 //return true;
3139
- } else if (event.getSource() == povItem)
3406
+ } else if (source == povItem)
31403407 {
31413408 generatePOV();
31423409 //return true;
3143
- } else if (event.getSource() == zBufferItem)
3410
+ } else if (source == zBufferItem)
31443411 {
31453412 try
31463413 {
....@@ -3162,21 +3429,8 @@
31623429 cameraView.repaint();
31633430 //return true;
31643431 }
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)
3432
+ */ else // combos...
3433
+ if (source == texresMenu)
31803434 {
31813435 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31823436 copy.texres = texresMenu.getSelectedIndex();
....@@ -3188,12 +3442,289 @@
31883442 }
31893443 }
31903444
3445
+ void New()
3446
+ {
3447
+ while (copy.Size() > 1)
3448
+ {
3449
+ copy.remove(1);
3450
+ }
3451
+
3452
+ ResetModel();
3453
+ objEditor.refreshContents();
3454
+ }
3455
+
3456
+ static public byte[] Compress(Object3D o)
3457
+ {
3458
+ try
3459
+ {
3460
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3461
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3462
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3463
+
3464
+ Object3D parent = o.parent;
3465
+ o.parent = null;
3466
+
3467
+ out.writeObject(o);
3468
+
3469
+ o.parent = parent;
3470
+
3471
+ out.flush();
3472
+
3473
+ zstream.close();
3474
+ out.close();
3475
+
3476
+ return baos.toByteArray();
3477
+ } catch (Exception e)
3478
+ {
3479
+ System.err.println(e);
3480
+ return null;
3481
+ }
3482
+ }
3483
+
3484
+ static public Object Uncompress(byte[] bytes)
3485
+ {
3486
+ System.out.println("#bytes = " + bytes.length);
3487
+ try
3488
+ {
3489
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3490
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3491
+ ObjectInputStream in = new ObjectInputStream(istream);
3492
+ Object obj = in.readObject();
3493
+ in.close();
3494
+
3495
+ return obj;
3496
+ } catch (Exception e)
3497
+ {
3498
+ System.err.println(e);
3499
+ return null;
3500
+ }
3501
+ }
3502
+
3503
+ static public Object clone(Object o)
3504
+ {
3505
+ try
3506
+ {
3507
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3508
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3509
+
3510
+ out.writeObject(o);
3511
+
3512
+ out.flush();
3513
+ out.close();
3514
+
3515
+ byte[] bytes = baos.toByteArray();
3516
+
3517
+ System.out.println("clone = " + bytes.length);
3518
+
3519
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3520
+ ObjectInputStream in = new ObjectInputStream(bais);
3521
+ Object obj = in.readObject();
3522
+ in.close();
3523
+
3524
+ return obj;
3525
+ } catch (Exception e)
3526
+ {
3527
+ System.err.println(e);
3528
+ return null;
3529
+ }
3530
+ }
3531
+
3532
+ cRadio GetCurrentTab()
3533
+ {
3534
+ cRadio ab;
3535
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3536
+ {
3537
+ ab = (cRadio)e.nextElement();
3538
+ if(ab.GetObject() == copy)
3539
+ {
3540
+ return ab;
3541
+ }
3542
+ }
3543
+
3544
+ return null;
3545
+ }
3546
+
3547
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3548
+
3549
+ public void Save()
3550
+ {
3551
+ System.err.println("Save");
3552
+
3553
+ cRadio tab = GetCurrentTab();
3554
+
3555
+ boolean temp = CameraPane.SWITCH;
3556
+ CameraPane.SWITCH = false;
3557
+
3558
+ copy.ExtractBigData(hashtable);
3559
+
3560
+ byte[] compress = Compress(copy);
3561
+
3562
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3563
+ tab.graphs[tab.undoindex++] = compress;
3564
+
3565
+ copy.RestoreBigData(hashtable);
3566
+
3567
+ CameraPane.SWITCH = temp;
3568
+
3569
+ //assert(hashtable.isEmpty());
3570
+
3571
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3572
+ {
3573
+ tab.graphs[i] = null;
3574
+ }
3575
+
3576
+ SetUndoStates();
3577
+
3578
+ // test save
3579
+ if (false)
3580
+ {
3581
+ try
3582
+ {
3583
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3584
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3585
+
3586
+ p.writeObject(copy);
3587
+
3588
+ p.flush();
3589
+
3590
+ ostream.close();
3591
+ } catch (Exception e)
3592
+ {
3593
+ e.printStackTrace();
3594
+ }
3595
+ }
3596
+ }
3597
+
3598
+ void CopyChanged(Object3D obj)
3599
+ {
3600
+ SetUndoStates();
3601
+
3602
+ boolean temp = CameraPane.SWITCH;
3603
+ CameraPane.SWITCH = false;
3604
+
3605
+ copy.ExtractBigData(hashtable);
3606
+
3607
+ copy.clear();
3608
+
3609
+ for (int i=0; i<obj.Size(); i++)
3610
+ {
3611
+ copy.add(obj.get(i));
3612
+ }
3613
+
3614
+ copy.RestoreBigData(hashtable);
3615
+
3616
+ CameraPane.SWITCH = temp;
3617
+
3618
+ //assert(hashtable.isEmpty());
3619
+
3620
+ copy.Touch();
3621
+
3622
+ ResetModel();
3623
+ copy.HardTouch(); // recompile?
3624
+
3625
+ cRadio ab;
3626
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3627
+ {
3628
+ ab = (cRadio)e.nextElement();
3629
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3630
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3631
+ if (test != null)
3632
+ {
3633
+ test.editWindow = ab.object.editWindow;
3634
+ ab.object = test;
3635
+ }
3636
+ }
3637
+
3638
+ refreshContents();
3639
+ }
3640
+
3641
+ cButton undoButton;
3642
+ cButton redoButton;
3643
+
3644
+ void SetUndoStates()
3645
+ {
3646
+ cRadio tab = GetCurrentTab();
3647
+
3648
+ undoButton.setEnabled(tab.undoindex > 0);
3649
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3650
+ }
3651
+
3652
+ public void Undo()
3653
+ {
3654
+ System.err.println("Undo");
3655
+
3656
+ cRadio tab = GetCurrentTab();
3657
+
3658
+ if (tab.undoindex == 0)
3659
+ {
3660
+ java.awt.Toolkit.getDefaultToolkit().beep();
3661
+ return;
3662
+ }
3663
+
3664
+ if (tab.graphs[tab.undoindex] == null)
3665
+ {
3666
+ Save();
3667
+ tab.undoindex -= 1;
3668
+ }
3669
+
3670
+ tab.undoindex -= 1;
3671
+
3672
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3673
+ }
3674
+
3675
+ public void Redo()
3676
+ {
3677
+ cRadio tab = GetCurrentTab();
3678
+
3679
+ if (tab.graphs[tab.undoindex + 1] == null)
3680
+ {
3681
+ java.awt.Toolkit.getDefaultToolkit().beep();
3682
+ return;
3683
+ }
3684
+
3685
+ tab.undoindex += 1;
3686
+
3687
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3688
+ }
3689
+
3690
+ void ImportGFD()
3691
+ {
3692
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3693
+ browser.show();
3694
+ String filename = browser.getFile();
3695
+ if (filename != null && filename.length() > 0)
3696
+ {
3697
+ String fullname = browser.getDirectory() + filename;
3698
+
3699
+ //Object3D readobj =
3700
+ objEditor.ReadGFD(fullname, objEditor);
3701
+ //makeSomething(readobj);
3702
+ }
3703
+ }
3704
+
3705
+ void ImportVRMLX3D()
3706
+ {
3707
+ if (Grafreed.standAlone)
3708
+ {
3709
+ /**/
3710
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3711
+ browser.show();
3712
+ String filename = browser.getFile();
3713
+ if (filename != null && filename.length() > 0)
3714
+ {
3715
+ String fullname = browser.getDirectory() + filename;
3716
+ LoadVRMLX3D(fullname);
3717
+ }
3718
+ /**/
3719
+ }
3720
+ }
3721
+
31913722 void ToggleAnimation()
31923723 {
31933724 if (!Globals.ANIMATION)
31943725 {
31953726 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3196
- browser.show();
3727
+ browser.setVisible(true);
31973728 String filename = browser.getFile();
31983729 if (filename != null && filename.length() > 0)
31993730 {
....@@ -3203,8 +3734,8 @@
32033734
32043735 Globals.ANIMATION ^= true;
32053736
3206
- GrafreeD.wav.cursor = 0;
3207
- GrafreeD.wav.loop = 0;
3737
+ Grafreed.wav.cursor = 0;
3738
+ Grafreed.wav.loop = 0;
32083739 }
32093740 } else
32103741 {
....@@ -3254,7 +3785,7 @@
32543785 void CreateMaterial()
32553786 {
32563787 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
3788
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32583789 if (copy.selection.size() > 0)
32593790 //SetMaterial(copy);
32603791 {
....@@ -3305,7 +3836,7 @@
33053836 assert false;
33063837 }
33073838
3308
- void EditSelection()
3839
+ void EditSelection(boolean newWindow)
33093840 {
33103841 }
33113842
....@@ -3313,11 +3844,11 @@
33133844 {
33143845 copy.ResetBlockLoop(); // temporary problem
33153846
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
3847
+ boolean random = CameraPane.SWITCH;
3848
+ CameraPane.SWITCH = false; // parse everything
33183849 copy.ResetDisplayList();
33193850 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
3851
+ CameraPane.SWITCH = random;
33213852 }
33223853
33233854 // public void applySelf()
....@@ -3391,6 +3922,36 @@
33913922 {
33923923 //System.out.println("Propagate = " + propagate);
33933924 copy.UpdateMaterial(anchor, current, propagate);
3925
+
3926
+ if (copy.material != null)
3927
+ {
3928
+ cMaterial mat = copy.material;
3929
+
3930
+ colorField.SetToolTipValue((mat.color));
3931
+ modulationField.SetToolTipValue((mat.modulation));
3932
+ metalnessField.SetToolTipValue((mat.metalness));
3933
+ diffuseField.SetToolTipValue((mat.diffuse));
3934
+ specularField.SetToolTipValue((mat.specular));
3935
+ shininessField.SetToolTipValue((mat.shininess));
3936
+ shiftField.SetToolTipValue((mat.shift));
3937
+ ambientField.SetToolTipValue((mat.ambient));
3938
+ lightareaField.SetToolTipValue((mat.lightarea));
3939
+ diffusenessField.SetToolTipValue((mat.factor));
3940
+ velvetField.SetToolTipValue((mat.velvet));
3941
+ sheenField.SetToolTipValue((mat.sheen));
3942
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3943
+ backlitField.SetToolTipValue((mat.bump));
3944
+ anisoField.SetToolTipValue((mat.aniso));
3945
+ anisoVField.SetToolTipValue((mat.anisoV));
3946
+ cameraField.SetToolTipValue((mat.cameralight));
3947
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3948
+ shadowField.SetToolTipValue((mat.shadow));
3949
+ textureField.SetToolTipValue((mat.texture));
3950
+ opacityField.SetToolTipValue((mat.opacity));
3951
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3952
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3953
+ }
3954
+
33943955 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33953956 {
33963957 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3435,6 +3996,7 @@
34353996 || e.getSource() == apertureField
34363997 || e.getSource() == shadowblurField)
34373998 {
3999
+ new Exception().printStackTrace();
34384000 System.exit(0);
34394001 cameraView.options1[0] = (float) focusField.getFloat() * 10;
34404002 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3505,7 +4067,7 @@
35054067 }
35064068
35074069 if (normalpushField != null)
3508
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4070
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35094071 }
35104072
35114073 void SnapObject()
....@@ -3769,6 +4331,8 @@
37694331
37704332 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37714333 {
4334
+ if (Globals.SAVEONMAKE) // && resetmodel)
4335
+ Save();
37724336 //Tween.set(thing, 0).target(1).start(tweenManager);
37734337 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37744338 // if (thing instanceof GenericJointDemo)
....@@ -3855,6 +4419,12 @@
38554419 {
38564420 ResetModel();
38574421 Select(thing.GetTreePath(), true, false); // unselect... false);
4422
+
4423
+ if (thing.Size() == 0)
4424
+ {
4425
+ //EditSelection(false);
4426
+ }
4427
+
38584428 refreshContents();
38594429 }
38604430
....@@ -3972,6 +4542,7 @@
39724542 }
39734543 }
39744544 }
4545
+
39754546 LoadGFDThread loadGFDThread;
39764547
39774548 void ReadGFD(String fullname, iCallBack cb)
....@@ -3991,8 +4562,10 @@
39914562
39924563 try
39934564 {
4565
+ // Try compressed version first.
39944566 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3995
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4567
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4568
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39964569
39974570 readobj = (Object3D) p.readObject();
39984571 istream.close();
....@@ -4000,7 +4573,20 @@
40004573 readobj.ResetDisplayList();
40014574 } catch (Exception e)
40024575 {
4003
- e.printStackTrace();
4576
+ //e.printStackTrace();
4577
+ try
4578
+ {
4579
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4580
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4581
+
4582
+ readobj = (Object3D) p.readObject();
4583
+ istream.close();
4584
+
4585
+ readobj.ResetDisplayList();
4586
+ } catch (Exception e2)
4587
+ {
4588
+ e2.printStackTrace();
4589
+ }
40044590 }
40054591 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40064592 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4046,6 +4632,12 @@
40464632
40474633 void LoadIt(Object obj)
40484634 {
4635
+ if (obj == null)
4636
+ {
4637
+ // Invalid file
4638
+ return;
4639
+ }
4640
+
40494641 System.out.println("Loaded " + obj);
40504642 //new Exception().printStackTrace();
40514643 Object3D readobj = (Object3D) obj;
....@@ -4055,6 +4647,8 @@
40554647
40564648 if (readobj != null)
40574649 {
4650
+ if (Globals.SAVEONMAKE)
4651
+ Save();
40584652 try
40594653 {
40604654 //readobj.deepCopySelf(copy);
....@@ -4117,7 +4711,7 @@
41174711
41184712 void load() // throws ClassNotFoundException
41194713 {
4120
- if (GrafreeD.standAlone)
4714
+ if (Grafreed.standAlone)
41214715 {
41224716 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41234717 browser.show();
....@@ -4204,11 +4798,13 @@
42044798 try
42054799 {
42064800 FileOutputStream ostream = new FileOutputStream(lastname);
4207
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4801
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4802
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42084803
42094804 p.writeObject(copy);
42104805 p.flush();
42114806
4807
+ zstream.close();
42124808 ostream.close();
42134809
42144810 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4218,17 +4814,20 @@
42184814 {
42194815 }
42204816 }
4817
+
42214818 String lastname;
42224819
42234820 void saveAs()
42244821 {
4225
- if (GrafreeD.standAlone)
4822
+ if (Grafreed.standAlone)
42264823 {
42274824 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42284825 browser.setVisible(true);
42294826 String filename = browser.getFile();
42304827 if (filename != null && filename.length() > 0)
42314828 {
4829
+ if (!filename.endsWith(".gfd"))
4830
+ filename += ".gfd";
42324831 lastname = browser.getDirectory() + filename;
42334832 save();
42344833 }
....@@ -4327,13 +4926,13 @@
43274926 try
43284927 {
43294928 FileOutputStream ostream = new FileOutputStream(filename);
4330
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4331
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4929
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4930
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43324931
43334932 Object3D objectparent = obj.parent;
43344933 obj.parent = null;
43354934
4336
- Object3D object = (Object3D) GrafreeD.clone(obj);
4935
+ Object3D object = (Object3D) Grafreed.clone(obj);
43374936
43384937 obj.parent = objectparent;
43394938
....@@ -4345,8 +4944,8 @@
43454944 p.writeObject(object);
43464945 p.flush();
43474946
4947
+ zstream.close();
43484948 ostream.close();
4349
- // zstream.close();
43504949
43514950 // group.selection.get(0).parent = parent;
43524951 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4367,7 +4966,7 @@
43674966 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43684967 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43694968 copy.generatePOV(buffer);
4370
- if (GrafreeD.standAlone)
4969
+ if (Grafreed.standAlone)
43714970 {
43724971 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43734972 browser.show();
....@@ -4393,7 +4992,8 @@
43934992 Object3D client;
43944993 Object3D copy;
43954994 MenuBar menuBar;
4396
- Menu windowMenu;
4995
+ Menu fileMenu;
4996
+ MenuItem newItem;
43974997 MenuItem loadItem;
43984998 MenuItem saveItem;
43994999 MenuItem saveAsItem;
....@@ -4401,13 +5001,11 @@
44015001 MenuItem reexportItem;
44025002 MenuItem povItem;
44035003 MenuItem closeItem;
4404
- Menu cameraMenu;
5004
+
44055005 CheckboxMenuItem zBufferItem;
44065006 //MenuItem normalLensItem;
4407
- MenuItem editCameraItem;
4408
- MenuItem revertCameraItem;
4409
- CheckboxMenuItem toggleLiveItem;
44105007 MenuItem stepItem;
5008
+ CheckboxMenuItem toggleLiveItem;
44115009 CheckboxMenuItem toggleFullScreenItem;
44125010 CheckboxMenuItem toggleTimelineItem;
44135011 CheckboxMenuItem toggleRenderItem;
....@@ -4416,25 +5014,38 @@
44165014 CheckboxMenuItem toggleFootContactItem;
44175015 CheckboxMenuItem toggleDLItem;
44185016 CheckboxMenuItem toggleTextureItem;
4419
- CheckboxMenuItem toggleRandomItem;
5017
+ CheckboxMenuItem toggleSwitchItem;
44205018 CheckboxMenuItem toggleRootItem;
44215019 CheckboxMenuItem animationItem;
44225020 CheckboxMenuItem toggleHandleItem;
44235021 CheckboxMenuItem togglePaintItem;
44245022 JSplitPane mainPanel;
44255023 JScrollPane scrollpane;
5024
+
44265025 JPanel toolbarPanel;
4427
- JPanel treePanel;
5026
+
5027
+ cGridBag treePanel;
5028
+
44285029 JPanel radioPanel;
44295030 ButtonGroup buttonGroup;
4430
- cGridBag ctrlPanel;
5031
+
5032
+ cGridBag toolboxPanel;
44315033 cGridBag materialPanel;
5034
+ cGridBag ctrlPanel;
5035
+
44325036 JScrollPane infoPanel;
5037
+
44335038 cGridBag optionsPanel;
5039
+
44345040 JTabbedPane objectPanel;
5041
+ boolean materialFlushed;
5042
+ Object3D latestObject;
5043
+
44355044 cGridBag XYZPanel;
5045
+
44365046 JSplitPane gridPanel;
44375047 JSplitPane bigPanel;
5048
+
44385049 cGridBag bigThree;
44395050 cGridBag scenePanel;
44405051 cGridBag centralPanel;
....@@ -4549,8 +5160,13 @@
45495160 cNumberSlider fogField;
45505161 JLabel opacityPowerLabel;
45515162 cNumberSlider opacityPowerField;
4552
- JTree jTree;
5163
+ cTree jTree;
45535164 //ObjectUI parent;
45545165
45555166 cNumberSlider normalpushField;
5167
+
5168
+ private MenuItem importGFDItem;
5169
+ private MenuItem importVRMLX3DItem;
5170
+ private MenuItem import3DSItem;
5171
+ private MenuItem importOBJItem;
45565172 }