Normand Briere
2019-06-26 89b25e7cc97f6fe221dfd41c4d463500f8a31bc1
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.*;
....@@ -35,6 +36,67 @@
3536
3637 GroupEditor callee;
3738 JFrame frame;
39
+
40
+ static ObjEditor theFrame;
41
+
42
+ cButton GetButton(String name, boolean border)
43
+ {
44
+ try
45
+ {
46
+ ImageIcon icon = GetIcon(name);
47
+ return new cButton(icon, border);
48
+ }
49
+ catch (Exception e)
50
+ {
51
+ return new cButton(name, border);
52
+ }
53
+ }
54
+
55
+ cToggleButton GetToggleButton(String name, boolean border)
56
+ {
57
+ try
58
+ {
59
+ ImageIcon icon = GetIcon(name);
60
+ return new cToggleButton(icon, border);
61
+ }
62
+ catch (Exception e)
63
+ {
64
+ return new cToggleButton(name, border);
65
+ }
66
+ }
67
+
68
+ cCheckBox GetCheckBox(String name, boolean border)
69
+ {
70
+ try
71
+ {
72
+ ImageIcon icon = GetIcon(name);
73
+ return new cCheckBox(icon, border);
74
+ }
75
+ catch (Exception e)
76
+ {
77
+ return new cCheckBox(name, border);
78
+ }
79
+ }
80
+
81
+ private ImageIcon GetIcon(String name) throws IOException
82
+ {
83
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
+
85
+ if (image.getWidth() != 24 && image.getHeight() != 24)
86
+ {
87
+ BufferedImage resized = new BufferedImage(24, 24, image.getType());
88
+ Graphics2D g = resized.createGraphics();
89
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
90
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
+ g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
92
+ g.dispose();
93
+
94
+ image = resized;
95
+ }
96
+
97
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
+ return icon;
99
+ }
38100
39101 // SCRIPT
40102
....@@ -138,34 +200,42 @@
138200 public void closeUI()
139201 {
140202 //new Exception().printStackTrace();
141
- System.out.println("this = " + this);
142
- System.out.println("objEditor = " + objEditor);
203
+// System.out.println("this = " + this);
204
+// System.out.println("objEditor = " + objEditor);
143205 //nameField.removeActionListener(this);
144
- objEditor.ctrlPanel.remove(nameField);
206
+// objEditor.ctrlPanel.remove(nameField);
145207
146
- if (!GroupEditor.allparams)
208
+ objEditor.ctrlPanel.remove(namePanel);
209
+
210
+ if (!allparams)
147211 return;
148212
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);
213
+// objEditor.ctrlPanel.remove(liveCB);
214
+// objEditor.ctrlPanel.remove(hideCB);
215
+// objEditor.ctrlPanel.remove(markCB);
216
+//
217
+// objEditor.ctrlPanel.remove(randomCB);
218
+// objEditor.ctrlPanel.remove(speedupCB);
219
+// objEditor.ctrlPanel.remove(rewindCB);
220
+//
221
+// objEditor.ctrlPanel.remove(resetButton);
222
+// objEditor.ctrlPanel.remove(stepButton);
223
+//// objEditor.ctrlPanel.remove(stepAllButton);
224
+//// objEditor.ctrlPanel.remove(resetAllButton);
225
+// objEditor.ctrlPanel.remove(link2masterCB);
226
+// //objEditor.ctrlPanel.remove(flipVCB);
227
+// //objEditor.ctrlPanel.remove(texresMenu);
228
+// objEditor.ctrlPanel.remove(slowerButton);
229
+// objEditor.ctrlPanel.remove(fasterButton);
230
+// objEditor.ctrlPanel.remove(remarkButton);
167231
168
- Remove(normalpushField);
232
+ objEditor.ctrlPanel.remove(setupPanel);
233
+ objEditor.ctrlPanel.remove(setupPanel2);
234
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
235
+ objEditor.ctrlPanel.remove(pushPanel);
236
+ //objEditor.ctrlPanel.remove(fillPanel);
237
+
238
+ //Remove(normalpushField);
169239 }
170240
171241 public ObjEditor GetEditor()
....@@ -236,6 +306,7 @@
236306 //localCopy.parent = null;
237307
238308 frame = new JFrame();
309
+ frame.setUndecorated(true);
239310 objEditor = this;
240311 this.callee = callee;
241312
....@@ -266,27 +337,48 @@
266337 return frame.action(event, obj);
267338 }
268339
340
+ // Cannot work without static
341
+ static boolean allparams = true;
342
+
343
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
344
+
269345 void SetupMenu()
270346 {
271347 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..."));
348
+ menuBar.add(fileMenu = new Menu("File"));
349
+ fileMenu.add(newItem = new MenuItem("New"));
350
+ fileMenu.add(loadItem = new MenuItem("Open..."));
351
+
352
+ //oe.menuBar.add(menu = new Menu("Include"));
353
+ Menu menu = new Menu("Import");
354
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
355
+ importOBJItem.addActionListener(this);
356
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
357
+ import3DSItem.addActionListener(this);
358
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
359
+ importVRMLX3DItem.addActionListener(this);
360
+ menu.add("-");
361
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
362
+ importGFDItem.addActionListener(this);
363
+ fileMenu.add(menu);
364
+ fileMenu.add("-");
365
+
366
+ fileMenu.add(saveItem = new MenuItem("Save"));
367
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
277368 //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("-");
369
+ fileMenu.add("-");
370
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
371
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
372
+ fileMenu.add("-");
282373 if (client.parent != null)
283374 {
284
- windowMenu.add(closeItem = new MenuItem("Close"));
375
+ fileMenu.add(closeItem = new MenuItem("Close"));
285376 } else
286377 {
287
- windowMenu.add(closeItem = new MenuItem("Exit"));
378
+ fileMenu.add(closeItem = new MenuItem("Exit"));
288379 }
289380
381
+ newItem.addActionListener(this);
290382 loadItem.addActionListener(this);
291383 saveItem.addActionListener(this);
292384 saveAsItem.addActionListener(this);
....@@ -295,79 +387,64 @@
295387 //povItem.addActionListener(this);
296388 closeItem.addActionListener(this);
297389
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
-
353390 objectPanel = new JTabbedPane();
391
+
392
+ ChangeListener changeListener = new ChangeListener()
393
+ {
394
+ public void stateChanged(ChangeEvent changeEvent)
395
+ {
396
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
397
+// {
398
+// if (latestObject != null)
399
+// {
400
+// refreshContents(true);
401
+// SetMaterial(latestObject);
402
+// }
403
+//
404
+// materialFlushed = true;
405
+// }
406
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
407
+// {
408
+// if (listUI.size() == 0)
409
+// EditSelection(false);
410
+// }
411
+
412
+ refreshContents(false); // To refresh Info tab
413
+ }
414
+ };
415
+ objectPanel.addChangeListener(changeListener);
416
+
354417 toolbarPanel = new JPanel();
355418 toolbarPanel.setName("Toolbar");
356
- treePanel = new JPanel();
419
+ treePanel = new cGridBag();
357420 treePanel.setName("Tree");
358
- ctrlPanel = new JPanel(); // new GridBagLayout());
359
- ctrlPanel.setName("Edit");
360
- materialPanel = new JPanel();
421
+
422
+ editPanel = new cGridBag().setVertical(true);
423
+ editPanel.setName("Edit");
424
+
425
+ ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
426
+
427
+ editCommandsPanel = new cGridBag();
428
+ editPanel.add(editCommandsPanel);
429
+ editPanel.add(ctrlPanel);
430
+
431
+ toolboxPanel = new cGridBag().setVertical(false);
432
+ toolboxPanel.setName("Toolbox");
433
+
434
+ materialPanel = new cGridBag().setVertical(true);
361435 materialPanel.setName("Material");
436
+
362437 /*JTextPane*/
363438 infoarea = createTextPane();
439
+ doc = infoarea.getStyledDocument();
440
+
364441 infoarea.setEditable(true);
365442 SetText();
366443 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
367444 // infoarea.setOpaque(false);
368445 // //infoarea.setForeground(textcolor);
369
- infoarea.setLineWrap(true);
370
- infoarea.setWrapStyleWord(true);
446
+// TEXTAREA infoarea.setLineWrap(true);
447
+// TEXTAREA infoarea.setWrapStyleWord(true);
371448 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
372449 infoPanel.setPreferredSize(new Dimension(50, 200));
373450 infoPanel.setName("Info");
....@@ -378,16 +455,16 @@
378455 mainPanel.setName("Main");
379456 mainPanel.setContinuousLayout(true);
380457 mainPanel.setOneTouchExpandable(true);
381
- mainPanel.setDividerLocation(1.0);
382458 mainPanel.setDividerSize(9);
383
- mainPanel.setResizeWeight(0);
459
+ mainPanel.setDividerLocation(0.5); //1.0);
460
+ mainPanel.setResizeWeight(0.5);
384461
385462 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
386463 //mainPanel.setLayout(new GridBagLayout());
387464 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
388
- treePanel.setLayout(new GridBagLayout());
389
- ctrlPanel.setLayout(new GridBagLayout());
390
- materialPanel.setLayout(new GridBagLayout());
465
+// treePanel.setLayout(new GridBagLayout());
466
+ //ctrlPanel.setLayout(new GridBagLayout());
467
+ //materialPanel.setLayout(new GridBagLayout());
391468
392469 aConstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
393470 GridBagConstraints.NORTHEAST, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0);
....@@ -426,7 +503,7 @@
426503 static String newline = "\n";
427504 protected static final String buttonString = "JButton";
428505 StyledDocument doc;
429
- JTextArea infoarea;
506
+ JTextPane infoarea;
430507
431508 void ClearInfo()
432509 {
....@@ -449,10 +526,10 @@
449526 e.printStackTrace();
450527 }
451528
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();
529
+// String selection = infoarea.getText();
530
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
531
+// java.awt.datatransfer.Clipboard clipboard =
532
+// Toolkit.getDefaultToolkit().getSystemClipboard();
456533 //clipboard.setContents(data, data);
457534 }
458535
....@@ -475,13 +552,13 @@
475552 //SendInfo("Name:", "bold");
476553 if (sel.GetTextures() != null || debug)
477554 {
478
- si.SendInfo(sel.toString(), "bold");
555
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
479556 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
480557 if (sel.Size() > 0)
481558 {
482559 si.SendInfo("#children = " + sel.Size(), "regular");
483560 }
484
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
561
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
485562 if (debug)
486563 {
487564 try
....@@ -493,7 +570,10 @@
493570 }
494571
495572 if (full)
496
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
573
+ {
574
+ si.SendInfo(" BBox min: " + minima, "regular");
575
+ si.SendInfo(" BBox max: " + maxima, "regular");
576
+ }
497577
498578 if (sel.bRep != null)
499579 {
....@@ -520,7 +600,7 @@
520600 }
521601 if (sel.support != null)
522602 {
523
- si.SendInfo(" support: " + sel.support, "regular");
603
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
524604 }
525605 if (sel.scriptnode != null)
526606 {
....@@ -591,6 +671,9 @@
591671 {
592672 CameraPane.pointflow = (PointFlow) sel;
593673 }
674
+
675
+ si.SendInfo("_____________________", "regular");
676
+ si.SendInfo("", "regular");
594677 }
595678 }
596679
....@@ -606,68 +689,140 @@
606689 }
607690 }
608691
692
+static GraphicsDevice device = GraphicsEnvironment
693
+ .getLocalGraphicsEnvironment().getScreenDevices()[0];
694
+
695
+ Rectangle keeprect;
696
+ cRadio radio;
697
+
698
+cButton keepButton;
699
+ cButton twoButton; // Full 3D
700
+ cButton sixButton;
701
+ cButton threeButton;
702
+ cButton sevenButton;
703
+ cButton fourButton; // full panel
704
+ cButton oneButton; // full XYZ
705
+ //cButton currentLayout;
706
+
707
+ boolean maximized;
708
+
709
+ cButton fullscreenLayout;
710
+
711
+ void Minimize()
712
+ {
713
+ frame.setState(Frame.ICONIFIED);
714
+ }
715
+
716
+ void Maximize()
717
+ {
718
+ if (maximized)
719
+ {
720
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
721
+ }
722
+ else
723
+ {
724
+ keeprect = frame.getBounds();
725
+ Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
726
+ Dimension rect2 = frame.getToolkit().getScreenSize();
727
+ frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
728
+// frame.setState(Frame.MAXIMIZED_BOTH);
729
+ }
730
+
731
+ maximized ^= true;
732
+ }
733
+
609734 void ToggleFullScreen()
610735 {
611
- if (CameraPane.FULLSCREEN)
736
+ cameraView.ToggleFullScreen();
737
+
738
+ if (!CameraPane.FULLSCREEN)
612739 {
613
- frame.getContentPane().remove(/*"Center",*/bigThree);
614
- framePanel.add(bigThree);
615
- frame.getContentPane().add(/*"Center",*/framePanel);
740
+ device.setFullScreenWindow(null);
741
+ //frame.setVisible(false);
742
+// frame.removeNotify();
743
+// frame.setUndecorated(false);
744
+// frame.addNotify();
745
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
746
+
747
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
748
+// X framePanel.add(bigThree);
749
+// X frame.getContentPane().add(/*"Center",*/framePanel);
750
+ framePanel.setDividerLocation(1);
751
+
752
+ //frame.setVisible(true);
753
+ radio.layout = keepButton;
754
+ //theFrame = null;
755
+ keepButton = null;
756
+ radio.layout.doClick();
757
+
616758 } else
617759 {
618
- frame.getContentPane().remove(/*"Center",*/framePanel);
619
- framePanel.remove(bigThree);
620
- frame.getContentPane().add(/*"Center",*/bigThree);
760
+ keepButton = radio.layout;
761
+ //keeprect = frame.getBounds();
762
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
763
+// frame.getToolkit().getScreenSize().height);
764
+ //frame.setVisible(false);
765
+ device.setFullScreenWindow(frame);
766
+// frame.removeNotify();
767
+// frame.setUndecorated(true);
768
+// frame.addNotify();
769
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
770
+// X framePanel.remove(bigThree);
771
+// X frame.getContentPane().add(/*"Center",*/bigThree);
772
+ framePanel.setDividerLocation(0);
773
+
774
+ radio.layout = fullscreenLayout;
775
+ radio.layout.doClick();
776
+ //frame.setVisible(true);
621777 }
622
- cameraView.ToggleFullScreen();
623778 }
624779
625
- private JTextArea createTextPane()
780
+ private JTextPane createTextPane()
626781 {
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
- };
782
+// TEXTAREA String[] initString =
783
+// {
784
+// "This is an editable JTextPane, ", //regular
785
+// "another ", //italic
786
+// "styled ", //bold
787
+// "text ", //small
788
+// "component, ", //large
789
+// "which supports embedded components..." + newline,//regular
790
+// " " + newline, //button
791
+// "...and embedded icons..." + newline, //regular
792
+// " ", //icon
793
+// newline + "JTextPane is a subclass of JEditorPane that "
794
+// + "uses a StyledEditorKit and StyledDocument, and provides "
795
+// + "cover methods for interacting with those objects."
796
+// };
797
+//
798
+// String[] initStyles =
799
+// {
800
+// "regular", "italic", "bold", "small", "large",
801
+// "regular", "button", "regular", "icon",
802
+// "regular"
803
+// };
804
+//
805
+// JTextPane textPane = new JTextPane();
806
+// textPane.setEditable(true);
807
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
808
+// addStylesToDocument(doc);
809
+//
810
+// try
811
+// {
812
+// for (int j = 0; j < 2; j++)
813
+// {
814
+// for (int i = 0; i < initString.length; i++)
815
+// {
816
+// doc.insertString(doc.getLength(), initString[i],
817
+// doc.getStyle(initStyles[i]));
818
+// }
819
+// }
820
+// } catch (BadLocationException ble)
821
+// {
822
+// System.err.println("Couldn't insert initial text into text pane.");
823
+// }
642824
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;
825
+ return new JTextPane(); // textPane;
671826 }
672827
673828 protected void addStylesToDocument(StyledDocument doc)
....@@ -720,7 +875,7 @@
720875 protected static ImageIcon createImageIcon(String path,
721876 String description)
722877 {
723
- java.net.URL imgURL = GrafreeD.class.getResource(path);
878
+ java.net.URL imgURL = Grafreed.class.getResource(path);
724879 if (imgURL != null)
725880 {
726881 return new ImageIcon(imgURL, description);
....@@ -752,6 +907,7 @@
752907 // NumberSlider vDivsField;
753908 // JCheckBox endcaps;
754909 JCheckBox liveCB;
910
+ JCheckBox selectCB;
755911 JCheckBox hideCB;
756912 JCheckBox link2masterCB;
757913 JCheckBox markCB;
....@@ -759,7 +915,12 @@
759915 JCheckBox speedupCB;
760916 JCheckBox rewindCB;
761917 JCheckBox flipVCB;
918
+
919
+ cCheckBox toggleTextureCB;
920
+ cCheckBox toggleSwitchCB;
921
+
762922 JComboBox texresMenu;
923
+
763924 JButton resetButton;
764925 JButton stepButton;
765926 JButton stepAllButton;
....@@ -767,115 +928,87 @@
767928 JButton slowerButton;
768929 JButton fasterButton;
769930 JButton remarkButton;
931
+
932
+ cGridBag editPanel;
933
+ cGridBag editCommandsPanel;
934
+
935
+ cGridBag namePanel;
936
+ cGridBag setupPanel;
937
+ cGridBag setupPanel2;
938
+ cGridBag objectCommandsPanel;
939
+ cGridBag pushPanel;
940
+ cGridBag fillPanel;
770941
771
- JCheckBox AddCheckBox(ObjEditor oe, String label, boolean on)
942
+ JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
772943 {
773944 JCheckBox cb;
774945
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);
946
+ panel.add(cb = new JCheckBox(label, on)); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
780947 cb.addItemListener(this);
781
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
782
- oe.aConstraints.gridwidth = 1;
783
- oe.aConstraints.gridx += 1;
784948
785949 return cb;
786950 }
787951
788
- cButton AddButton(ObjEditor oe, String label)
952
+ cButton AddButton(cGridBag panel, String label)
789953 {
790954 cButton cb;
791955
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);
956
+ panel.add(cb = new cButton(label)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
797957 cb.addActionListener(this);
798
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
799
- oe.aConstraints.gridwidth = 1;
800
- oe.aConstraints.gridx += 1;
801958
802959 return cb;
803960 }
804961
805
- JComboBox AddCombo(ObjEditor oe, java.util.Vector list, int item)
962
+ JComboBox AddCombo(cGridBag panel, java.util.Vector list, int item)
806963 {
807964 JComboBox combo;
808965
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;
966
+ panel.add(combo = new JComboBox(new cListModel(list, item))); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
812967 combo.addActionListener(this);
813968
814969 return combo;
815970 }
816971
817
- NumberSlider AddSlider(JPanel ctrlPanel, String label, double min, double max, double current, double pow)
972
+ cGridBag AddSlider(cGridBag panel, String label, double min, double max, double current, double pow)
818973 {
819
- NumberSlider combo;
974
+ cGridBag control = new cGridBag();
975
+
976
+ cNumberSlider combo;
820977
821978 JLabel jlabel = new JLabel(label);
822
-
823
- aConstraints.fill = GridBagConstraints.VERTICAL;
824979 jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
825
- aConstraints.gridwidth = 1;
826
- ctrlPanel.add(jlabel, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
827
- aConstraints.gridx += 1;
828
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
829
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
830
- ctrlPanel.add(combo = new NumberSlider(min, max, pow), aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
831
- aConstraints.gridx += 1;
832
- aConstraints.gridwidth = 1;
833
-
980
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
981
+ control.add(combo = new cNumberSlider(this, min, max, pow)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
834982 combo.setFloat(current);
835
-
836
- combo.label = jlabel;
837
-
838
- combo.addChangeListener(this);
839
-
840
- return combo;
983
+
984
+ panel.add(control);
985
+
986
+ return control;
841987 }
842988
843
- NumberSlider AddSlider(JPanel ctrlPanel, String label, int min, int max, int current)
989
+ cGridBag AddSlider(cGridBag panel, String label, int min, int max, int current)
844990 {
845
- NumberSlider combo;
991
+ cGridBag control = new cGridBag();
992
+
993
+ cNumberSlider combo;
846994
847995 JLabel jlabel = new JLabel(label);
848
-
849
- aConstraints.fill = GridBagConstraints.VERTICAL;
850996 jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
851
- aConstraints.gridwidth = 2;
852
- ctrlPanel.add(jlabel, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
853
- aConstraints.gridx += 1;
854
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
855
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
856
- ctrlPanel.add(combo = new NumberSlider(min, max), aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
857
- aConstraints.gridx += 1;
858
- aConstraints.gridwidth = 1;
859
-
997
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
998
+ control.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
860999 combo.setInteger(current);
8611000
862
- combo.label = jlabel;
863
-
864
- combo.addChangeListener(this);
865
-
866
- return combo;
1001
+ panel.add(control);
1002
+
1003
+ return control;
8671004 }
8681005
869
- JTextArea AddText(JPanel ctrlPanel, String name)
1006
+ JTextArea AddText(cGridBag ctrlPanel, String name)
8701007 {
8711008 JTextArea text;
8721009
873
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
874
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
875
- ctrlPanel.add(text = new JTextArea(name), aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
1010
+ ctrlPanel.add(text = new JTextArea(name)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8761011 text.addCaretListener(this);
877
- aConstraints.gridx += 1;
878
- aConstraints.gridwidth = 1;
8791012
8801013 return text;
8811014 }
....@@ -905,9 +1038,16 @@
9051038 objEditor.ctrlPanel.remove(j);
9061039 }
9071040
1041
+ void Remove(cNumberSlider j)
1042
+ {
1043
+ j.removeChangeListener(this);
1044
+ //objEditor.ctrlPanel.remove(j.label);
1045
+ objEditor.ctrlPanel.remove(j);
1046
+ }
1047
+
9081048 /*
9091049 */
910
- void Return() // ObjEditor oe)
1050
+ void Return0() // ObjEditor oe)
9111051 {
9121052 aConstraints.gridy += 1;
9131053 aConstraints.gridx = 0;
....@@ -962,37 +1102,76 @@
9621102
9631103 void SetupUI2(ObjEditor oe)
9641104 {
965
-// oe.aConstraints.weightx = 0;
966
-// oe.aConstraints.weighty = 0;
967
-// oe.aConstraints.gridx = 0;
968
-// oe.aConstraints.gridy = 0;
969
- SetupName(oe);
1105
+ //SetupName(oe);
9701106
971
- if (!GroupEditor.allparams)
1107
+ namePanel = new cGridBag();
1108
+
1109
+ nameField = AddText(namePanel, copy.GetName());
1110
+ namePanel.add(nameField);
1111
+ oe.ctrlPanel.add(namePanel);
1112
+
1113
+ oe.ctrlPanel.Return();
1114
+
1115
+ if (!allparams)
9721116 return;
9731117
974
- liveCB = AddCheckBox(oe, "Live", copy.live);
975
- link2masterCB = AddCheckBox(oe, "Supp", copy.link2master);
976
- hideCB = AddCheckBox(oe, "Hide", copy.hide);
1118
+ setupPanel = new cGridBag().setVertical(false);
1119
+
1120
+ liveCB = AddCheckBox(setupPanel, "Live", copy.live);
1121
+ liveCB.setToolTipText("Animate object");
1122
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1123
+ selectCB.setToolTipText("Make object selectable");
9771124 // Return();
978
- markCB = AddCheckBox(oe, "Mark", copy.marked);
979
- rewindCB = AddCheckBox(oe, "Rew", copy.rewind);
980
- randomCB = AddCheckBox(oe, "Rand", copy.random);
981
- Return();
982
- resetButton = AddButton(oe, "Reset");
983
- stepButton = AddButton(oe, "Step");
1125
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1126
+ hideCB.setToolTipText("Hide object");
1127
+ markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1128
+ markCB.setToolTipText("Set the animation target transform");
1129
+
1130
+ setupPanel2 = new cGridBag().setVertical(false);
1131
+
1132
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1133
+ rewindCB.setToolTipText("Rewind animation");
1134
+
1135
+ randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1136
+ randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1137
+
1138
+ if (Globals.ADVANCED)
1139
+ {
1140
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1141
+ link2masterCB.setToolTipText("Attach to support");
1142
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1143
+ speedupCB.setToolTipText("Option motion capture");
1144
+ }
1145
+
1146
+ oe.ctrlPanel.add(setupPanel);
1147
+ oe.ctrlPanel.Return();
1148
+ oe.ctrlPanel.add(setupPanel2);
1149
+ oe.ctrlPanel.Return();
1150
+
1151
+ objectCommandsPanel = new cGridBag().setVertical(false);
1152
+
1153
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1154
+ resetButton.setToolTipText("Jump to frame zero");
1155
+ stepButton = AddButton(objectCommandsPanel, "Step");
1156
+ stepButton.setToolTipText("Step one frame");
9841157 // resetAllButton = AddButton(oe, "Reset All");
9851158 // stepAllButton = AddButton(oe, "Step All");
986
- speedupCB = AddCheckBox(oe, "Speed", copy.speedup);
9871159 // Return();
988
- slowerButton = AddButton(oe, "Slow");
989
- fasterButton = AddButton(oe, "Fast");
990
- remarkButton = AddButton(oe, "Rem");
1160
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1161
+ slowerButton.setToolTipText("Decrease animation speed");
1162
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1163
+ fasterButton.setToolTipText("Increase animation speed");
1164
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1165
+ remarkButton.setToolTipText("Set the current transform as the target");
9911166
992
- Return();
1167
+ oe.ctrlPanel.add(objectCommandsPanel);
1168
+ oe.ctrlPanel.Return();
9931169
994
- normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1);
995
- Return();
1170
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
1171
+ normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1172
+ //Return();
1173
+
1174
+ oe.ctrlPanel.Return();
9961175
9971176 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
9981177 // ObjEditor.aConstraints.gridx += 1;
....@@ -1087,7 +1266,7 @@
10871266 oe.aConstraints.gridwidth = 1;
10881267 /**/
10891268 nameField = AddText(oe.ctrlPanel, copy.GetName());
1090
- Return();
1269
+ oe.ctrlPanel.Return();
10911270
10921271 //ctrlPanel.add(textureButton = new Button("Texture..."));
10931272 //textureButton.setEnabled(false);
....@@ -1191,8 +1370,11 @@
11911370 //worldPanel.setName("World");
11921371 centralPanel = new cGridBag();
11931372 centralPanel.preferredWidth = 20;
1194
- timelinePanel = new JPanel(new BorderLayout());
1195
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1373
+
1374
+ if (Globals.ADVANCED)
1375
+ {
1376
+ timelinePanel = new JPanel(new BorderLayout());
1377
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11961378
11971379 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11981380 cameraPanel.setContinuousLayout(true);
....@@ -1201,7 +1383,10 @@
12011383 // cameraPanel.setDividerSize(9);
12021384 cameraPanel.setResizeWeight(1.0);
12031385
1386
+ }
1387
+
12041388 centralPanel.add(cameraView);
1389
+ centralPanel.setFocusable(true);
12051390 //frame.setJMenuBar(timelineMenubar);
12061391 //centralPanel.add(timelinePanel);
12071392
....@@ -1264,11 +1449,13 @@
12641449 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12651450 //tmp.setName("Edit");
12661451 objectPanel.add(materialPanel);
1267
- JPanel north = new JPanel(new BorderLayout());
1268
- north.setName("Edit");
1269
- north.add(ctrlPanel, BorderLayout.NORTH);
1270
- objectPanel.add(north);
1452
+// JPanel north = new JPanel(new BorderLayout());
1453
+// north.setName("Edit");
1454
+// north.add(ctrlPanel, BorderLayout.NORTH);
1455
+// objectPanel.add(north);
1456
+ objectPanel.add(editPanel);
12711457 objectPanel.add(infoPanel);
1458
+ objectPanel.add(toolboxPanel);
12721459
12731460 /*
12741461 aConstraints.gridx = 0;
....@@ -1277,7 +1464,7 @@
12771464 aConstraints.gridy += 1;
12781465 aConstraints.gridwidth = 1;
12791466 mainPanel.add(objectPanel, aConstraints);
1280
- */
1467
+ */
12811468
12821469 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12831470 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1289,21 +1476,21 @@
12891476 scrollpane.addMouseWheelListener(this); // Default not fast enough
12901477
12911478 /*JTabbedPane*/ scenePanel = new cGridBag();
1292
- scenePanel.preferredWidth = 7;
1479
+ scenePanel.preferredWidth = 6;
12931480
12941481 JTabbedPane tabbedPane = new JTabbedPane();
12951482 tabbedPane.add(scrollpane);
12961483
1297
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1298
-
1299
- optionsPanel = new JPanel(new GridBagLayout());
1484
+ optionsPanel = new cGridBag().setVertical(false);
13001485
13011486 optionsPanel.setName("Options");
13021487
1303
- AddOptions(optionsPanel, aConstraints);
1488
+ AddOptions(optionsPanel); //, aConstraints);
13041489
13051490 tabbedPane.add(optionsPanel);
13061491
1492
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1493
+
13071494 scenePanel.add(tabbedPane);
13081495
13091496 /*
....@@ -1395,9 +1582,13 @@
13951582
13961583 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13971584
1398
- frame.setSize(1024, 768);
1399
- frame.show();
1585
+ frame.setSize(1280, 860);
1586
+
1587
+ frame.validate();
1588
+ frame.setVisible(true);
14001589
1590
+ cameraView.requestFocusInWindow();
1591
+
14011592 gridPanel.setDividerLocation(1.0);
14021593
14031594 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -1411,7 +1602,7 @@
14111602 });
14121603 }
14131604
1414
- void AddOptions(JPanel panel, GridBagConstraints constraints)
1605
+ void AddOptions(cGridBag panel) //, GridBagConstraints constraints)
14151606 {
14161607 }
14171608
....@@ -1426,260 +1617,173 @@
14261617 ctrlPanel.removeAll();
14271618 }
14281619
1429
- void SetupMaterial(JPanel ctrlPanel)
1620
+ void SetupMaterial(cGridBag panel)
14301621 {
1431
- aConstraints.weighty = 0;
1432
- //aConstraints.weightx = 1;
1433
- /*
1622
+ /*
14341623 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14351624 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1436
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1437
- aConstraints.gridx += 1;
14381625 */
14391626
1440
- aConstraints.gridwidth = 1;
1441
- ctrlPanel.add(createMaterialButton = new cButton("Create"), aConstraints);
1442
- aConstraints.gridx += 1;
1443
- aConstraints.weighty = 0;
1444
- aConstraints.gridwidth = 1;
1627
+ cGridBag editBar = new cGridBag().setVertical(false);
1628
+
1629
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1630
+ createMaterialButton.setToolTipText("Create material");
14451631
14461632 /*
14471633 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
1448
- aConstraints.gridx += 1;
1449
- aConstraints.weighty = 0;
1450
- aConstraints.gridwidth = 1;
14511634 */
14521635
1453
- ctrlPanel.add(clearMaterialButton = new cButton("Clear"), aConstraints);
1454
- aConstraints.gridx += 1;
1636
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1637
+ clearMaterialButton.setToolTipText("Clear material");
1638
+
1639
+ if (Globals.ADVANCED)
1640
+ {
1641
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1642
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1643
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1644
+ }
14551645
1456
- ctrlPanel.add(resetSlidersButton = new cButton("Reset"), aConstraints);
1457
-
1458
- aConstraints.gridx += 1;
1459
-
1460
- ctrlPanel.add(propagateToggle = new cCheckBox("Prop", propagate), aConstraints);
1461
-
1462
- aConstraints.gridx += 1;
1463
-
1464
- ctrlPanel.add(multiplyToggle = new cCheckBox("Mult", false), aConstraints);
1465
-
1466
- aConstraints.gridx = 0;
1467
- aConstraints.gridy += 1;
1468
- aConstraints.weighty = 0;
1469
- aConstraints.gridwidth = 1;
1646
+ editBar.preferredHeight = 15;
1647
+
1648
+ panel.add(editBar);
1649
+
14701650 /**/
14711651 //aConstraints.weighty = 0;
14721652 ////aConstraints.weightx = 1;
14731653 //aConstraints.weighty = 1;
14741654 aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
14751655 //aConstraints.gridx += 1;
1476
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1477
- aConstraints.weighty = 0;
1478
- aConstraints.gridx = 0;
1479
- aConstraints.gridy += 1;
1480
- aConstraints.gridwidth = 1;
1656
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14811657
1482
- ctrlPanel.add(colorLabel = new JLabel("Color/hue"), aConstraints);
1483
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1484
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1485
- aConstraints.gridx += 1;
1486
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1487
- //aConstraints.weightx = 0;
1488
- ctrlPanel.add(colorField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1489
- aConstraints.gridx = 0;
1490
- aConstraints.gridy += 1;
1491
- aConstraints.gridwidth = 1;
1658
+ cGridBag colorSection = new cGridBag().setVertical(true);
1659
+
1660
+ cGridBag color = new cGridBag();
1661
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1662
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1663
+ color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1664
+ //colorField.preferredWidth = 200;
1665
+ colorSection.add(color);
14921666
1493
- ctrlPanel.add(modulationLabel = new JLabel("Saturation"), aConstraints);
1494
- modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1495
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1496
- aConstraints.gridx += 1;
1497
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1498
- ctrlPanel.add(modulationField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1499
- aConstraints.gridx = 0;
1500
- aConstraints.gridy += 1;
1501
- aConstraints.gridwidth = 1;
1667
+ cGridBag modulation = new cGridBag();
1668
+ modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
1669
+ modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1670
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1671
+ colorSection.add(modulation);
15021672
1503
- ctrlPanel.add(textureLabel = new JLabel("Texture"), aConstraints);
1504
- textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1505
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1506
- aConstraints.gridx += 1;
1507
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1508
- ctrlPanel.add(textureField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1509
- aConstraints.gridx = 0;
1510
- aConstraints.gridy += 1;
1511
- aConstraints.gridwidth = 1;
1673
+ cGridBag texture = new cGridBag();
1674
+ texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
1675
+ textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1676
+ texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1677
+ colorSection.add(texture);
15121678
1513
- ctrlPanel.add(anisoLabel = new JLabel("AnisoU"), aConstraints);
1514
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1515
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1516
- aConstraints.gridx += 1;
1517
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1518
- ctrlPanel.add(anisoField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1519
- aConstraints.gridx = 0;
1520
- aConstraints.gridy += 1;
1521
- aConstraints.gridwidth = 1;
1679
+ cGridBag anisoU = new cGridBag();
1680
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1681
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1682
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1683
+ colorSection.add(anisoU);
15221684
1523
- ctrlPanel.add(anisoVLabel = new JLabel("AnisoV"), aConstraints);
1524
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1525
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1526
- aConstraints.gridx += 1;
1527
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1528
- ctrlPanel.add(anisoVField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1529
- aConstraints.gridx = 0;
1530
- aConstraints.gridy += 1;
1531
- aConstraints.gridwidth = 1;
1685
+ cGridBag anisoV = new cGridBag();
1686
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1687
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1688
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1689
+ colorSection.add(anisoV);
15321690
1533
- ctrlPanel.add(shadowbiasLabel = new JLabel("Shadowbias"), aConstraints);
1534
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1535
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1536
- aConstraints.gridx += 1;
1537
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1538
- ctrlPanel.add(shadowbiasField = new NumberSlider(0.001, 50, -1), aConstraints);
1539
- aConstraints.gridx = 0;
1540
- aConstraints.gridy += 1;
1541
- aConstraints.gridwidth = 1;
1691
+ cGridBag shadowbias = new cGridBag();
1692
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1693
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1694
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1695
+ colorSection.add(shadowbias);
15421696
1543
- //aConstraints.weighty = 1;
1544
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
1545
- //aConstraints.gridx += 1;
1546
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1547
- aConstraints.weighty = 0;
1548
- aConstraints.gridx = 0;
1549
- aConstraints.gridy += 1;
1550
- aConstraints.gridwidth = 1;
1697
+ panel.add(new JSeparator());
1698
+
1699
+ panel.add(colorSection);
1700
+
1701
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
1702
+
1703
+ cGridBag diffuseSection = new cGridBag().setVertical(true);
1704
+
1705
+ cGridBag diffuse = new cGridBag();
1706
+ diffuse.add(diffuseLabel = new JLabel("Diffuse")); // , aConstraints);
1707
+ diffuseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1708
+ diffuse.add(diffuseField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1709
+ diffuseSection.add(diffuse);
15511710
1552
- ctrlPanel.add(diffuseLabel = new JLabel("Diffuse"), aConstraints);
1553
- diffuseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1554
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1555
- aConstraints.gridx += 1;
1556
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1557
- ctrlPanel.add(diffuseField = new NumberSlider(0.001, 50, -1), aConstraints);
1558
- aConstraints.gridx = 0;
1559
- aConstraints.gridy += 1;
1560
- aConstraints.gridwidth = 1;
1711
+ cGridBag diffuseness = new cGridBag();
1712
+ diffuseness.add(diffusenessLabel = new JLabel("Diffusion")); // , aConstraints);
1713
+ diffusenessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1714
+ diffuseness.add(diffusenessField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1715
+ diffuseSection.add(diffuseness);
15611716
1562
- ctrlPanel.add(diffusenessLabel = new JLabel("Diffusion"), aConstraints);
1563
- diffusenessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1564
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1565
- aConstraints.gridx += 1;
1566
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1567
- ctrlPanel.add(diffusenessField = new NumberSlider(0.001, 50, -1), aConstraints);
1568
- aConstraints.gridx = 0;
1569
- aConstraints.gridy += 1;
1570
- aConstraints.gridwidth = 1;
1717
+ cGridBag selfshadow = new cGridBag();
1718
+ selfshadow.add(selfshadowLabel = new JLabel("Selfshadow")); // , aConstraints);
1719
+ selfshadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1720
+ selfshadow.add(selfshadowField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1721
+ diffuseSection.add(selfshadow);
15711722
1572
- ctrlPanel.add(selfshadowLabel = new JLabel("Selfshadow"), aConstraints);
1573
- selfshadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1574
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1575
- aConstraints.gridx += 1;
1576
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1577
- ctrlPanel.add(selfshadowField = new NumberSlider(0.001, 50, -1), aConstraints);
1578
- aConstraints.gridx = 0;
1579
- aConstraints.gridy += 1;
1580
- aConstraints.gridwidth = 1;
1723
+ cGridBag sheen = new cGridBag();
1724
+ sheen.add(sheenLabel = new JLabel("Sheen")); // , aConstraints);
1725
+ sheenLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1726
+ sheen.add(sheenField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1727
+ diffuseSection.add(sheen);
15811728
1582
- ctrlPanel.add(sheenLabel = new JLabel("Sheen"), aConstraints);
1583
- sheenLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1584
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1585
- aConstraints.gridx += 1;
1586
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1587
- ctrlPanel.add(sheenField = new NumberSlider(0.001, 50, -1), aConstraints);
1588
- aConstraints.gridx = 0;
1589
- aConstraints.gridy += 1;
1590
- aConstraints.gridwidth = 1;
1729
+ cGridBag subsurface = new cGridBag();
1730
+ subsurface.add(subsurfaceLabel = new JLabel("Subsurface")); // , aConstraints);
1731
+ subsurfaceLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1732
+ subsurface.add(subsurfaceField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1733
+ diffuseSection.add(subsurface);
15911734
1592
- ctrlPanel.add(subsurfaceLabel = new JLabel("Subsurface"), aConstraints);
1593
- subsurfaceLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1594
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1595
- aConstraints.gridx += 1;
1596
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1597
- ctrlPanel.add(subsurfaceField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1598
- aConstraints.gridx = 0;
1599
- aConstraints.gridy += 1;
1600
- aConstraints.gridwidth = 1;
1735
+ cGridBag shadow = new cGridBag();
1736
+ shadow.add(shadowLabel = new JLabel("Shadowing")); // , aConstraints);
1737
+ shadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1738
+ shadow.add(shadowField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1739
+ diffuseSection.add(shadow);
16011740
1602
- ctrlPanel.add(shadowLabel = new JLabel("Shadowing"), aConstraints);
1603
- shadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1604
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1605
- aConstraints.gridx += 1;
1606
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1607
- ctrlPanel.add(shadowField = new NumberSlider(0.001, 50, -1), aConstraints);
1608
- aConstraints.gridx = 0;
1609
- aConstraints.gridy += 1;
1610
- aConstraints.gridwidth = 1;
1741
+ cGridBag fakedepth = new cGridBag();
1742
+ fakedepth.add(fakedepthLabel = new JLabel("Fakedepth")); // , aConstraints);
1743
+ fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1744
+ fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1745
+ diffuseSection.add(fakedepth);
16111746
1612
- ctrlPanel.add(fakedepthLabel = new JLabel("Fakedepth"), aConstraints);
1613
- fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1614
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1615
- aConstraints.gridx += 1;
1616
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1617
- ctrlPanel.add(fakedepthField = new NumberSlider(0.001, 50, -1), aConstraints);
1618
- aConstraints.gridx = 0;
1619
- aConstraints.gridy += 1;
1620
- aConstraints.gridwidth = 1;
1747
+ panel.add(new JSeparator());
1748
+
1749
+ panel.add(diffuseSection);
1750
+
1751
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
1752
+
1753
+ cGridBag specularSection = new cGridBag().setVertical(true);
16211754
1622
- //aConstraints.weighty = 1;
1623
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
1624
- //aConstraints.gridx += 1;
1625
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1626
- aConstraints.weighty = 0;
1627
- aConstraints.gridx = 0;
1628
- aConstraints.gridy += 1;
1629
- aConstraints.gridwidth = 1;
1755
+ cGridBag specular = new cGridBag();
1756
+ specular.add(specularLabel = new JLabel("Specular")); // , aConstraints);
1757
+ specularLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1758
+ specular.add(specularField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1759
+ specularSection.add(specular);
16301760
1631
- ctrlPanel.add(specularLabel = new JLabel("Specular"), aConstraints);
1632
- specularLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1633
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1634
- aConstraints.gridx += 1;
1635
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1636
- ctrlPanel.add(specularField = new NumberSlider(0.001, 50, -1), aConstraints);
1637
- aConstraints.gridx = 0;
1638
- aConstraints.gridy += 1;
1639
- aConstraints.gridwidth = 1;
1761
+ cGridBag lightarea = new cGridBag();
1762
+ lightarea.add(lightareaLabel = new JLabel("Lightarea")); // , aConstraints);
1763
+ lightareaLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1764
+ lightarea.add(lightareaField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1765
+ specularSection.add(lightarea);
16401766
1641
- ctrlPanel.add(lightareaLabel = new JLabel("Lightarea"), aConstraints);
1642
- lightareaLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1643
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1644
- aConstraints.gridx += 1;
1645
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1646
- ctrlPanel.add(lightareaField = new NumberSlider(0.001, 50, -1), aConstraints);
1647
- aConstraints.gridx = 0;
1648
- aConstraints.gridy += 1;
1649
- aConstraints.gridwidth = 1;
1767
+ cGridBag shininess = new cGridBag();
1768
+ shininess.add(shininessLabel = new JLabel("Roughness")); // , aConstraints);
1769
+ shininessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1770
+ shininess.add(shininessField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1771
+ specularSection.add(shininess);
16501772
1651
- ctrlPanel.add(shininessLabel = new JLabel("Roughness"), aConstraints);
1652
- shininessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1653
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1654
- aConstraints.gridx += 1;
1655
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1656
- ctrlPanel.add(shininessField = new NumberSlider(0.001, 50, -1), aConstraints);
1657
- aConstraints.gridx = 0;
1658
- aConstraints.gridy += 1;
1659
- aConstraints.gridwidth = 1;
1773
+ cGridBag metalness = new cGridBag();
1774
+ metalness.add(metalnessLabel = new JLabel("Metalness")); // , aConstraints);
1775
+ metalnessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1776
+ metalness.add(metalnessField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1777
+ specularSection.add(metalness);
16601778
1661
- ctrlPanel.add(metalnessLabel = new JLabel("Metalness"), aConstraints);
1662
- metalnessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1663
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1664
- aConstraints.gridx += 1;
1665
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1666
- ctrlPanel.add(metalnessField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1667
- aConstraints.gridx = 0;
1668
- aConstraints.gridy += 1;
1669
- aConstraints.gridwidth = 1;
1779
+ cGridBag velvet = new cGridBag();
1780
+ velvet.add(velvetLabel = new JLabel("Velvet")); // , aConstraints);
1781
+ velvetLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1782
+ velvet.add(velvetField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1783
+ specularSection.add(velvet);
16701784
1671
- ctrlPanel.add(velvetLabel = new JLabel("Velvet"), aConstraints);
1672
- velvetLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1673
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1674
- aConstraints.gridx += 1;
1675
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1676
- ctrlPanel.add(velvetField = new NumberSlider(0.001, 50, -1), aConstraints);
1677
- aConstraints.gridx = 0;
1678
- aConstraints.gridy += 1;
1679
- aConstraints.gridwidth = 1;
1680
-
1681
- shiftField = AddSlider(ctrlPanel, "Shift", 0.001, 50, copy.material.shift, -1);
1682
- Return();
1785
+ shiftField = (cNumberSlider)AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1).getComponent(1);
1786
+ //Return();
16831787 // ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
16841788 // shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16851789 // aConstraints.fill = GridBagConstraints.HORIZONTAL;
....@@ -1690,130 +1794,93 @@
16901794 // aConstraints.gridy += 1;
16911795 // aConstraints.gridwidth = 1;
16921796
1693
- //aConstraints.weighty = 1;
1694
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
1695
- //aConstraints.gridx += 1;
1696
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1697
- aConstraints.weighty = 0;
1698
- aConstraints.gridx = 0;
1699
- aConstraints.gridy += 1;
1700
- aConstraints.gridwidth = 1;
17011797
1702
- ctrlPanel.add(cameraLabel = new JLabel("GlobalLight"), aConstraints);
1703
- cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1704
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1705
- aConstraints.gridx += 1;
1706
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1707
- ctrlPanel.add(cameraField = new NumberSlider(0.001, 50, -1), aConstraints);
1708
- aConstraints.gridx = 0;
1709
- aConstraints.gridy += 1;
1710
- aConstraints.gridwidth = 1;
1798
+ panel.add(new JSeparator());
1799
+
1800
+ panel.add(specularSection);
1801
+
1802
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
1803
+
1804
+ cGridBag globalSection = new cGridBag().setVertical(true);
17111805
1712
- ctrlPanel.add(ambientLabel = new JLabel("Ambient"), aConstraints);
1713
- ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1714
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1715
- aConstraints.gridx += 1;
1716
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1717
- ctrlPanel.add(ambientField = new NumberSlider(0.001, 50, -1), aConstraints);
1718
- aConstraints.gridx = 0;
1719
- aConstraints.gridy += 1;
1720
- aConstraints.gridwidth = 1;
1806
+ cGridBag camera = new cGridBag();
1807
+ camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
1808
+ cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1809
+ camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1810
+ globalSection.add(camera);
17211811
1722
- ctrlPanel.add(backlitLabel = new JLabel("Backlit"), aConstraints);
1723
- backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1724
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1725
- aConstraints.gridx += 1;
1726
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1727
- ctrlPanel.add(backlitField = new NumberSlider(0.001, 50, -1), aConstraints);
1728
- aConstraints.gridx = 0;
1729
- aConstraints.gridy += 1;
1730
- aConstraints.gridwidth = 1;
1812
+ cGridBag ambient = new cGridBag();
1813
+ ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
1814
+ ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1815
+ ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1816
+ globalSection.add(ambient);
17311817
1732
- ctrlPanel.add(opacityLabel = new JLabel("Opacity"), aConstraints);
1733
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1734
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1735
- aConstraints.gridx += 1;
1736
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1737
- ctrlPanel.add(opacityField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1738
- aConstraints.gridx = 0;
1739
- aConstraints.gridy += 1;
1740
- aConstraints.gridwidth = 1;
1741
- aConstraints.weighty = 0;
1818
+ cGridBag backlit = new cGridBag();
1819
+ backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
1820
+ backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1821
+ backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1822
+ globalSection.add(backlit);
17421823
1743
- ctrlPanel.add(bumpLabel = new JLabel("Bump"), aConstraints);
1744
- bumpLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1745
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1746
- aConstraints.gridx += 1;
1747
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1748
- ctrlPanel.add(bumpField = new NumberSlider(0.0, 2), aConstraints);
1749
- aConstraints.gridx = 0;
1750
- aConstraints.gridy += 1;
1751
- aConstraints.gridwidth = 1;
1824
+ cGridBag opacity = new cGridBag();
1825
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1826
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1827
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1828
+ globalSection.add(opacity);
17521829
1753
- ctrlPanel.add(noiseLabel = new JLabel("Noise"), aConstraints);
1754
- noiseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1755
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1756
- aConstraints.gridx += 1;
1757
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1758
- ctrlPanel.add(noiseField = new NumberSlider(0.0, 1/*5*/), aConstraints);
1759
- aConstraints.gridx = 0;
1760
- aConstraints.gridy += 1;
1761
- aConstraints.gridwidth = 1;
1830
+ panel.add(new JSeparator());
1831
+
1832
+ panel.add(globalSection);
1833
+
1834
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
1835
+
1836
+ cGridBag textureSection = new cGridBag().setVertical(true);
17621837
1763
- ctrlPanel.add(powerLabel = new JLabel("Turbulance"), aConstraints);
1764
- powerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1765
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1766
- aConstraints.gridx += 1;
1767
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1768
- ctrlPanel.add(powerField = new NumberSlider(0.0, 5), aConstraints);
1769
- aConstraints.gridx = 0;
1770
- aConstraints.gridy += 1;
1771
- aConstraints.gridwidth = 1;
1838
+ cGridBag bump = new cGridBag();
1839
+ bump.add(bumpLabel = new JLabel("Bump")); // , aConstraints);
1840
+ bumpLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1841
+ bump.add(bumpField = new cNumberSlider(this, 0.0, 2)); // , aConstraints);
1842
+ textureSection.add(bump);
17721843
1773
- ctrlPanel.add(borderfadeLabel = new JLabel("Borderfade"), aConstraints);
1774
- borderfadeLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1775
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1776
- aConstraints.gridx += 1;
1777
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1778
- ctrlPanel.add(borderfadeField = new NumberSlider(0.0, 2), aConstraints);
1779
- aConstraints.gridx = 0;
1780
- aConstraints.gridy += 1;
1781
- aConstraints.gridwidth = 1;
1844
+ cGridBag noise = new cGridBag();
1845
+ noise.add(noiseLabel = new JLabel("Noise")); // , aConstraints);
1846
+ noiseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1847
+ noise.add(noiseField = new cNumberSlider(this, 0.0, 1/*5*/)); // , aConstraints);
1848
+ textureSection.add(noise);
17821849
1783
- ctrlPanel.add(fogLabel = new JLabel("Punch"), aConstraints);
1784
- fogLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1785
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1786
- aConstraints.gridx += 1;
1787
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1788
- ctrlPanel.add(fogField = new NumberSlider(0.0, 20), aConstraints);
1789
- aConstraints.gridx = 0;
1790
- aConstraints.gridy += 1;
1791
- aConstraints.gridwidth = 1;
1850
+ cGridBag power = new cGridBag();
1851
+ power.add(powerLabel = new JLabel("Turbulance")); // , aConstraints);
1852
+ powerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1853
+ power.add(powerField = new cNumberSlider(this, 0.0, 5)); // , aConstraints);
1854
+ textureSection.add(power);
17921855
1793
- ctrlPanel.add(opacityPowerLabel = new JLabel("Halo"), aConstraints);
1794
- opacityPowerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1795
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1796
- aConstraints.gridx += 1;
1797
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1798
- ctrlPanel.add(opacityPowerField = new NumberSlider(0.0, 10 /*10 dec 2013*/), aConstraints);
1799
- aConstraints.gridx = 0;
1800
- aConstraints.gridy += 1;
1801
- aConstraints.gridwidth = 1;
1856
+ cGridBag borderfade = new cGridBag();
1857
+ borderfade.add(borderfadeLabel = new JLabel("Borderfade")); // , aConstraints);
1858
+ borderfadeLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1859
+ borderfade.add(borderfadeField = new cNumberSlider(this, 0.0, 2)); // , aConstraints);
1860
+ textureSection.add(borderfade);
18021861
1803
- //aConstraints.weighty = 1;
1804
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
1805
- //aConstraints.gridx += 1;
1806
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1807
- aConstraints.weighty = 0;
1862
+ cGridBag fog = new cGridBag();
1863
+ fog.add(fogLabel = new JLabel("Punch")); // , aConstraints);
1864
+ fogLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1865
+ fog.add(fogField = new cNumberSlider(this, 0.0, 20)); // , aConstraints);
1866
+ textureSection.add(fog);
18081867
1809
- aConstraints.gridx = 0;
1810
- aConstraints.gridy = 0;
1811
- aConstraints.gridwidth = 1;
1868
+ cGridBag opacityPower = new cGridBag();
1869
+ opacityPower.add(opacityPowerLabel = new JLabel("Halo")); // , aConstraints);
1870
+ opacityPowerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1871
+ opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
1872
+ textureSection.add(opacityPower);
1873
+
1874
+ panel.add(new JSeparator());
1875
+
1876
+ panel.add(textureSection);
1877
+
1878
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18121879
18131880 SetMaterial(copy); // .GetMaterial());
18141881
1815
- colorField.addChangeListener(this);
1816
- modulationField.addChangeListener(this);
1882
+ //colorField.addChangeListener(this);
1883
+// modulationField.addChangeListener(this);
18171884 metalnessField.addChangeListener(this);
18181885 diffuseField.addChangeListener(this);
18191886 specularField.addChangeListener(this);
....@@ -1843,12 +1910,15 @@
18431910 opacityPowerField.addChangeListener(this);
18441911 /**/
18451912
1846
- resetSlidersButton.addActionListener(this);
18471913 clearMaterialButton.addActionListener(this);
18481914 createMaterialButton.addActionListener(this);
1849
-
1850
- propagateToggle.addItemListener(this);
1851
- multiplyToggle.addItemListener(this);
1915
+
1916
+ if (Globals.ADVANCED)
1917
+ {
1918
+ resetSlidersButton.addActionListener(this);
1919
+ propagateToggle.addItemListener(this);
1920
+ multiplyToggle.addItemListener(this);
1921
+ }
18521922 }
18531923
18541924 void DropFile(java.io.File[] files, boolean textures)
....@@ -2019,7 +2089,7 @@
20192089
20202090 //? flashIt = false;
20212091 CameraPane pane = (CameraPane) cameraView;
2022
- pane.clickStart(location.x, location.y, 0);
2092
+ pane.clickStart(location.x, location.y, 0, 0);
20232093 pane.clickEnd(location.x, location.y, 0, true);
20242094
20252095 if (group.selection.size() == 1)
....@@ -2068,6 +2138,7 @@
20682138 e2.printStackTrace();
20692139 }
20702140 }
2141
+
20712142 LoadJMEThread loadThread;
20722143
20732144 class LoadJMEThread extends Thread
....@@ -2125,6 +2196,7 @@
21252196 //LoadFile0(filename, converter);
21262197 }
21272198 }
2199
+
21282200 LoadOBJThread loadObjThread;
21292201
21302202 class LoadOBJThread extends Thread
....@@ -2203,19 +2275,19 @@
22032275
22042276 void LoadObjFile(String fullname)
22052277 {
2206
- /*
2278
+ System.out.println("Loading " + fullname);
2279
+ /**/
22072280 //lastFilename = fullname;
22082281 if(loadObjThread == null)
22092282 {
2210
- loadObjThread = new LoadOBJThread();
2211
- loadObjThread.start();
2283
+ loadObjThread = new LoadOBJThread();
2284
+ loadObjThread.start();
22122285 }
22132286
22142287 loadObjThread.add(fullname);
2215
- */
2288
+ /**/
22162289
2217
- System.out.println("Loading " + fullname);
2218
- makeSomething(new FileObject(fullname, true), true);
2290
+ //makeSomething(new FileObject(fullname, true), true);
22192291 }
22202292
22212293 void LoadGFDFile(String fullname)
....@@ -2476,11 +2548,11 @@
24762548
24772549 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
24782550 {
2479
- if (GrafreeD.standAlone)
2551
+ if (Grafreed.standAlone)
24802552 {
24812553 /**/
24822554 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2483
- browser.show();
2555
+ browser.setVisible(true);
24842556 String filename = browser.getFile();
24852557 if (filename != null && filename.length() > 0)
24862558 {
....@@ -2625,6 +2697,7 @@
26252697 }
26262698 if (input == null)
26272699 {
2700
+ new Exception().printStackTrace();
26282701 System.exit(0);
26292702 }
26302703
....@@ -2831,6 +2904,8 @@
28312904
28322905 void SetMaterial(Object3D object)
28332906 {
2907
+ latestObject = object;
2908
+
28342909 cMaterial mat = object.material;
28352910
28362911 if (mat == null)
....@@ -2839,7 +2914,8 @@
28392914 return;
28402915 }
28412916
2842
- multiplyToggle.setSelected(mat.multiply);
2917
+ if (multiplyToggle != null)
2918
+ multiplyToggle.setSelected(mat.multiply);
28432919
28442920 assert (object.projectedVertices != null);
28452921
....@@ -3015,7 +3091,7 @@
30153091 cameraView.ToggleDL();
30163092 cameraView.repaint();
30173093 return;
3018
- } else if (event.getSource() == toggleTextureItem)
3094
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
30193095 {
30203096 cameraView.ToggleTexture();
30213097 // june 2013 copy.HardTouch();
....@@ -3054,9 +3130,9 @@
30543130 frame.validate();
30553131
30563132 return;
3057
- } else if (event.getSource() == toggleRandomItem)
3133
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30583134 {
3059
- cameraView.ToggleRandom();
3135
+ cameraView.ToggleSwitch();
30603136 cameraView.repaint();
30613137 return;
30623138 } else if (event.getSource() == toggleHandleItem)
....@@ -3085,6 +3161,10 @@
30853161 {
30863162 copy.live ^= true;
30873163 return;
3164
+ } else if (event.getSource() == selectCB)
3165
+ {
3166
+ copy.dontselect ^= true;
3167
+ return;
30883168 } else if (event.getSource() == hideCB)
30893169 {
30903170 copy.hide ^= true;
....@@ -3099,6 +3179,7 @@
30993179 if (event.getSource() == randomCB)
31003180 {
31013181 copy.random ^= true;
3182
+ objEditor.refreshContents();
31023183 return;
31033184 }
31043185 if (event.getSource() == speedupCB)
....@@ -3122,8 +3203,9 @@
31223203
31233204 public void actionPerformed(ActionEvent event)
31243205 {
3206
+ Object source = event.getSource();
31253207 // SCRIPT DIALOG
3126
- if (event.getSource() == okbutton)
3208
+ if (source == okbutton)
31273209 {
31283210 textpanel.setVisible(false);
31293211 textpanel.remove(textarea);
....@@ -3135,7 +3217,7 @@
31353217 textarea = null;
31363218 textpanel = null;
31373219 }
3138
- if (event.getSource() == cancelbutton)
3220
+ if (source == cancelbutton)
31393221 {
31403222 textpanel.setVisible(false);
31413223 textpanel.remove(textarea);
....@@ -3147,50 +3229,50 @@
31473229 //applySelf();
31483230 //client.refreshEditWindow();
31493231 //refreshContents();
3150
- if (event.getSource() == nameField)
3232
+ if (source == nameField)
31513233 {
31523234 //System.out.println("ObjEditor " + event);
31533235 applySelf0(true);
31543236 //parent.applySelf();
31553237 objEditor.refreshContents();
3156
- } else if (event.getSource() == resetButton)
3238
+ } else if (source == resetButton)
31573239 {
31583240 CameraPane.fullreset = true;
31593241 copy.Reset(); // ResetMeshes();
31603242 copy.Touch();
31613243 objEditor.refreshContents();
3162
- } else if (event.getSource() == stepItem)
3244
+ } else if (source == stepItem)
31633245 {
31643246 //cameraView.ONESTEP = true;
31653247 Globals.ONESTEP = true;
31663248 cameraView.repaint();
31673249 return;
3168
- } else if (event.getSource() == stepButton)
3250
+ } else if (source == stepButton)
31693251 {
31703252 copy.Step();
31713253 copy.Touch();
31723254 objEditor.refreshContents();
3173
- } else if (event.getSource() == slowerButton)
3255
+ } else if (source == slowerButton)
31743256 {
31753257 copy.Slower();
31763258 copy.Touch();
31773259 objEditor.refreshContents();
3178
- } else if (event.getSource() == fasterButton)
3260
+ } else if (source == fasterButton)
31793261 {
31803262 copy.Faster();
31813263 copy.Touch();
31823264 objEditor.refreshContents();
3183
- } else if (event.getSource() == remarkButton)
3265
+ } else if (source == remarkButton)
31843266 {
31853267 copy.Remark();
31863268 copy.Touch();
31873269 objEditor.refreshContents();
3188
- } else if (event.getSource() == stepAllButton)
3270
+ } else if (source == stepAllButton)
31893271 {
31903272 copy.StepAll();
31913273 copy.Touch();
31923274 objEditor.refreshContents();
3193
- } else if (event.getSource() == resetAllButton)
3275
+ } else if (source == resetAllButton)
31943276 {
31953277 //CameraPane.fullreset = true;
31963278 copy.ResetAll(); // ResetMeshes();
....@@ -3223,53 +3305,75 @@
32233305 // Close();
32243306 // }
32253307 // else
3226
- if (event.getSource() == resetSlidersButton)
3308
+ if (source == resetSlidersButton)
32273309 {
32283310 ResetSliders();
3229
- } else if (event.getSource() == clearMaterialButton)
3311
+ } else if (source == clearMaterialButton)
32303312 {
32313313 ClearMaterial();
3232
- } else if (event.getSource() == createMaterialButton)
3314
+ } else if (source == createMaterialButton)
32333315 {
32343316 CreateMaterial();
3235
- } else if (event.getSource() == clearPanelButton)
3317
+ } else if (source == clearPanelButton)
32363318 {
32373319 copy.ClearUI();
32383320 refreshContents(true);
3239
- } /*
3240
- }
3241
-
3242
- public boolean action(Event event, Object arg)
3243
- {
3244
- */ else if (event.getSource() == closeItem)
3321
+ } else if (source == importGFDItem)
3322
+ {
3323
+ ImportGFD();
3324
+ } else
3325
+ if (source == importVRMLX3DItem)
3326
+ {
3327
+ ImportVRMLX3D();
3328
+ } else
3329
+ if (source == import3DSItem)
3330
+ {
3331
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3332
+ } else
3333
+ if (source == importOBJItem)
3334
+ {
3335
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3336
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3337
+ browser.setVisible(true);
3338
+ String filename = browser.getFile();
3339
+ if (filename != null && filename.length() > 0)
3340
+ {
3341
+ String fullname = browser.getDirectory() + filename;
3342
+ makeSomething(ReadOBJ(fullname), true);
3343
+ }
3344
+ } else
3345
+ if (source == closeItem)
32453346 {
32463347 Close();
32473348 //return true;
3248
- } else if (event.getSource() == loadItem)
3349
+ } else if (source == loadItem)
32493350 {
32503351 load();
32513352 //return true;
3252
- } else if (event.getSource() == saveItem)
3353
+ } else if (source == newItem)
3354
+ {
3355
+ New();
3356
+ } else if (source == saveItem)
32533357 {
32543358 save();
32553359 //return true;
3256
- } else if (event.getSource() == saveAsItem)
3360
+ } else if (source == saveAsItem)
32573361 {
32583362 saveAs();
32593363 //return true;
3260
- } else if (event.getSource() == reexportItem)
3364
+ } else if (source == reexportItem)
32613365 {
32623366 reexport();
32633367 //return true;
3264
- } else if (event.getSource() == exportAsItem)
3368
+ } else if (source == exportAsItem)
32653369 {
32663370 export();
32673371 //return true;
3268
- } else if (event.getSource() == povItem)
3372
+ } else if (source == povItem)
32693373 {
32703374 generatePOV();
32713375 //return true;
3272
- } else if (event.getSource() == zBufferItem)
3376
+ } else if (source == zBufferItem)
32733377 {
32743378 try
32753379 {
....@@ -3291,21 +3395,8 @@
32913395 cameraView.repaint();
32923396 //return true;
32933397 }
3294
- */ else if (event.getSource() == editCameraItem)
3295
- {
3296
- cameraView.ProtectCamera();
3297
- cameraView.repaint();
3298
- return;
3299
- } else if (event.getSource() == revertCameraItem)
3300
- {
3301
- cameraView.RevertCamera();
3302
- cameraView.repaint();
3303
- return;
3304
-// } else if (event.getSource() == textureButton)
3305
-// {
3306
-// return; // true;
3307
- } else // combos...
3308
- if (event.getSource() == texresMenu)
3398
+ */ else // combos...
3399
+ if (source == texresMenu)
33093400 {
33103401 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
33113402 copy.texres = texresMenu.getSelectedIndex();
....@@ -3317,12 +3408,287 @@
33173408 }
33183409 }
33193410
3411
+ void New()
3412
+ {
3413
+ while (copy.Size() > 1)
3414
+ {
3415
+ copy.remove(1);
3416
+ }
3417
+
3418
+ ResetModel();
3419
+ objEditor.refreshContents();
3420
+ }
3421
+
3422
+ static public byte[] Compress(Object3D o)
3423
+ {
3424
+ try
3425
+ {
3426
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3427
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3428
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3429
+
3430
+ Object3D parent = o.parent;
3431
+ o.parent = null;
3432
+
3433
+ out.writeObject(o);
3434
+
3435
+ o.parent = parent;
3436
+
3437
+ out.flush();
3438
+
3439
+ zstream.close();
3440
+ out.close();
3441
+
3442
+ return baos.toByteArray();
3443
+ } catch (Exception e)
3444
+ {
3445
+ System.err.println(e);
3446
+ return null;
3447
+ }
3448
+ }
3449
+
3450
+ static public Object Uncompress(byte[] bytes)
3451
+ {
3452
+ System.out.println("#bytes = " + bytes.length);
3453
+ try
3454
+ {
3455
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3456
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3457
+ ObjectInputStream in = new ObjectInputStream(istream);
3458
+ Object obj = in.readObject();
3459
+ in.close();
3460
+
3461
+ return obj;
3462
+ } catch (Exception e)
3463
+ {
3464
+ System.err.println(e);
3465
+ return null;
3466
+ }
3467
+ }
3468
+
3469
+ static public Object clone(Object o)
3470
+ {
3471
+ try
3472
+ {
3473
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3474
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3475
+
3476
+ out.writeObject(o);
3477
+
3478
+ out.flush();
3479
+ out.close();
3480
+
3481
+ byte[] bytes = baos.toByteArray();
3482
+
3483
+ System.out.println("clone = " + bytes.length);
3484
+
3485
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3486
+ ObjectInputStream in = new ObjectInputStream(bais);
3487
+ Object obj = in.readObject();
3488
+ in.close();
3489
+
3490
+ return obj;
3491
+ } catch (Exception e)
3492
+ {
3493
+ System.err.println(e);
3494
+ return null;
3495
+ }
3496
+ }
3497
+
3498
+ cRadio GetCurrentTab()
3499
+ {
3500
+ cRadio ab;
3501
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3502
+ {
3503
+ ab = (cRadio)e.nextElement();
3504
+ if(ab.GetObject() == copy)
3505
+ {
3506
+ return ab;
3507
+ }
3508
+ }
3509
+
3510
+ return null;
3511
+ }
3512
+
3513
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3514
+
3515
+ public void Save()
3516
+ {
3517
+ System.err.println("Save");
3518
+
3519
+ cRadio tab = GetCurrentTab();
3520
+
3521
+ boolean temp = CameraPane.SWITCH;
3522
+ CameraPane.SWITCH = false;
3523
+
3524
+ copy.ExtractBigData(hashtable);
3525
+
3526
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3527
+ tab.graphs[tab.undoindex++] = Compress(copy);
3528
+
3529
+ copy.RestoreBigData(hashtable);
3530
+
3531
+ CameraPane.SWITCH = temp;
3532
+
3533
+ //assert(hashtable.isEmpty());
3534
+
3535
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3536
+ {
3537
+ tab.graphs[i] = null;
3538
+ }
3539
+
3540
+ SetUndoStates();
3541
+
3542
+ // test save
3543
+ if (false)
3544
+ {
3545
+ try
3546
+ {
3547
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3548
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3549
+
3550
+ p.writeObject(copy);
3551
+
3552
+ p.flush();
3553
+
3554
+ ostream.close();
3555
+ } catch (Exception e)
3556
+ {
3557
+ e.printStackTrace();
3558
+ }
3559
+ }
3560
+ }
3561
+
3562
+ void CopyChanged(Object3D obj)
3563
+ {
3564
+ SetUndoStates();
3565
+
3566
+ boolean temp = CameraPane.SWITCH;
3567
+ CameraPane.SWITCH = false;
3568
+
3569
+ copy.ExtractBigData(hashtable);
3570
+
3571
+ copy.clear();
3572
+
3573
+ for (int i=0; i<obj.Size(); i++)
3574
+ {
3575
+ copy.add(obj.get(i));
3576
+ }
3577
+
3578
+ copy.RestoreBigData(hashtable);
3579
+
3580
+ CameraPane.SWITCH = temp;
3581
+
3582
+ //assert(hashtable.isEmpty());
3583
+
3584
+ copy.Touch();
3585
+
3586
+ ResetModel();
3587
+ copy.HardTouch(); // recompile?
3588
+
3589
+ cRadio ab;
3590
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3591
+ {
3592
+ ab = (cRadio)e.nextElement();
3593
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3594
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3595
+ if (test != null)
3596
+ {
3597
+ test.editWindow = ab.object.editWindow;
3598
+ ab.object = test;
3599
+ }
3600
+ }
3601
+
3602
+ refreshContents();
3603
+ }
3604
+
3605
+ cButton undoButton;
3606
+ cButton redoButton;
3607
+
3608
+ void SetUndoStates()
3609
+ {
3610
+ cRadio tab = GetCurrentTab();
3611
+
3612
+ undoButton.setEnabled(tab.undoindex > 0);
3613
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3614
+ }
3615
+
3616
+ public void Undo()
3617
+ {
3618
+ System.err.println("Undo");
3619
+
3620
+ cRadio tab = GetCurrentTab();
3621
+
3622
+ if (tab.undoindex == 0)
3623
+ {
3624
+ java.awt.Toolkit.getDefaultToolkit().beep();
3625
+ return;
3626
+ }
3627
+
3628
+ if (tab.graphs[tab.undoindex] == null)
3629
+ {
3630
+ Save();
3631
+ tab.undoindex -= 1;
3632
+ }
3633
+
3634
+ tab.undoindex -= 1;
3635
+
3636
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3637
+ }
3638
+
3639
+ public void Redo()
3640
+ {
3641
+ cRadio tab = GetCurrentTab();
3642
+
3643
+ if (tab.graphs[tab.undoindex + 1] == null)
3644
+ {
3645
+ java.awt.Toolkit.getDefaultToolkit().beep();
3646
+ return;
3647
+ }
3648
+
3649
+ tab.undoindex += 1;
3650
+
3651
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3652
+ }
3653
+
3654
+ void ImportGFD()
3655
+ {
3656
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3657
+ browser.show();
3658
+ String filename = browser.getFile();
3659
+ if (filename != null && filename.length() > 0)
3660
+ {
3661
+ String fullname = browser.getDirectory() + filename;
3662
+
3663
+ //Object3D readobj =
3664
+ objEditor.ReadGFD(fullname, objEditor);
3665
+ //makeSomething(readobj);
3666
+ }
3667
+ }
3668
+
3669
+ void ImportVRMLX3D()
3670
+ {
3671
+ if (Grafreed.standAlone)
3672
+ {
3673
+ /**/
3674
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3675
+ browser.show();
3676
+ String filename = browser.getFile();
3677
+ if (filename != null && filename.length() > 0)
3678
+ {
3679
+ String fullname = browser.getDirectory() + filename;
3680
+ LoadVRMLX3D(fullname);
3681
+ }
3682
+ /**/
3683
+ }
3684
+ }
3685
+
33203686 void ToggleAnimation()
33213687 {
33223688 if (!Globals.ANIMATION)
33233689 {
33243690 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3325
- browser.show();
3691
+ browser.setVisible(true);
33263692 String filename = browser.getFile();
33273693 if (filename != null && filename.length() > 0)
33283694 {
....@@ -3332,8 +3698,8 @@
33323698
33333699 Globals.ANIMATION ^= true;
33343700
3335
- GrafreeD.wav.cursor = 0;
3336
- GrafreeD.wav.loop = 0;
3701
+ Grafreed.wav.cursor = 0;
3702
+ Grafreed.wav.loop = 0;
33373703 }
33383704 } else
33393705 {
....@@ -3383,7 +3749,7 @@
33833749 void CreateMaterial()
33843750 {
33853751 //copy.ClearMaterial(); // PATCH
3386
- copy.CreateMaterialS(multiplyToggle.isSelected());
3752
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
33873753 if (copy.selection.size() > 0)
33883754 //SetMaterial(copy);
33893755 {
....@@ -3434,7 +3800,7 @@
34343800 assert false;
34353801 }
34363802
3437
- void EditSelection()
3803
+ void EditSelection(boolean newWindow)
34383804 {
34393805 }
34403806
....@@ -3442,11 +3808,11 @@
34423808 {
34433809 copy.ResetBlockLoop(); // temporary problem
34443810
3445
- boolean random = CameraPane.RANDOM;
3446
- CameraPane.RANDOM = false; // parse everything
3811
+ boolean random = CameraPane.SWITCH;
3812
+ CameraPane.SWITCH = false; // parse everything
34473813 copy.ResetDisplayList();
34483814 copy.HardTouch();
3449
- CameraPane.RANDOM = random;
3815
+ CameraPane.SWITCH = random;
34503816 }
34513817
34523818 // public void applySelf()
....@@ -3516,10 +3882,40 @@
35163882 current.fakedepth = (float) fakedepthField.getFloat();
35173883 current.shadowbias = (float) shadowbiasField.getFloat();
35183884
3519
- if (!NumberSlider.frozen)
3885
+ if (!cNumberSlider.frozen)
35203886 {
35213887 //System.out.println("Propagate = " + propagate);
35223888 copy.UpdateMaterial(anchor, current, propagate);
3889
+
3890
+ if (copy.material != null)
3891
+ {
3892
+ cMaterial mat = copy.material;
3893
+
3894
+ colorField.SetToolTipValue((mat.color));
3895
+ modulationField.SetToolTipValue((mat.modulation));
3896
+ metalnessField.SetToolTipValue((mat.metalness));
3897
+ diffuseField.SetToolTipValue((mat.diffuse));
3898
+ specularField.SetToolTipValue((mat.specular));
3899
+ shininessField.SetToolTipValue((mat.shininess));
3900
+ shiftField.SetToolTipValue((mat.shift));
3901
+ ambientField.SetToolTipValue((mat.ambient));
3902
+ lightareaField.SetToolTipValue((mat.lightarea));
3903
+ diffusenessField.SetToolTipValue((mat.factor));
3904
+ velvetField.SetToolTipValue((mat.velvet));
3905
+ sheenField.SetToolTipValue((mat.sheen));
3906
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3907
+ backlitField.SetToolTipValue((mat.bump));
3908
+ anisoField.SetToolTipValue((mat.aniso));
3909
+ anisoVField.SetToolTipValue((mat.anisoV));
3910
+ cameraField.SetToolTipValue((mat.cameralight));
3911
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3912
+ shadowField.SetToolTipValue((mat.shadow));
3913
+ textureField.SetToolTipValue((mat.texture));
3914
+ opacityField.SetToolTipValue((mat.opacity));
3915
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3916
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3917
+ }
3918
+
35233919 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
35243920 {
35253921 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3564,6 +3960,7 @@
35643960 || e.getSource() == apertureField
35653961 || e.getSource() == shadowblurField)
35663962 {
3963
+ new Exception().printStackTrace();
35673964 System.exit(0);
35683965 cameraView.options1[0] = (float) focusField.getFloat() * 10;
35693966 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3634,7 +4031,7 @@
36344031 }
36354032
36364033 if (normalpushField != null)
3637
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4034
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
36384035 }
36394036
36404037 void SnapObject()
....@@ -3889,7 +4286,7 @@
38894286
38904287 radioPanel.revalidate();
38914288 radioPanel.repaint();
3892
- ctrlPanel.revalidate(); // ? new
4289
+ ctrlPanel.validate(); // ? new
38934290 ctrlPanel.repaint();
38944291 }
38954292 }
....@@ -3898,6 +4295,8 @@
38984295
38994296 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
39004297 {
4298
+ if (Globals.SAVEONMAKE) // && resetmodel)
4299
+ Save();
39014300 //Tween.set(thing, 0).target(1).start(tweenManager);
39024301 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
39034302 // if (thing instanceof GenericJointDemo)
....@@ -3984,6 +4383,12 @@
39844383 {
39854384 ResetModel();
39864385 Select(thing.GetTreePath(), true, false); // unselect... false);
4386
+
4387
+ if (thing.Size() == 0)
4388
+ {
4389
+ //EditSelection(false);
4390
+ }
4391
+
39874392 refreshContents();
39884393 }
39894394
....@@ -4101,6 +4506,7 @@
41014506 }
41024507 }
41034508 }
4509
+
41044510 LoadGFDThread loadGFDThread;
41054511
41064512 void ReadGFD(String fullname, iCallBack cb)
....@@ -4120,8 +4526,10 @@
41204526
41214527 try
41224528 {
4529
+ // Try compressed version first.
41234530 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4124
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4531
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4532
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
41254533
41264534 readobj = (Object3D) p.readObject();
41274535 istream.close();
....@@ -4129,7 +4537,20 @@
41294537 readobj.ResetDisplayList();
41304538 } catch (Exception e)
41314539 {
4132
- e.printStackTrace();
4540
+ //e.printStackTrace();
4541
+ try
4542
+ {
4543
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4544
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4545
+
4546
+ readobj = (Object3D) p.readObject();
4547
+ istream.close();
4548
+
4549
+ readobj.ResetDisplayList();
4550
+ } catch (Exception e2)
4551
+ {
4552
+ e2.printStackTrace();
4553
+ }
41334554 }
41344555 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
41354556 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4175,6 +4596,12 @@
41754596
41764597 void LoadIt(Object obj)
41774598 {
4599
+ if (obj == null)
4600
+ {
4601
+ // Invalid file
4602
+ return;
4603
+ }
4604
+
41784605 System.out.println("Loaded " + obj);
41794606 //new Exception().printStackTrace();
41804607 Object3D readobj = (Object3D) obj;
....@@ -4184,6 +4611,8 @@
41844611
41854612 if (readobj != null)
41864613 {
4614
+ if (Globals.SAVEONMAKE)
4615
+ Save();
41874616 try
41884617 {
41894618 //readobj.deepCopySelf(copy);
....@@ -4246,7 +4675,7 @@
42464675
42474676 void load() // throws ClassNotFoundException
42484677 {
4249
- if (GrafreeD.standAlone)
4678
+ if (Grafreed.standAlone)
42504679 {
42514680 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
42524681 browser.show();
....@@ -4333,11 +4762,13 @@
43334762 try
43344763 {
43354764 FileOutputStream ostream = new FileOutputStream(lastname);
4336
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4765
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4766
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43374767
43384768 p.writeObject(copy);
43394769 p.flush();
43404770
4771
+ zstream.close();
43414772 ostream.close();
43424773
43434774 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4347,17 +4778,20 @@
43474778 {
43484779 }
43494780 }
4781
+
43504782 String lastname;
43514783
43524784 void saveAs()
43534785 {
4354
- if (GrafreeD.standAlone)
4786
+ if (Grafreed.standAlone)
43554787 {
43564788 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
43574789 browser.setVisible(true);
43584790 String filename = browser.getFile();
43594791 if (filename != null && filename.length() > 0)
43604792 {
4793
+ if (!filename.endsWith(".gfd"))
4794
+ filename += ".gfd";
43614795 lastname = browser.getDirectory() + filename;
43624796 save();
43634797 }
....@@ -4456,13 +4890,13 @@
44564890 try
44574891 {
44584892 FileOutputStream ostream = new FileOutputStream(filename);
4459
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4460
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4893
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4894
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
44614895
44624896 Object3D objectparent = obj.parent;
44634897 obj.parent = null;
44644898
4465
- Object3D object = (Object3D) GrafreeD.clone(obj);
4899
+ Object3D object = (Object3D) Grafreed.clone(obj);
44664900
44674901 obj.parent = objectparent;
44684902
....@@ -4474,8 +4908,8 @@
44744908 p.writeObject(object);
44754909 p.flush();
44764910
4911
+ zstream.close();
44774912 ostream.close();
4478
- // zstream.close();
44794913
44804914 // group.selection.get(0).parent = parent;
44814915 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4496,7 +4930,7 @@
44964930 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
44974931 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
44984932 copy.generatePOV(buffer);
4499
- if (GrafreeD.standAlone)
4933
+ if (Grafreed.standAlone)
45004934 {
45014935 FileDialog browser = new FileDialog(frame, "Export POV", 1);
45024936 browser.show();
....@@ -4522,7 +4956,8 @@
45224956 Object3D client;
45234957 Object3D copy;
45244958 MenuBar menuBar;
4525
- Menu windowMenu;
4959
+ Menu fileMenu;
4960
+ MenuItem newItem;
45264961 MenuItem loadItem;
45274962 MenuItem saveItem;
45284963 MenuItem saveAsItem;
....@@ -4530,13 +4965,11 @@
45304965 MenuItem reexportItem;
45314966 MenuItem povItem;
45324967 MenuItem closeItem;
4533
- Menu cameraMenu;
4968
+
45344969 CheckboxMenuItem zBufferItem;
45354970 //MenuItem normalLensItem;
4536
- MenuItem editCameraItem;
4537
- MenuItem revertCameraItem;
4538
- CheckboxMenuItem toggleLiveItem;
45394971 MenuItem stepItem;
4972
+ CheckboxMenuItem toggleLiveItem;
45404973 CheckboxMenuItem toggleFullScreenItem;
45414974 CheckboxMenuItem toggleTimelineItem;
45424975 CheckboxMenuItem toggleRenderItem;
....@@ -4545,25 +4978,38 @@
45454978 CheckboxMenuItem toggleFootContactItem;
45464979 CheckboxMenuItem toggleDLItem;
45474980 CheckboxMenuItem toggleTextureItem;
4548
- CheckboxMenuItem toggleRandomItem;
4981
+ CheckboxMenuItem toggleSwitchItem;
45494982 CheckboxMenuItem toggleRootItem;
45504983 CheckboxMenuItem animationItem;
45514984 CheckboxMenuItem toggleHandleItem;
45524985 CheckboxMenuItem togglePaintItem;
45534986 JSplitPane mainPanel;
45544987 JScrollPane scrollpane;
4988
+
45554989 JPanel toolbarPanel;
4556
- JPanel treePanel;
4990
+
4991
+ cGridBag treePanel;
4992
+
45574993 JPanel radioPanel;
45584994 ButtonGroup buttonGroup;
4559
- JPanel ctrlPanel;
4560
- JPanel materialPanel;
4995
+
4996
+ cGridBag toolboxPanel;
4997
+ cGridBag materialPanel;
4998
+ cGridBag ctrlPanel;
4999
+
45615000 JScrollPane infoPanel;
4562
- JPanel optionsPanel;
5001
+
5002
+ cGridBag optionsPanel;
5003
+
45635004 JTabbedPane objectPanel;
5005
+ boolean materialFlushed;
5006
+ Object3D latestObject;
5007
+
45645008 cGridBag XYZPanel;
5009
+
45655010 JSplitPane gridPanel;
45665011 JSplitPane bigPanel;
5012
+
45675013 cGridBag bigThree;
45685014 cGridBag scenePanel;
45695015 cGridBag centralPanel;
....@@ -4619,67 +5065,72 @@
46195065 // MATERIAL
46205066 JLabel materialLabel;
46215067 JLabel colorLabel;
4622
- NumberSlider colorField;
5068
+ cNumberSlider colorField;
46235069 JLabel modulationLabel;
4624
- NumberSlider modulationField;
5070
+ cNumberSlider modulationField;
46255071 JLabel metalnessLabel;
4626
- NumberSlider metalnessField;
5072
+ cNumberSlider metalnessField;
46275073 JLabel diffuseLabel;
4628
- NumberSlider diffuseField;
5074
+ cNumberSlider diffuseField;
46295075 JLabel specularLabel;
4630
- NumberSlider specularField;
5076
+ cNumberSlider specularField;
46315077 JLabel shininessLabel;
4632
- NumberSlider shininessField;
5078
+ cNumberSlider shininessField;
46335079 JLabel shiftLabel;
4634
- NumberSlider shiftField;
5080
+ cNumberSlider shiftField;
46355081 JLabel ambientLabel;
4636
- NumberSlider ambientField;
5082
+ cNumberSlider ambientField;
46375083 JLabel lightareaLabel;
4638
- NumberSlider lightareaField;
5084
+ cNumberSlider lightareaField;
46395085 JLabel diffusenessLabel;
4640
- NumberSlider diffusenessField;
5086
+ cNumberSlider diffusenessField;
46415087 JLabel velvetLabel;
4642
- NumberSlider velvetField;
5088
+ cNumberSlider velvetField;
46435089 JLabel sheenLabel;
4644
- NumberSlider sheenField;
5090
+ cNumberSlider sheenField;
46455091 JLabel subsurfaceLabel;
4646
- NumberSlider subsurfaceField;
5092
+ cNumberSlider subsurfaceField;
46475093 //JLabel bumpLabel;
46485094 //NumberSlider bumpField;
46495095 JLabel backlitLabel;
4650
- NumberSlider backlitField;
5096
+ cNumberSlider backlitField;
46515097 JLabel anisoLabel;
4652
- NumberSlider anisoField;
5098
+ cNumberSlider anisoField;
46535099 JLabel anisoVLabel;
4654
- NumberSlider anisoVField;
5100
+ cNumberSlider anisoVField;
46555101 JLabel cameraLabel;
4656
- NumberSlider cameraField;
5102
+ cNumberSlider cameraField;
46575103 JLabel selfshadowLabel;
4658
- NumberSlider selfshadowField;
5104
+ cNumberSlider selfshadowField;
46595105 JLabel shadowLabel;
4660
- NumberSlider shadowField;
5106
+ cNumberSlider shadowField;
46615107 JLabel textureLabel;
4662
- NumberSlider textureField;
5108
+ cNumberSlider textureField;
46635109 JLabel opacityLabel;
4664
- NumberSlider opacityField;
5110
+ cNumberSlider opacityField;
46655111 JLabel fakedepthLabel;
4666
- NumberSlider fakedepthField;
5112
+ cNumberSlider fakedepthField;
46675113 JLabel shadowbiasLabel;
4668
- NumberSlider shadowbiasField;
5114
+ cNumberSlider shadowbiasField;
46695115 JLabel bumpLabel;
4670
- NumberSlider bumpField;
5116
+ cNumberSlider bumpField;
46715117 JLabel noiseLabel;
4672
- NumberSlider noiseField;
5118
+ cNumberSlider noiseField;
46735119 JLabel powerLabel;
4674
- NumberSlider powerField;
5120
+ cNumberSlider powerField;
46755121 JLabel borderfadeLabel;
4676
- NumberSlider borderfadeField;
5122
+ cNumberSlider borderfadeField;
46775123 JLabel fogLabel;
4678
- NumberSlider fogField;
5124
+ cNumberSlider fogField;
46795125 JLabel opacityPowerLabel;
4680
- NumberSlider opacityPowerField;
4681
- JTree jTree;
5126
+ cNumberSlider opacityPowerField;
5127
+ cTree jTree;
46825128 //ObjectUI parent;
46835129
4684
- NumberSlider normalpushField;
5130
+ cNumberSlider normalpushField;
5131
+
5132
+ private MenuItem importGFDItem;
5133
+ private MenuItem importVRMLX3DItem;
5134
+ private MenuItem import3DSItem;
5135
+ private MenuItem importOBJItem;
46855136 }