Normand Briere
2019-07-01 6600d22461ccc1cb602f238a9ffa83cf07dd830e
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(false);
239313 objEditor = this;
240314 this.callee = callee;
241315
....@@ -266,28 +340,49 @@
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(openItem = 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
290
- loadItem.addActionListener(this);
384
+ newItem.addActionListener(this);
385
+ openItem.addActionListener(this);
291386 saveItem.addActionListener(this);
292387 saveAsItem.addActionListener(this);
293388 exportAsItem.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(1, 1));
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,169 @@
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
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
749
+ }
750
+
751
+ maximized ^= true;
752
+
753
+ frame.validate();
754
+ }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
759
+
609760 void ToggleFullScreen()
610761 {
611
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
612767 {
613
- frame.getContentPane().remove(/*"Center",*/bigThree);
614
- framePanel.add(bigThree);
615
- frame.getContentPane().add(/*"Center",*/framePanel);
768
+ device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
774
+ //frame.setVisible(false);
775
+// frame.removeNotify();
776
+// frame.setUndecorated(false);
777
+// frame.addNotify();
778
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
779
+
780
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
781
+// X framePanel.add(bigThree);
782
+// X frame.getContentPane().add(/*"Center",*/framePanel);
783
+ framePanel.setDividerLocation(46);
784
+
785
+ //frame.setVisible(true);
786
+ radio.layout = keepButton;
787
+ //theFrame = null;
788
+ keepButton = null;
789
+ radio.layout.doClick();
790
+
616791 } else
617792 {
618
- frame.getContentPane().remove(/*"Center",*/framePanel);
619
- framePanel.remove(bigThree);
620
- frame.getContentPane().add(/*"Center",*/bigThree);
793
+ keepButton = radio.layout;
794
+ //keeprect = frame.getBounds();
795
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
796
+// frame.getToolkit().getScreenSize().height);
797
+ //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
801
+ device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
804
+// frame.removeNotify();
805
+// frame.setUndecorated(true);
806
+// frame.addNotify();
807
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
808
+// X framePanel.remove(bigThree);
809
+// X frame.getContentPane().add(/*"Center",*/bigThree);
810
+ framePanel.setDividerLocation(0);
811
+
812
+ radio.layout = fullscreenLayout;
813
+ radio.layout.doClick();
814
+ //frame.setVisible(true);
621815 }
622
- cameraView.ToggleFullScreen();
816
+ frame.validate();
623817 }
624818
625
- private JTextArea createTextPane()
819
+ private JTextPane createTextPane()
626820 {
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
- };
821
+// TEXTAREA String[] initString =
822
+// {
823
+// "This is an editable JTextPane, ", //regular
824
+// "another ", //italic
825
+// "styled ", //bold
826
+// "text ", //small
827
+// "component, ", //large
828
+// "which supports embedded components..." + newline,//regular
829
+// " " + newline, //button
830
+// "...and embedded icons..." + newline, //regular
831
+// " ", //icon
832
+// newline + "JTextPane is a subclass of JEditorPane that "
833
+// + "uses a StyledEditorKit and StyledDocument, and provides "
834
+// + "cover methods for interacting with those objects."
835
+// };
836
+//
837
+// String[] initStyles =
838
+// {
839
+// "regular", "italic", "bold", "small", "large",
840
+// "regular", "button", "regular", "icon",
841
+// "regular"
842
+// };
843
+//
844
+// JTextPane textPane = new JTextPane();
845
+// textPane.setEditable(true);
846
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
847
+// addStylesToDocument(doc);
848
+//
849
+// try
850
+// {
851
+// for (int j = 0; j < 2; j++)
852
+// {
853
+// for (int i = 0; i < initString.length; i++)
854
+// {
855
+// doc.insertString(doc.getLength(), initString[i],
856
+// doc.getStyle(initStyles[i]));
857
+// }
858
+// }
859
+// } catch (BadLocationException ble)
860
+// {
861
+// System.err.println("Couldn't insert initial text into text pane.");
862
+// }
642863
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;
864
+ return new JTextPane(); // textPane;
671865 }
672866
673867 protected void addStylesToDocument(StyledDocument doc)
....@@ -720,7 +914,7 @@
720914 protected static ImageIcon createImageIcon(String path,
721915 String description)
722916 {
723
- java.net.URL imgURL = GrafreeD.class.getResource(path);
917
+ java.net.URL imgURL = Grafreed.class.getResource(path);
724918 if (imgURL != null)
725919 {
726920 return new ImageIcon(imgURL, description);
....@@ -752,6 +946,7 @@
752946 // NumberSlider vDivsField;
753947 // JCheckBox endcaps;
754948 JCheckBox liveCB;
949
+ JCheckBox selectCB;
755950 JCheckBox hideCB;
756951 JCheckBox link2masterCB;
757952 JCheckBox markCB;
....@@ -759,7 +954,12 @@
759954 JCheckBox speedupCB;
760955 JCheckBox rewindCB;
761956 JCheckBox flipVCB;
957
+
958
+ cCheckBox toggleTextureCB;
959
+ cCheckBox toggleSwitchCB;
960
+
762961 JComboBox texresMenu;
962
+
763963 JButton resetButton;
764964 JButton stepButton;
765965 JButton stepAllButton;
....@@ -767,54 +967,48 @@
767967 JButton slowerButton;
768968 JButton fasterButton;
769969 JButton remarkButton;
970
+
971
+ cGridBag editPanel;
972
+ cGridBag editCommandsPanel;
973
+
974
+ cGridBag namePanel;
975
+ cGridBag setupPanel;
976
+ cGridBag setupPanel2;
977
+ cGridBag objectCommandsPanel;
978
+ cGridBag pushPanel;
979
+ cGridBag fillPanel;
770980
771
- JCheckBox AddCheckBox(ObjEditor oe, String label, boolean on)
981
+ JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
772982 {
773983 JCheckBox cb;
774984
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);
985
+ panel.add(cb = new JCheckBox(label, on)); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
780986 cb.addItemListener(this);
781
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
782
- oe.aConstraints.gridwidth = 1;
783
- oe.aConstraints.gridx += 1;
784987
785988 return cb;
786989 }
787990
788
- cButton AddButton(ObjEditor oe, String label)
991
+ cButton AddButton(cGridBag panel, String label)
789992 {
790993 cButton cb;
791994
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);
995
+ panel.add(cb = new cButton(label)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
797996 cb.addActionListener(this);
798
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
799
- oe.aConstraints.gridwidth = 1;
800
- oe.aConstraints.gridx += 1;
801997
802998 return cb;
803999 }
8041000
805
- JComboBox AddCombo(ObjEditor oe, java.util.Vector list, int item)
1001
+ JComboBox AddCombo(cGridBag panel, java.util.Vector list, int item)
8061002 {
8071003 JComboBox combo;
8081004
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;
1005
+ panel.add(combo = new JComboBox(new cListModel(list, item))); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8121006 combo.addActionListener(this);
8131007
8141008 return combo;
8151009 }
8161010
817
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, double min, double max, double current, double pow)
1011
+ cGridBag AddSlider(cGridBag panel, String label, double min, double max, double current, double pow)
8181012 {
8191013 cGridBag control = new cGridBag();
8201014
....@@ -826,12 +1020,12 @@
8261020 control.add(combo = new cNumberSlider(this, min, max, pow)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8271021 combo.setFloat(current);
8281022
829
- ctrlPanel.add(control);
1023
+ panel.add(control);
8301024
831
- return combo;
1025
+ return control;
8321026 }
8331027
834
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, int min, int max, int current)
1028
+ cGridBag AddSlider(cGridBag panel, String label, int min, int max, int current)
8351029 {
8361030 cGridBag control = new cGridBag();
8371031
....@@ -839,25 +1033,21 @@
8391033
8401034 JLabel jlabel = new JLabel(label);
8411035 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);
1036
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
1037
+ control.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8441038 combo.setInteger(current);
8451039
846
- ctrlPanel.add(control);
1040
+ panel.add(control);
8471041
848
- return combo;
1042
+ return control;
8491043 }
8501044
8511045 JTextArea AddText(cGridBag ctrlPanel, String name)
8521046 {
8531047 JTextArea text;
8541048
855
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
856
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
8571049 ctrlPanel.add(text = new JTextArea(name)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8581050 text.addCaretListener(this);
859
- aConstraints.gridx += 1;
860
- aConstraints.gridwidth = 1;
8611051
8621052 return text;
8631053 }
....@@ -896,7 +1086,7 @@
8961086
8971087 /*
8981088 */
899
- void Return() // ObjEditor oe)
1089
+ void Return0() // ObjEditor oe)
9001090 {
9011091 aConstraints.gridy += 1;
9021092 aConstraints.gridx = 0;
....@@ -951,37 +1141,76 @@
9511141
9521142 void SetupUI2(ObjEditor oe)
9531143 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
958
- SetupName(oe);
1144
+ //SetupName(oe);
9591145
960
- if (!GroupEditor.allparams)
1146
+ namePanel = new cGridBag();
1147
+
1148
+ nameField = AddText(namePanel, copy.GetName());
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
1150
+ oe.ctrlPanel.add(namePanel);
1151
+
1152
+ oe.ctrlPanel.Return();
1153
+
1154
+ if (!allparams)
9611155 return;
9621156
963
- liveCB = AddCheckBox(oe, "Live", copy.live);
964
- link2masterCB = AddCheckBox(oe, "Supp", copy.link2master);
965
- hideCB = AddCheckBox(oe, "Hide", copy.hide);
1157
+ setupPanel = new cGridBag().setVertical(false);
1158
+
1159
+ liveCB = AddCheckBox(setupPanel, "Live", copy.live);
1160
+ liveCB.setToolTipText("Animate object");
1161
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1162
+ selectCB.setToolTipText("Make object selectable");
9661163 // 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");
1164
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1165
+ hideCB.setToolTipText("Hide object");
1166
+ markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1167
+ markCB.setToolTipText("As animation target transform");
1168
+
1169
+ setupPanel2 = new cGridBag().setVertical(false);
1170
+
1171
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1172
+ rewindCB.setToolTipText("Rewind animation");
1173
+
1174
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1175
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
1176
+
1177
+ if (Globals.ADVANCED)
1178
+ {
1179
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1180
+ link2masterCB.setToolTipText("Attach to support");
1181
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1182
+ speedupCB.setToolTipText("Option motion capture");
1183
+ }
1184
+
1185
+ oe.ctrlPanel.add(setupPanel);
1186
+ oe.ctrlPanel.Return();
1187
+ oe.ctrlPanel.add(setupPanel2);
1188
+ oe.ctrlPanel.Return();
1189
+
1190
+ objectCommandsPanel = new cGridBag().setVertical(false);
1191
+
1192
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1193
+ resetButton.setToolTipText("Jump to frame zero");
1194
+ stepButton = AddButton(objectCommandsPanel, "Step");
1195
+ stepButton.setToolTipText("Step one frame");
9731196 // resetAllButton = AddButton(oe, "Reset All");
9741197 // stepAllButton = AddButton(oe, "Step All");
975
- speedupCB = AddCheckBox(oe, "Speed", copy.speedup);
9761198 // Return();
977
- slowerButton = AddButton(oe, "Slow");
978
- fasterButton = AddButton(oe, "Fast");
979
- remarkButton = AddButton(oe, "Rem");
1199
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1200
+ slowerButton.setToolTipText("Decrease animation speed");
1201
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1202
+ fasterButton.setToolTipText("Increase animation speed");
1203
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1204
+ remarkButton.setToolTipText("Set the current transform as the target");
9801205
981
- Return();
1206
+ oe.ctrlPanel.add(objectCommandsPanel);
1207
+ oe.ctrlPanel.Return();
9821208
983
- normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1);
984
- Return();
1209
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
1210
+ normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1211
+ //Return();
1212
+
1213
+ oe.ctrlPanel.Return();
9851214
9861215 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
9871216 // ObjEditor.aConstraints.gridx += 1;
....@@ -1076,7 +1305,7 @@
10761305 oe.aConstraints.gridwidth = 1;
10771306 /**/
10781307 nameField = AddText(oe.ctrlPanel, copy.GetName());
1079
- Return();
1308
+ oe.ctrlPanel.Return();
10801309
10811310 //ctrlPanel.add(textureButton = new Button("Texture..."));
10821311 //textureButton.setEnabled(false);
....@@ -1180,8 +1409,11 @@
11801409 //worldPanel.setName("World");
11811410 centralPanel = new cGridBag();
11821411 centralPanel.preferredWidth = 20;
1183
- timelinePanel = new JPanel(new BorderLayout());
1184
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1412
+
1413
+ if (Globals.ADVANCED)
1414
+ {
1415
+ timelinePanel = new JPanel(new BorderLayout());
1416
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11851417
11861418 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11871419 cameraPanel.setContinuousLayout(true);
....@@ -1190,7 +1422,10 @@
11901422 // cameraPanel.setDividerSize(9);
11911423 cameraPanel.setResizeWeight(1.0);
11921424
1425
+ }
1426
+
11931427 centralPanel.add(cameraView);
1428
+ centralPanel.setFocusable(true);
11941429 //frame.setJMenuBar(timelineMenubar);
11951430 //centralPanel.add(timelinePanel);
11961431
....@@ -1253,11 +1488,16 @@
12531488 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12541489 //tmp.setName("Edit");
12551490 objectPanel.add(materialPanel);
1256
- JPanel north = new JPanel(new BorderLayout());
1257
- north.setName("Edit");
1258
- north.add(ctrlPanel, BorderLayout.NORTH);
1259
- objectPanel.add(north);
1260
- objectPanel.add(infoPanel);
1491
+// JPanel north = new JPanel(new BorderLayout());
1492
+// north.setName("Edit");
1493
+// north.add(ctrlPanel, BorderLayout.NORTH);
1494
+// objectPanel.add(north);
1495
+ objectPanel.add(editPanel);
1496
+
1497
+ //if (Globals.ADVANCED)
1498
+ objectPanel.add(infoPanel);
1499
+
1500
+ objectPanel.add(toolboxPanel);
12611501
12621502 /*
12631503 aConstraints.gridx = 0;
....@@ -1266,7 +1506,7 @@
12661506 aConstraints.gridy += 1;
12671507 aConstraints.gridwidth = 1;
12681508 mainPanel.add(objectPanel, aConstraints);
1269
- */
1509
+ */
12701510
12711511 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12721512 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1278,14 +1518,12 @@
12781518 scrollpane.addMouseWheelListener(this); // Default not fast enough
12791519
12801520 /*JTabbedPane*/ scenePanel = new cGridBag();
1281
- scenePanel.preferredWidth = 7;
1521
+ scenePanel.preferredWidth = 6;
12821522
12831523 JTabbedPane tabbedPane = new JTabbedPane();
12841524 tabbedPane.add(scrollpane);
12851525
1286
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1287
-
1288
- optionsPanel = new cGridBag().setVertical(true);
1526
+ optionsPanel = new cGridBag().setVertical(false);
12891527
12901528 optionsPanel.setName("Options");
12911529
....@@ -1293,6 +1531,8 @@
12931531
12941532 tabbedPane.add(optionsPanel);
12951533
1534
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1535
+
12961536 scenePanel.add(tabbedPane);
12971537
12981538 /*
....@@ -1365,9 +1605,9 @@
13651605 // aConstraints.gridheight = 1;
13661606
13671607 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1368
- framePanel.setContinuousLayout(true);
1369
- framePanel.setOneTouchExpandable(true);
1370
- framePanel.setDividerLocation(0.8);
1608
+ framePanel.setContinuousLayout(false);
1609
+ framePanel.setOneTouchExpandable(false);
1610
+ //.setDividerLocation(0.8);
13711611 //framePanel.setDividerSize(15);
13721612 //framePanel.setResizeWeight(0.15);
13731613 framePanel.setName("Frame");
....@@ -1384,10 +1624,15 @@
13841624
13851625 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13861626
1387
- frame.setSize(1024, 768);
1388
- frame.show();
1389
-
1627
+ frame.setSize(1280, 860);
1628
+
1629
+ cameraView.requestFocusInWindow();
1630
+
13901631 gridPanel.setDividerLocation(1.0);
1632
+
1633
+ frame.validate();
1634
+
1635
+ frame.setVisible(true);
13911636
13921637 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13931638 frame.addWindowListener(new WindowAdapter()
....@@ -1415,7 +1660,7 @@
14151660 ctrlPanel.removeAll();
14161661 }
14171662
1418
- void SetupMaterial(cGridBag ctrlPanel)
1663
+ void SetupMaterial(cGridBag panel)
14191664 {
14201665 /*
14211666 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
....@@ -1424,18 +1669,26 @@
14241669
14251670 cGridBag editBar = new cGridBag().setVertical(false);
14261671
1427
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
1672
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1673
+ createMaterialButton.setToolTipText("Create material");
14281674
14291675 /*
14301676 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14311677 */
14321678
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);
1679
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1680
+ clearMaterialButton.setToolTipText("Clear material");
1681
+
1682
+ if (Globals.ADVANCED)
1683
+ {
1684
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1685
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1686
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1687
+ }
14371688
1438
- ctrlPanel.add(editBar);
1689
+ editBar.preferredHeight = 15;
1690
+
1691
+ panel.add(editBar);
14391692
14401693 /**/
14411694 //aConstraints.weighty = 0;
....@@ -1445,17 +1698,13 @@
14451698 //aConstraints.gridx += 1;
14461699 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14471700
1448
- JPanel colorPanel = new JPanel(new BorderLayout());
1449
- colorPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1450
-
14511701 cGridBag colorSection = new cGridBag().setVertical(true);
1452
-
1453
- colorPanel.add(colorSection);
14541702
14551703 cGridBag color = new cGridBag();
14561704 color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
14571705 colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14581706 color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1707
+ //colorField.preferredWidth = 200;
14591708 colorSection.add(color);
14601709
14611710 cGridBag modulation = new cGridBag();
....@@ -1470,34 +1719,13 @@
14701719 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14711720 colorSection.add(texture);
14721721
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);
1722
+ panel.add(new JSeparator());
1723
+
1724
+ panel.add(colorSection);
14921725
14931726 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14941727
1495
- JPanel diffusePanel = new JPanel(new BorderLayout());
1496
- diffusePanel.setBorder(BorderFactory.createLineBorder(Color.black));
1497
-
14981728 cGridBag diffuseSection = new cGridBag().setVertical(true);
1499
-
1500
- diffusePanel.add(diffuseSection);
15011729
15021730 cGridBag diffuse = new cGridBag();
15031731 diffuse.add(diffuseLabel = new JLabel("Diffuse")); // , aConstraints);
....@@ -1541,16 +1769,19 @@
15411769 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15421770 diffuseSection.add(fakedepth);
15431771
1544
- ctrlPanel.add(diffusePanel);
1772
+ cGridBag shadowbias = new cGridBag();
1773
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1774
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1775
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1776
+ diffuseSection.add(shadowbias);
1777
+
1778
+ panel.add(new JSeparator());
1779
+
1780
+ panel.add(diffuseSection);
15451781
15461782 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15471783
1548
- JPanel specularPanel = new JPanel(new BorderLayout());
1549
- specularPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1550
-
15511784 cGridBag specularSection = new cGridBag().setVertical(true);
1552
-
1553
- specularPanel.add(specularSection);
15541785
15551786 cGridBag specular = new cGridBag();
15561787 specular.add(specularLabel = new JLabel("Specular")); // , aConstraints);
....@@ -1582,7 +1813,7 @@
15821813 velvet.add(velvetField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15831814 specularSection.add(velvet);
15841815
1585
- shiftField = AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1);
1816
+ shiftField = (cNumberSlider)AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1).getComponent(1);
15861817 //Return();
15871818 // ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
15881819 // shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
....@@ -1594,52 +1825,58 @@
15941825 // aConstraints.gridy += 1;
15951826 // aConstraints.gridwidth = 1;
15961827
1828
+ cGridBag anisoU = new cGridBag();
1829
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1830
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1831
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1832
+ specularSection.add(anisoU);
15971833
1598
- ctrlPanel.add(specularPanel);
1834
+ cGridBag anisoV = new cGridBag();
1835
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1836
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1837
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
+ specularSection.add(anisoV);
1839
+
1840
+
1841
+ panel.add(new JSeparator());
1842
+
1843
+ panel.add(specularSection);
15991844
16001845 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16011846
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);
1847
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16081848
16091849 cGridBag camera = new cGridBag();
16101850 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16111851 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16121852 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(camera);
1853
+ colorSection.add(camera);
16141854
16151855 cGridBag ambient = new cGridBag();
16161856 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16171857 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16181858 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(ambient);
1859
+ colorSection.add(ambient);
16201860
16211861 cGridBag backlit = new cGridBag();
16221862 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16231863 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16241864 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1625
- globalSection.add(backlit);
1865
+ colorSection.add(backlit);
16261866
16271867 cGridBag opacity = new cGridBag();
16281868 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
16291869 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16301870 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1631
- globalSection.add(opacity);
1871
+ colorSection.add(opacity);
16321872
1633
- ctrlPanel.add(globalPanel);
1873
+ //panel.add(new JSeparator());
1874
+
1875
+ //panel.add(globalSection);
16341876
16351877 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16361878
1637
- JPanel texturePanel = new JPanel(new BorderLayout());
1638
- texturePanel.setBorder(BorderFactory.createLineBorder(Color.black));
1639
-
16401879 cGridBag textureSection = new cGridBag().setVertical(true);
1641
-
1642
- texturePanel.add(textureSection);
16431880
16441881 cGridBag bump = new cGridBag();
16451882 bump.add(bumpLabel = new JLabel("Bump")); // , aConstraints);
....@@ -1677,7 +1914,9 @@
16771914 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16781915 textureSection.add(opacityPower);
16791916
1680
- ctrlPanel.add(texturePanel);
1917
+ panel.add(new JSeparator());
1918
+
1919
+ panel.add(textureSection);
16811920
16821921 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16831922
....@@ -1714,12 +1953,15 @@
17141953 opacityPowerField.addChangeListener(this);
17151954 /**/
17161955
1717
- resetSlidersButton.addActionListener(this);
17181956 clearMaterialButton.addActionListener(this);
17191957 createMaterialButton.addActionListener(this);
1720
-
1721
- propagateToggle.addItemListener(this);
1722
- multiplyToggle.addItemListener(this);
1958
+
1959
+ if (Globals.ADVANCED)
1960
+ {
1961
+ resetSlidersButton.addActionListener(this);
1962
+ propagateToggle.addItemListener(this);
1963
+ multiplyToggle.addItemListener(this);
1964
+ }
17231965 }
17241966
17251967 void DropFile(java.io.File[] files, boolean textures)
....@@ -1890,7 +2132,7 @@
18902132
18912133 //? flashIt = false;
18922134 CameraPane pane = (CameraPane) cameraView;
1893
- pane.clickStart(location.x, location.y, 0);
2135
+ pane.clickStart(location.x, location.y, 0, 0);
18942136 pane.clickEnd(location.x, location.y, 0, true);
18952137
18962138 if (group.selection.size() == 1)
....@@ -1939,6 +2181,7 @@
19392181 e2.printStackTrace();
19402182 }
19412183 }
2184
+
19422185 LoadJMEThread loadThread;
19432186
19442187 class LoadJMEThread extends Thread
....@@ -1996,6 +2239,7 @@
19962239 //LoadFile0(filename, converter);
19972240 }
19982241 }
2242
+
19992243 LoadOBJThread loadObjThread;
20002244
20012245 class LoadOBJThread extends Thread
....@@ -2074,19 +2318,19 @@
20742318
20752319 void LoadObjFile(String fullname)
20762320 {
2077
- /*
2321
+ System.out.println("Loading " + fullname);
2322
+ /**/
20782323 //lastFilename = fullname;
20792324 if(loadObjThread == null)
20802325 {
2081
- loadObjThread = new LoadOBJThread();
2082
- loadObjThread.start();
2326
+ loadObjThread = new LoadOBJThread();
2327
+ loadObjThread.start();
20832328 }
20842329
20852330 loadObjThread.add(fullname);
2086
- */
2331
+ /**/
20872332
2088
- System.out.println("Loading " + fullname);
2089
- makeSomething(new FileObject(fullname, true), true);
2333
+ //makeSomething(new FileObject(fullname, true), true);
20902334 }
20912335
20922336 void LoadGFDFile(String fullname)
....@@ -2347,11 +2591,11 @@
23472591
23482592 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23492593 {
2350
- if (GrafreeD.standAlone)
2594
+ if (Grafreed.standAlone)
23512595 {
23522596 /**/
23532597 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2354
- browser.show();
2598
+ browser.setVisible(true);
23552599 String filename = browser.getFile();
23562600 if (filename != null && filename.length() > 0)
23572601 {
....@@ -2496,6 +2740,7 @@
24962740 }
24972741 if (input == null)
24982742 {
2743
+ new Exception().printStackTrace();
24992744 System.exit(0);
25002745 }
25012746
....@@ -2702,6 +2947,8 @@
27022947
27032948 void SetMaterial(Object3D object)
27042949 {
2950
+ latestObject = object;
2951
+
27052952 cMaterial mat = object.material;
27062953
27072954 if (mat == null)
....@@ -2710,7 +2957,8 @@
27102957 return;
27112958 }
27122959
2713
- multiplyToggle.setSelected(mat.multiply);
2960
+ if (multiplyToggle != null)
2961
+ multiplyToggle.setSelected(mat.multiply);
27142962
27152963 assert (object.projectedVertices != null);
27162964
....@@ -2812,12 +3060,17 @@
28123060 // }
28133061
28143062 /**/
2815
- if (deselect)
3063
+ if (deselect || child == null)
28163064 {
28173065 //group.deselectAll();
28183066 //freeze = true;
28193067 GetTree().clearSelection();
28203068 //freeze = false;
3069
+
3070
+ if (child == null)
3071
+ {
3072
+ return;
3073
+ }
28213074 }
28223075
28233076 //group.addSelectee(child);
....@@ -2886,7 +3139,7 @@
28863139 cameraView.ToggleDL();
28873140 cameraView.repaint();
28883141 return;
2889
- } else if (event.getSource() == toggleTextureItem)
3142
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28903143 {
28913144 cameraView.ToggleTexture();
28923145 // june 2013 copy.HardTouch();
....@@ -2925,9 +3178,9 @@
29253178 frame.validate();
29263179
29273180 return;
2928
- } else if (event.getSource() == toggleRandomItem)
3181
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29293182 {
2930
- cameraView.ToggleRandom();
3183
+ cameraView.ToggleSwitch();
29313184 cameraView.repaint();
29323185 return;
29333186 } else if (event.getSource() == toggleHandleItem)
....@@ -2956,6 +3209,10 @@
29563209 {
29573210 copy.live ^= true;
29583211 return;
3212
+ } else if (event.getSource() == selectCB)
3213
+ {
3214
+ copy.dontselect ^= true;
3215
+ return;
29593216 } else if (event.getSource() == hideCB)
29603217 {
29613218 copy.hide ^= true;
....@@ -2970,6 +3227,7 @@
29703227 if (event.getSource() == randomCB)
29713228 {
29723229 copy.random ^= true;
3230
+ objEditor.refreshContents();
29733231 return;
29743232 }
29753233 if (event.getSource() == speedupCB)
....@@ -2993,8 +3251,9 @@
29933251
29943252 public void actionPerformed(ActionEvent event)
29953253 {
3254
+ Object source = event.getSource();
29963255 // SCRIPT DIALOG
2997
- if (event.getSource() == okbutton)
3256
+ if (source == okbutton)
29983257 {
29993258 textpanel.setVisible(false);
30003259 textpanel.remove(textarea);
....@@ -3006,7 +3265,7 @@
30063265 textarea = null;
30073266 textpanel = null;
30083267 }
3009
- if (event.getSource() == cancelbutton)
3268
+ if (source == cancelbutton)
30103269 {
30113270 textpanel.setVisible(false);
30123271 textpanel.remove(textarea);
....@@ -3018,50 +3277,50 @@
30183277 //applySelf();
30193278 //client.refreshEditWindow();
30203279 //refreshContents();
3021
- if (event.getSource() == nameField)
3280
+ if (source == nameField)
30223281 {
30233282 //System.out.println("ObjEditor " + event);
30243283 applySelf0(true);
30253284 //parent.applySelf();
30263285 objEditor.refreshContents();
3027
- } else if (event.getSource() == resetButton)
3286
+ } else if (source == resetButton)
30283287 {
30293288 CameraPane.fullreset = true;
30303289 copy.Reset(); // ResetMeshes();
30313290 copy.Touch();
30323291 objEditor.refreshContents();
3033
- } else if (event.getSource() == stepItem)
3292
+ } else if (source == stepItem)
30343293 {
30353294 //cameraView.ONESTEP = true;
30363295 Globals.ONESTEP = true;
30373296 cameraView.repaint();
30383297 return;
3039
- } else if (event.getSource() == stepButton)
3298
+ } else if (source == stepButton)
30403299 {
30413300 copy.Step();
30423301 copy.Touch();
30433302 objEditor.refreshContents();
3044
- } else if (event.getSource() == slowerButton)
3303
+ } else if (source == slowerButton)
30453304 {
30463305 copy.Slower();
30473306 copy.Touch();
30483307 objEditor.refreshContents();
3049
- } else if (event.getSource() == fasterButton)
3308
+ } else if (source == fasterButton)
30503309 {
30513310 copy.Faster();
30523311 copy.Touch();
30533312 objEditor.refreshContents();
3054
- } else if (event.getSource() == remarkButton)
3313
+ } else if (source == remarkButton)
30553314 {
30563315 copy.Remark();
30573316 copy.Touch();
30583317 objEditor.refreshContents();
3059
- } else if (event.getSource() == stepAllButton)
3318
+ } else if (source == stepAllButton)
30603319 {
30613320 copy.StepAll();
30623321 copy.Touch();
30633322 objEditor.refreshContents();
3064
- } else if (event.getSource() == resetAllButton)
3323
+ } else if (source == resetAllButton)
30653324 {
30663325 //CameraPane.fullreset = true;
30673326 copy.ResetAll(); // ResetMeshes();
....@@ -3094,53 +3353,79 @@
30943353 // Close();
30953354 // }
30963355 // else
3097
- if (event.getSource() == resetSlidersButton)
3356
+ if (source == resetSlidersButton)
30983357 {
30993358 ResetSliders();
3100
- } else if (event.getSource() == clearMaterialButton)
3359
+ } else if (source == clearMaterialButton)
31013360 {
31023361 ClearMaterial();
3103
- } else if (event.getSource() == createMaterialButton)
3362
+ } else if (source == createMaterialButton)
31043363 {
31053364 CreateMaterial();
3106
- } else if (event.getSource() == clearPanelButton)
3365
+ } else if (source == clearPanelButton)
31073366 {
31083367 copy.ClearUI();
31093368 refreshContents(true);
3110
- } /*
3111
- }
3112
-
3113
- public boolean action(Event event, Object arg)
3114
- {
3115
- */ else if (event.getSource() == closeItem)
3369
+ } else if (source == importGFDItem)
3370
+ {
3371
+ ImportGFD();
3372
+ } else
3373
+ if (source == importVRMLX3DItem)
3374
+ {
3375
+ ImportVRMLX3D();
3376
+ } else
3377
+ if (source == import3DSItem)
3378
+ {
3379
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3380
+ } else
3381
+ if (source == importOBJItem)
3382
+ {
3383
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3384
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3385
+ browser.setVisible(true);
3386
+ String filename = browser.getFile();
3387
+ if (filename != null && filename.length() > 0)
3388
+ {
3389
+ String fullname = browser.getDirectory() + filename;
3390
+ makeSomething(ReadOBJ(fullname), true);
3391
+ }
3392
+ } else
3393
+ if (source == closeItem)
31163394 {
31173395 Close();
31183396 //return true;
3119
- } else if (event.getSource() == loadItem)
3397
+ } else if (source == openItem)
31203398 {
3121
- load();
3399
+ Open();
31223400 //return true;
3123
- } else if (event.getSource() == saveItem)
3401
+ } else if (source == newItem)
3402
+ {
3403
+ New();
3404
+ } else if (source == saveItem)
31243405 {
31253406 save();
31263407 //return true;
3127
- } else if (event.getSource() == saveAsItem)
3408
+ } else if (source == saveAsItem)
31283409 {
31293410 saveAs();
31303411 //return true;
3131
- } else if (event.getSource() == reexportItem)
3412
+ } else if (source == reexportItem)
31323413 {
31333414 reexport();
31343415 //return true;
3135
- } else if (event.getSource() == exportAsItem)
3416
+ } else if (source == exportAsItem)
31363417 {
31373418 export();
31383419 //return true;
3139
- } else if (event.getSource() == povItem)
3420
+ } else if (source == povItem)
31403421 {
31413422 generatePOV();
31423423 //return true;
3143
- } else if (event.getSource() == zBufferItem)
3424
+ } else if (event.getSource() == archiveItem)
3425
+ {
3426
+ cTools.Archive(frame);
3427
+ return;
3428
+ } else if (source == zBufferItem)
31443429 {
31453430 try
31463431 {
....@@ -3162,21 +3447,8 @@
31623447 cameraView.repaint();
31633448 //return true;
31643449 }
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)
3450
+ */ else // combos...
3451
+ if (source == texresMenu)
31803452 {
31813453 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31823454 copy.texres = texresMenu.getSelectedIndex();
....@@ -3188,12 +3460,289 @@
31883460 }
31893461 }
31903462
3463
+ void New()
3464
+ {
3465
+ while (copy.Size() > 1)
3466
+ {
3467
+ copy.remove(1);
3468
+ }
3469
+
3470
+ ResetModel();
3471
+ objEditor.refreshContents();
3472
+ }
3473
+
3474
+ static public byte[] Compress(Object3D o)
3475
+ {
3476
+ try
3477
+ {
3478
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3479
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3480
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3481
+
3482
+ Object3D parent = o.parent;
3483
+ o.parent = null;
3484
+
3485
+ out.writeObject(o);
3486
+
3487
+ o.parent = parent;
3488
+
3489
+ out.flush();
3490
+
3491
+ zstream.close();
3492
+ out.close();
3493
+
3494
+ return baos.toByteArray();
3495
+ } catch (Exception e)
3496
+ {
3497
+ System.err.println(e);
3498
+ return null;
3499
+ }
3500
+ }
3501
+
3502
+ static public Object Uncompress(byte[] bytes)
3503
+ {
3504
+ System.out.println("#bytes = " + bytes.length);
3505
+ try
3506
+ {
3507
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3508
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3509
+ ObjectInputStream in = new ObjectInputStream(istream);
3510
+ Object obj = in.readObject();
3511
+ in.close();
3512
+
3513
+ return obj;
3514
+ } catch (Exception e)
3515
+ {
3516
+ System.err.println(e);
3517
+ return null;
3518
+ }
3519
+ }
3520
+
3521
+ static public Object clone(Object o)
3522
+ {
3523
+ try
3524
+ {
3525
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3526
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3527
+
3528
+ out.writeObject(o);
3529
+
3530
+ out.flush();
3531
+ out.close();
3532
+
3533
+ byte[] bytes = baos.toByteArray();
3534
+
3535
+ System.out.println("clone = " + bytes.length);
3536
+
3537
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3538
+ ObjectInputStream in = new ObjectInputStream(bais);
3539
+ Object obj = in.readObject();
3540
+ in.close();
3541
+
3542
+ return obj;
3543
+ } catch (Exception e)
3544
+ {
3545
+ System.err.println(e);
3546
+ return null;
3547
+ }
3548
+ }
3549
+
3550
+ cRadio GetCurrentTab()
3551
+ {
3552
+ cRadio ab;
3553
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3554
+ {
3555
+ ab = (cRadio)e.nextElement();
3556
+ if(ab.GetObject() == copy)
3557
+ {
3558
+ return ab;
3559
+ }
3560
+ }
3561
+
3562
+ return null;
3563
+ }
3564
+
3565
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3566
+
3567
+ public void Save()
3568
+ {
3569
+ System.err.println("Save");
3570
+
3571
+ cRadio tab = GetCurrentTab();
3572
+
3573
+ boolean temp = CameraPane.SWITCH;
3574
+ CameraPane.SWITCH = false;
3575
+
3576
+ copy.ExtractBigData(hashtable);
3577
+
3578
+ byte[] compress = Compress(copy);
3579
+
3580
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3581
+ tab.graphs[tab.undoindex++] = compress;
3582
+
3583
+ copy.RestoreBigData(hashtable);
3584
+
3585
+ CameraPane.SWITCH = temp;
3586
+
3587
+ //assert(hashtable.isEmpty());
3588
+
3589
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3590
+ {
3591
+ tab.graphs[i] = null;
3592
+ }
3593
+
3594
+ SetUndoStates();
3595
+
3596
+ // test save
3597
+ if (false)
3598
+ {
3599
+ try
3600
+ {
3601
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3602
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3603
+
3604
+ p.writeObject(copy);
3605
+
3606
+ p.flush();
3607
+
3608
+ ostream.close();
3609
+ } catch (Exception e)
3610
+ {
3611
+ e.printStackTrace();
3612
+ }
3613
+ }
3614
+ }
3615
+
3616
+ void CopyChanged(Object3D obj)
3617
+ {
3618
+ SetUndoStates();
3619
+
3620
+ boolean temp = CameraPane.SWITCH;
3621
+ CameraPane.SWITCH = false;
3622
+
3623
+ copy.ExtractBigData(hashtable);
3624
+
3625
+ copy.clear();
3626
+
3627
+ for (int i=0; i<obj.Size(); i++)
3628
+ {
3629
+ copy.add(obj.get(i));
3630
+ }
3631
+
3632
+ copy.RestoreBigData(hashtable);
3633
+
3634
+ CameraPane.SWITCH = temp;
3635
+
3636
+ //assert(hashtable.isEmpty());
3637
+
3638
+ copy.Touch();
3639
+
3640
+ ResetModel();
3641
+ copy.HardTouch(); // recompile?
3642
+
3643
+ cRadio ab;
3644
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3645
+ {
3646
+ ab = (cRadio)e.nextElement();
3647
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3648
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3649
+ if (test != null)
3650
+ {
3651
+ test.editWindow = ab.object.editWindow;
3652
+ ab.object = test;
3653
+ }
3654
+ }
3655
+
3656
+ refreshContents();
3657
+ }
3658
+
3659
+ cButton undoButton;
3660
+ cButton redoButton;
3661
+
3662
+ void SetUndoStates()
3663
+ {
3664
+ cRadio tab = GetCurrentTab();
3665
+
3666
+ undoButton.setEnabled(tab.undoindex > 0);
3667
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3668
+ }
3669
+
3670
+ public void Undo()
3671
+ {
3672
+ System.err.println("Undo");
3673
+
3674
+ cRadio tab = GetCurrentTab();
3675
+
3676
+ if (tab.undoindex == 0)
3677
+ {
3678
+ java.awt.Toolkit.getDefaultToolkit().beep();
3679
+ return;
3680
+ }
3681
+
3682
+ if (tab.graphs[tab.undoindex] == null)
3683
+ {
3684
+ Save();
3685
+ tab.undoindex -= 1;
3686
+ }
3687
+
3688
+ tab.undoindex -= 1;
3689
+
3690
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3691
+ }
3692
+
3693
+ public void Redo()
3694
+ {
3695
+ cRadio tab = GetCurrentTab();
3696
+
3697
+ if (tab.graphs[tab.undoindex + 1] == null)
3698
+ {
3699
+ java.awt.Toolkit.getDefaultToolkit().beep();
3700
+ return;
3701
+ }
3702
+
3703
+ tab.undoindex += 1;
3704
+
3705
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3706
+ }
3707
+
3708
+ void ImportGFD()
3709
+ {
3710
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", 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
+
3717
+ //Object3D readobj =
3718
+ objEditor.ReadGFD(fullname, objEditor);
3719
+ //makeSomething(readobj);
3720
+ }
3721
+ }
3722
+
3723
+ void ImportVRMLX3D()
3724
+ {
3725
+ if (Grafreed.standAlone)
3726
+ {
3727
+ /**/
3728
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3729
+ browser.show();
3730
+ String filename = browser.getFile();
3731
+ if (filename != null && filename.length() > 0)
3732
+ {
3733
+ String fullname = browser.getDirectory() + filename;
3734
+ LoadVRMLX3D(fullname);
3735
+ }
3736
+ /**/
3737
+ }
3738
+ }
3739
+
31913740 void ToggleAnimation()
31923741 {
31933742 if (!Globals.ANIMATION)
31943743 {
31953744 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3196
- browser.show();
3745
+ browser.setVisible(true);
31973746 String filename = browser.getFile();
31983747 if (filename != null && filename.length() > 0)
31993748 {
....@@ -3203,8 +3752,8 @@
32033752
32043753 Globals.ANIMATION ^= true;
32053754
3206
- GrafreeD.wav.cursor = 0;
3207
- GrafreeD.wav.loop = 0;
3755
+ Grafreed.wav.cursor = 0;
3756
+ Grafreed.wav.loop = 0;
32083757 }
32093758 } else
32103759 {
....@@ -3254,7 +3803,7 @@
32543803 void CreateMaterial()
32553804 {
32563805 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
3806
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32583807 if (copy.selection.size() > 0)
32593808 //SetMaterial(copy);
32603809 {
....@@ -3305,7 +3854,7 @@
33053854 assert false;
33063855 }
33073856
3308
- void EditSelection()
3857
+ void EditSelection(boolean newWindow)
33093858 {
33103859 }
33113860
....@@ -3313,11 +3862,11 @@
33133862 {
33143863 copy.ResetBlockLoop(); // temporary problem
33153864
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
3865
+ boolean random = CameraPane.SWITCH;
3866
+ CameraPane.SWITCH = false; // parse everything
33183867 copy.ResetDisplayList();
33193868 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
3869
+ CameraPane.SWITCH = random;
33213870 }
33223871
33233872 // public void applySelf()
....@@ -3391,6 +3940,36 @@
33913940 {
33923941 //System.out.println("Propagate = " + propagate);
33933942 copy.UpdateMaterial(anchor, current, propagate);
3943
+
3944
+ if (copy.material != null)
3945
+ {
3946
+ cMaterial mat = copy.material;
3947
+
3948
+ colorField.SetToolTipValue((mat.color));
3949
+ modulationField.SetToolTipValue((mat.modulation));
3950
+ metalnessField.SetToolTipValue((mat.metalness));
3951
+ diffuseField.SetToolTipValue((mat.diffuse));
3952
+ specularField.SetToolTipValue((mat.specular));
3953
+ shininessField.SetToolTipValue((mat.shininess));
3954
+ shiftField.SetToolTipValue((mat.shift));
3955
+ ambientField.SetToolTipValue((mat.ambient));
3956
+ lightareaField.SetToolTipValue((mat.lightarea));
3957
+ diffusenessField.SetToolTipValue((mat.factor));
3958
+ velvetField.SetToolTipValue((mat.velvet));
3959
+ sheenField.SetToolTipValue((mat.sheen));
3960
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3961
+ backlitField.SetToolTipValue((mat.bump));
3962
+ anisoField.SetToolTipValue((mat.aniso));
3963
+ anisoVField.SetToolTipValue((mat.anisoV));
3964
+ cameraField.SetToolTipValue((mat.cameralight));
3965
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3966
+ shadowField.SetToolTipValue((mat.shadow));
3967
+ textureField.SetToolTipValue((mat.texture));
3968
+ opacityField.SetToolTipValue((mat.opacity));
3969
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3970
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3971
+ }
3972
+
33943973 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33953974 {
33963975 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3435,6 +4014,7 @@
34354014 || e.getSource() == apertureField
34364015 || e.getSource() == shadowblurField)
34374016 {
4017
+ new Exception().printStackTrace();
34384018 System.exit(0);
34394019 cameraView.options1[0] = (float) focusField.getFloat() * 10;
34404020 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3505,7 +4085,7 @@
35054085 }
35064086
35074087 if (normalpushField != null)
3508
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4088
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35094089 }
35104090
35114091 void SnapObject()
....@@ -3769,6 +4349,8 @@
37694349
37704350 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37714351 {
4352
+ if (Globals.SAVEONMAKE) // && resetmodel)
4353
+ Save();
37724354 //Tween.set(thing, 0).target(1).start(tweenManager);
37734355 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37744356 // if (thing instanceof GenericJointDemo)
....@@ -3855,6 +4437,12 @@
38554437 {
38564438 ResetModel();
38574439 Select(thing.GetTreePath(), true, false); // unselect... false);
4440
+
4441
+ if (thing.Size() == 0)
4442
+ {
4443
+ //EditSelection(false);
4444
+ }
4445
+
38584446 refreshContents();
38594447 }
38604448
....@@ -3972,6 +4560,7 @@
39724560 }
39734561 }
39744562 }
4563
+
39754564 LoadGFDThread loadGFDThread;
39764565
39774566 void ReadGFD(String fullname, iCallBack cb)
....@@ -3991,8 +4580,10 @@
39914580
39924581 try
39934582 {
4583
+ // Try compressed version first.
39944584 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3995
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4585
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4586
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39964587
39974588 readobj = (Object3D) p.readObject();
39984589 istream.close();
....@@ -4000,7 +4591,20 @@
40004591 readobj.ResetDisplayList();
40014592 } catch (Exception e)
40024593 {
4003
- e.printStackTrace();
4594
+ //e.printStackTrace();
4595
+ try
4596
+ {
4597
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4598
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4599
+
4600
+ readobj = (Object3D) p.readObject();
4601
+ istream.close();
4602
+
4603
+ readobj.ResetDisplayList();
4604
+ } catch (Exception e2)
4605
+ {
4606
+ e2.printStackTrace();
4607
+ }
40044608 }
40054609 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40064610 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4046,6 +4650,12 @@
40464650
40474651 void LoadIt(Object obj)
40484652 {
4653
+ if (obj == null)
4654
+ {
4655
+ // Invalid file
4656
+ return;
4657
+ }
4658
+
40494659 System.out.println("Loaded " + obj);
40504660 //new Exception().printStackTrace();
40514661 Object3D readobj = (Object3D) obj;
....@@ -4055,6 +4665,8 @@
40554665
40564666 if (readobj != null)
40574667 {
4668
+ if (Globals.SAVEONMAKE)
4669
+ Save();
40584670 try
40594671 {
40604672 //readobj.deepCopySelf(copy);
....@@ -4115,9 +4727,9 @@
41154727 }
41164728 }
41174729
4118
- void load() // throws ClassNotFoundException
4730
+ void Open() // throws ClassNotFoundException
41194731 {
4120
- if (GrafreeD.standAlone)
4732
+ if (Grafreed.standAlone)
41214733 {
41224734 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41234735 browser.show();
....@@ -4204,11 +4816,13 @@
42044816 try
42054817 {
42064818 FileOutputStream ostream = new FileOutputStream(lastname);
4207
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4819
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4820
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42084821
42094822 p.writeObject(copy);
42104823 p.flush();
42114824
4825
+ zstream.close();
42124826 ostream.close();
42134827
42144828 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4218,17 +4832,20 @@
42184832 {
42194833 }
42204834 }
4835
+
42214836 String lastname;
42224837
42234838 void saveAs()
42244839 {
4225
- if (GrafreeD.standAlone)
4840
+ if (Grafreed.standAlone)
42264841 {
42274842 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42284843 browser.setVisible(true);
42294844 String filename = browser.getFile();
42304845 if (filename != null && filename.length() > 0)
42314846 {
4847
+ if (!filename.endsWith(".gfd"))
4848
+ filename += ".gfd";
42324849 lastname = browser.getDirectory() + filename;
42334850 save();
42344851 }
....@@ -4327,13 +4944,13 @@
43274944 try
43284945 {
43294946 FileOutputStream ostream = new FileOutputStream(filename);
4330
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4331
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4947
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4948
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43324949
43334950 Object3D objectparent = obj.parent;
43344951 obj.parent = null;
43354952
4336
- Object3D object = (Object3D) GrafreeD.clone(obj);
4953
+ Object3D object = (Object3D) Grafreed.clone(obj);
43374954
43384955 obj.parent = objectparent;
43394956
....@@ -4345,8 +4962,8 @@
43454962 p.writeObject(object);
43464963 p.flush();
43474964
4965
+ zstream.close();
43484966 ostream.close();
4349
- // zstream.close();
43504967
43514968 // group.selection.get(0).parent = parent;
43524969 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4367,7 +4984,7 @@
43674984 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43684985 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43694986 copy.generatePOV(buffer);
4370
- if (GrafreeD.standAlone)
4987
+ if (Grafreed.standAlone)
43714988 {
43724989 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43734990 browser.show();
....@@ -4393,21 +5010,20 @@
43935010 Object3D client;
43945011 Object3D copy;
43955012 MenuBar menuBar;
4396
- Menu windowMenu;
4397
- MenuItem loadItem;
5013
+ Menu fileMenu;
5014
+ MenuItem newItem;
5015
+ MenuItem openItem;
43985016 MenuItem saveItem;
43995017 MenuItem saveAsItem;
44005018 MenuItem exportAsItem;
44015019 MenuItem reexportItem;
44025020 MenuItem povItem;
44035021 MenuItem closeItem;
4404
- Menu cameraMenu;
5022
+
44055023 CheckboxMenuItem zBufferItem;
44065024 //MenuItem normalLensItem;
4407
- MenuItem editCameraItem;
4408
- MenuItem revertCameraItem;
4409
- CheckboxMenuItem toggleLiveItem;
44105025 MenuItem stepItem;
5026
+ CheckboxMenuItem toggleLiveItem;
44115027 CheckboxMenuItem toggleFullScreenItem;
44125028 CheckboxMenuItem toggleTimelineItem;
44135029 CheckboxMenuItem toggleRenderItem;
....@@ -4416,25 +5032,39 @@
44165032 CheckboxMenuItem toggleFootContactItem;
44175033 CheckboxMenuItem toggleDLItem;
44185034 CheckboxMenuItem toggleTextureItem;
4419
- CheckboxMenuItem toggleRandomItem;
5035
+ CheckboxMenuItem toggleSwitchItem;
44205036 CheckboxMenuItem toggleRootItem;
44215037 CheckboxMenuItem animationItem;
5038
+ MenuItem archiveItem;
44225039 CheckboxMenuItem toggleHandleItem;
44235040 CheckboxMenuItem togglePaintItem;
44245041 JSplitPane mainPanel;
44255042 JScrollPane scrollpane;
5043
+
44265044 JPanel toolbarPanel;
4427
- JPanel treePanel;
5045
+
5046
+ cGridBag treePanel;
5047
+
44285048 JPanel radioPanel;
44295049 ButtonGroup buttonGroup;
4430
- cGridBag ctrlPanel;
5050
+
5051
+ cGridBag toolboxPanel;
44315052 cGridBag materialPanel;
5053
+ cGridBag ctrlPanel;
5054
+
44325055 JScrollPane infoPanel;
5056
+
44335057 cGridBag optionsPanel;
5058
+
44345059 JTabbedPane objectPanel;
5060
+ boolean materialFlushed;
5061
+ Object3D latestObject;
5062
+
44355063 cGridBag XYZPanel;
5064
+
44365065 JSplitPane gridPanel;
44375066 JSplitPane bigPanel;
5067
+
44385068 cGridBag bigThree;
44395069 cGridBag scenePanel;
44405070 cGridBag centralPanel;
....@@ -4549,8 +5179,13 @@
45495179 cNumberSlider fogField;
45505180 JLabel opacityPowerLabel;
45515181 cNumberSlider opacityPowerField;
4552
- JTree jTree;
5182
+ cTree jTree;
45535183 //ObjectUI parent;
45545184
45555185 cNumberSlider normalpushField;
5186
+
5187
+ private MenuItem importGFDItem;
5188
+ private MenuItem importVRMLX3DItem;
5189
+ private MenuItem import3DSItem;
5190
+ private MenuItem importOBJItem;
45565191 }