Normand Briere
2019-06-27 1807e7752960ac229cddd34b100e92cadbac9459
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,79 +390,64 @@
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);
372452 infoPanel.setPreferredSize(new Dimension(50, 200));
373453 infoPanel.setName("Info");
....@@ -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,140 @@
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
+ }
725
+
726
+ void Maximize()
727
+ {
728
+ if (maximized)
729
+ {
730
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
731
+ }
732
+ else
733
+ {
734
+ keeprect = frame.getBounds();
735
+ Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
736
+ Dimension rect2 = frame.getToolkit().getScreenSize();
737
+ frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
738
+// frame.setState(Frame.MAXIMIZED_BOTH);
739
+ }
740
+
741
+ maximized ^= true;
742
+ }
743
+
609744 void ToggleFullScreen()
610745 {
611
- if (CameraPane.FULLSCREEN)
746
+ cameraView.ToggleFullScreen();
747
+
748
+ if (!CameraPane.FULLSCREEN)
612749 {
613
- frame.getContentPane().remove(/*"Center",*/bigThree);
614
- framePanel.add(bigThree);
615
- frame.getContentPane().add(/*"Center",*/framePanel);
750
+ device.setFullScreenWindow(null);
751
+ //frame.setVisible(false);
752
+// frame.removeNotify();
753
+// frame.setUndecorated(false);
754
+// frame.addNotify();
755
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
756
+
757
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
758
+// X framePanel.add(bigThree);
759
+// X frame.getContentPane().add(/*"Center",*/framePanel);
760
+ framePanel.setDividerLocation(1);
761
+
762
+ //frame.setVisible(true);
763
+ radio.layout = keepButton;
764
+ //theFrame = null;
765
+ keepButton = null;
766
+ radio.layout.doClick();
767
+
616768 } else
617769 {
618
- frame.getContentPane().remove(/*"Center",*/framePanel);
619
- framePanel.remove(bigThree);
620
- frame.getContentPane().add(/*"Center",*/bigThree);
770
+ keepButton = radio.layout;
771
+ //keeprect = frame.getBounds();
772
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
773
+// frame.getToolkit().getScreenSize().height);
774
+ //frame.setVisible(false);
775
+ device.setFullScreenWindow(frame);
776
+// frame.removeNotify();
777
+// frame.setUndecorated(true);
778
+// frame.addNotify();
779
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
780
+// X framePanel.remove(bigThree);
781
+// X frame.getContentPane().add(/*"Center",*/bigThree);
782
+ framePanel.setDividerLocation(0);
783
+
784
+ radio.layout = fullscreenLayout;
785
+ radio.layout.doClick();
786
+ //frame.setVisible(true);
621787 }
622
- cameraView.ToggleFullScreen();
623788 }
624789
625
- private JTextArea createTextPane()
790
+ private JTextPane createTextPane()
626791 {
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
- };
792
+// TEXTAREA String[] initString =
793
+// {
794
+// "This is an editable JTextPane, ", //regular
795
+// "another ", //italic
796
+// "styled ", //bold
797
+// "text ", //small
798
+// "component, ", //large
799
+// "which supports embedded components..." + newline,//regular
800
+// " " + newline, //button
801
+// "...and embedded icons..." + newline, //regular
802
+// " ", //icon
803
+// newline + "JTextPane is a subclass of JEditorPane that "
804
+// + "uses a StyledEditorKit and StyledDocument, and provides "
805
+// + "cover methods for interacting with those objects."
806
+// };
807
+//
808
+// String[] initStyles =
809
+// {
810
+// "regular", "italic", "bold", "small", "large",
811
+// "regular", "button", "regular", "icon",
812
+// "regular"
813
+// };
814
+//
815
+// JTextPane textPane = new JTextPane();
816
+// textPane.setEditable(true);
817
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
818
+// addStylesToDocument(doc);
819
+//
820
+// try
821
+// {
822
+// for (int j = 0; j < 2; j++)
823
+// {
824
+// for (int i = 0; i < initString.length; i++)
825
+// {
826
+// doc.insertString(doc.getLength(), initString[i],
827
+// doc.getStyle(initStyles[i]));
828
+// }
829
+// }
830
+// } catch (BadLocationException ble)
831
+// {
832
+// System.err.println("Couldn't insert initial text into text pane.");
833
+// }
642834
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;
835
+ return new JTextPane(); // textPane;
671836 }
672837
673838 protected void addStylesToDocument(StyledDocument doc)
....@@ -720,7 +885,7 @@
720885 protected static ImageIcon createImageIcon(String path,
721886 String description)
722887 {
723
- java.net.URL imgURL = GrafreeD.class.getResource(path);
888
+ java.net.URL imgURL = Grafreed.class.getResource(path);
724889 if (imgURL != null)
725890 {
726891 return new ImageIcon(imgURL, description);
....@@ -752,6 +917,7 @@
752917 // NumberSlider vDivsField;
753918 // JCheckBox endcaps;
754919 JCheckBox liveCB;
920
+ JCheckBox selectCB;
755921 JCheckBox hideCB;
756922 JCheckBox link2masterCB;
757923 JCheckBox markCB;
....@@ -759,7 +925,12 @@
759925 JCheckBox speedupCB;
760926 JCheckBox rewindCB;
761927 JCheckBox flipVCB;
928
+
929
+ cCheckBox toggleTextureCB;
930
+ cCheckBox toggleSwitchCB;
931
+
762932 JComboBox texresMenu;
933
+
763934 JButton resetButton;
764935 JButton stepButton;
765936 JButton stepAllButton;
....@@ -767,54 +938,48 @@
767938 JButton slowerButton;
768939 JButton fasterButton;
769940 JButton remarkButton;
941
+
942
+ cGridBag editPanel;
943
+ cGridBag editCommandsPanel;
944
+
945
+ cGridBag namePanel;
946
+ cGridBag setupPanel;
947
+ cGridBag setupPanel2;
948
+ cGridBag objectCommandsPanel;
949
+ cGridBag pushPanel;
950
+ cGridBag fillPanel;
770951
771
- JCheckBox AddCheckBox(ObjEditor oe, String label, boolean on)
952
+ JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
772953 {
773954 JCheckBox cb;
774955
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);
956
+ panel.add(cb = new JCheckBox(label, on)); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
780957 cb.addItemListener(this);
781
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
782
- oe.aConstraints.gridwidth = 1;
783
- oe.aConstraints.gridx += 1;
784958
785959 return cb;
786960 }
787961
788
- cButton AddButton(ObjEditor oe, String label)
962
+ cButton AddButton(cGridBag panel, String label)
789963 {
790964 cButton cb;
791965
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);
966
+ panel.add(cb = new cButton(label)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
797967 cb.addActionListener(this);
798
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
799
- oe.aConstraints.gridwidth = 1;
800
- oe.aConstraints.gridx += 1;
801968
802969 return cb;
803970 }
804971
805
- JComboBox AddCombo(ObjEditor oe, java.util.Vector list, int item)
972
+ JComboBox AddCombo(cGridBag panel, java.util.Vector list, int item)
806973 {
807974 JComboBox combo;
808975
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;
976
+ panel.add(combo = new JComboBox(new cListModel(list, item))); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
812977 combo.addActionListener(this);
813978
814979 return combo;
815980 }
816981
817
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, double min, double max, double current, double pow)
982
+ cGridBag AddSlider(cGridBag panel, String label, double min, double max, double current, double pow)
818983 {
819984 cGridBag control = new cGridBag();
820985
....@@ -826,12 +991,12 @@
826991 control.add(combo = new cNumberSlider(this, min, max, pow)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
827992 combo.setFloat(current);
828993
829
- ctrlPanel.add(control);
994
+ panel.add(control);
830995
831
- return combo;
996
+ return control;
832997 }
833998
834
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, int min, int max, int current)
999
+ cGridBag AddSlider(cGridBag panel, String label, int min, int max, int current)
8351000 {
8361001 cGridBag control = new cGridBag();
8371002
....@@ -839,25 +1004,21 @@
8391004
8401005 JLabel jlabel = new JLabel(label);
8411006 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);
1007
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
1008
+ control.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8441009 combo.setInteger(current);
8451010
846
- ctrlPanel.add(control);
1011
+ panel.add(control);
8471012
848
- return combo;
1013
+ return control;
8491014 }
8501015
8511016 JTextArea AddText(cGridBag ctrlPanel, String name)
8521017 {
8531018 JTextArea text;
8541019
855
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
856
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
8571020 ctrlPanel.add(text = new JTextArea(name)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8581021 text.addCaretListener(this);
859
- aConstraints.gridx += 1;
860
- aConstraints.gridwidth = 1;
8611022
8621023 return text;
8631024 }
....@@ -896,7 +1057,7 @@
8961057
8971058 /*
8981059 */
899
- void Return() // ObjEditor oe)
1060
+ void Return0() // ObjEditor oe)
9001061 {
9011062 aConstraints.gridy += 1;
9021063 aConstraints.gridx = 0;
....@@ -951,37 +1112,76 @@
9511112
9521113 void SetupUI2(ObjEditor oe)
9531114 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
958
- SetupName(oe);
1115
+ //SetupName(oe);
9591116
960
- if (!GroupEditor.allparams)
1117
+ namePanel = new cGridBag();
1118
+
1119
+ nameField = AddText(namePanel, copy.GetName());
1120
+ namePanel.add(nameField);
1121
+ oe.ctrlPanel.add(namePanel);
1122
+
1123
+ oe.ctrlPanel.Return();
1124
+
1125
+ if (!allparams)
9611126 return;
9621127
963
- liveCB = AddCheckBox(oe, "Live", copy.live);
964
- link2masterCB = AddCheckBox(oe, "Supp", copy.link2master);
965
- hideCB = AddCheckBox(oe, "Hide", copy.hide);
1128
+ setupPanel = new cGridBag().setVertical(false);
1129
+
1130
+ liveCB = AddCheckBox(setupPanel, "Live", copy.live);
1131
+ liveCB.setToolTipText("Animate object");
1132
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1133
+ selectCB.setToolTipText("Make object selectable");
9661134 // 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");
1135
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1136
+ hideCB.setToolTipText("Hide object");
1137
+ markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1138
+ markCB.setToolTipText("As animation target transform");
1139
+
1140
+ setupPanel2 = new cGridBag().setVertical(false);
1141
+
1142
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1143
+ rewindCB.setToolTipText("Rewind animation");
1144
+
1145
+ randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1146
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
1147
+
1148
+ if (Globals.ADVANCED)
1149
+ {
1150
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1151
+ link2masterCB.setToolTipText("Attach to support");
1152
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1153
+ speedupCB.setToolTipText("Option motion capture");
1154
+ }
1155
+
1156
+ oe.ctrlPanel.add(setupPanel);
1157
+ oe.ctrlPanel.Return();
1158
+ oe.ctrlPanel.add(setupPanel2);
1159
+ oe.ctrlPanel.Return();
1160
+
1161
+ objectCommandsPanel = new cGridBag().setVertical(false);
1162
+
1163
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1164
+ resetButton.setToolTipText("Jump to frame zero");
1165
+ stepButton = AddButton(objectCommandsPanel, "Step");
1166
+ stepButton.setToolTipText("Step one frame");
9731167 // resetAllButton = AddButton(oe, "Reset All");
9741168 // stepAllButton = AddButton(oe, "Step All");
975
- speedupCB = AddCheckBox(oe, "Speed", copy.speedup);
9761169 // Return();
977
- slowerButton = AddButton(oe, "Slow");
978
- fasterButton = AddButton(oe, "Fast");
979
- remarkButton = AddButton(oe, "Rem");
1170
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1171
+ slowerButton.setToolTipText("Decrease animation speed");
1172
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1173
+ fasterButton.setToolTipText("Increase animation speed");
1174
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1175
+ remarkButton.setToolTipText("Set the current transform as the target");
9801176
981
- Return();
1177
+ oe.ctrlPanel.add(objectCommandsPanel);
1178
+ oe.ctrlPanel.Return();
9821179
983
- normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1);
984
- Return();
1180
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
1181
+ normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1182
+ //Return();
1183
+
1184
+ oe.ctrlPanel.Return();
9851185
9861186 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
9871187 // ObjEditor.aConstraints.gridx += 1;
....@@ -1076,7 +1276,7 @@
10761276 oe.aConstraints.gridwidth = 1;
10771277 /**/
10781278 nameField = AddText(oe.ctrlPanel, copy.GetName());
1079
- Return();
1279
+ oe.ctrlPanel.Return();
10801280
10811281 //ctrlPanel.add(textureButton = new Button("Texture..."));
10821282 //textureButton.setEnabled(false);
....@@ -1180,8 +1380,11 @@
11801380 //worldPanel.setName("World");
11811381 centralPanel = new cGridBag();
11821382 centralPanel.preferredWidth = 20;
1183
- timelinePanel = new JPanel(new BorderLayout());
1184
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1383
+
1384
+ if (Globals.ADVANCED)
1385
+ {
1386
+ timelinePanel = new JPanel(new BorderLayout());
1387
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11851388
11861389 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11871390 cameraPanel.setContinuousLayout(true);
....@@ -1190,7 +1393,10 @@
11901393 // cameraPanel.setDividerSize(9);
11911394 cameraPanel.setResizeWeight(1.0);
11921395
1396
+ }
1397
+
11931398 centralPanel.add(cameraView);
1399
+ centralPanel.setFocusable(true);
11941400 //frame.setJMenuBar(timelineMenubar);
11951401 //centralPanel.add(timelinePanel);
11961402
....@@ -1253,11 +1459,13 @@
12531459 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12541460 //tmp.setName("Edit");
12551461 objectPanel.add(materialPanel);
1256
- JPanel north = new JPanel(new BorderLayout());
1257
- north.setName("Edit");
1258
- north.add(ctrlPanel, BorderLayout.NORTH);
1259
- objectPanel.add(north);
1462
+// JPanel north = new JPanel(new BorderLayout());
1463
+// north.setName("Edit");
1464
+// north.add(ctrlPanel, BorderLayout.NORTH);
1465
+// objectPanel.add(north);
1466
+ objectPanel.add(editPanel);
12601467 objectPanel.add(infoPanel);
1468
+ objectPanel.add(toolboxPanel);
12611469
12621470 /*
12631471 aConstraints.gridx = 0;
....@@ -1266,7 +1474,7 @@
12661474 aConstraints.gridy += 1;
12671475 aConstraints.gridwidth = 1;
12681476 mainPanel.add(objectPanel, aConstraints);
1269
- */
1477
+ */
12701478
12711479 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12721480 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1278,14 +1486,12 @@
12781486 scrollpane.addMouseWheelListener(this); // Default not fast enough
12791487
12801488 /*JTabbedPane*/ scenePanel = new cGridBag();
1281
- scenePanel.preferredWidth = 7;
1489
+ scenePanel.preferredWidth = 6;
12821490
12831491 JTabbedPane tabbedPane = new JTabbedPane();
12841492 tabbedPane.add(scrollpane);
12851493
1286
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1287
-
1288
- optionsPanel = new cGridBag().setVertical(true);
1494
+ optionsPanel = new cGridBag().setVertical(false);
12891495
12901496 optionsPanel.setName("Options");
12911497
....@@ -1293,6 +1499,8 @@
12931499
12941500 tabbedPane.add(optionsPanel);
12951501
1502
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1503
+
12961504 scenePanel.add(tabbedPane);
12971505
12981506 /*
....@@ -1384,9 +1592,13 @@
13841592
13851593 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13861594
1387
- frame.setSize(1024, 768);
1388
- frame.show();
1595
+ frame.setSize(1280, 860);
1596
+
1597
+ frame.validate();
1598
+ frame.setVisible(true);
13891599
1600
+ cameraView.requestFocusInWindow();
1601
+
13901602 gridPanel.setDividerLocation(1.0);
13911603
13921604 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -1415,7 +1627,7 @@
14151627 ctrlPanel.removeAll();
14161628 }
14171629
1418
- void SetupMaterial(cGridBag ctrlPanel)
1630
+ void SetupMaterial(cGridBag panel)
14191631 {
14201632 /*
14211633 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
....@@ -1424,18 +1636,26 @@
14241636
14251637 cGridBag editBar = new cGridBag().setVertical(false);
14261638
1427
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
1639
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1640
+ createMaterialButton.setToolTipText("Create material");
14281641
14291642 /*
14301643 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14311644 */
14321645
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);
1646
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1647
+ clearMaterialButton.setToolTipText("Clear material");
1648
+
1649
+ if (Globals.ADVANCED)
1650
+ {
1651
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1652
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1653
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1654
+ }
14371655
1438
- ctrlPanel.add(editBar);
1656
+ editBar.preferredHeight = 15;
1657
+
1658
+ panel.add(editBar);
14391659
14401660 /**/
14411661 //aConstraints.weighty = 0;
....@@ -1445,17 +1665,13 @@
14451665 //aConstraints.gridx += 1;
14461666 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14471667
1448
- JPanel colorPanel = new JPanel(new BorderLayout());
1449
- colorPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1450
-
14511668 cGridBag colorSection = new cGridBag().setVertical(true);
1452
-
1453
- colorPanel.add(colorSection);
14541669
14551670 cGridBag color = new cGridBag();
14561671 color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
14571672 colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14581673 color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1674
+ //colorField.preferredWidth = 200;
14591675 colorSection.add(color);
14601676
14611677 cGridBag modulation = new cGridBag();
....@@ -1488,16 +1704,13 @@
14881704 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
14891705 colorSection.add(shadowbias);
14901706
1491
- ctrlPanel.add(colorPanel);
1707
+ panel.add(new JSeparator());
1708
+
1709
+ panel.add(colorSection);
14921710
14931711 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14941712
1495
- JPanel diffusePanel = new JPanel(new BorderLayout());
1496
- diffusePanel.setBorder(BorderFactory.createLineBorder(Color.black));
1497
-
14981713 cGridBag diffuseSection = new cGridBag().setVertical(true);
1499
-
1500
- diffusePanel.add(diffuseSection);
15011714
15021715 cGridBag diffuse = new cGridBag();
15031716 diffuse.add(diffuseLabel = new JLabel("Diffuse")); // , aConstraints);
....@@ -1541,16 +1754,13 @@
15411754 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15421755 diffuseSection.add(fakedepth);
15431756
1544
- ctrlPanel.add(diffusePanel);
1757
+ panel.add(new JSeparator());
1758
+
1759
+ panel.add(diffuseSection);
15451760
15461761 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15471762
1548
- JPanel specularPanel = new JPanel(new BorderLayout());
1549
- specularPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1550
-
15511763 cGridBag specularSection = new cGridBag().setVertical(true);
1552
-
1553
- specularPanel.add(specularSection);
15541764
15551765 cGridBag specular = new cGridBag();
15561766 specular.add(specularLabel = new JLabel("Specular")); // , aConstraints);
....@@ -1582,7 +1792,7 @@
15821792 velvet.add(velvetField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15831793 specularSection.add(velvet);
15841794
1585
- shiftField = AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1);
1795
+ shiftField = (cNumberSlider)AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1).getComponent(1);
15861796 //Return();
15871797 // ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
15881798 // shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
....@@ -1595,16 +1805,13 @@
15951805 // aConstraints.gridwidth = 1;
15961806
15971807
1598
- ctrlPanel.add(specularPanel);
1808
+ panel.add(new JSeparator());
1809
+
1810
+ panel.add(specularSection);
15991811
16001812 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16011813
1602
- JPanel globalPanel = new JPanel(new BorderLayout());
1603
- globalPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1604
-
16051814 cGridBag globalSection = new cGridBag().setVertical(true);
1606
-
1607
- globalPanel.add(globalSection);
16081815
16091816 cGridBag camera = new cGridBag();
16101817 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
....@@ -1630,16 +1837,13 @@
16301837 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16311838 globalSection.add(opacity);
16321839
1633
- ctrlPanel.add(globalPanel);
1840
+ panel.add(new JSeparator());
1841
+
1842
+ panel.add(globalSection);
16341843
16351844 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16361845
1637
- JPanel texturePanel = new JPanel(new BorderLayout());
1638
- texturePanel.setBorder(BorderFactory.createLineBorder(Color.black));
1639
-
16401846 cGridBag textureSection = new cGridBag().setVertical(true);
1641
-
1642
- texturePanel.add(textureSection);
16431847
16441848 cGridBag bump = new cGridBag();
16451849 bump.add(bumpLabel = new JLabel("Bump")); // , aConstraints);
....@@ -1677,7 +1881,9 @@
16771881 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16781882 textureSection.add(opacityPower);
16791883
1680
- ctrlPanel.add(texturePanel);
1884
+ panel.add(new JSeparator());
1885
+
1886
+ panel.add(textureSection);
16811887
16821888 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16831889
....@@ -1714,12 +1920,15 @@
17141920 opacityPowerField.addChangeListener(this);
17151921 /**/
17161922
1717
- resetSlidersButton.addActionListener(this);
17181923 clearMaterialButton.addActionListener(this);
17191924 createMaterialButton.addActionListener(this);
1720
-
1721
- propagateToggle.addItemListener(this);
1722
- multiplyToggle.addItemListener(this);
1925
+
1926
+ if (Globals.ADVANCED)
1927
+ {
1928
+ resetSlidersButton.addActionListener(this);
1929
+ propagateToggle.addItemListener(this);
1930
+ multiplyToggle.addItemListener(this);
1931
+ }
17231932 }
17241933
17251934 void DropFile(java.io.File[] files, boolean textures)
....@@ -1890,7 +2099,7 @@
18902099
18912100 //? flashIt = false;
18922101 CameraPane pane = (CameraPane) cameraView;
1893
- pane.clickStart(location.x, location.y, 0);
2102
+ pane.clickStart(location.x, location.y, 0, 0);
18942103 pane.clickEnd(location.x, location.y, 0, true);
18952104
18962105 if (group.selection.size() == 1)
....@@ -1939,6 +2148,7 @@
19392148 e2.printStackTrace();
19402149 }
19412150 }
2151
+
19422152 LoadJMEThread loadThread;
19432153
19442154 class LoadJMEThread extends Thread
....@@ -1996,6 +2206,7 @@
19962206 //LoadFile0(filename, converter);
19972207 }
19982208 }
2209
+
19992210 LoadOBJThread loadObjThread;
20002211
20012212 class LoadOBJThread extends Thread
....@@ -2074,19 +2285,19 @@
20742285
20752286 void LoadObjFile(String fullname)
20762287 {
2077
- /*
2288
+ System.out.println("Loading " + fullname);
2289
+ /**/
20782290 //lastFilename = fullname;
20792291 if(loadObjThread == null)
20802292 {
2081
- loadObjThread = new LoadOBJThread();
2082
- loadObjThread.start();
2293
+ loadObjThread = new LoadOBJThread();
2294
+ loadObjThread.start();
20832295 }
20842296
20852297 loadObjThread.add(fullname);
2086
- */
2298
+ /**/
20872299
2088
- System.out.println("Loading " + fullname);
2089
- makeSomething(new FileObject(fullname, true), true);
2300
+ //makeSomething(new FileObject(fullname, true), true);
20902301 }
20912302
20922303 void LoadGFDFile(String fullname)
....@@ -2347,11 +2558,11 @@
23472558
23482559 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23492560 {
2350
- if (GrafreeD.standAlone)
2561
+ if (Grafreed.standAlone)
23512562 {
23522563 /**/
23532564 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2354
- browser.show();
2565
+ browser.setVisible(true);
23552566 String filename = browser.getFile();
23562567 if (filename != null && filename.length() > 0)
23572568 {
....@@ -2496,6 +2707,7 @@
24962707 }
24972708 if (input == null)
24982709 {
2710
+ new Exception().printStackTrace();
24992711 System.exit(0);
25002712 }
25012713
....@@ -2702,6 +2914,8 @@
27022914
27032915 void SetMaterial(Object3D object)
27042916 {
2917
+ latestObject = object;
2918
+
27052919 cMaterial mat = object.material;
27062920
27072921 if (mat == null)
....@@ -2710,7 +2924,8 @@
27102924 return;
27112925 }
27122926
2713
- multiplyToggle.setSelected(mat.multiply);
2927
+ if (multiplyToggle != null)
2928
+ multiplyToggle.setSelected(mat.multiply);
27142929
27152930 assert (object.projectedVertices != null);
27162931
....@@ -2812,12 +3027,17 @@
28123027 // }
28133028
28143029 /**/
2815
- if (deselect)
3030
+ if (deselect || child == null)
28163031 {
28173032 //group.deselectAll();
28183033 //freeze = true;
28193034 GetTree().clearSelection();
28203035 //freeze = false;
3036
+
3037
+ if (child == null)
3038
+ {
3039
+ return;
3040
+ }
28213041 }
28223042
28233043 //group.addSelectee(child);
....@@ -2886,7 +3106,7 @@
28863106 cameraView.ToggleDL();
28873107 cameraView.repaint();
28883108 return;
2889
- } else if (event.getSource() == toggleTextureItem)
3109
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28903110 {
28913111 cameraView.ToggleTexture();
28923112 // june 2013 copy.HardTouch();
....@@ -2925,9 +3145,9 @@
29253145 frame.validate();
29263146
29273147 return;
2928
- } else if (event.getSource() == toggleRandomItem)
3148
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29293149 {
2930
- cameraView.ToggleRandom();
3150
+ cameraView.ToggleSwitch();
29313151 cameraView.repaint();
29323152 return;
29333153 } else if (event.getSource() == toggleHandleItem)
....@@ -2956,6 +3176,10 @@
29563176 {
29573177 copy.live ^= true;
29583178 return;
3179
+ } else if (event.getSource() == selectCB)
3180
+ {
3181
+ copy.dontselect ^= true;
3182
+ return;
29593183 } else if (event.getSource() == hideCB)
29603184 {
29613185 copy.hide ^= true;
....@@ -2970,6 +3194,7 @@
29703194 if (event.getSource() == randomCB)
29713195 {
29723196 copy.random ^= true;
3197
+ objEditor.refreshContents();
29733198 return;
29743199 }
29753200 if (event.getSource() == speedupCB)
....@@ -2993,8 +3218,9 @@
29933218
29943219 public void actionPerformed(ActionEvent event)
29953220 {
3221
+ Object source = event.getSource();
29963222 // SCRIPT DIALOG
2997
- if (event.getSource() == okbutton)
3223
+ if (source == okbutton)
29983224 {
29993225 textpanel.setVisible(false);
30003226 textpanel.remove(textarea);
....@@ -3006,7 +3232,7 @@
30063232 textarea = null;
30073233 textpanel = null;
30083234 }
3009
- if (event.getSource() == cancelbutton)
3235
+ if (source == cancelbutton)
30103236 {
30113237 textpanel.setVisible(false);
30123238 textpanel.remove(textarea);
....@@ -3018,50 +3244,50 @@
30183244 //applySelf();
30193245 //client.refreshEditWindow();
30203246 //refreshContents();
3021
- if (event.getSource() == nameField)
3247
+ if (source == nameField)
30223248 {
30233249 //System.out.println("ObjEditor " + event);
30243250 applySelf0(true);
30253251 //parent.applySelf();
30263252 objEditor.refreshContents();
3027
- } else if (event.getSource() == resetButton)
3253
+ } else if (source == resetButton)
30283254 {
30293255 CameraPane.fullreset = true;
30303256 copy.Reset(); // ResetMeshes();
30313257 copy.Touch();
30323258 objEditor.refreshContents();
3033
- } else if (event.getSource() == stepItem)
3259
+ } else if (source == stepItem)
30343260 {
30353261 //cameraView.ONESTEP = true;
30363262 Globals.ONESTEP = true;
30373263 cameraView.repaint();
30383264 return;
3039
- } else if (event.getSource() == stepButton)
3265
+ } else if (source == stepButton)
30403266 {
30413267 copy.Step();
30423268 copy.Touch();
30433269 objEditor.refreshContents();
3044
- } else if (event.getSource() == slowerButton)
3270
+ } else if (source == slowerButton)
30453271 {
30463272 copy.Slower();
30473273 copy.Touch();
30483274 objEditor.refreshContents();
3049
- } else if (event.getSource() == fasterButton)
3275
+ } else if (source == fasterButton)
30503276 {
30513277 copy.Faster();
30523278 copy.Touch();
30533279 objEditor.refreshContents();
3054
- } else if (event.getSource() == remarkButton)
3280
+ } else if (source == remarkButton)
30553281 {
30563282 copy.Remark();
30573283 copy.Touch();
30583284 objEditor.refreshContents();
3059
- } else if (event.getSource() == stepAllButton)
3285
+ } else if (source == stepAllButton)
30603286 {
30613287 copy.StepAll();
30623288 copy.Touch();
30633289 objEditor.refreshContents();
3064
- } else if (event.getSource() == resetAllButton)
3290
+ } else if (source == resetAllButton)
30653291 {
30663292 //CameraPane.fullreset = true;
30673293 copy.ResetAll(); // ResetMeshes();
....@@ -3094,53 +3320,75 @@
30943320 // Close();
30953321 // }
30963322 // else
3097
- if (event.getSource() == resetSlidersButton)
3323
+ if (source == resetSlidersButton)
30983324 {
30993325 ResetSliders();
3100
- } else if (event.getSource() == clearMaterialButton)
3326
+ } else if (source == clearMaterialButton)
31013327 {
31023328 ClearMaterial();
3103
- } else if (event.getSource() == createMaterialButton)
3329
+ } else if (source == createMaterialButton)
31043330 {
31053331 CreateMaterial();
3106
- } else if (event.getSource() == clearPanelButton)
3332
+ } else if (source == clearPanelButton)
31073333 {
31083334 copy.ClearUI();
31093335 refreshContents(true);
3110
- } /*
3111
- }
3112
-
3113
- public boolean action(Event event, Object arg)
3114
- {
3115
- */ else if (event.getSource() == closeItem)
3336
+ } else if (source == importGFDItem)
3337
+ {
3338
+ ImportGFD();
3339
+ } else
3340
+ if (source == importVRMLX3DItem)
3341
+ {
3342
+ ImportVRMLX3D();
3343
+ } else
3344
+ if (source == import3DSItem)
3345
+ {
3346
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3347
+ } else
3348
+ if (source == importOBJItem)
3349
+ {
3350
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3351
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3352
+ browser.setVisible(true);
3353
+ String filename = browser.getFile();
3354
+ if (filename != null && filename.length() > 0)
3355
+ {
3356
+ String fullname = browser.getDirectory() + filename;
3357
+ makeSomething(ReadOBJ(fullname), true);
3358
+ }
3359
+ } else
3360
+ if (source == closeItem)
31163361 {
31173362 Close();
31183363 //return true;
3119
- } else if (event.getSource() == loadItem)
3364
+ } else if (source == loadItem)
31203365 {
31213366 load();
31223367 //return true;
3123
- } else if (event.getSource() == saveItem)
3368
+ } else if (source == newItem)
3369
+ {
3370
+ New();
3371
+ } else if (source == saveItem)
31243372 {
31253373 save();
31263374 //return true;
3127
- } else if (event.getSource() == saveAsItem)
3375
+ } else if (source == saveAsItem)
31283376 {
31293377 saveAs();
31303378 //return true;
3131
- } else if (event.getSource() == reexportItem)
3379
+ } else if (source == reexportItem)
31323380 {
31333381 reexport();
31343382 //return true;
3135
- } else if (event.getSource() == exportAsItem)
3383
+ } else if (source == exportAsItem)
31363384 {
31373385 export();
31383386 //return true;
3139
- } else if (event.getSource() == povItem)
3387
+ } else if (source == povItem)
31403388 {
31413389 generatePOV();
31423390 //return true;
3143
- } else if (event.getSource() == zBufferItem)
3391
+ } else if (source == zBufferItem)
31443392 {
31453393 try
31463394 {
....@@ -3162,21 +3410,8 @@
31623410 cameraView.repaint();
31633411 //return true;
31643412 }
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)
3413
+ */ else // combos...
3414
+ if (source == texresMenu)
31803415 {
31813416 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31823417 copy.texres = texresMenu.getSelectedIndex();
....@@ -3188,12 +3423,287 @@
31883423 }
31893424 }
31903425
3426
+ void New()
3427
+ {
3428
+ while (copy.Size() > 1)
3429
+ {
3430
+ copy.remove(1);
3431
+ }
3432
+
3433
+ ResetModel();
3434
+ objEditor.refreshContents();
3435
+ }
3436
+
3437
+ static public byte[] Compress(Object3D o)
3438
+ {
3439
+ try
3440
+ {
3441
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3442
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3443
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3444
+
3445
+ Object3D parent = o.parent;
3446
+ o.parent = null;
3447
+
3448
+ out.writeObject(o);
3449
+
3450
+ o.parent = parent;
3451
+
3452
+ out.flush();
3453
+
3454
+ zstream.close();
3455
+ out.close();
3456
+
3457
+ return baos.toByteArray();
3458
+ } catch (Exception e)
3459
+ {
3460
+ System.err.println(e);
3461
+ return null;
3462
+ }
3463
+ }
3464
+
3465
+ static public Object Uncompress(byte[] bytes)
3466
+ {
3467
+ System.out.println("#bytes = " + bytes.length);
3468
+ try
3469
+ {
3470
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3471
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3472
+ ObjectInputStream in = new ObjectInputStream(istream);
3473
+ Object obj = in.readObject();
3474
+ in.close();
3475
+
3476
+ return obj;
3477
+ } catch (Exception e)
3478
+ {
3479
+ System.err.println(e);
3480
+ return null;
3481
+ }
3482
+ }
3483
+
3484
+ static public Object clone(Object o)
3485
+ {
3486
+ try
3487
+ {
3488
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3489
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3490
+
3491
+ out.writeObject(o);
3492
+
3493
+ out.flush();
3494
+ out.close();
3495
+
3496
+ byte[] bytes = baos.toByteArray();
3497
+
3498
+ System.out.println("clone = " + bytes.length);
3499
+
3500
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3501
+ ObjectInputStream in = new ObjectInputStream(bais);
3502
+ Object obj = in.readObject();
3503
+ in.close();
3504
+
3505
+ return obj;
3506
+ } catch (Exception e)
3507
+ {
3508
+ System.err.println(e);
3509
+ return null;
3510
+ }
3511
+ }
3512
+
3513
+ cRadio GetCurrentTab()
3514
+ {
3515
+ cRadio ab;
3516
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3517
+ {
3518
+ ab = (cRadio)e.nextElement();
3519
+ if(ab.GetObject() == copy)
3520
+ {
3521
+ return ab;
3522
+ }
3523
+ }
3524
+
3525
+ return null;
3526
+ }
3527
+
3528
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3529
+
3530
+ public void Save()
3531
+ {
3532
+ System.err.println("Save");
3533
+
3534
+ cRadio tab = GetCurrentTab();
3535
+
3536
+ boolean temp = CameraPane.SWITCH;
3537
+ CameraPane.SWITCH = false;
3538
+
3539
+ copy.ExtractBigData(hashtable);
3540
+
3541
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3542
+ tab.graphs[tab.undoindex++] = Compress(copy);
3543
+
3544
+ copy.RestoreBigData(hashtable);
3545
+
3546
+ CameraPane.SWITCH = temp;
3547
+
3548
+ //assert(hashtable.isEmpty());
3549
+
3550
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3551
+ {
3552
+ tab.graphs[i] = null;
3553
+ }
3554
+
3555
+ SetUndoStates();
3556
+
3557
+ // test save
3558
+ if (false)
3559
+ {
3560
+ try
3561
+ {
3562
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3563
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3564
+
3565
+ p.writeObject(copy);
3566
+
3567
+ p.flush();
3568
+
3569
+ ostream.close();
3570
+ } catch (Exception e)
3571
+ {
3572
+ e.printStackTrace();
3573
+ }
3574
+ }
3575
+ }
3576
+
3577
+ void CopyChanged(Object3D obj)
3578
+ {
3579
+ SetUndoStates();
3580
+
3581
+ boolean temp = CameraPane.SWITCH;
3582
+ CameraPane.SWITCH = false;
3583
+
3584
+ copy.ExtractBigData(hashtable);
3585
+
3586
+ copy.clear();
3587
+
3588
+ for (int i=0; i<obj.Size(); i++)
3589
+ {
3590
+ copy.add(obj.get(i));
3591
+ }
3592
+
3593
+ copy.RestoreBigData(hashtable);
3594
+
3595
+ CameraPane.SWITCH = temp;
3596
+
3597
+ //assert(hashtable.isEmpty());
3598
+
3599
+ copy.Touch();
3600
+
3601
+ ResetModel();
3602
+ copy.HardTouch(); // recompile?
3603
+
3604
+ cRadio ab;
3605
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3606
+ {
3607
+ ab = (cRadio)e.nextElement();
3608
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3609
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3610
+ if (test != null)
3611
+ {
3612
+ test.editWindow = ab.object.editWindow;
3613
+ ab.object = test;
3614
+ }
3615
+ }
3616
+
3617
+ refreshContents();
3618
+ }
3619
+
3620
+ cButton undoButton;
3621
+ cButton redoButton;
3622
+
3623
+ void SetUndoStates()
3624
+ {
3625
+ cRadio tab = GetCurrentTab();
3626
+
3627
+ undoButton.setEnabled(tab.undoindex > 0);
3628
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3629
+ }
3630
+
3631
+ public void Undo()
3632
+ {
3633
+ System.err.println("Undo");
3634
+
3635
+ cRadio tab = GetCurrentTab();
3636
+
3637
+ if (tab.undoindex == 0)
3638
+ {
3639
+ java.awt.Toolkit.getDefaultToolkit().beep();
3640
+ return;
3641
+ }
3642
+
3643
+ if (tab.graphs[tab.undoindex] == null)
3644
+ {
3645
+ Save();
3646
+ tab.undoindex -= 1;
3647
+ }
3648
+
3649
+ tab.undoindex -= 1;
3650
+
3651
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3652
+ }
3653
+
3654
+ public void Redo()
3655
+ {
3656
+ cRadio tab = GetCurrentTab();
3657
+
3658
+ if (tab.graphs[tab.undoindex + 1] == null)
3659
+ {
3660
+ java.awt.Toolkit.getDefaultToolkit().beep();
3661
+ return;
3662
+ }
3663
+
3664
+ tab.undoindex += 1;
3665
+
3666
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3667
+ }
3668
+
3669
+ void ImportGFD()
3670
+ {
3671
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3672
+ browser.show();
3673
+ String filename = browser.getFile();
3674
+ if (filename != null && filename.length() > 0)
3675
+ {
3676
+ String fullname = browser.getDirectory() + filename;
3677
+
3678
+ //Object3D readobj =
3679
+ objEditor.ReadGFD(fullname, objEditor);
3680
+ //makeSomething(readobj);
3681
+ }
3682
+ }
3683
+
3684
+ void ImportVRMLX3D()
3685
+ {
3686
+ if (Grafreed.standAlone)
3687
+ {
3688
+ /**/
3689
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3690
+ browser.show();
3691
+ String filename = browser.getFile();
3692
+ if (filename != null && filename.length() > 0)
3693
+ {
3694
+ String fullname = browser.getDirectory() + filename;
3695
+ LoadVRMLX3D(fullname);
3696
+ }
3697
+ /**/
3698
+ }
3699
+ }
3700
+
31913701 void ToggleAnimation()
31923702 {
31933703 if (!Globals.ANIMATION)
31943704 {
31953705 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3196
- browser.show();
3706
+ browser.setVisible(true);
31973707 String filename = browser.getFile();
31983708 if (filename != null && filename.length() > 0)
31993709 {
....@@ -3203,8 +3713,8 @@
32033713
32043714 Globals.ANIMATION ^= true;
32053715
3206
- GrafreeD.wav.cursor = 0;
3207
- GrafreeD.wav.loop = 0;
3716
+ Grafreed.wav.cursor = 0;
3717
+ Grafreed.wav.loop = 0;
32083718 }
32093719 } else
32103720 {
....@@ -3254,7 +3764,7 @@
32543764 void CreateMaterial()
32553765 {
32563766 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
3767
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32583768 if (copy.selection.size() > 0)
32593769 //SetMaterial(copy);
32603770 {
....@@ -3305,7 +3815,7 @@
33053815 assert false;
33063816 }
33073817
3308
- void EditSelection()
3818
+ void EditSelection(boolean newWindow)
33093819 {
33103820 }
33113821
....@@ -3313,11 +3823,11 @@
33133823 {
33143824 copy.ResetBlockLoop(); // temporary problem
33153825
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
3826
+ boolean random = CameraPane.SWITCH;
3827
+ CameraPane.SWITCH = false; // parse everything
33183828 copy.ResetDisplayList();
33193829 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
3830
+ CameraPane.SWITCH = random;
33213831 }
33223832
33233833 // public void applySelf()
....@@ -3391,6 +3901,36 @@
33913901 {
33923902 //System.out.println("Propagate = " + propagate);
33933903 copy.UpdateMaterial(anchor, current, propagate);
3904
+
3905
+ if (copy.material != null)
3906
+ {
3907
+ cMaterial mat = copy.material;
3908
+
3909
+ colorField.SetToolTipValue((mat.color));
3910
+ modulationField.SetToolTipValue((mat.modulation));
3911
+ metalnessField.SetToolTipValue((mat.metalness));
3912
+ diffuseField.SetToolTipValue((mat.diffuse));
3913
+ specularField.SetToolTipValue((mat.specular));
3914
+ shininessField.SetToolTipValue((mat.shininess));
3915
+ shiftField.SetToolTipValue((mat.shift));
3916
+ ambientField.SetToolTipValue((mat.ambient));
3917
+ lightareaField.SetToolTipValue((mat.lightarea));
3918
+ diffusenessField.SetToolTipValue((mat.factor));
3919
+ velvetField.SetToolTipValue((mat.velvet));
3920
+ sheenField.SetToolTipValue((mat.sheen));
3921
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3922
+ backlitField.SetToolTipValue((mat.bump));
3923
+ anisoField.SetToolTipValue((mat.aniso));
3924
+ anisoVField.SetToolTipValue((mat.anisoV));
3925
+ cameraField.SetToolTipValue((mat.cameralight));
3926
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3927
+ shadowField.SetToolTipValue((mat.shadow));
3928
+ textureField.SetToolTipValue((mat.texture));
3929
+ opacityField.SetToolTipValue((mat.opacity));
3930
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3931
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3932
+ }
3933
+
33943934 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33953935 {
33963936 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3435,6 +3975,7 @@
34353975 || e.getSource() == apertureField
34363976 || e.getSource() == shadowblurField)
34373977 {
3978
+ new Exception().printStackTrace();
34383979 System.exit(0);
34393980 cameraView.options1[0] = (float) focusField.getFloat() * 10;
34403981 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3505,7 +4046,7 @@
35054046 }
35064047
35074048 if (normalpushField != null)
3508
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4049
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35094050 }
35104051
35114052 void SnapObject()
....@@ -3769,6 +4310,8 @@
37694310
37704311 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37714312 {
4313
+ if (Globals.SAVEONMAKE) // && resetmodel)
4314
+ Save();
37724315 //Tween.set(thing, 0).target(1).start(tweenManager);
37734316 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37744317 // if (thing instanceof GenericJointDemo)
....@@ -3855,6 +4398,12 @@
38554398 {
38564399 ResetModel();
38574400 Select(thing.GetTreePath(), true, false); // unselect... false);
4401
+
4402
+ if (thing.Size() == 0)
4403
+ {
4404
+ //EditSelection(false);
4405
+ }
4406
+
38584407 refreshContents();
38594408 }
38604409
....@@ -3972,6 +4521,7 @@
39724521 }
39734522 }
39744523 }
4524
+
39754525 LoadGFDThread loadGFDThread;
39764526
39774527 void ReadGFD(String fullname, iCallBack cb)
....@@ -3991,8 +4541,10 @@
39914541
39924542 try
39934543 {
4544
+ // Try compressed version first.
39944545 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3995
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4546
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4547
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39964548
39974549 readobj = (Object3D) p.readObject();
39984550 istream.close();
....@@ -4000,7 +4552,20 @@
40004552 readobj.ResetDisplayList();
40014553 } catch (Exception e)
40024554 {
4003
- e.printStackTrace();
4555
+ //e.printStackTrace();
4556
+ try
4557
+ {
4558
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4559
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4560
+
4561
+ readobj = (Object3D) p.readObject();
4562
+ istream.close();
4563
+
4564
+ readobj.ResetDisplayList();
4565
+ } catch (Exception e2)
4566
+ {
4567
+ e2.printStackTrace();
4568
+ }
40044569 }
40054570 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40064571 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4046,6 +4611,12 @@
40464611
40474612 void LoadIt(Object obj)
40484613 {
4614
+ if (obj == null)
4615
+ {
4616
+ // Invalid file
4617
+ return;
4618
+ }
4619
+
40494620 System.out.println("Loaded " + obj);
40504621 //new Exception().printStackTrace();
40514622 Object3D readobj = (Object3D) obj;
....@@ -4055,6 +4626,8 @@
40554626
40564627 if (readobj != null)
40574628 {
4629
+ if (Globals.SAVEONMAKE)
4630
+ Save();
40584631 try
40594632 {
40604633 //readobj.deepCopySelf(copy);
....@@ -4117,7 +4690,7 @@
41174690
41184691 void load() // throws ClassNotFoundException
41194692 {
4120
- if (GrafreeD.standAlone)
4693
+ if (Grafreed.standAlone)
41214694 {
41224695 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41234696 browser.show();
....@@ -4204,11 +4777,13 @@
42044777 try
42054778 {
42064779 FileOutputStream ostream = new FileOutputStream(lastname);
4207
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4780
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4781
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42084782
42094783 p.writeObject(copy);
42104784 p.flush();
42114785
4786
+ zstream.close();
42124787 ostream.close();
42134788
42144789 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4218,17 +4793,20 @@
42184793 {
42194794 }
42204795 }
4796
+
42214797 String lastname;
42224798
42234799 void saveAs()
42244800 {
4225
- if (GrafreeD.standAlone)
4801
+ if (Grafreed.standAlone)
42264802 {
42274803 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42284804 browser.setVisible(true);
42294805 String filename = browser.getFile();
42304806 if (filename != null && filename.length() > 0)
42314807 {
4808
+ if (!filename.endsWith(".gfd"))
4809
+ filename += ".gfd";
42324810 lastname = browser.getDirectory() + filename;
42334811 save();
42344812 }
....@@ -4327,13 +4905,13 @@
43274905 try
43284906 {
43294907 FileOutputStream ostream = new FileOutputStream(filename);
4330
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4331
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4908
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4909
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43324910
43334911 Object3D objectparent = obj.parent;
43344912 obj.parent = null;
43354913
4336
- Object3D object = (Object3D) GrafreeD.clone(obj);
4914
+ Object3D object = (Object3D) Grafreed.clone(obj);
43374915
43384916 obj.parent = objectparent;
43394917
....@@ -4345,8 +4923,8 @@
43454923 p.writeObject(object);
43464924 p.flush();
43474925
4926
+ zstream.close();
43484927 ostream.close();
4349
- // zstream.close();
43504928
43514929 // group.selection.get(0).parent = parent;
43524930 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4367,7 +4945,7 @@
43674945 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43684946 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43694947 copy.generatePOV(buffer);
4370
- if (GrafreeD.standAlone)
4948
+ if (Grafreed.standAlone)
43714949 {
43724950 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43734951 browser.show();
....@@ -4393,7 +4971,8 @@
43934971 Object3D client;
43944972 Object3D copy;
43954973 MenuBar menuBar;
4396
- Menu windowMenu;
4974
+ Menu fileMenu;
4975
+ MenuItem newItem;
43974976 MenuItem loadItem;
43984977 MenuItem saveItem;
43994978 MenuItem saveAsItem;
....@@ -4401,13 +4980,11 @@
44014980 MenuItem reexportItem;
44024981 MenuItem povItem;
44034982 MenuItem closeItem;
4404
- Menu cameraMenu;
4983
+
44054984 CheckboxMenuItem zBufferItem;
44064985 //MenuItem normalLensItem;
4407
- MenuItem editCameraItem;
4408
- MenuItem revertCameraItem;
4409
- CheckboxMenuItem toggleLiveItem;
44104986 MenuItem stepItem;
4987
+ CheckboxMenuItem toggleLiveItem;
44114988 CheckboxMenuItem toggleFullScreenItem;
44124989 CheckboxMenuItem toggleTimelineItem;
44134990 CheckboxMenuItem toggleRenderItem;
....@@ -4416,25 +4993,38 @@
44164993 CheckboxMenuItem toggleFootContactItem;
44174994 CheckboxMenuItem toggleDLItem;
44184995 CheckboxMenuItem toggleTextureItem;
4419
- CheckboxMenuItem toggleRandomItem;
4996
+ CheckboxMenuItem toggleSwitchItem;
44204997 CheckboxMenuItem toggleRootItem;
44214998 CheckboxMenuItem animationItem;
44224999 CheckboxMenuItem toggleHandleItem;
44235000 CheckboxMenuItem togglePaintItem;
44245001 JSplitPane mainPanel;
44255002 JScrollPane scrollpane;
5003
+
44265004 JPanel toolbarPanel;
4427
- JPanel treePanel;
5005
+
5006
+ cGridBag treePanel;
5007
+
44285008 JPanel radioPanel;
44295009 ButtonGroup buttonGroup;
4430
- cGridBag ctrlPanel;
5010
+
5011
+ cGridBag toolboxPanel;
44315012 cGridBag materialPanel;
5013
+ cGridBag ctrlPanel;
5014
+
44325015 JScrollPane infoPanel;
5016
+
44335017 cGridBag optionsPanel;
5018
+
44345019 JTabbedPane objectPanel;
5020
+ boolean materialFlushed;
5021
+ Object3D latestObject;
5022
+
44355023 cGridBag XYZPanel;
5024
+
44365025 JSplitPane gridPanel;
44375026 JSplitPane bigPanel;
5027
+
44385028 cGridBag bigThree;
44395029 cGridBag scenePanel;
44405030 cGridBag centralPanel;
....@@ -4549,8 +5139,13 @@
45495139 cNumberSlider fogField;
45505140 JLabel opacityPowerLabel;
45515141 cNumberSlider opacityPowerField;
4552
- JTree jTree;
5142
+ cTree jTree;
45535143 //ObjectUI parent;
45545144
45555145 cNumberSlider normalpushField;
5146
+
5147
+ private MenuItem importGFDItem;
5148
+ private MenuItem importVRMLX3DItem;
5149
+ private MenuItem import3DSItem;
5150
+ private MenuItem importOBJItem;
45565151 }