Normand Briere
2019-08-07 59de607850161a26863f92961d53caae7a2dabc8
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -30,11 +34,87 @@
3034 iSendInfo
3135 //KeyListener
3236 {
37
+ public cToggleButton pinButton;
3338 boolean timeline;
3439 boolean wasFullScreen;
3540
3641 GroupEditor callee;
3742 JFrame frame;
43
+
44
+ static ObjEditor theFrame;
45
+
46
+ public cGridBag GetSeparator()
47
+ {
48
+ cGridBag separator = new cGridBag();
49
+ separator.add(new JSeparator());
50
+ separator.preferredHeight = 5;
51
+ return separator;
52
+ }
53
+
54
+ cButton GetButton(String name, boolean border)
55
+ {
56
+ ImageIcon icon = GetIcon(name);
57
+ return new cButton(icon, border);
58
+ }
59
+
60
+ cLabel GetLabel(String name, boolean border)
61
+ {
62
+ //ImageIcon icon = GetIcon(name);
63
+ return new cLabel(GetImage(name), border);
64
+ }
65
+
66
+ cToggleButton GetToggleButton(String name, boolean border)
67
+ {
68
+ ImageIcon icon = GetIcon(name);
69
+ return new cToggleButton(icon, border);
70
+ }
71
+
72
+ cCheckBox GetCheckBox(String name, boolean border)
73
+ {
74
+ ImageIcon icon = GetIcon(name);
75
+ return new cCheckBox(icon, border);
76
+ }
77
+
78
+ ImageIcon GetIcon(String name)
79
+ {
80
+ try
81
+ {
82
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
83
+
84
+// if (image.getWidth() > 48 && image.getHeight() > 48)
85
+// {
86
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
87
+// Graphics2D g = resized.createGraphics();
88
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
89
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
90
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
91
+// g.dispose();
92
+//
93
+// image = resized;
94
+// }
95
+
96
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
97
+ return icon;
98
+ }
99
+ catch (Exception e)
100
+ {
101
+ return null;
102
+ }
103
+ }
104
+
105
+ BufferedImage GetImage(String name)
106
+ {
107
+ try
108
+ {
109
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
110
+
111
+ return image;
112
+ }
113
+ catch (Exception e)
114
+ {
115
+ return null;
116
+ }
117
+ }
38118
39119 // SCRIPT
40120
....@@ -143,7 +223,9 @@
143223 //nameField.removeActionListener(this);
144224 // objEditor.ctrlPanel.remove(nameField);
145225
146
- if (!GroupEditor.allparams)
226
+ objEditor.ctrlPanel.remove(namePanel);
227
+
228
+ if (!allparams)
147229 return;
148230
149231 // objEditor.ctrlPanel.remove(liveCB);
....@@ -165,9 +247,9 @@
165247 // objEditor.ctrlPanel.remove(fasterButton);
166248 // objEditor.ctrlPanel.remove(remarkButton);
167249
168
- objEditor.ctrlPanel.remove(namePanel);
169250 objEditor.ctrlPanel.remove(setupPanel);
170
- objEditor.ctrlPanel.remove(commandsPanel);
251
+ objEditor.ctrlPanel.remove(setupPanel2);
252
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
171253 objEditor.ctrlPanel.remove(pushPanel);
172254 //objEditor.ctrlPanel.remove(fillPanel);
173255
....@@ -215,6 +297,12 @@
215297 client = inClient;
216298 copy = client;
217299
300
+ if (copy.versionlist == null)
301
+ {
302
+ copy.versionlist = new Object3D[100];
303
+ copy.versionindex = -1;
304
+ }
305
+
218306 // "this" is not called: SetupUI2(objEditor);
219307 }
220308
....@@ -228,6 +316,12 @@
228316 client = inClient;
229317 copy = client;
230318
319
+ if (copy.versionlist == null)
320
+ {
321
+ copy.versionlist = new Object3D[100];
322
+ copy.versionindex = -1;
323
+ }
324
+
231325 SetupUI2(callee.GetEditor());
232326 }
233327
....@@ -242,6 +336,7 @@
242336 //localCopy.parent = null;
243337
244338 frame = new JFrame();
339
+ frame.setUndecorated(false);
245340 objEditor = this;
246341 this.callee = callee;
247342
....@@ -259,6 +354,12 @@
259354 copy = localCopy;
260355 copy.editWindow = this;
261356
357
+ if (copy.versionlist == null)
358
+ {
359
+// copy.versions = new byte[100][];
360
+// copy.versionindex = -1;
361
+ }
362
+
262363 SetupMenu();
263364
264365 //SetupName(objEditor); // new
....@@ -272,28 +373,49 @@
272373 return frame.action(event, obj);
273374 }
274375
376
+ // Cannot work without static
377
+ static boolean allparams = true;
378
+
379
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
380
+
275381 void SetupMenu()
276382 {
277383 frame.setMenuBar(menuBar = new MenuBar());
278
- menuBar.add(windowMenu = new Menu("File"));
279
- windowMenu.add(loadItem = new MenuItem("Load..."));
280
- windowMenu.add("-");
281
- windowMenu.add(saveItem = new MenuItem("Save"));
282
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
384
+ menuBar.add(fileMenu = new Menu("File"));
385
+ fileMenu.add(newItem = new MenuItem("New"));
386
+ fileMenu.add(openItem = new MenuItem("Open..."));
387
+
388
+ //oe.menuBar.add(menu = new Menu("Include"));
389
+ Menu menu = new Menu("Import");
390
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
391
+ importOBJItem.addActionListener(this);
392
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
393
+ import3DSItem.addActionListener(this);
394
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
395
+ importVRMLX3DItem.addActionListener(this);
396
+ menu.add("-");
397
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
398
+ importGFDItem.addActionListener(this);
399
+ fileMenu.add(menu);
400
+ fileMenu.add("-");
401
+
402
+ fileMenu.add(saveItem = new MenuItem("Save"));
403
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
283404 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
284
- windowMenu.add("-");
285
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
286
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
287
- windowMenu.add("-");
405
+ fileMenu.add("-");
406
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
407
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
408
+ fileMenu.add("-");
288409 if (client.parent != null)
289410 {
290
- windowMenu.add(closeItem = new MenuItem("Close"));
411
+ fileMenu.add(closeItem = new MenuItem("Close"));
291412 } else
292413 {
293
- windowMenu.add(closeItem = new MenuItem("Exit"));
414
+ fileMenu.add(closeItem = new MenuItem("Exit"));
294415 }
295416
296
- loadItem.addActionListener(this);
417
+ newItem.addActionListener(this);
418
+ openItem.addActionListener(this);
297419 saveItem.addActionListener(this);
298420 saveAsItem.addActionListener(this);
299421 exportAsItem.addActionListener(this);
....@@ -301,82 +423,71 @@
301423 //povItem.addActionListener(this);
302424 closeItem.addActionListener(this);
303425
304
- menuBar.add(cameraMenu = new Menu("View"));
305
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
306
- //zBufferItem.addActionListener(this);
307
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
308
- //normalLensItem.addActionListener(this);
309
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
310
- revertCameraItem.addActionListener(this);
311
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
312
- toggleTimelineItem.addItemListener(this);
313
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
314
- toggleFullScreenItem.addItemListener(this);
315
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
316
- cameraMenu.add("-");
317
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
318
- toggleTextureItem.addItemListener(this);
319
- toggleTextureItem.setState(CameraPane.textureon);
320
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
321
- toggleLiveItem.addItemListener(this);
322
- toggleLiveItem.setState(Globals.isLIVE());
323
- cameraMenu.add(stepItem = new MenuItem("Step"));
324
- stepItem.addActionListener(this);
325
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
326
-// toggleDLItem.addItemListener(this);
327
-// toggleDLItem.setState(false);
328
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
329
- toggleRenderItem.addItemListener(this);
330
- toggleRenderItem.setState(!CameraPane.frozen);
331
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
332
- toggleDebugItem.addItemListener(this);
333
- toggleDebugItem.setState(CameraPane.DEBUG);
334
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
335
- toggleFrustumItem.addItemListener(this);
336
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
337
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
338
- toggleFootContactItem.addItemListener(this);
339
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
340
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
341
- toggleRandomItem.addItemListener(this);
342
- toggleRandomItem.setState(CameraPane.RANDOM);
343
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
344
- toggleHandleItem.addItemListener(this);
345
- toggleHandleItem.setState(CameraPane.HANDLES);
346
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
347
- togglePaintItem.addItemListener(this);
348
- togglePaintItem.setState(CameraPane.PAINTMODE);
349
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
350
-// toggleRootItem.addItemListener(this);
351
-// toggleRootItem.setState(false);
352
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
353
-// animationItem.addItemListener(this);
354
-// animationItem.setState(CameraPane.ANIMATION);
355
- cameraMenu.add("-");
356
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
357
- editCameraItem.addActionListener(this);
358
-
359426 objectPanel = new JTabbedPane();
427
+
428
+ ChangeListener changeListener = new ChangeListener()
429
+ {
430
+ public void stateChanged(ChangeEvent changeEvent)
431
+ {
432
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
433
+// {
434
+// if (latestObject != null)
435
+// {
436
+// refreshContents(true);
437
+// SetMaterial(latestObject);
438
+// }
439
+//
440
+// materialFlushed = true;
441
+// }
442
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
443
+// {
444
+// if (listUI.size() == 0)
445
+// EditSelection(false);
446
+// }
447
+
448
+ refreshContents(false); // To refresh Info tab
449
+ }
450
+ };
451
+ objectPanel.addChangeListener(changeListener);
452
+
360453 toolbarPanel = new JPanel();
361454 toolbarPanel.setName("Toolbar");
362
- treePanel = new JPanel();
455
+
456
+ treePanel = new cGridBag();
363457 treePanel.setName("Tree");
458
+
459
+ editPanel = new cGridBag().setVertical(true);
460
+ //editPanel.setName("Edit");
461
+
364462 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
365
- ctrlPanel.setName("Edit");
366
- materialPanel = new cGridBag().setVertical(true);
367
- materialPanel.setName("Material");
463
+
464
+ editCommandsPanel = new cGridBag();
465
+ editPanel.add(editCommandsPanel);
466
+ editPanel.add(ctrlPanel);
467
+
468
+ toolboxPanel = new cGridBag().setVertical(true);
469
+ //toolboxPanel.setName("Toolbox");
470
+
471
+ skyboxPanel = new cGridBag().setVertical(true);
472
+
473
+ materialPanel = new cGridBag().setVertical(false);
474
+ //materialPanel.setName("Material");
475
+
368476 /*JTextPane*/
369477 infoarea = createTextPane();
478
+ doc = infoarea.getStyledDocument();
479
+
370480 infoarea.setEditable(true);
371481 SetText();
482
+
372483 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
373484 // infoarea.setOpaque(false);
374485 // //infoarea.setForeground(textcolor);
375
- infoarea.setLineWrap(true);
376
- infoarea.setWrapStyleWord(true);
486
+// TEXTAREA infoarea.setLineWrap(true);
487
+// TEXTAREA infoarea.setWrapStyleWord(true);
377488 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
378
- infoPanel.setPreferredSize(new Dimension(50, 200));
379
- infoPanel.setName("Info");
489
+ infoPanel.setPreferredSize(new Dimension(1, 1));
490
+ //infoPanel.setName("Info");
380491 //infoPanel.setLayout(new BorderLayout());
381492 //infoPanel.add(createTextPane());
382493
....@@ -384,14 +495,21 @@
384495 mainPanel.setName("Main");
385496 mainPanel.setContinuousLayout(true);
386497 mainPanel.setOneTouchExpandable(true);
387
- mainPanel.setDividerLocation(1.0);
388498 mainPanel.setDividerSize(9);
389
- mainPanel.setResizeWeight(0);
390
-
499
+ mainPanel.setDividerLocation(0.5); //1.0);
500
+ mainPanel.setResizeWeight(0.5);
501
+
502
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
503
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
504
+ divider.setDividerSize(15);
505
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
506
+
507
+ mainPanel.setUI(new BasicSplitPaneUI());
508
+
391509 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
392510 //mainPanel.setLayout(new GridBagLayout());
393511 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
394
- treePanel.setLayout(new GridBagLayout());
512
+// treePanel.setLayout(new GridBagLayout());
395513 //ctrlPanel.setLayout(new GridBagLayout());
396514 //materialPanel.setLayout(new GridBagLayout());
397515
....@@ -432,7 +550,7 @@
432550 static String newline = "\n";
433551 protected static final String buttonString = "JButton";
434552 StyledDocument doc;
435
- JTextArea infoarea;
553
+ JTextPane infoarea;
436554
437555 void ClearInfo()
438556 {
....@@ -455,10 +573,10 @@
455573 e.printStackTrace();
456574 }
457575
458
- String selection = infoarea.getText();
459
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
460
- java.awt.datatransfer.Clipboard clipboard =
461
- Toolkit.getDefaultToolkit().getSystemClipboard();
576
+// String selection = infoarea.getText();
577
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
578
+// java.awt.datatransfer.Clipboard clipboard =
579
+// Toolkit.getDefaultToolkit().getSystemClipboard();
462580 //clipboard.setContents(data, data);
463581 }
464582
....@@ -481,13 +599,13 @@
481599 //SendInfo("Name:", "bold");
482600 if (sel.GetTextures() != null || debug)
483601 {
484
- si.SendInfo(sel.toString(), "bold");
602
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
485603 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
486604 if (sel.Size() > 0)
487605 {
488606 si.SendInfo("#children = " + sel.Size(), "regular");
489607 }
490
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
608
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
491609 if (debug)
492610 {
493611 try
....@@ -499,7 +617,10 @@
499617 }
500618
501619 if (full)
502
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
620
+ {
621
+ si.SendInfo(" BBox min: " + minima, "regular");
622
+ si.SendInfo(" BBox max: " + maxima, "regular");
623
+ }
503624
504625 if (sel.bRep != null)
505626 {
....@@ -526,7 +647,7 @@
526647 }
527648 if (sel.support != null)
528649 {
529
- si.SendInfo(" support: " + sel.support, "regular");
650
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
530651 }
531652 if (sel.scriptnode != null)
532653 {
....@@ -597,6 +718,9 @@
597718 {
598719 CameraPane.pointflow = (PointFlow) sel;
599720 }
721
+
722
+ si.SendInfo("_____________________", "regular");
723
+ si.SendInfo("", "regular");
600724 }
601725 }
602726
....@@ -612,68 +736,194 @@
612736 }
613737 }
614738
739
+//static GraphicsDevice device = GraphicsEnvironment
740
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
741
+
742
+ Rectangle keeprect;
743
+ cRadio radio;
744
+
745
+cButton keepButton;
746
+ cButton twoButton; // Full 3D
747
+ cButton sixButton;
748
+ cButton threeButton;
749
+ cButton sevenButton;
750
+ cButton fourButton; // full panel
751
+ cButton oneButton; // full XYZ
752
+ //cButton currentLayout;
753
+
754
+ boolean maximized;
755
+
756
+ cButton fullscreenLayout;
757
+
758
+ void Minimize()
759
+ {
760
+ frame.setState(Frame.ICONIFIED);
761
+ frame.validate();
762
+ }
763
+
764
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
765
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
766
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
767
+ void Maximize()
768
+ {
769
+ if (CameraPane.FULLSCREEN)
770
+ {
771
+ ToggleFullScreen();
772
+ }
773
+
774
+ if (maximized)
775
+ {
776
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
777
+ }
778
+ else
779
+ {
780
+ keeprect = frame.getBounds();
781
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
782
+// Dimension rect2 = frame.getToolkit().getScreenSize();
783
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
784
+// frame.setState(Frame.MAXIMIZED_BOTH);
785
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
786
+ }
787
+
788
+ maximized ^= true;
789
+
790
+ frame.validate();
791
+ }
792
+
793
+ cButton minButton;
794
+ cButton maxButton;
795
+ cButton fullButton;
796
+
615797 void ToggleFullScreen()
616798 {
617
- if (CameraPane.FULLSCREEN)
799
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
800
+
801
+ cameraView.ToggleFullScreen();
802
+
803
+ if (!CameraPane.FULLSCREEN)
618804 {
619
- frame.getContentPane().remove(/*"Center",*/bigThree);
620
- framePanel.add(bigThree);
621
- frame.getContentPane().add(/*"Center",*/framePanel);
805
+ device.setFullScreenWindow(null);
806
+ frame.dispose();
807
+ frame.setUndecorated(false);
808
+ frame.validate();
809
+ frame.setVisible(true);
810
+
811
+ //frame.setVisible(false);
812
+// frame.removeNotify();
813
+// frame.setUndecorated(false);
814
+// frame.addNotify();
815
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
816
+
817
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
818
+// X framePanel.add(bigThree);
819
+// X frame.getContentPane().add(/*"Center",*/framePanel);
820
+ framePanel.setDividerLocation(46);
821
+
822
+ //frame.setVisible(true);
823
+ radio.layout = keepButton;
824
+ //theFrame = null;
825
+ keepButton = null;
826
+ radio.layout.doClick();
827
+
622828 } else
623829 {
624
- frame.getContentPane().remove(/*"Center",*/framePanel);
625
- framePanel.remove(bigThree);
626
- frame.getContentPane().add(/*"Center",*/bigThree);
830
+ keepButton = radio.layout;
831
+ //keeprect = frame.getBounds();
832
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
833
+// frame.getToolkit().getScreenSize().height);
834
+ //frame.setVisible(false);
835
+
836
+ frame.dispose();
837
+ frame.setUndecorated(true);
838
+ device.setFullScreenWindow(frame);
839
+ frame.validate();
840
+ frame.setVisible(true);
841
+// frame.removeNotify();
842
+// frame.setUndecorated(true);
843
+// frame.addNotify();
844
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
845
+// X framePanel.remove(bigThree);
846
+// X frame.getContentPane().add(/*"Center",*/bigThree);
847
+ framePanel.setDividerLocation(0);
848
+
849
+ radio.layout = fullscreenLayout;
850
+ radio.layout.doClick();
851
+ //frame.setVisible(true);
627852 }
628
- cameraView.ToggleFullScreen();
853
+ frame.validate();
854
+
855
+ cameraView.requestFocusInWindow();
629856 }
630857
631
- private JTextArea createTextPane()
858
+ private Object3D CompressCopy()
632859 {
633
- String[] initString =
634
- {
635
- "This is an editable JTextPane, ", //regular
636
- "another ", //italic
637
- "styled ", //bold
638
- "text ", //small
639
- "component, ", //large
640
- "which supports embedded components..." + newline,//regular
641
- " " + newline, //button
642
- "...and embedded icons..." + newline, //regular
643
- " ", //icon
644
- newline + "JTextPane is a subclass of JEditorPane that "
645
- + "uses a StyledEditorKit and StyledDocument, and provides "
646
- + "cover methods for interacting with those objects."
647
- };
860
+ boolean temp = CameraPane.SWITCH;
861
+ CameraPane.SWITCH = false;
862
+
863
+ copy.ExtractBigData(versiontable);
864
+ // if (copy == client)
865
+
866
+ Object3D versions[] = copy.versionlist;
867
+ copy.versionlist = null;
868
+
869
+ //byte[] compress = Compress(copy);
870
+ Object3D compress = (Object3D)Grafreed.clone(copy);
871
+
872
+ copy.versionlist = versions;
873
+
874
+ copy.RestoreBigData(versiontable);
875
+
876
+ CameraPane.SWITCH = temp;
877
+
878
+ return compress;
879
+ }
648880
649
- String[] initStyles =
650
- {
651
- "regular", "italic", "bold", "small", "large",
652
- "regular", "button", "regular", "icon",
653
- "regular"
654
- };
881
+ private JTextPane createTextPane()
882
+ {
883
+// TEXTAREA String[] initString =
884
+// {
885
+// "This is an editable JTextPane, ", //regular
886
+// "another ", //italic
887
+// "styled ", //bold
888
+// "text ", //small
889
+// "component, ", //large
890
+// "which supports embedded components..." + newline,//regular
891
+// " " + newline, //button
892
+// "...and embedded icons..." + newline, //regular
893
+// " ", //icon
894
+// newline + "JTextPane is a subclass of JEditorPane that "
895
+// + "uses a StyledEditorKit and StyledDocument, and provides "
896
+// + "cover methods for interacting with those objects."
897
+// };
898
+//
899
+// String[] initStyles =
900
+// {
901
+// "regular", "italic", "bold", "small", "large",
902
+// "regular", "button", "regular", "icon",
903
+// "regular"
904
+// };
905
+//
906
+// JTextPane textPane = new JTextPane();
907
+// textPane.setEditable(true);
908
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
909
+// addStylesToDocument(doc);
910
+//
911
+// try
912
+// {
913
+// for (int j = 0; j < 2; j++)
914
+// {
915
+// for (int i = 0; i < initString.length; i++)
916
+// {
917
+// doc.insertString(doc.getLength(), initString[i],
918
+// doc.getStyle(initStyles[i]));
919
+// }
920
+// }
921
+// } catch (BadLocationException ble)
922
+// {
923
+// System.err.println("Couldn't insert initial text into text pane.");
924
+// }
655925
656
- JTextPane textPane = new JTextPane();
657
- textPane.setEditable(true);
658
- /*StyledDocument*/ doc = textPane.getStyledDocument();
659
- addStylesToDocument(doc);
660
-
661
- try
662
- {
663
- for (int j = 0; j < 2; j++)
664
- {
665
- for (int i = 0; i < initString.length; i++)
666
- {
667
- doc.insertString(doc.getLength(), initString[i],
668
- doc.getStyle(initStyles[i]));
669
- }
670
- }
671
- } catch (BadLocationException ble)
672
- {
673
- System.err.println("Couldn't insert initial text into text pane.");
674
- }
675
-
676
- return new JTextArea(); // textPane;
926
+ return new JTextPane(); // textPane;
677927 }
678928
679929 protected void addStylesToDocument(StyledDocument doc)
....@@ -726,7 +976,7 @@
726976 protected static ImageIcon createImageIcon(String path,
727977 String description)
728978 {
729
- java.net.URL imgURL = GrafreeD.class.getResource(path);
979
+ java.net.URL imgURL = Grafreed.class.getResource(path);
730980 if (imgURL != null)
731981 {
732982 return new ImageIcon(imgURL, description);
....@@ -749,6 +999,7 @@
749999 {
7501000 SetupMaterial(materialPanel);
7511001 }
1002
+
7521003 //SetupName();
7531004 //SetupViews();
7541005 }
....@@ -758,6 +1009,7 @@
7581009 // NumberSlider vDivsField;
7591010 // JCheckBox endcaps;
7601011 JCheckBox liveCB;
1012
+ JCheckBox selectableCB;
7611013 JCheckBox hideCB;
7621014 JCheckBox link2masterCB;
7631015 JCheckBox markCB;
....@@ -765,7 +1017,12 @@
7651017 JCheckBox speedupCB;
7661018 JCheckBox rewindCB;
7671019 JCheckBox flipVCB;
1020
+
1021
+ cCheckBox toggleTextureCB;
1022
+ cCheckBox toggleSwitchCB;
1023
+
7681024 JComboBox texresMenu;
1025
+
7691026 JButton resetButton;
7701027 JButton stepButton;
7711028 JButton stepAllButton;
....@@ -774,9 +1031,13 @@
7741031 JButton fasterButton;
7751032 JButton remarkButton;
7761033
1034
+ cGridBag editPanel;
1035
+ cGridBag editCommandsPanel;
1036
+
7771037 cGridBag namePanel;
7781038 cGridBag setupPanel;
779
- cGridBag commandsPanel;
1039
+ cGridBag setupPanel2;
1040
+ cGridBag objectCommandsPanel;
7801041 cGridBag pushPanel;
7811042 cGridBag fillPanel;
7821043
....@@ -943,52 +1204,88 @@
9431204
9441205 void SetupUI2(ObjEditor oe)
9451206 {
946
-// oe.aConstraints.weightx = 0;
947
-// oe.aConstraints.weighty = 0;
948
-// oe.aConstraints.gridx = 0;
949
-// oe.aConstraints.gridy = 0;
9501207 //SetupName(oe);
9511208
9521209 namePanel = new cGridBag();
9531210
1211
+ //if (copy.pinned)
1212
+ {
1213
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1214
+ pinButton.setSelected(copy.pinned);
1215
+ cGridBag t = new cGridBag();
1216
+ t.preferredWidth = 2;
1217
+ t.add(pinButton);
1218
+ namePanel.add(t);
1219
+
1220
+ pinButton.addItemListener(this);
1221
+ }
1222
+
9541223 nameField = AddText(namePanel, copy.GetName());
955
- namePanel.add(nameField);
1224
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9561225 oe.ctrlPanel.add(namePanel);
9571226
9581227 oe.ctrlPanel.Return();
9591228
960
- if (!GroupEditor.allparams)
1229
+ if (!allparams)
9611230 return;
9621231
9631232 setupPanel = new cGridBag().setVertical(false);
9641233
9651234 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
966
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
967
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1235
+ liveCB.setToolTipText("Animate object");
1236
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1237
+ selectableCB.setToolTipText("Make object selectable");
9681238 // Return();
1239
+
1240
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1241
+ hideCB.setToolTipText("Hide object");
9691242 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
970
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
971
- randomCB = AddCheckBox(setupPanel, "Rand", copy.random);
1243
+ markCB.setToolTipText("As animation target transform");
1244
+
1245
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1246
+
1247
+ setupPanel2 = new cGridBag().setVertical(false);
1248
+
1249
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1250
+ rewindCB.setToolTipText("Rewind animation");
1251
+
1252
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1253
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9721254
1255
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1256
+ link2masterCB.setToolTipText("Attach to support");
1257
+
1258
+ if (Globals.ADVANCED)
1259
+ {
1260
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1261
+ speedupCB.setToolTipText("Option motion capture");
1262
+ }
1263
+
9731264 oe.ctrlPanel.add(setupPanel);
9741265 oe.ctrlPanel.Return();
1266
+ oe.ctrlPanel.add(setupPanel2);
1267
+ oe.ctrlPanel.Return();
9751268
976
- commandsPanel = new cGridBag().setVertical(false);
1269
+ objectCommandsPanel = new cGridBag().setVertical(false);
9771270
978
- resetButton = AddButton(commandsPanel, "Reset");
979
- stepButton = AddButton(commandsPanel, "Step");
1271
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1272
+ resetButton.setToolTipText("Jump to frame zero");
1273
+ stepButton = AddButton(objectCommandsPanel, "Step");
1274
+ stepButton.setToolTipText("Step one frame");
9801275 // resetAllButton = AddButton(oe, "Reset All");
9811276 // stepAllButton = AddButton(oe, "Step All");
982
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
9831277 // Return();
984
- slowerButton = AddButton(commandsPanel, "Slow");
985
- fasterButton = AddButton(commandsPanel, "Fast");
986
- remarkButton = AddButton(commandsPanel, "Remark");
1278
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1279
+ slowerButton.setToolTipText("Decrease animation speed");
1280
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1281
+ fasterButton.setToolTipText("Increase animation speed");
1282
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1283
+ remarkButton.setToolTipText("Set the current transform as the target");
9871284
988
- oe.ctrlPanel.add(commandsPanel);
1285
+ oe.ctrlPanel.add(objectCommandsPanel);
9891286 oe.ctrlPanel.Return();
9901287
991
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1288
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
9921289 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
9931290 //Return();
9941291
....@@ -1191,8 +1488,11 @@
11911488 //worldPanel.setName("World");
11921489 centralPanel = new cGridBag();
11931490 centralPanel.preferredWidth = 20;
1194
- timelinePanel = new JPanel(new BorderLayout());
1195
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1491
+
1492
+ if (Globals.ADVANCED)
1493
+ {
1494
+ timelinePanel = new JPanel(new BorderLayout());
1495
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11961496
11971497 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11981498 cameraPanel.setContinuousLayout(true);
....@@ -1201,7 +1501,10 @@
12011501 // cameraPanel.setDividerSize(9);
12021502 cameraPanel.setResizeWeight(1.0);
12031503
1504
+ }
1505
+
12041506 centralPanel.add(cameraView);
1507
+ centralPanel.setFocusable(true);
12051508 //frame.setJMenuBar(timelineMenubar);
12061509 //centralPanel.add(timelinePanel);
12071510
....@@ -1227,6 +1530,7 @@
12271530 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12281531 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12291532 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1533
+ //XYZPanel.setName("XYZ");
12301534
12311535 /*
12321536 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1264,13 +1568,29 @@
12641568 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12651569 //tmp.setName("Edit");
12661570 objectPanel.add(materialPanel);
1571
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1572
+ objectPanel.setToolTipTextAt(0, "Material");
1573
+
1574
+ objectPanel.add(toolboxPanel);
1575
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1576
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1577
+
1578
+ objectPanel.add(skyboxPanel);
1579
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1580
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1581
+
12671582 // JPanel north = new JPanel(new BorderLayout());
12681583 // north.setName("Edit");
12691584 // north.add(ctrlPanel, BorderLayout.NORTH);
12701585 // objectPanel.add(north);
1271
- objectPanel.add(ctrlPanel);
1272
- objectPanel.add(infoPanel);
1273
-
1586
+ objectPanel.add(editPanel);
1587
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1588
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1589
+
1590
+ objectPanel.add(XYZPanel);
1591
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1592
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1593
+
12741594 /*
12751595 aConstraints.gridx = 0;
12761596 aConstraints.gridwidth = 1;
....@@ -1278,7 +1598,7 @@
12781598 aConstraints.gridy += 1;
12791599 aConstraints.gridwidth = 1;
12801600 mainPanel.add(objectPanel, aConstraints);
1281
- */
1601
+ */
12821602
12831603 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12841604 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1290,14 +1610,12 @@
12901610 scrollpane.addMouseWheelListener(this); // Default not fast enough
12911611
12921612 /*JTabbedPane*/ scenePanel = new cGridBag();
1293
- scenePanel.preferredWidth = 7;
1613
+ scenePanel.preferredWidth = 5;
12941614
12951615 JTabbedPane tabbedPane = new JTabbedPane();
12961616 tabbedPane.add(scrollpane);
12971617
1298
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1299
-
1300
- optionsPanel = new cGridBag().setVertical(true);
1618
+ optionsPanel = new cGridBag().setVertical(false);
13011619
13021620 optionsPanel.setName("Options");
13031621
....@@ -1305,8 +1623,15 @@
13051623
13061624 tabbedPane.add(optionsPanel);
13071625
1626
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1627
+
13081628 scenePanel.add(tabbedPane);
13091629
1630
+ //if (Globals.ADVANCED)
1631
+ tabbedPane.add(infoPanel);
1632
+ tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1633
+ tabbedPane.setToolTipTextAt(3, "Information");
1634
+
13101635 /*
13111636 cTree jTree = new cTree(null);
13121637 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1368,7 +1693,7 @@
13681693 bigThree = new cGridBag();
13691694 bigThree.addComponent(scenePanel);
13701695 bigThree.addComponent(centralPanel);
1371
- bigThree.addComponent(XYZPanel);
1696
+ //bigThree.addComponent(XYZPanel);
13721697
13731698 // // SIDE EFFECT!!!
13741699 // aConstraints.gridx = 0;
....@@ -1377,9 +1702,9 @@
13771702 // aConstraints.gridheight = 1;
13781703
13791704 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1380
- framePanel.setContinuousLayout(true);
1381
- framePanel.setOneTouchExpandable(true);
1382
- framePanel.setDividerLocation(0.8);
1705
+ framePanel.setContinuousLayout(false);
1706
+ framePanel.setOneTouchExpandable(false);
1707
+ //.setDividerLocation(0.8);
13831708 //framePanel.setDividerSize(15);
13841709 //framePanel.setResizeWeight(0.15);
13851710 framePanel.setName("Frame");
....@@ -1396,15 +1721,19 @@
13961721
13971722 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13981723
1399
- frame.setSize(1024, 768);
1400
- frame.show();
1401
-
1724
+ frame.setSize(1280, 860);
1725
+
1726
+ cameraView.requestFocusInWindow();
1727
+
14021728 gridPanel.setDividerLocation(1.0);
1729
+
1730
+ frame.validate();
1731
+
1732
+ frame.setVisible(true);
14031733
14041734 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14051735 frame.addWindowListener(new WindowAdapter()
14061736 {
1407
-
14081737 public void windowClosing(WindowEvent e)
14091738 {
14101739 Close();
....@@ -1427,26 +1756,406 @@
14271756 ctrlPanel.removeAll();
14281757 }
14291758
1430
- void SetupMaterial(cGridBag panel)
1759
+ void SetupMaterial(cGridBag materialpanel)
14311760 {
1432
- /*
1761
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1762
+
1763
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1764
+ skin.setToolTipText("Skin");
1765
+ skin.addMouseListener(new MouseAdapter()
1766
+ {
1767
+ public void mouseClicked(MouseEvent e)
1768
+ {
1769
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1770
+ cMaterial material = object.material;
1771
+
1772
+ // Skin
1773
+ colorField.setFloat(material.color);
1774
+ saturationField.setFloat(material.modulation);
1775
+ subsurfaceField.setFloat(material.subsurface);
1776
+ selfshadowField.setFloat(material.diffuseness);
1777
+ diffusenessField.setFloat(material.factor);
1778
+ shininessField.setFloat(material.shininess);
1779
+ shadowbiasField.setFloat(material.shadowbias);
1780
+ diffuseField.setFloat(material.diffuse);
1781
+ specularField.setFloat(material.specular);
1782
+
1783
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1784
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1785
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1786
+
1787
+ materialtouched = true;
1788
+ applySelf();
1789
+ }
1790
+ });
1791
+ presetpanel.add(skin);
1792
+
1793
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1794
+ lambert.setToolTipText("Diffuse");
1795
+ lambert.addMouseListener(new MouseAdapter()
1796
+ {
1797
+ public void mouseClicked(MouseEvent e)
1798
+ {
1799
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1800
+ cMaterial material = object.material;
1801
+
1802
+ diffusenessField.setFloat(material.factor);
1803
+ selfshadowField.setFloat(material.diffuseness);
1804
+
1805
+ materialtouched = true;
1806
+ applySelf();
1807
+ }
1808
+ });
1809
+ presetpanel.add(lambert);
1810
+
1811
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1812
+ diffuse2.setToolTipText("Diffuse2");
1813
+ diffuse2.addMouseListener(new MouseAdapter()
1814
+ {
1815
+ public void mouseClicked(MouseEvent e)
1816
+ {
1817
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1818
+ cMaterial material = object.material;
1819
+
1820
+ diffusenessField.setFloat(material.factor);
1821
+ selfshadowField.setFloat(material.diffuseness);
1822
+
1823
+ materialtouched = true;
1824
+ applySelf();
1825
+ }
1826
+ });
1827
+ presetpanel.add(diffuse2);
1828
+
1829
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1830
+ diffusemoon.setToolTipText("Moon");
1831
+ diffusemoon.addMouseListener(new MouseAdapter()
1832
+ {
1833
+ public void mouseClicked(MouseEvent e)
1834
+ {
1835
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1836
+ cMaterial material = object.material;
1837
+
1838
+ diffusenessField.setFloat(material.factor);
1839
+ selfshadowField.setFloat(material.diffuseness);
1840
+
1841
+ materialtouched = true;
1842
+ applySelf();
1843
+ }
1844
+ });
1845
+ presetpanel.add(diffusemoon);
1846
+
1847
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1848
+ diffusemoon2.setToolTipText("Moon2");
1849
+ diffusemoon2.addMouseListener(new MouseAdapter()
1850
+ {
1851
+ public void mouseClicked(MouseEvent e)
1852
+ {
1853
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1854
+ cMaterial material = object.material;
1855
+
1856
+ diffusenessField.setFloat(material.factor);
1857
+ selfshadowField.setFloat(material.diffuseness);
1858
+
1859
+ materialtouched = true;
1860
+ applySelf();
1861
+ }
1862
+ });
1863
+ presetpanel.add(diffusemoon2);
1864
+
1865
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1866
+ diffusemoon3.setToolTipText("Moon3");
1867
+ diffusemoon3.addMouseListener(new MouseAdapter()
1868
+ {
1869
+ public void mouseClicked(MouseEvent e)
1870
+ {
1871
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1872
+ cMaterial material = object.material;
1873
+
1874
+ diffusenessField.setFloat(material.factor);
1875
+ selfshadowField.setFloat(material.diffuseness);
1876
+
1877
+ materialtouched = true;
1878
+ applySelf();
1879
+ }
1880
+ });
1881
+ presetpanel.add(diffusemoon3);
1882
+
1883
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1884
+ diffusesheen.setToolTipText("Sheen");
1885
+ diffusesheen.addMouseListener(new MouseAdapter()
1886
+ {
1887
+ public void mouseClicked(MouseEvent e)
1888
+ {
1889
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1890
+ cMaterial material = object.material;
1891
+
1892
+ sheenField.setFloat(material.sheen);
1893
+
1894
+ materialtouched = true;
1895
+ applySelf();
1896
+ }
1897
+ });
1898
+ presetpanel.add(diffusesheen);
1899
+
1900
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1901
+ rough.setToolTipText("Rough metal");
1902
+ rough.addMouseListener(new MouseAdapter()
1903
+ {
1904
+ public void mouseClicked(MouseEvent e)
1905
+ {
1906
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1907
+ cMaterial material = object.material;
1908
+
1909
+ shininessField.setFloat(material.shininess);
1910
+ velvetField.setFloat(material.velvet);
1911
+
1912
+ materialtouched = true;
1913
+ applySelf();
1914
+ }
1915
+ });
1916
+ presetpanel.add(rough);
1917
+
1918
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
1919
+ rough2.setToolTipText("Medium metal");
1920
+ rough2.addMouseListener(new MouseAdapter()
1921
+ {
1922
+ public void mouseClicked(MouseEvent e)
1923
+ {
1924
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
1925
+ cMaterial material = object.material;
1926
+
1927
+ shininessField.setFloat(material.shininess);
1928
+ lightareaField.setFloat(material.lightarea);
1929
+
1930
+ materialtouched = true;
1931
+ applySelf();
1932
+ }
1933
+ });
1934
+ presetpanel.add(rough2);
1935
+
1936
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
1937
+ shini0.setToolTipText("Shiny");
1938
+ shini0.addMouseListener(new MouseAdapter()
1939
+ {
1940
+ public void mouseClicked(MouseEvent e)
1941
+ {
1942
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
1943
+ cMaterial material = object.material;
1944
+
1945
+ shininessField.setFloat(material.shininess);
1946
+ lightareaField.setFloat(material.lightarea);
1947
+
1948
+ materialtouched = true;
1949
+ applySelf();
1950
+ }
1951
+ });
1952
+ presetpanel.add(shini0);
1953
+
1954
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
1955
+ shini1.setToolTipText("Shiny2");
1956
+ shini1.addMouseListener(new MouseAdapter()
1957
+ {
1958
+ public void mouseClicked(MouseEvent e)
1959
+ {
1960
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
1961
+ cMaterial material = object.material;
1962
+
1963
+ shininessField.setFloat(material.shininess);
1964
+ lightareaField.setFloat(material.lightarea);
1965
+
1966
+ materialtouched = true;
1967
+ applySelf();
1968
+ }
1969
+ });
1970
+ presetpanel.add(shini1);
1971
+
1972
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
1973
+ shini2.setToolTipText("Shiny3");
1974
+ shini2.addMouseListener(new MouseAdapter()
1975
+ {
1976
+ public void mouseClicked(MouseEvent e)
1977
+ {
1978
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
1979
+ cMaterial material = object.material;
1980
+
1981
+ shininessField.setFloat(material.shininess);
1982
+ lightareaField.setFloat(material.lightarea);
1983
+
1984
+ materialtouched = true;
1985
+ applySelf();
1986
+ }
1987
+ });
1988
+ presetpanel.add(shini2);
1989
+
1990
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
1991
+ aniso.setToolTipText("AnisoU");
1992
+ aniso.addMouseListener(new MouseAdapter()
1993
+ {
1994
+ public void mouseClicked(MouseEvent e)
1995
+ {
1996
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
1997
+ cMaterial material = object.material;
1998
+
1999
+ anisoField.setFloat(material.aniso);
2000
+ anisoVField.setFloat(material.anisoV);
2001
+
2002
+ materialtouched = true;
2003
+ applySelf();
2004
+ }
2005
+ });
2006
+ presetpanel.add(aniso);
2007
+
2008
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2009
+ aniso2.setToolTipText("AnisoV");
2010
+ aniso2.addMouseListener(new MouseAdapter()
2011
+ {
2012
+ public void mouseClicked(MouseEvent e)
2013
+ {
2014
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2015
+ cMaterial material = object.material;
2016
+
2017
+ anisoField.setFloat(material.aniso);
2018
+ anisoVField.setFloat(material.anisoV);
2019
+
2020
+ materialtouched = true;
2021
+ applySelf();
2022
+ }
2023
+ });
2024
+ presetpanel.add(aniso2);
2025
+
2026
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2027
+ aniso3.setToolTipText("AnisoUV");
2028
+ aniso3.addMouseListener(new MouseAdapter()
2029
+ {
2030
+ public void mouseClicked(MouseEvent e)
2031
+ {
2032
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2033
+ cMaterial material = object.material;
2034
+
2035
+ anisoField.setFloat(material.aniso);
2036
+ anisoVField.setFloat(material.anisoV);
2037
+
2038
+ materialtouched = true;
2039
+ applySelf();
2040
+ }
2041
+ });
2042
+ presetpanel.add(aniso3);
2043
+
2044
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2045
+ velvet0.setToolTipText("Velvet");
2046
+ velvet0.addMouseListener(new MouseAdapter()
2047
+ {
2048
+ public void mouseClicked(MouseEvent e)
2049
+ {
2050
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2051
+ cMaterial material = object.material;
2052
+
2053
+ diffusenessField.setFloat(material.factor);
2054
+ selfshadowField.setFloat(material.diffuseness);
2055
+ sheenField.setFloat(material.sheen);
2056
+ shininessField.setFloat(material.shininess);
2057
+ velvetField.setFloat(material.velvet);
2058
+ shiftField.setFloat(material.shift);
2059
+
2060
+ materialtouched = true;
2061
+ applySelf();
2062
+ }
2063
+ });
2064
+ presetpanel.add(velvet0);
2065
+
2066
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2067
+ bump0.setToolTipText("Bump texture");
2068
+ bump0.addMouseListener(new MouseAdapter()
2069
+ {
2070
+ public void mouseClicked(MouseEvent e)
2071
+ {
2072
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2073
+ cMaterial material = object.material;
2074
+
2075
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2076
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2077
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2078
+
2079
+ materialtouched = true;
2080
+ applySelf();
2081
+ }
2082
+ });
2083
+ presetpanel.add(bump0);
2084
+
2085
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2086
+ halo.setToolTipText("Halo");
2087
+ halo.addMouseListener(new MouseAdapter()
2088
+ {
2089
+ public void mouseClicked(MouseEvent e)
2090
+ {
2091
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2092
+ cMaterial material = object.material;
2093
+
2094
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2095
+
2096
+ materialtouched = true;
2097
+ applySelf();
2098
+ }
2099
+ });
2100
+ presetpanel.add(halo);
2101
+
2102
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2103
+ candle.setToolTipText("Candle");
2104
+ candle.addMouseListener(new MouseAdapter()
2105
+ {
2106
+ public void mouseClicked(MouseEvent e)
2107
+ {
2108
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2109
+ cMaterial material = object.material;
2110
+
2111
+ subsurfaceField.setFloat(material.subsurface);
2112
+ shadowbiasField.setFloat(material.shadowbias);
2113
+ ambientField.setFloat(material.ambient);
2114
+ specularField.setFloat(material.specular);
2115
+ lightareaField.setFloat(material.lightarea);
2116
+ shininessField.setFloat(material.shininess);
2117
+
2118
+ materialtouched = true;
2119
+ applySelf();
2120
+ }
2121
+ });
2122
+ presetpanel.add(candle);
2123
+
2124
+ cGridBag panel = new cGridBag().setVertical(true);
2125
+
2126
+ presetpanel.preferredWidth = 1;
2127
+
2128
+ materialpanel.add(presetpanel);
2129
+ materialpanel.add(panel);
2130
+
2131
+ panel.preferredWidth = 8;
2132
+
2133
+ /*
14332134 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14342135 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1435
- */
2136
+ */
14362137
14372138 cGridBag editBar = new cGridBag().setVertical(false);
14382139
1439
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
2140
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2141
+ createMaterialButton.setToolTipText("Create material");
14402142
14412143 /*
14422144 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14432145 */
14442146
1445
- editBar.add(clearMaterialButton = new cButton("Clear")); // , aConstraints);
1446
- editBar.add(resetSlidersButton = new cButton("Reset")); // , aConstraints);
1447
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1448
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
2147
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2148
+ clearMaterialButton.setToolTipText("Clear material");
2149
+
2150
+ if (Globals.ADVANCED)
2151
+ {
2152
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2153
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
2154
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
2155
+ }
14492156
2157
+ editBar.preferredHeight = 15;
2158
+
14502159 panel.add(editBar);
14512160
14522161 /**/
....@@ -1458,45 +2167,50 @@
14582167 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14592168
14602169 cGridBag colorSection = new cGridBag().setVertical(true);
2170
+
2171
+ cGridBag huepanel = new cGridBag();
2172
+ cGridBag huelabel = new cGridBag();
2173
+ skin = GetLabel("icons/hue.png", false);
2174
+ skin.fit = true;
2175
+ huelabel.add(skin);
2176
+ huelabel.preferredWidth = 20;
2177
+ huepanel.add(new cGridBag()); // Label
2178
+ huepanel.add(huelabel); // Field/slider
2179
+
2180
+ huepanel.preferredHeight = 7;
2181
+
2182
+ colorSection.add(huepanel);
14612183
14622184 cGridBag color = new cGridBag();
1463
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1464
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1465
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2185
+
2186
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2187
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2188
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2189
+
14662190 //colorField.preferredWidth = 200;
14672191 colorSection.add(color);
14682192
14692193 cGridBag modulation = new cGridBag();
14702194 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14712195 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1472
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2196
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14732197 colorSection.add(modulation);
14742198
2199
+ cGridBag opacity = new cGridBag();
2200
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2201
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2202
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2203
+ colorSection.add(opacity);
2204
+
2205
+ colorSection.add(GetSeparator());
2206
+
14752207 cGridBag texture = new cGridBag();
14762208 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14772209 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14782210 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14792211 colorSection.add(texture);
14802212
1481
- cGridBag anisoU = new cGridBag();
1482
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1483
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1484
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1485
- colorSection.add(anisoU);
1486
-
1487
- cGridBag anisoV = new cGridBag();
1488
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1489
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1490
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1491
- colorSection.add(anisoV);
1492
-
1493
- cGridBag shadowbias = new cGridBag();
1494
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1495
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1496
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1497
- colorSection.add(shadowbias);
1498
-
1499
- panel.add(new JSeparator());
2213
+ panel.add(GetSeparator());
15002214
15012215 panel.add(colorSection);
15022216
....@@ -1546,7 +2260,13 @@
15462260 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15472261 diffuseSection.add(fakedepth);
15482262
1549
- panel.add(new JSeparator());
2263
+ cGridBag shadowbias = new cGridBag();
2264
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2265
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2266
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2267
+ diffuseSection.add(shadowbias);
2268
+
2269
+ panel.add(GetSeparator());
15502270
15512271 panel.add(diffuseSection);
15522272
....@@ -1596,42 +2316,48 @@
15962316 // aConstraints.gridy += 1;
15972317 // aConstraints.gridwidth = 1;
15982318
2319
+ cGridBag anisoU = new cGridBag();
2320
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2321
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2322
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2323
+ specularSection.add(anisoU);
15992324
1600
- panel.add(new JSeparator());
2325
+ cGridBag anisoV = new cGridBag();
2326
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2327
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2328
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2329
+ specularSection.add(anisoV);
2330
+
2331
+
2332
+ panel.add(GetSeparator());
16012333
16022334 panel.add(specularSection);
16032335
16042336 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16052337
1606
- cGridBag globalSection = new cGridBag().setVertical(true);
2338
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16072339
16082340 cGridBag camera = new cGridBag();
16092341 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16102342 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16112343 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1612
- globalSection.add(camera);
2344
+ colorSection.add(camera);
16132345
16142346 cGridBag ambient = new cGridBag();
16152347 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16162348 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16172349 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1618
- globalSection.add(ambient);
2350
+ colorSection.add(ambient);
16192351
16202352 cGridBag backlit = new cGridBag();
16212353 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16222354 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16232355 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1624
- globalSection.add(backlit);
2356
+ colorSection.add(backlit);
16252357
1626
- cGridBag opacity = new cGridBag();
1627
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1628
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1629
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1630
- globalSection.add(opacity);
1631
-
1632
- panel.add(new JSeparator());
2358
+ //panel.add(new JSeparator());
16332359
1634
- panel.add(globalSection);
2360
+ //panel.add(globalSection);
16352361
16362362 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16372363
....@@ -1673,7 +2399,7 @@
16732399 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16742400 textureSection.add(opacityPower);
16752401
1676
- panel.add(new JSeparator());
2402
+ panel.add(GetSeparator());
16772403
16782404 panel.add(textureSection);
16792405
....@@ -1712,12 +2438,15 @@
17122438 opacityPowerField.addChangeListener(this);
17132439 /**/
17142440
1715
- resetSlidersButton.addActionListener(this);
17162441 clearMaterialButton.addActionListener(this);
17172442 createMaterialButton.addActionListener(this);
1718
-
1719
- propagateToggle.addItemListener(this);
1720
- multiplyToggle.addItemListener(this);
2443
+
2444
+ if (Globals.ADVANCED)
2445
+ {
2446
+ resetSlidersButton.addActionListener(this);
2447
+ propagateToggle.addItemListener(this);
2448
+ multiplyToggle.addItemListener(this);
2449
+ }
17212450 }
17222451
17232452 void DropFile(java.io.File[] files, boolean textures)
....@@ -1735,8 +2464,9 @@
17352464 // 3D models
17362465 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17372466 {
1738
- lastConverter = new com.jmex.model.converters.MaxToJme();
1739
- LoadFile(filename, lastConverter);
2467
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2468
+ //LoadFile(filename, lastConverter);
2469
+ LoadObjFile(filename); // New 3ds loader
17402470 continue;
17412471 }
17422472 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1888,7 +2618,7 @@
18882618
18892619 //? flashIt = false;
18902620 CameraPane pane = (CameraPane) cameraView;
1891
- pane.clickStart(location.x, location.y, 0);
2621
+ pane.clickStart(location.x, location.y, 0, 0);
18922622 pane.clickEnd(location.x, location.y, 0, true);
18932623
18942624 if (group.selection.size() == 1)
....@@ -1937,6 +2667,7 @@
19372667 e2.printStackTrace();
19382668 }
19392669 }
2670
+
19402671 LoadJMEThread loadThread;
19412672
19422673 class LoadJMEThread extends Thread
....@@ -1994,6 +2725,7 @@
19942725 //LoadFile0(filename, converter);
19952726 }
19962727 }
2728
+
19972729 LoadOBJThread loadObjThread;
19982730
19992731 class LoadOBJThread extends Thread
....@@ -2072,19 +2804,19 @@
20722804
20732805 void LoadObjFile(String fullname)
20742806 {
2075
- /*
2807
+ System.out.println("Loading " + fullname);
2808
+ /**/
20762809 //lastFilename = fullname;
20772810 if(loadObjThread == null)
20782811 {
2079
- loadObjThread = new LoadOBJThread();
2080
- loadObjThread.start();
2812
+ loadObjThread = new LoadOBJThread();
2813
+ loadObjThread.start();
20812814 }
20822815
20832816 loadObjThread.add(fullname);
2084
- */
2817
+ /**/
20852818
2086
- System.out.println("Loading " + fullname);
2087
- makeSomething(new FileObject(fullname, true), true);
2819
+ //makeSomething(new FileObject(fullname, true), true);
20882820 }
20892821
20902822 void LoadGFDFile(String fullname)
....@@ -2345,11 +3077,11 @@
23453077
23463078 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23473079 {
2348
- if (GrafreeD.standAlone)
3080
+ if (Grafreed.standAlone)
23493081 {
23503082 /**/
23513083 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2352
- browser.show();
3084
+ browser.setVisible(true);
23533085 String filename = browser.getFile();
23543086 if (filename != null && filename.length() > 0)
23553087 {
....@@ -2460,6 +3192,7 @@
24603192 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24613193 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24623194 }
3195
+
24633196 //cJME.count++;
24643197 //cJME.count %= 12;
24653198 if (gc)
....@@ -2643,6 +3376,7 @@
26433376 }
26443377 }
26453378 }
3379
+
26463380 cFileSystemPane FSPane;
26473381
26483382 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2652,7 +3386,7 @@
26523386
26533387 freezematerial = true;
26543388 colorField.setFloat(mat.color);
2655
- modulationField.setFloat(mat.modulation);
3389
+ saturationField.setFloat(mat.modulation);
26563390 metalnessField.setFloat(mat.metalness);
26573391 diffuseField.setFloat(mat.diffuse);
26583392 specularField.setFloat(mat.specular);
....@@ -2696,11 +3430,14 @@
26963430 }
26973431 }
26983432 }
3433
+
26993434 freezematerial = false;
27003435 }
27013436
27023437 void SetMaterial(Object3D object)
27033438 {
3439
+ latestObject = object;
3440
+
27043441 cMaterial mat = object.material;
27053442
27063443 if (mat == null)
....@@ -2709,7 +3446,8 @@
27093446 return;
27103447 }
27113448
2712
- multiplyToggle.setSelected(mat.multiply);
3449
+ if (multiplyToggle != null)
3450
+ multiplyToggle.setSelected(mat.multiply);
27133451
27143452 assert (object.projectedVertices != null);
27153453
....@@ -2811,12 +3549,17 @@
28113549 // }
28123550
28133551 /**/
2814
- if (deselect)
3552
+ if (deselect || child == null)
28153553 {
28163554 //group.deselectAll();
28173555 //freeze = true;
28183556 GetTree().clearSelection();
28193557 //freeze = false;
3558
+
3559
+ if (child == null)
3560
+ {
3561
+ return;
3562
+ }
28203563 }
28213564
28223565 //group.addSelectee(child);
....@@ -2850,6 +3593,17 @@
28503593 public void itemStateChanged(ItemEvent event)
28513594 {
28523595 // System.out.println("Propagate = " + propagate);
3596
+ if (event.getSource() == pinButton)
3597
+ {
3598
+ copy.pinned ^= true;
3599
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3600
+ {
3601
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3602
+ copy.CloseUI();
3603
+ //copy.editWindow.refreshContents();
3604
+ }
3605
+ }
3606
+ else
28533607 if (event.getSource() == propagateToggle)
28543608 {
28553609 propagate ^= true;
....@@ -2885,7 +3639,7 @@
28853639 cameraView.ToggleDL();
28863640 cameraView.repaint();
28873641 return;
2888
- } else if (event.getSource() == toggleTextureItem)
3642
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28893643 {
28903644 cameraView.ToggleTexture();
28913645 // june 2013 copy.HardTouch();
....@@ -2924,9 +3678,9 @@
29243678 frame.validate();
29253679
29263680 return;
2927
- } else if (event.getSource() == toggleRandomItem)
3681
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29283682 {
2929
- cameraView.ToggleRandom();
3683
+ cameraView.ToggleSwitch();
29303684 cameraView.repaint();
29313685 return;
29323686 } else if (event.getSource() == toggleHandleItem)
....@@ -2954,12 +3708,17 @@
29543708 } else if (event.getSource() == liveCB)
29553709 {
29563710 copy.live ^= true;
3711
+ objEditor.refreshContents(true); // To show item colors
3712
+ return;
3713
+ } else if (event.getSource() == selectableCB)
3714
+ {
3715
+ copy.dontselect ^= true;
29573716 return;
29583717 } else if (event.getSource() == hideCB)
29593718 {
29603719 copy.hide ^= true;
29613720 copy.Touch(); // display list issue
2962
- objEditor.refreshContents();
3721
+ objEditor.refreshContents(true); // To show item colors
29633722 return;
29643723 } else if (event.getSource() == link2masterCB)
29653724 {
....@@ -2969,6 +3728,7 @@
29693728 if (event.getSource() == randomCB)
29703729 {
29713730 copy.random ^= true;
3731
+ objEditor.refreshContents();
29723732 return;
29733733 }
29743734 if (event.getSource() == speedupCB)
....@@ -2992,8 +3752,9 @@
29923752
29933753 public void actionPerformed(ActionEvent event)
29943754 {
3755
+ Object source = event.getSource();
29953756 // SCRIPT DIALOG
2996
- if (event.getSource() == okbutton)
3757
+ if (source == okbutton)
29973758 {
29983759 textpanel.setVisible(false);
29993760 textpanel.remove(textarea);
....@@ -3005,7 +3766,7 @@
30053766 textarea = null;
30063767 textpanel = null;
30073768 }
3008
- if (event.getSource() == cancelbutton)
3769
+ if (source == cancelbutton)
30093770 {
30103771 textpanel.setVisible(false);
30113772 textpanel.remove(textarea);
....@@ -3017,50 +3778,50 @@
30173778 //applySelf();
30183779 //client.refreshEditWindow();
30193780 //refreshContents();
3020
- if (event.getSource() == nameField)
3781
+ if (source == nameField)
30213782 {
30223783 //System.out.println("ObjEditor " + event);
30233784 applySelf0(true);
30243785 //parent.applySelf();
30253786 objEditor.refreshContents();
3026
- } else if (event.getSource() == resetButton)
3787
+ } else if (source == resetButton)
30273788 {
30283789 CameraPane.fullreset = true;
30293790 copy.Reset(); // ResetMeshes();
30303791 copy.Touch();
30313792 objEditor.refreshContents();
3032
- } else if (event.getSource() == stepItem)
3793
+ } else if (source == stepItem)
30333794 {
30343795 //cameraView.ONESTEP = true;
30353796 Globals.ONESTEP = true;
30363797 cameraView.repaint();
30373798 return;
3038
- } else if (event.getSource() == stepButton)
3799
+ } else if (source == stepButton)
30393800 {
30403801 copy.Step();
30413802 copy.Touch();
30423803 objEditor.refreshContents();
3043
- } else if (event.getSource() == slowerButton)
3804
+ } else if (source == slowerButton)
30443805 {
30453806 copy.Slower();
30463807 copy.Touch();
30473808 objEditor.refreshContents();
3048
- } else if (event.getSource() == fasterButton)
3809
+ } else if (source == fasterButton)
30493810 {
30503811 copy.Faster();
30513812 copy.Touch();
30523813 objEditor.refreshContents();
3053
- } else if (event.getSource() == remarkButton)
3814
+ } else if (source == remarkButton)
30543815 {
30553816 copy.Remark();
30563817 copy.Touch();
30573818 objEditor.refreshContents();
3058
- } else if (event.getSource() == stepAllButton)
3819
+ } else if (source == stepAllButton)
30593820 {
30603821 copy.StepAll();
30613822 copy.Touch();
30623823 objEditor.refreshContents();
3063
- } else if (event.getSource() == resetAllButton)
3824
+ } else if (source == resetAllButton)
30643825 {
30653826 //CameraPane.fullreset = true;
30663827 copy.ResetAll(); // ResetMeshes();
....@@ -3093,53 +3854,79 @@
30933854 // Close();
30943855 // }
30953856 // else
3096
- if (event.getSource() == resetSlidersButton)
3857
+ if (source == resetSlidersButton)
30973858 {
30983859 ResetSliders();
3099
- } else if (event.getSource() == clearMaterialButton)
3860
+ } else if (source == clearMaterialButton)
31003861 {
31013862 ClearMaterial();
3102
- } else if (event.getSource() == createMaterialButton)
3863
+ } else if (source == createMaterialButton)
31033864 {
31043865 CreateMaterial();
3105
- } else if (event.getSource() == clearPanelButton)
3866
+ } else if (source == clearPanelButton)
31063867 {
31073868 copy.ClearUI();
31083869 refreshContents(true);
3109
- } /*
3110
- }
3111
-
3112
- public boolean action(Event event, Object arg)
3113
- {
3114
- */ else if (event.getSource() == closeItem)
3870
+ } else if (source == importGFDItem)
3871
+ {
3872
+ ImportGFD();
3873
+ } else
3874
+ if (source == importVRMLX3DItem)
3875
+ {
3876
+ ImportVRMLX3D();
3877
+ } else
3878
+ if (source == import3DSItem)
3879
+ {
3880
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3881
+ } else
3882
+ if (source == importOBJItem)
3883
+ {
3884
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3885
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3886
+ browser.setVisible(true);
3887
+ String filename = browser.getFile();
3888
+ if (filename != null && filename.length() > 0)
3889
+ {
3890
+ String fullname = browser.getDirectory() + filename;
3891
+ makeSomething(ReadOBJ(fullname), true);
3892
+ }
3893
+ } else
3894
+ if (source == closeItem)
31153895 {
31163896 Close();
31173897 //return true;
3118
- } else if (event.getSource() == loadItem)
3898
+ } else if (source == openItem)
31193899 {
3120
- load();
3900
+ Open();
31213901 //return true;
3122
- } else if (event.getSource() == saveItem)
3902
+ } else if (source == newItem)
3903
+ {
3904
+ New();
3905
+ } else if (source == saveItem)
31233906 {
31243907 save();
31253908 //return true;
3126
- } else if (event.getSource() == saveAsItem)
3909
+ } else if (source == saveAsItem)
31273910 {
31283911 saveAs();
31293912 //return true;
3130
- } else if (event.getSource() == reexportItem)
3913
+ } else if (source == reexportItem)
31313914 {
31323915 reexport();
31333916 //return true;
3134
- } else if (event.getSource() == exportAsItem)
3917
+ } else if (source == exportAsItem)
31353918 {
31363919 export();
31373920 //return true;
3138
- } else if (event.getSource() == povItem)
3921
+ } else if (source == povItem)
31393922 {
31403923 generatePOV();
31413924 //return true;
3142
- } else if (event.getSource() == zBufferItem)
3925
+ } else if (event.getSource() == archiveItem)
3926
+ {
3927
+ cTools.Archive(frame);
3928
+ return;
3929
+ } else if (source == zBufferItem)
31433930 {
31443931 try
31453932 {
....@@ -3161,21 +3948,8 @@
31613948 cameraView.repaint();
31623949 //return true;
31633950 }
3164
- */ else if (event.getSource() == editCameraItem)
3165
- {
3166
- cameraView.ProtectCamera();
3167
- cameraView.repaint();
3168
- return;
3169
- } else if (event.getSource() == revertCameraItem)
3170
- {
3171
- cameraView.RevertCamera();
3172
- cameraView.repaint();
3173
- return;
3174
-// } else if (event.getSource() == textureButton)
3175
-// {
3176
-// return; // true;
3177
- } else // combos...
3178
- if (event.getSource() == texresMenu)
3951
+ */ else // combos...
3952
+ if (source == texresMenu)
31793953 {
31803954 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31813955 copy.texres = texresMenu.getSelectedIndex();
....@@ -3187,12 +3961,472 @@
31873961 }
31883962 }
31893963
3964
+ void New()
3965
+ {
3966
+ while (copy.Size() > 1)
3967
+ {
3968
+ copy.remove(1);
3969
+ }
3970
+
3971
+ ResetModel();
3972
+ objEditor.refreshContents();
3973
+ }
3974
+
3975
+ static public byte[] Compress(Object3D o)
3976
+ {
3977
+ // Slower to actually compress.
3978
+ try
3979
+ {
3980
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3981
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3982
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
3983
+
3984
+ Object3D parent = o.parent;
3985
+ o.parent = null;
3986
+
3987
+ out.writeObject(o);
3988
+
3989
+ o.parent = parent;
3990
+
3991
+ out.flush();
3992
+
3993
+ baos //zstream
3994
+ .close();
3995
+ out.close();
3996
+
3997
+ byte[] bytes = baos.toByteArray();
3998
+
3999
+ System.out.println("save #bytes = " + bytes.length);
4000
+ return bytes;
4001
+ } catch (Exception e)
4002
+ {
4003
+ System.err.println(e);
4004
+ return null;
4005
+ }
4006
+ }
4007
+
4008
+ static public Object Uncompress(byte[] bytes)
4009
+ {
4010
+ System.out.println("restore #bytes = " + bytes.length);
4011
+ try
4012
+ {
4013
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4014
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4015
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
4016
+ Object obj = in.readObject();
4017
+
4018
+ bais //istream
4019
+ .close();
4020
+ in.close();
4021
+
4022
+ return obj;
4023
+ } catch (Exception e)
4024
+ {
4025
+ System.err.println(e);
4026
+ return null;
4027
+ }
4028
+ }
4029
+
4030
+ static public Object clone(Object o)
4031
+ {
4032
+ try
4033
+ {
4034
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4035
+ ObjectOutputStream out = new ObjectOutputStream(baos);
4036
+
4037
+ out.writeObject(o);
4038
+
4039
+ out.flush();
4040
+ out.close();
4041
+
4042
+ byte[] bytes = baos.toByteArray();
4043
+
4044
+ System.out.println("clone = " + bytes.length);
4045
+
4046
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4047
+ ObjectInputStream in = new ObjectInputStream(bais);
4048
+ Object obj = in.readObject();
4049
+ in.close();
4050
+
4051
+ return obj;
4052
+ } catch (Exception e)
4053
+ {
4054
+ System.err.println(e);
4055
+ return null;
4056
+ }
4057
+ }
4058
+
4059
+ cRadio GetCurrentTab()
4060
+ {
4061
+ cRadio ab;
4062
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4063
+ {
4064
+ ab = (cRadio)e.nextElement();
4065
+ if(ab.GetObject() == copy)
4066
+ {
4067
+ return ab;
4068
+ }
4069
+ }
4070
+
4071
+ return null;
4072
+ }
4073
+
4074
+
4075
+ public void Save()
4076
+ {
4077
+ //Save(true);
4078
+ Replace();
4079
+ SetUndoStates();
4080
+ }
4081
+
4082
+ private boolean Equal(byte[] compress, byte[] name)
4083
+ {
4084
+ if (compress.length != name.length)
4085
+ {
4086
+ return false;
4087
+ }
4088
+
4089
+ for (int i=compress.length; --i>=0;)
4090
+ {
4091
+ if (compress[i] != name[i])
4092
+ return false;
4093
+ }
4094
+
4095
+ return true;
4096
+ }
4097
+
4098
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4099
+
4100
+ void DeleteVersion()
4101
+ {
4102
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4103
+ {
4104
+ copy.versionlist[i] = copy.versionlist[i+1];
4105
+ }
4106
+
4107
+ CopyChanged();
4108
+
4109
+ SetUndoStates();
4110
+ }
4111
+
4112
+ public boolean Save(boolean user)
4113
+ {
4114
+ System.err.println("Save");
4115
+ //Replace();
4116
+
4117
+ cRadio tab = GetCurrentTab();
4118
+
4119
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
4120
+
4121
+ boolean thesame = false;
4122
+
4123
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4124
+// {
4125
+// thesame = true;
4126
+// }
4127
+
4128
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
4129
+ if (!thesame)
4130
+ {
4131
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4132
+ {
4133
+ copy.versionlist[i] = copy.versionlist[i-1];
4134
+ }
4135
+
4136
+ //tab.user[tab.versionindex] = user;
4137
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4138
+
4139
+ copy.versionlist[++copy.versionindex] = compress;
4140
+
4141
+ // if (increment)
4142
+ // tab.versionindex++;
4143
+ }
4144
+
4145
+ //copy.RestoreBigData(versiontable);
4146
+
4147
+ //assert(hashtable.isEmpty());
4148
+
4149
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4150
+// {
4151
+// //tab.user[i] = false;
4152
+// copy.versionlist[i] = null;
4153
+// }
4154
+
4155
+ SetUndoStates();
4156
+
4157
+ // test save
4158
+ if (false)
4159
+ {
4160
+ try
4161
+ {
4162
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
4163
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
4164
+
4165
+ p.writeObject(copy);
4166
+
4167
+ p.flush();
4168
+
4169
+ ostream.close();
4170
+ } catch (Exception e)
4171
+ {
4172
+ e.printStackTrace();
4173
+ }
4174
+ }
4175
+
4176
+ return !thesame;
4177
+ }
4178
+
4179
+ boolean flashIt = true;
4180
+
4181
+ void RefreshSelection()
4182
+ {
4183
+ Object3D selection = new Object3D();
4184
+
4185
+ for (int i = 0; i < copy.selection.size(); i++)
4186
+ {
4187
+ Object3D elem = copy.selection.elementAt(i);
4188
+
4189
+ Object3D obj = copy.GetObject(elem.GetUUID());
4190
+
4191
+ if (obj == null)
4192
+ {
4193
+ copy.selection.remove(i--);
4194
+ }
4195
+ else
4196
+ {
4197
+ selection.add(obj);
4198
+ copy.selection.setElementAt(obj, i);
4199
+ }
4200
+ }
4201
+
4202
+ flashIt = false;
4203
+ GetTree().clearSelection();
4204
+ for (int i = 0; i < selection.size(); i++)
4205
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4206
+ flashIt = true;
4207
+
4208
+ //refreshContents(false);
4209
+ }
4210
+
4211
+ void CopyChanged()
4212
+ {
4213
+ Object3D obj = copy.versionlist[copy.versionindex];
4214
+
4215
+ SetUndoStates();
4216
+
4217
+ boolean temp = CameraPane.SWITCH;
4218
+ CameraPane.SWITCH = false;
4219
+
4220
+ copy.ExtractBigData(versiontable);
4221
+
4222
+ copy.clear();
4223
+
4224
+ copy.skyboxname = obj.skyboxname;
4225
+ copy.skyboxext = obj.skyboxext;
4226
+
4227
+ for (int i=0; i<obj.Size(); i++)
4228
+ {
4229
+ copy.add(obj.get(i));
4230
+ }
4231
+
4232
+ copy.RestoreBigData(versiontable);
4233
+
4234
+ CameraPane.SWITCH = temp;
4235
+
4236
+ RefreshSelection();
4237
+ //assert(hashtable.isEmpty());
4238
+
4239
+ copy.Touch();
4240
+
4241
+ ResetModel();
4242
+ copy.HardTouch(); // recompile?
4243
+
4244
+ cRadio ab;
4245
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4246
+ {
4247
+ ab = (cRadio)e.nextElement();
4248
+ Object3D test = copy.GetObject(ab.object.GetUUID());
4249
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
4250
+ if (test != null)
4251
+ {
4252
+ test.editWindow = ab.object.editWindow;
4253
+ ab.object = test;
4254
+ }
4255
+ }
4256
+
4257
+ refreshContents(true);
4258
+ }
4259
+
4260
+ cButton previousVersionButton;
4261
+ cButton restoreButton;
4262
+ cButton replaceButton;
4263
+ cButton nextVersionButton;
4264
+ cButton saveVersionButton;
4265
+ cButton deleteVersionButton;
4266
+
4267
+ boolean muteSlider;
4268
+
4269
+ int VersionCount()
4270
+ {
4271
+ int count = 0;
4272
+
4273
+ for (int i = copy.versionlist.length; --i >= 0;)
4274
+ {
4275
+ if (copy.versionlist[i] != null)
4276
+ count++;
4277
+ }
4278
+
4279
+ return count;
4280
+ }
4281
+
4282
+ void SetUndoStates()
4283
+ {
4284
+ cRadio tab = GetCurrentTab();
4285
+
4286
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
4287
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
4288
+
4289
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4290
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4291
+
4292
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4293
+ copy.versionlist[copy.versionindex + 1] != null);
4294
+
4295
+ muteSlider = true;
4296
+ versionSlider.setMaximum(VersionCount() - 1);
4297
+ versionSlider.setInteger(copy.versionindex);
4298
+ muteSlider = false;
4299
+ }
4300
+
4301
+ public boolean PreviousVersion()
4302
+ {
4303
+ // Option?
4304
+ Replace();
4305
+
4306
+ System.err.println("Undo");
4307
+
4308
+ cRadio tab = GetCurrentTab();
4309
+
4310
+ if (copy.versionindex == 0)
4311
+ {
4312
+ java.awt.Toolkit.getDefaultToolkit().beep();
4313
+ return false;
4314
+ }
4315
+
4316
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4317
+// {
4318
+// if (Save(false))
4319
+// tab.versionindex -= 1;
4320
+// else
4321
+// {
4322
+// if (tab.versionindex <= 0)
4323
+// return false;
4324
+// else
4325
+// tab.versionindex -= 1;
4326
+// }
4327
+// }
4328
+
4329
+ copy.versionindex -= 1;
4330
+
4331
+ CopyChanged();
4332
+
4333
+ return true;
4334
+ }
4335
+
4336
+ public boolean Restore()
4337
+ {
4338
+ System.err.println("Restore");
4339
+
4340
+ cRadio tab = GetCurrentTab();
4341
+
4342
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4343
+ {
4344
+ java.awt.Toolkit.getDefaultToolkit().beep();
4345
+ return false;
4346
+ }
4347
+
4348
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4349
+ CopyChanged();
4350
+
4351
+ return true;
4352
+ }
4353
+
4354
+ public boolean Replace()
4355
+ {
4356
+ System.err.println("Replace");
4357
+
4358
+ cRadio tab = GetCurrentTab();
4359
+
4360
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4361
+ {
4362
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4363
+ return false;
4364
+ }
4365
+
4366
+ copy.versionlist[copy.versionindex] = CompressCopy();
4367
+
4368
+ return true;
4369
+ }
4370
+
4371
+ public void NextVersion()
4372
+ {
4373
+ // Option?
4374
+ Replace();
4375
+
4376
+ cRadio tab = GetCurrentTab();
4377
+
4378
+ if (copy.versionlist[copy.versionindex + 1] == null)
4379
+ {
4380
+ java.awt.Toolkit.getDefaultToolkit().beep();
4381
+ return;
4382
+ }
4383
+
4384
+ copy.versionindex += 1;
4385
+
4386
+ CopyChanged();
4387
+
4388
+ //if (!tab.user[tab.versionindex])
4389
+ // tab.graphs[tab.versionindex] = null;
4390
+ }
4391
+
4392
+ void ImportGFD()
4393
+ {
4394
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
4395
+ browser.show();
4396
+ String filename = browser.getFile();
4397
+ if (filename != null && filename.length() > 0)
4398
+ {
4399
+ String fullname = browser.getDirectory() + filename;
4400
+
4401
+ //Object3D readobj =
4402
+ objEditor.ReadGFD(fullname, objEditor);
4403
+ //makeSomething(readobj);
4404
+ }
4405
+ }
4406
+
4407
+ void ImportVRMLX3D()
4408
+ {
4409
+ if (Grafreed.standAlone)
4410
+ {
4411
+ /**/
4412
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
4413
+ browser.show();
4414
+ String filename = browser.getFile();
4415
+ if (filename != null && filename.length() > 0)
4416
+ {
4417
+ String fullname = browser.getDirectory() + filename;
4418
+ LoadVRMLX3D(fullname);
4419
+ }
4420
+ /**/
4421
+ }
4422
+ }
4423
+
31904424 void ToggleAnimation()
31914425 {
31924426 if (!Globals.ANIMATION)
31934427 {
31944428 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3195
- browser.show();
4429
+ browser.setVisible(true);
31964430 String filename = browser.getFile();
31974431 if (filename != null && filename.length() > 0)
31984432 {
....@@ -3202,8 +4436,8 @@
32024436
32034437 Globals.ANIMATION ^= true;
32044438
3205
- GrafreeD.wav.cursor = 0;
3206
- GrafreeD.wav.loop = 0;
4439
+ Grafreed.wav.cursor = 0;
4440
+ Grafreed.wav.loop = 0;
32074441 }
32084442 } else
32094443 {
....@@ -3224,7 +4458,6 @@
32244458 callee.refreshContents();
32254459 } else
32264460 {
3227
- new Exception().printStackTrace();
32284461 System.exit(0);
32294462 }
32304463 }
....@@ -3254,7 +4487,7 @@
32544487 void CreateMaterial()
32554488 {
32564489 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
4490
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32584491 if (copy.selection.size() > 0)
32594492 //SetMaterial(copy);
32604493 {
....@@ -3305,7 +4538,7 @@
33054538 assert false;
33064539 }
33074540
3308
- void EditSelection()
4541
+ void EditSelection(boolean newWindow)
33094542 {
33104543 }
33114544
....@@ -3313,11 +4546,11 @@
33134546 {
33144547 copy.ResetBlockLoop(); // temporary problem
33154548
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
4549
+ boolean random = CameraPane.SWITCH;
4550
+ CameraPane.SWITCH = false; // parse everything
33184551 copy.ResetDisplayList();
33194552 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
4553
+ CameraPane.SWITCH = random;
33214554 }
33224555
33234556 // public void applySelf()
....@@ -3364,7 +4597,7 @@
33644597 //copy.material = new cMaterial(copy.GetMaterial());
33654598
33664599 current.color = (float) colorField.getFloat();
3367
- current.modulation = (float) modulationField.getFloat();
4600
+ current.modulation = (float) saturationField.getFloat();
33684601 current.metalness = (float) metalnessField.getFloat();
33694602 current.diffuse = (float) diffuseField.getFloat();
33704603 current.specular = (float) specularField.getFloat();
....@@ -3391,6 +4624,36 @@
33914624 {
33924625 //System.out.println("Propagate = " + propagate);
33934626 copy.UpdateMaterial(anchor, current, propagate);
4627
+
4628
+ if (copy.material != null)
4629
+ {
4630
+ cMaterial mat = copy.material;
4631
+
4632
+ colorField.SetToolTipValue((mat.color));
4633
+ saturationField.SetToolTipValue((mat.modulation));
4634
+ metalnessField.SetToolTipValue((mat.metalness));
4635
+ diffuseField.SetToolTipValue((mat.diffuse));
4636
+ specularField.SetToolTipValue((mat.specular));
4637
+ shininessField.SetToolTipValue((mat.shininess));
4638
+ shiftField.SetToolTipValue((mat.shift));
4639
+ ambientField.SetToolTipValue((mat.ambient));
4640
+ lightareaField.SetToolTipValue((mat.lightarea));
4641
+ diffusenessField.SetToolTipValue((mat.factor));
4642
+ velvetField.SetToolTipValue((mat.velvet));
4643
+ sheenField.SetToolTipValue((mat.sheen));
4644
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4645
+ backlitField.SetToolTipValue((mat.bump));
4646
+ anisoField.SetToolTipValue((mat.aniso));
4647
+ anisoVField.SetToolTipValue((mat.anisoV));
4648
+ cameraField.SetToolTipValue((mat.cameralight));
4649
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4650
+ shadowField.SetToolTipValue((mat.shadow));
4651
+ textureField.SetToolTipValue((mat.texture));
4652
+ opacityField.SetToolTipValue((mat.opacity));
4653
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4654
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
4655
+ }
4656
+
33944657 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33954658 {
33964659 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3419,9 +4682,26 @@
34194682 //copy.Touch();
34204683 }
34214684
4685
+ cNumberSlider versionSlider;
4686
+
34224687 public void stateChanged(ChangeEvent e)
34234688 {
34244689 // assert(false);
4690
+ if (e.getSource() == versionSlider)
4691
+ {
4692
+ if (muteSlider)
4693
+ return;
4694
+
4695
+ int version = versionSlider.getInteger();
4696
+
4697
+ if (copy.versionlist[version] != null)
4698
+ {
4699
+ copy.versionindex = version;
4700
+ CopyChanged();
4701
+ }
4702
+
4703
+ return;
4704
+ }
34254705
34264706 if (freezematerial)
34274707 {
....@@ -3457,6 +4737,12 @@
34574737 {
34584738 //System.out.println("stateChanged = " + this);
34594739 materialtouched = true;
4740
+
4741
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4742
+ {
4743
+ saturationField.setFloat(1);
4744
+ }
4745
+
34604746 applySelf();
34614747 //System.out.println("this = " + this);
34624748 //System.out.println("PARENT = " + parent);
....@@ -3506,7 +4792,7 @@
35064792 }
35074793
35084794 if (normalpushField != null)
3509
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4795
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35104796 }
35114797
35124798 void SnapObject()
....@@ -3756,6 +5042,7 @@
37565042 {
37575043 if (GetTree() != null)
37585044 {
5045
+ GetTree().revalidate();
37595046 GetTree().repaint();
37605047 }
37615048
....@@ -3764,12 +5051,17 @@
37645051 ctrlPanel.validate(); // ? new
37655052 ctrlPanel.repaint();
37665053 }
5054
+
5055
+ if (previousVersionButton != null && copy.versionlist != null)
5056
+ SetUndoStates();
37675057 }
37685058
37695059 static TweenManager tweenManager = new TweenManager();
37705060
37715061 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37725062 {
5063
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5064
+ Save();
37735065 //Tween.set(thing, 0).target(1).start(tweenManager);
37745066 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37755067 // if (thing instanceof GenericJointDemo)
....@@ -3856,6 +5148,12 @@
38565148 {
38575149 ResetModel();
38585150 Select(thing.GetTreePath(), true, false); // unselect... false);
5151
+
5152
+ if (thing.Size() == 0)
5153
+ {
5154
+ //EditSelection(false);
5155
+ }
5156
+
38595157 refreshContents();
38605158 }
38615159
....@@ -3973,6 +5271,7 @@
39735271 }
39745272 }
39755273 }
5274
+
39765275 LoadGFDThread loadGFDThread;
39775276
39785277 void ReadGFD(String fullname, iCallBack cb)
....@@ -3992,8 +5291,10 @@
39925291
39935292 try
39945293 {
5294
+ // Try compressed version first.
39955295 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3996
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5296
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
5297
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39975298
39985299 readobj = (Object3D) p.readObject();
39995300 istream.close();
....@@ -4001,7 +5302,22 @@
40015302 readobj.ResetDisplayList();
40025303 } catch (Exception e)
40035304 {
4004
- e.printStackTrace();
5305
+ if (!e.toString().contains("GZIP"))
5306
+ e.printStackTrace();
5307
+
5308
+ try
5309
+ {
5310
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
5311
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5312
+
5313
+ readobj = (Object3D) p.readObject();
5314
+ istream.close();
5315
+
5316
+ readobj.ResetDisplayList();
5317
+ } catch (Exception e2)
5318
+ {
5319
+ e2.printStackTrace();
5320
+ }
40055321 }
40065322 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40075323 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4047,6 +5363,12 @@
40475363
40485364 void LoadIt(Object obj)
40495365 {
5366
+ if (obj == null)
5367
+ {
5368
+ // Invalid file
5369
+ return;
5370
+ }
5371
+
40505372 System.out.println("Loaded " + obj);
40515373 //new Exception().printStackTrace();
40525374 Object3D readobj = (Object3D) obj;
....@@ -4056,10 +5378,14 @@
40565378
40575379 if (readobj != null)
40585380 {
5381
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5382
+ // Save();
40595383 try
40605384 {
40615385 //readobj.deepCopySelf(copy);
40625386 copy.clear(); // june 2014
5387
+ copy.skyboxname = readobj.skyboxname;
5388
+ copy.skyboxext = readobj.skyboxext;
40635389 for (int i = 0; i < readobj.size(); i++)
40645390 {
40655391 Object3D child = readobj.get(i); // reserve(i);
....@@ -4100,6 +5426,7 @@
41005426 }
41015427 } catch (ClassCastException e)
41025428 {
5429
+ e.printStackTrace();
41035430 assert (false);
41045431 Composite c = (Composite) copy;
41055432 c.children.clear();
....@@ -4110,17 +5437,28 @@
41105437 c.addChild(csg);
41115438 }
41125439
5440
+ copy.versionlist = readobj.versionlist;
5441
+ copy.versionindex = readobj.versionindex;
5442
+
5443
+ if (copy.versionlist == null)
5444
+ {
5445
+ copy.versionlist = new Object3D[100];
5446
+ copy.versionindex = -1;
5447
+ }
5448
+
5449
+ //? SetUndoStates();
5450
+
41135451 ResetModel();
41145452 copy.HardTouch(); // recompile?
41155453 refreshContents();
41165454 }
41175455 }
41185456
4119
- void load() // throws ClassNotFoundException
5457
+ void Open() // throws ClassNotFoundException
41205458 {
4121
- if (GrafreeD.standAlone)
5459
+ if (Grafreed.standAlone)
41225460 {
4123
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5461
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
41245462 browser.show();
41255463 String filename = browser.getFile();
41265464 if (filename != null && filename.length() > 0)
....@@ -4205,11 +5543,13 @@
42055543 try
42065544 {
42075545 FileOutputStream ostream = new FileOutputStream(lastname);
4208
- ObjectOutputStream p = new ObjectOutputStream(ostream);
5546
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5547
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42095548
42105549 p.writeObject(copy);
42115550 p.flush();
42125551
5552
+ zstream.close();
42135553 ostream.close();
42145554
42155555 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4217,19 +5557,23 @@
42175557 //ps.print(buffer.toString());
42185558 } catch (IOException e)
42195559 {
5560
+ e.printStackTrace();
42205561 }
42215562 }
5563
+
42225564 String lastname;
42235565
42245566 void saveAs()
42255567 {
4226
- if (GrafreeD.standAlone)
5568
+ if (Grafreed.standAlone)
42275569 {
42285570 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42295571 browser.setVisible(true);
42305572 String filename = browser.getFile();
42315573 if (filename != null && filename.length() > 0)
42325574 {
5575
+ if (!filename.endsWith(".gfd"))
5576
+ filename += ".gfd";
42335577 lastname = browser.getDirectory() + filename;
42345578 save();
42355579 }
....@@ -4328,13 +5672,13 @@
43285672 try
43295673 {
43305674 FileOutputStream ostream = new FileOutputStream(filename);
4331
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4332
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
5675
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5676
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43335677
43345678 Object3D objectparent = obj.parent;
43355679 obj.parent = null;
43365680
4337
- Object3D object = (Object3D) GrafreeD.clone(obj);
5681
+ Object3D object = (Object3D) Grafreed.clone(obj);
43385682
43395683 obj.parent = objectparent;
43405684
....@@ -4346,8 +5690,8 @@
43465690 p.writeObject(object);
43475691 p.flush();
43485692
5693
+ zstream.close();
43495694 ostream.close();
4350
- // zstream.close();
43515695
43525696 // group.selection.get(0).parent = parent;
43535697 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4368,7 +5712,7 @@
43685712 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43695713 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43705714 copy.generatePOV(buffer);
4371
- if (GrafreeD.standAlone)
5715
+ if (Grafreed.standAlone)
43725716 {
43735717 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43745718 browser.show();
....@@ -4394,19 +5738,18 @@
43945738 Object3D client;
43955739 Object3D copy;
43965740 MenuBar menuBar;
4397
- Menu windowMenu;
4398
- MenuItem loadItem;
5741
+ Menu fileMenu;
5742
+ MenuItem newItem;
5743
+ MenuItem openItem;
43995744 MenuItem saveItem;
44005745 MenuItem saveAsItem;
44015746 MenuItem exportAsItem;
44025747 MenuItem reexportItem;
44035748 MenuItem povItem;
44045749 MenuItem closeItem;
4405
- Menu cameraMenu;
5750
+
44065751 CheckboxMenuItem zBufferItem;
44075752 //MenuItem normalLensItem;
4408
- MenuItem editCameraItem;
4409
- MenuItem revertCameraItem;
44105753 MenuItem stepItem;
44115754 CheckboxMenuItem toggleLiveItem;
44125755 CheckboxMenuItem toggleFullScreenItem;
....@@ -4417,25 +5760,40 @@
44175760 CheckboxMenuItem toggleFootContactItem;
44185761 CheckboxMenuItem toggleDLItem;
44195762 CheckboxMenuItem toggleTextureItem;
4420
- CheckboxMenuItem toggleRandomItem;
5763
+ CheckboxMenuItem toggleSwitchItem;
44215764 CheckboxMenuItem toggleRootItem;
44225765 CheckboxMenuItem animationItem;
5766
+ MenuItem archiveItem;
44235767 CheckboxMenuItem toggleHandleItem;
44245768 CheckboxMenuItem togglePaintItem;
44255769 JSplitPane mainPanel;
44265770 JScrollPane scrollpane;
5771
+
44275772 JPanel toolbarPanel;
4428
- JPanel treePanel;
5773
+
5774
+ cGridBag treePanel;
5775
+
44295776 JPanel radioPanel;
44305777 ButtonGroup buttonGroup;
4431
- cGridBag ctrlPanel;
5778
+
5779
+ cGridBag toolboxPanel;
5780
+ cGridBag skyboxPanel;
44325781 cGridBag materialPanel;
5782
+ cGridBag ctrlPanel;
5783
+
44335784 JScrollPane infoPanel;
5785
+
44345786 cGridBag optionsPanel;
5787
+
44355788 JTabbedPane objectPanel;
5789
+ boolean materialFlushed;
5790
+ Object3D latestObject;
5791
+
44365792 cGridBag XYZPanel;
5793
+
44375794 JSplitPane gridPanel;
44385795 JSplitPane bigPanel;
5796
+
44395797 cGridBag bigThree;
44405798 cGridBag scenePanel;
44415799 cGridBag centralPanel;
....@@ -4493,7 +5851,7 @@
44935851 JLabel colorLabel;
44945852 cNumberSlider colorField;
44955853 JLabel modulationLabel;
4496
- cNumberSlider modulationField;
5854
+ cNumberSlider saturationField;
44975855 JLabel metalnessLabel;
44985856 cNumberSlider metalnessField;
44995857 JLabel diffuseLabel;
....@@ -4550,8 +5908,13 @@
45505908 cNumberSlider fogField;
45515909 JLabel opacityPowerLabel;
45525910 cNumberSlider opacityPowerField;
4553
- JTree jTree;
5911
+ cTree jTree;
45545912 //ObjectUI parent;
45555913
45565914 cNumberSlider normalpushField;
5915
+
5916
+ private MenuItem importGFDItem;
5917
+ private MenuItem importVRMLX3DItem;
5918
+ private MenuItem import3DSItem;
5919
+ private MenuItem importOBJItem;
45575920 }