Normand Briere
2019-08-18 66aca73cce89e4b4d7521862760edf4b0888bc38
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,131 @@
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 void AllocProjectedVertices(Object3D object)
47
+ {
48
+ assert (object.projectedVertices != null);
49
+
50
+ if (object.projectedVertices.length <= 2)
51
+ {
52
+ // Side effect...
53
+ Object3D.cVector2[] keep = object.projectedVertices;
54
+ object.projectedVertices = new Object3D.cVector2[3];
55
+ for (int i = 0; i < 3; i++)
56
+ {
57
+ if (i < keep.length)
58
+ {
59
+ object.projectedVertices[i] = keep[i];
60
+ } else
61
+ {
62
+ object.projectedVertices[i] = new Object3D.cVector2();
63
+ }
64
+ /*
65
+ if(keep.length == 0)
66
+ object.projectedVertices[0] = new Object3D.cVector2();
67
+ else
68
+ object.projectedVertices[0] = keep[0];
69
+ object.projectedVertices[1] = new Object3D.cVector2();
70
+ */
71
+ }
72
+ }
73
+ }
74
+
75
+ public cGridBag GetSeparator()
76
+ {
77
+ cGridBag separator = new cGridBag();
78
+ separator.add(new JSeparator());
79
+ separator.preferredHeight = 5;
80
+ return separator;
81
+ }
82
+
83
+ cButton GetButton(String name, boolean border)
84
+ {
85
+ ImageIcon icon = GetIcon(name);
86
+ if (icon != null || name.contains("/"))
87
+ return new cButton(icon, border);
88
+ else
89
+ return new cButton(name, border);
90
+ }
91
+
92
+ cLabel GetLabel(String name, boolean border)
93
+ {
94
+ //ImageIcon icon = GetIcon(name);
95
+ return new cLabel(GetImage(name), border);
96
+ }
97
+
98
+ cToggleButton GetToggleButton(String name, boolean border)
99
+ {
100
+ ImageIcon icon = GetIcon(name);
101
+ return new cToggleButton(icon, border);
102
+ }
103
+
104
+ cCheckBox GetCheckBox(String name, boolean border)
105
+ {
106
+ ImageIcon icon = GetIcon(name);
107
+ return new cCheckBox(icon, border);
108
+ }
109
+
110
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
111
+
112
+ static ImageIcon GetIcon(String name)
113
+ {
114
+ javax.swing.ImageIcon iconCache = icons.get(name);
115
+ if (iconCache != null)
116
+ {
117
+ return iconCache;
118
+ }
119
+
120
+ try
121
+ {
122
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
123
+
124
+// if (image.getWidth() > 48 && image.getHeight() > 48)
125
+// {
126
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
127
+// Graphics2D g = resized.createGraphics();
128
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
129
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
130
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
131
+// g.dispose();
132
+//
133
+// image = resized;
134
+// }
135
+
136
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
137
+
138
+ icons.put(name, icon);
139
+
140
+ return icon;
141
+ }
142
+ catch (Exception e)
143
+ {
144
+ //icons.put(name, null);
145
+ return null;
146
+ }
147
+ }
148
+
149
+ BufferedImage GetImage(String name)
150
+ {
151
+ try
152
+ {
153
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
154
+
155
+ return image;
156
+ }
157
+ catch (Exception e)
158
+ {
159
+ return null;
160
+ }
161
+ }
38162
39163 // SCRIPT
40164
....@@ -143,7 +267,9 @@
143267 //nameField.removeActionListener(this);
144268 // objEditor.ctrlPanel.remove(nameField);
145269
146
- if (!GroupEditor.allparams)
270
+ objEditor.ctrlPanel.remove(namePanel);
271
+
272
+ if (!allparams)
147273 return;
148274
149275 // objEditor.ctrlPanel.remove(liveCB);
....@@ -165,9 +291,9 @@
165291 // objEditor.ctrlPanel.remove(fasterButton);
166292 // objEditor.ctrlPanel.remove(remarkButton);
167293
168
- objEditor.ctrlPanel.remove(namePanel);
169294 objEditor.ctrlPanel.remove(setupPanel);
170
- objEditor.ctrlPanel.remove(commandsPanel);
295
+ objEditor.ctrlPanel.remove(setupPanel2);
296
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
171297 objEditor.ctrlPanel.remove(pushPanel);
172298 //objEditor.ctrlPanel.remove(fillPanel);
173299
....@@ -215,6 +341,14 @@
215341 client = inClient;
216342 copy = client;
217343
344
+// if (copy.versionlist == null)
345
+// {
346
+// copy.versionlist = new Object3D[100];
347
+// copy.versionindex = -1;
348
+//
349
+// callee.Save(true);
350
+// }
351
+
218352 // "this" is not called: SetupUI2(objEditor);
219353 }
220354
....@@ -228,6 +362,14 @@
228362 client = inClient;
229363 copy = client;
230364
365
+ if (copy.versionlist == null)
366
+ {
367
+ copy.versionlist = new Object3D[100];
368
+ copy.versionindex = -1;
369
+
370
+// Save(true);
371
+ }
372
+
231373 SetupUI2(callee.GetEditor());
232374 }
233375
....@@ -242,13 +384,15 @@
242384 //localCopy.parent = null;
243385
244386 frame = new JFrame();
387
+ frame.setUndecorated(false);
245388 objEditor = this;
246389 this.callee = callee;
247390
248391 //parent = p;
249392
250393 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
251
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
394
+ if (Globals.DEBUG)
395
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
252396 //gd.setFullScreenWindow(this);
253397 //setResizable(false);
254398 //if (!isDisplayable())
....@@ -259,6 +403,14 @@
259403 copy = localCopy;
260404 copy.editWindow = this;
261405
406
+// if (copy.versionlist == null)
407
+// {
408
+// copy.versionlist = new Object3D[100];
409
+// copy.versionindex = -1;
410
+//
411
+// Save(true);
412
+// }
413
+
262414 SetupMenu();
263415
264416 //SetupName(objEditor); // new
....@@ -272,28 +424,52 @@
272424 return frame.action(event, obj);
273425 }
274426
427
+ // Cannot work without static
428
+ static boolean allparams = true;
429
+
430
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
431
+
432
+ // This is to refresh the UI of the material panel.
433
+ boolean patchMaterial;
434
+
275435 void SetupMenu()
276436 {
277437 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..."));
438
+ menuBar.add(fileMenu = new Menu("File"));
439
+ fileMenu.add(newItem = new MenuItem("New"));
440
+ fileMenu.add(openItem = new MenuItem("Open..."));
441
+
442
+ //oe.menuBar.add(menu = new Menu("Include"));
443
+ Menu menu = new Menu("Import");
444
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
445
+ importOBJItem.addActionListener(this);
446
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
447
+ import3DSItem.addActionListener(this);
448
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
449
+ importVRMLX3DItem.addActionListener(this);
450
+ menu.add("-");
451
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
452
+ importGFDItem.addActionListener(this);
453
+ fileMenu.add(menu);
454
+ fileMenu.add("-");
455
+
456
+ fileMenu.add(saveItem = new MenuItem("Save"));
457
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
283458 //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("-");
459
+ fileMenu.add("-");
460
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
461
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
462
+ fileMenu.add("-");
288463 if (client.parent != null)
289464 {
290
- windowMenu.add(closeItem = new MenuItem("Close"));
465
+ fileMenu.add(closeItem = new MenuItem("Close"));
291466 } else
292467 {
293
- windowMenu.add(closeItem = new MenuItem("Exit"));
468
+ fileMenu.add(closeItem = new MenuItem("Exit"));
294469 }
295470
296
- loadItem.addActionListener(this);
471
+ newItem.addActionListener(this);
472
+ openItem.addActionListener(this);
297473 saveItem.addActionListener(this);
298474 saveAsItem.addActionListener(this);
299475 exportAsItem.addActionListener(this);
....@@ -301,84 +477,103 @@
301477 //povItem.addActionListener(this);
302478 closeItem.addActionListener(this);
303479
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
-
359480 objectPanel = new JTabbedPane();
481
+
482
+ ChangeListener changeListener = new ChangeListener()
483
+ {
484
+ //String name;
485
+
486
+ public void stateChanged(ChangeEvent changeEvent)
487
+ {
488
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
489
+// {
490
+// if (latestObject != null)
491
+// {
492
+// refreshContents(true);
493
+// SetMaterial(latestObject);
494
+// }
495
+//
496
+// materialFlushed = true;
497
+// }
498
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
499
+// {
500
+// if (listUI.size() == 0)
501
+// EditSelection(false);
502
+// }
503
+
504
+// if (objectPanel.getSelectedIndex() == 4)
505
+// {
506
+// name = copy.skyboxname;
507
+//
508
+// if (name == null)
509
+// {
510
+// name = "";
511
+// }
512
+//
513
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
514
+// copy.skyboxext = "jpg";
515
+// }
516
+// else
517
+// {
518
+// if (name != null)
519
+// {
520
+// if (name.equals(""))
521
+// {
522
+// copy.skyboxname = null;
523
+// copy.skyboxext = null;
524
+// }
525
+// else
526
+// {
527
+// copy.skyboxname = name;
528
+// }
529
+// }
530
+// }
531
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
532
+
533
+// refreshContents(false); // To refresh Info tab
534
+ cameraView.repaint();
535
+ }
536
+ };
537
+ objectPanel.addChangeListener(changeListener);
538
+
360539 toolbarPanel = new JPanel();
361540 toolbarPanel.setName("Toolbar");
541
+
362542 treePanel = new cGridBag();
363543 treePanel.setName("Tree");
544
+
545
+ editPanel = new cGridBag().setVertical(true);
546
+ //editPanel.setName("Edit");
547
+
364548 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
365
- ctrlPanel.setName("Edit");
366
- materialPanel = new cGridBag().setVertical(true);
367
- materialPanel.setName("Material");
549
+
550
+ editCommandsPanel = new cGridBag();
551
+ editPanel.add(editCommandsPanel);
552
+ editPanel.add(ctrlPanel);
553
+
554
+ toolboxPanel = new cGridBag().setVertical(true);
555
+ //toolboxPanel.setName("Toolbox");
556
+
557
+ skyboxPanel = new cGridBag().setVertical(true);
558
+
559
+ materialPanel = new cGridBag().setVertical(false);
560
+ //materialPanel.setName("Material");
561
+
368562 /*JTextPane*/
369563 infoarea = createTextPane();
370564 doc = infoarea.getStyledDocument();
371565
372566 infoarea.setEditable(true);
373567 SetText();
568
+
374569 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
375570 // infoarea.setOpaque(false);
376571 // //infoarea.setForeground(textcolor);
377572 // TEXTAREA infoarea.setLineWrap(true);
378573 // TEXTAREA infoarea.setWrapStyleWord(true);
379574 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
380
- infoPanel.setPreferredSize(new Dimension(50, 200));
381
- infoPanel.setName("Info");
575
+ infoPanel.setPreferredSize(new Dimension(1, 1));
576
+ //infoPanel.setName("Info");
382577 //infoPanel.setLayout(new BorderLayout());
383578 //infoPanel.add(createTextPane());
384579
....@@ -389,7 +584,14 @@
389584 mainPanel.setDividerSize(9);
390585 mainPanel.setDividerLocation(0.5); //1.0);
391586 mainPanel.setResizeWeight(0.5);
392
-
587
+
588
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
589
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
590
+ divider.setDividerSize(15);
591
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
592
+
593
+ mainPanel.setUI(new BasicSplitPaneUI());
594
+
393595 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
394596 //mainPanel.setLayout(new GridBagLayout());
395597 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -457,10 +659,10 @@
457659 e.printStackTrace();
458660 }
459661
460
- String selection = infoarea.getText();
461
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
462
- java.awt.datatransfer.Clipboard clipboard =
463
- Toolkit.getDefaultToolkit().getSystemClipboard();
662
+// String selection = infoarea.getText();
663
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
664
+// java.awt.datatransfer.Clipboard clipboard =
665
+// Toolkit.getDefaultToolkit().getSystemClipboard();
464666 //clipboard.setContents(data, data);
465667 }
466668
....@@ -483,13 +685,13 @@
483685 //SendInfo("Name:", "bold");
484686 if (sel.GetTextures() != null || debug)
485687 {
486
- si.SendInfo(sel.toString(), "bold");
688
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
487689 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
488690 if (sel.Size() > 0)
489691 {
490692 si.SendInfo("#children = " + sel.Size(), "regular");
491693 }
492
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
694
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
493695 if (debug)
494696 {
495697 try
....@@ -531,7 +733,7 @@
531733 }
532734 if (sel.support != null)
533735 {
534
- si.SendInfo(" support: " + sel.support, "regular");
736
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
535737 }
536738 if (sel.scriptnode != null)
537739 {
....@@ -620,21 +822,169 @@
620822 }
621823 }
622824
825
+//static GraphicsDevice device = GraphicsEnvironment
826
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
827
+
828
+ Rectangle keeprect;
829
+ cRadio radio;
830
+
831
+cButton keepButton;
832
+ cButton twoButton; // Full 3D
833
+ cButton sixButton;
834
+ cButton threeButton;
835
+ cButton sevenButton;
836
+ cButton fourButton; // full panel
837
+ cButton oneButton; // full XYZ
838
+ //cButton currentLayout;
839
+
840
+ boolean maximized;
841
+
842
+ cButton fullscreenLayout;
843
+ cButton expandedLayout;
844
+
845
+ void Minimize()
846
+ {
847
+ frame.setState(Frame.ICONIFIED);
848
+ frame.validate();
849
+ }
850
+
851
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
852
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
853
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
854
+ void Maximize()
855
+ {
856
+ if (CameraPane.FULLSCREEN)
857
+ {
858
+ ToggleFullScreen();
859
+ }
860
+
861
+ if (maximized)
862
+ {
863
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
864
+ }
865
+ else
866
+ {
867
+ keeprect = frame.getBounds();
868
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
869
+// Dimension rect2 = frame.getToolkit().getScreenSize();
870
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
871
+// frame.setState(Frame.MAXIMIZED_BOTH);
872
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
873
+ }
874
+
875
+ maximized ^= true;
876
+
877
+ frame.validate();
878
+ }
879
+
880
+ cButton minButton;
881
+ cButton maxButton;
882
+ cButton fullButton;
883
+ cButton collapseButton;
884
+ cButton maximize3DButton;
885
+
623886 void ToggleFullScreen()
624887 {
625
- if (CameraPane.FULLSCREEN)
888
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
889
+
890
+ cameraView.ToggleFullScreen();
891
+
892
+ if (!CameraPane.FULLSCREEN)
626893 {
627
- frame.getContentPane().remove(/*"Center",*/bigThree);
628
- framePanel.add(bigThree);
629
- frame.getContentPane().add(/*"Center",*/framePanel);
894
+ device.setFullScreenWindow(null);
895
+ frame.dispose();
896
+ frame.setUndecorated(false);
897
+ frame.validate();
898
+ frame.setVisible(true);
899
+
900
+ //frame.setVisible(false);
901
+// frame.removeNotify();
902
+// frame.setUndecorated(false);
903
+// frame.addNotify();
904
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
905
+
906
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
907
+// X framePanel.add(bigThree);
908
+// X frame.getContentPane().add(/*"Center",*/framePanel);
909
+// framePanel.setDividerLocation(46); // icons are 24x24
910
+
911
+ //frame.setVisible(true);
912
+// radio.layout = keepButton;
913
+ //theFrame = null;
914
+ keepButton = null;
915
+// radio.layout.doClick();
916
+
630917 } else
631918 {
632
- frame.getContentPane().remove(/*"Center",*/framePanel);
633
- framePanel.remove(bigThree);
634
- frame.getContentPane().add(/*"Center",*/bigThree);
919
+ keepButton = radio.layout;
920
+ //keeprect = frame.getBounds();
921
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
922
+// frame.getToolkit().getScreenSize().height);
923
+ //frame.setVisible(false);
924
+
925
+ frame.dispose();
926
+ frame.setUndecorated(true);
927
+ device.setFullScreenWindow(frame);
928
+ frame.validate();
929
+ frame.setVisible(true);
930
+// frame.removeNotify();
931
+// frame.setUndecorated(true);
932
+// frame.addNotify();
933
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
934
+// X framePanel.remove(bigThree);
935
+// X frame.getContentPane().add(/*"Center",*/bigThree);
936
+// framePanel.setDividerLocation(0);
937
+
938
+// radio.layout = fullscreenLayout;
939
+// radio.layout.doClick();
940
+ //frame.setVisible(true);
635941 }
636
- cameraView.ToggleFullScreen();
942
+ frame.validate();
943
+
944
+ cameraView.requestFocusInWindow();
637945 }
946
+
947
+ void CollapseToolbar()
948
+ {
949
+ framePanel.setDividerLocation(0);
950
+ //frame.validate();
951
+
952
+ cameraView.requestFocusInWindow();
953
+ }
954
+
955
+ private Object3D Duplicate(Object3D object)
956
+ {
957
+ boolean temp = CameraPane.SWITCH;
958
+ CameraPane.SWITCH = false;
959
+
960
+ if (Grafreed.grafreed.universe.versiontable == null)
961
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
962
+
963
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
964
+ // if (copy == client)
965
+
966
+ Object3D versions[] = object.versionlist;
967
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
968
+ object.versionlist = null;
969
+ object.versiontable = null;
970
+
971
+ Object3D parent = object.parent;
972
+ object.parent = null;
973
+
974
+ //byte[] compress = Compress(copy);
975
+ Object3D compress = (Object3D)Grafreed.clone(object);
976
+
977
+ object.parent = parent;
978
+
979
+ object.versionlist = versions;
980
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
981
+
982
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
983
+
984
+ CameraPane.SWITCH = temp;
985
+
986
+ return compress;
987
+ }
638988
639989 private JTextPane createTextPane()
640990 {
....@@ -734,7 +1084,7 @@
7341084 protected static ImageIcon createImageIcon(String path,
7351085 String description)
7361086 {
737
- java.net.URL imgURL = GrafreeD.class.getResource(path);
1087
+ java.net.URL imgURL = Grafreed.class.getResource(path);
7381088 if (imgURL != null)
7391089 {
7401090 return new ImageIcon(imgURL, description);
....@@ -757,6 +1107,7 @@
7571107 {
7581108 SetupMaterial(materialPanel);
7591109 }
1110
+
7601111 //SetupName();
7611112 //SetupViews();
7621113 }
....@@ -766,6 +1117,7 @@
7661117 // NumberSlider vDivsField;
7671118 // JCheckBox endcaps;
7681119 JCheckBox liveCB;
1120
+ JCheckBox selectableCB;
7691121 JCheckBox hideCB;
7701122 JCheckBox link2masterCB;
7711123 JCheckBox markCB;
....@@ -773,7 +1125,12 @@
7731125 JCheckBox speedupCB;
7741126 JCheckBox rewindCB;
7751127 JCheckBox flipVCB;
1128
+
1129
+ cCheckBox toggleTextureCB;
1130
+ cCheckBox toggleSwitchCB;
1131
+
7761132 JComboBox texresMenu;
1133
+
7771134 JButton resetButton;
7781135 JButton stepButton;
7791136 JButton stepAllButton;
....@@ -782,9 +1139,13 @@
7821139 JButton fasterButton;
7831140 JButton remarkButton;
7841141
1142
+ cGridBag editPanel;
1143
+ cGridBag editCommandsPanel;
1144
+
7851145 cGridBag namePanel;
7861146 cGridBag setupPanel;
787
- cGridBag commandsPanel;
1147
+ cGridBag setupPanel2;
1148
+ cGridBag objectCommandsPanel;
7881149 cGridBag pushPanel;
7891150 cGridBag fillPanel;
7901151
....@@ -951,52 +1312,88 @@
9511312
9521313 void SetupUI2(ObjEditor oe)
9531314 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
9581315 //SetupName(oe);
9591316
9601317 namePanel = new cGridBag();
9611318
1319
+ //if (copy.pinned)
1320
+ {
1321
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
1322
+ pinButton.setSelected(copy.pinned);
1323
+ cGridBag t = new cGridBag();
1324
+ t.preferredWidth = 2;
1325
+ t.add(pinButton);
1326
+ namePanel.add(t);
1327
+
1328
+ pinButton.addItemListener(this);
1329
+ }
1330
+
9621331 nameField = AddText(namePanel, copy.GetName());
963
- namePanel.add(nameField);
1332
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9641333 oe.ctrlPanel.add(namePanel);
9651334
9661335 oe.ctrlPanel.Return();
9671336
968
- if (!GroupEditor.allparams)
1337
+ if (!allparams)
9691338 return;
9701339
9711340 setupPanel = new cGridBag().setVertical(false);
9721341
9731342 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
974
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
975
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1343
+ liveCB.setToolTipText("Animate object");
1344
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1345
+ markCB.setToolTipText("Set target transform");
1346
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1347
+ selectableCB.setToolTipText("Make object selectable");
9761348 // Return();
977
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
978
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
979
- randomCB = AddCheckBox(setupPanel, "Rand", copy.random);
1349
+
1350
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1351
+ hideCB.setToolTipText("Hide object");
1352
+
1353
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1354
+
1355
+ setupPanel2 = new cGridBag().setVertical(false);
1356
+
1357
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1358
+ rewindCB.setToolTipText("Rewind animation");
1359
+
1360
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1361
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9801362
1363
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1364
+ link2masterCB.setToolTipText("Attach to support");
1365
+
1366
+ if (Globals.ADVANCED)
1367
+ {
1368
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1369
+ speedupCB.setToolTipText("Option motion capture");
1370
+ }
1371
+
9811372 oe.ctrlPanel.add(setupPanel);
9821373 oe.ctrlPanel.Return();
1374
+ oe.ctrlPanel.add(setupPanel2);
1375
+ oe.ctrlPanel.Return();
9831376
984
- commandsPanel = new cGridBag().setVertical(false);
1377
+ objectCommandsPanel = new cGridBag().setVertical(false);
9851378
986
- resetButton = AddButton(commandsPanel, "Reset");
987
- stepButton = AddButton(commandsPanel, "Step");
1379
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1380
+ resetButton.setToolTipText("Jump to frame zero");
1381
+ stepButton = AddButton(objectCommandsPanel, "Step");
1382
+ stepButton.setToolTipText("Step one frame");
9881383 // resetAllButton = AddButton(oe, "Reset All");
9891384 // stepAllButton = AddButton(oe, "Step All");
990
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
9911385 // Return();
992
- slowerButton = AddButton(commandsPanel, "Slow");
993
- fasterButton = AddButton(commandsPanel, "Fast");
994
- remarkButton = AddButton(commandsPanel, "Remark");
1386
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1387
+ slowerButton.setToolTipText("Decrease animation speed");
1388
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1389
+ fasterButton.setToolTipText("Increase animation speed");
1390
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1391
+ remarkButton.setToolTipText("Set the current transform as the target");
9951392
996
- oe.ctrlPanel.add(commandsPanel);
1393
+ oe.ctrlPanel.add(objectCommandsPanel);
9971394 oe.ctrlPanel.Return();
9981395
999
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1396
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
10001397 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
10011398 //Return();
10021399
....@@ -1153,6 +1550,7 @@
11531550
11541551 if (cam == null || !(copy.get(0) instanceof cGroup))
11551552 {
1553
+ if (Globals.DEBUG)
11561554 System.out.println("CREATE CAMERAS");
11571555 cams = new cTemplate();
11581556 cams.name = "Cameras";
....@@ -1199,8 +1597,11 @@
11991597 //worldPanel.setName("World");
12001598 centralPanel = new cGridBag();
12011599 centralPanel.preferredWidth = 20;
1202
- timelinePanel = new JPanel(new BorderLayout());
1203
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1600
+
1601
+ if (Globals.ADVANCED)
1602
+ {
1603
+ timelinePanel = new JPanel(new BorderLayout());
1604
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
12041605
12051606 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
12061607 cameraPanel.setContinuousLayout(true);
....@@ -1209,7 +1610,10 @@
12091610 // cameraPanel.setDividerSize(9);
12101611 cameraPanel.setResizeWeight(1.0);
12111612
1613
+ }
1614
+
12121615 centralPanel.add(cameraView);
1616
+ centralPanel.setFocusable(true);
12131617 //frame.setJMenuBar(timelineMenubar);
12141618 //centralPanel.add(timelinePanel);
12151619
....@@ -1228,6 +1632,45 @@
12281632 //frontView.object = copy;
12291633 //sideView.object = copy;
12301634
1635
+ transformPanel = new cGridBag().setVertical(true);
1636
+
1637
+ cGridBag resetTransformPanel = new cGridBag();
1638
+
1639
+ resetTransformPanel.preferredHeight = 2;
1640
+
1641
+ cButton resetTransform = GetButton("Reset all", !Globals.NIMBUSLAF);
1642
+ resetTransform.setToolTipText("Reset Translation, Rotation and Scale");
1643
+ resetTransform.addMouseListener(new MouseAdapter()
1644
+ {
1645
+ public void mouseClicked(MouseEvent e)
1646
+ {
1647
+ ResetTransform();
1648
+ }
1649
+ });
1650
+ resetTransformPanel.add(resetTransform);
1651
+
1652
+ resetTransform = GetButton("T only", !Globals.NIMBUSLAF);
1653
+ resetTransform.setToolTipText("Reset Translation only");
1654
+ resetTransform.addMouseListener(new MouseAdapter()
1655
+ {
1656
+ public void mouseClicked(MouseEvent e)
1657
+ {
1658
+ ResetTransform(1);
1659
+ }
1660
+ });
1661
+ resetTransformPanel.add(resetTransform);
1662
+
1663
+ resetTransform = GetButton("RS only", !Globals.NIMBUSLAF);
1664
+ resetTransform.setToolTipText("Reset Rotation and Scale only");
1665
+ resetTransform.addMouseListener(new MouseAdapter()
1666
+ {
1667
+ public void mouseClicked(MouseEvent e)
1668
+ {
1669
+ ResetTransform(2);
1670
+ }
1671
+ });
1672
+ resetTransformPanel.add(resetTransform);
1673
+
12311674 XYZPanel = new cGridBag().setVertical(true);
12321675 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
12331676
....@@ -1235,7 +1678,11 @@
12351678 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12361679 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12371680 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1681
+ //XYZPanel.setName("XYZ");
12381682
1683
+ transformPanel.add(resetTransformPanel);
1684
+ transformPanel.add(XYZPanel);
1685
+
12391686 /*
12401687 gridPanel = new JPanel(); //new BorderLayout());
12411688 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1243,12 +1690,12 @@
12431690 gridPanel.add(cameraView);
12441691 gridPanel.add(XYZPanel);
12451692 */
1246
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1247
- gridPanel.setContinuousLayout(true);
1248
- gridPanel.setOneTouchExpandable(true);
1249
- gridPanel.setDividerLocation(1.0);
1250
- gridPanel.setDividerSize(9);
1251
- gridPanel.setResizeWeight(0.85);
1693
+// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1694
+// gridPanel.setContinuousLayout(true);
1695
+// gridPanel.setOneTouchExpandable(true);
1696
+// gridPanel.setDividerLocation(1.0);
1697
+// gridPanel.setDividerSize(9);
1698
+// gridPanel.setResizeWeight(0.85);
12521699
12531700 // aConstraints.weighty = 0;
12541701 //System.out.println("THIS = " + this);
....@@ -1271,14 +1718,34 @@
12711718
12721719 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12731720 //tmp.setName("Edit");
1721
+ objectPanel.add(toolboxPanel);
1722
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1723
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
1724
+
12741725 objectPanel.add(materialPanel);
1726
+ objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1727
+ objectPanel.setToolTipTextAt(1, "Material");
1728
+
1729
+ objectPanel.add(skyboxPanel);
1730
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1731
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1732
+
12751733 // JPanel north = new JPanel(new BorderLayout());
12761734 // north.setName("Edit");
12771735 // north.add(ctrlPanel, BorderLayout.NORTH);
12781736 // objectPanel.add(north);
1279
- objectPanel.add(ctrlPanel);
1280
- objectPanel.add(infoPanel);
1281
-
1737
+ objectPanel.add(editPanel);
1738
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1739
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1740
+
1741
+ objectPanel.add(transformPanel);
1742
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1743
+ objectPanel.setToolTipTextAt(4, "TRS transform");
1744
+
1745
+ patchMaterial = true;
1746
+ cameraView.patchMaterial = this;
1747
+ objectPanel.setSelectedIndex(1);
1748
+
12821749 /*
12831750 aConstraints.gridx = 0;
12841751 aConstraints.gridwidth = 1;
....@@ -1286,7 +1753,7 @@
12861753 aConstraints.gridy += 1;
12871754 aConstraints.gridwidth = 1;
12881755 mainPanel.add(objectPanel, aConstraints);
1289
- */
1756
+ */
12901757
12911758 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12921759 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1298,22 +1765,62 @@
12981765 scrollpane.addMouseWheelListener(this); // Default not fast enough
12991766
13001767 /*JTabbedPane*/ scenePanel = new cGridBag();
1301
- scenePanel.preferredWidth = 7;
1768
+ scenePanel.preferredWidth = 6;
13021769
13031770 JTabbedPane tabbedPane = new JTabbedPane();
13041771 tabbedPane.add(scrollpane);
13051772
1306
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1307
-
1308
- optionsPanel = new cGridBag().setVertical(true);
1773
+ optionsPanel = new cGridBag().setVertical(false);
13091774
13101775 optionsPanel.setName("Options");
13111776
13121777 AddOptions(optionsPanel); //, aConstraints);
13131778
1779
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1780
+
13141781 tabbedPane.add(optionsPanel);
13151782
13161783 scenePanel.add(tabbedPane);
1784
+
1785
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1786
+ creditsPanel.setName("Credits");
1787
+
1788
+ cLabel ogaLabel = new cLabel(" Most Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1789
+ creditsPanel.add(ogaLabel);
1790
+
1791
+ cButton opengameartButton;
1792
+ creditsPanel.add(opengameartButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1793
+ opengameartButton.setToolTipText("https://opengameart.org");
1794
+
1795
+ opengameartButton.addMouseListener(new MouseAdapter()
1796
+ {
1797
+ public void mouseClicked(MouseEvent e)
1798
+ {
1799
+ try
1800
+ {
1801
+ Desktop.getDesktop().browse(new java.net.URI("https://opengameart.org/"));
1802
+ } catch (Exception e1)
1803
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1804
+ {
1805
+ e1.printStackTrace();
1806
+ }
1807
+ }
1808
+ });
1809
+
1810
+ for (int i=10; --i>=0;)
1811
+ {
1812
+ creditsPanel.add(new cGridBag());
1813
+ }
1814
+
1815
+ tabbedPane.add(creditsPanel);
1816
+ tabbedPane.setToolTipTextAt(3, "Credits");
1817
+
1818
+ if (Globals.ADVANCED)
1819
+ {
1820
+ tabbedPane.add(infoPanel);
1821
+ tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1822
+ tabbedPane.setToolTipTextAt(4, "Information");
1823
+ }
13171824
13181825 /*
13191826 cTree jTree = new cTree(null);
....@@ -1335,13 +1842,13 @@
13351842 jtp.add(tree);
13361843 */
13371844
1338
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1339
- bigPanel.setContinuousLayout(true);
1340
- bigPanel.setOneTouchExpandable(true);
1341
- bigPanel.setDividerLocation(0.8);
1342
- bigPanel.setDividerSize(15);
1343
- bigPanel.setResizeWeight(0.15);
1344
- bigPanel.setName("Scene");
1845
+// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1846
+// bigPanel.setContinuousLayout(true);
1847
+// bigPanel.setOneTouchExpandable(true);
1848
+// bigPanel.setDividerLocation(0.8);
1849
+// bigPanel.setDividerSize(15);
1850
+// bigPanel.setResizeWeight(0.15);
1851
+// bigPanel.setName("Scene");
13451852
13461853 //bigPanel.setLayout(new BorderLayout());
13471854 //bigPanel.setSize(new Dimension(10,10));
....@@ -1376,7 +1883,7 @@
13761883 bigThree = new cGridBag();
13771884 bigThree.addComponent(scenePanel);
13781885 bigThree.addComponent(centralPanel);
1379
- bigThree.addComponent(XYZPanel);
1886
+ //bigThree.addComponent(XYZPanel);
13801887
13811888 // // SIDE EFFECT!!!
13821889 // aConstraints.gridx = 0;
....@@ -1385,16 +1892,33 @@
13851892 // aConstraints.gridheight = 1;
13861893
13871894 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1388
- framePanel.setContinuousLayout(true);
1389
- framePanel.setOneTouchExpandable(true);
1390
- framePanel.setDividerLocation(0.8);
1895
+
1896
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1897
+ new java.beans.PropertyChangeListener()
1898
+ {
1899
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1900
+ {
1901
+ if ((Integer)pce.getOldValue() == 1)
1902
+ {
1903
+ if (radio.layout != expandedLayout)
1904
+ {
1905
+ radio.layout = expandedLayout;
1906
+ radio.layout.doClick();
1907
+ }
1908
+ }
1909
+ }
1910
+ });
1911
+
1912
+ framePanel.setContinuousLayout(false);
1913
+ framePanel.setOneTouchExpandable(false);
1914
+ //.setDividerLocation(0.8);
13911915 //framePanel.setDividerSize(15);
13921916 //framePanel.setResizeWeight(0.15);
13931917 framePanel.setName("Frame");
13941918
13951919 frame.getContentPane().setLayout(new BorderLayout());
13961920 /**/
1397
- JTabbedPane worldPane = new JTabbedPane();
1921
+ //JTabbedPane worldPane = new JTabbedPane();
13981922 //worldPane.add(bigPanel);
13991923 //worldPane.add(worldPanel);
14001924 /**/
....@@ -1404,15 +1928,19 @@
14041928
14051929 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14061930
1407
- frame.setSize(1024, 768);
1408
- frame.show();
1931
+ frame.setSize(1280, 860);
1932
+
1933
+ cameraView.requestFocusInWindow();
1934
+
1935
+// gridPanel.setDividerLocation(1.0);
1936
+
1937
+ frame.validate();
14091938
1410
- gridPanel.setDividerLocation(1.0);
1939
+ frame.setVisible(true);
14111940
14121941 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14131942 frame.addWindowListener(new WindowAdapter()
14141943 {
1415
-
14161944 public void windowClosing(WindowEvent e)
14171945 {
14181946 Close();
....@@ -1435,28 +1963,445 @@
14351963 ctrlPanel.removeAll();
14361964 }
14371965
1438
- void SetupMaterial(cGridBag panel)
1966
+ void SetupMaterial(cGridBag materialpanel)
14391967 {
1440
- /*
1968
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1969
+
1970
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
1971
+ skin.setToolTipText("Skin");
1972
+ skin.addMouseListener(new MouseAdapter()
1973
+ {
1974
+ public void mouseClicked(MouseEvent e)
1975
+ {
1976
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1977
+ cMaterial material = object.material;
1978
+
1979
+ // Skin
1980
+ colorField.setFloat(material.color);
1981
+ float saturation = material.modulation;
1982
+
1983
+ if (!cameraView.Skinshader)
1984
+ {
1985
+ saturation /= 1.5;
1986
+ }
1987
+
1988
+ saturationField.setFloat(saturation);
1989
+
1990
+ subsurfaceField.setFloat(material.subsurface);
1991
+ selfshadowField.setFloat(material.diffuseness);
1992
+ diffusenessField.setFloat(material.factor);
1993
+ shininessField.setFloat(material.shininess);
1994
+ shadowbiasField.setFloat(material.shadowbias);
1995
+ diffuseField.setFloat(material.diffuse);
1996
+ specularField.setFloat(material.specular);
1997
+
1998
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1999
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2000
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2001
+
2002
+ materialtouched = true;
2003
+ applySelf();
2004
+ }
2005
+ });
2006
+ presetpanel.add(skin);
2007
+
2008
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
2009
+ lambert.setToolTipText("Diffuse");
2010
+ lambert.addMouseListener(new MouseAdapter()
2011
+ {
2012
+ public void mouseClicked(MouseEvent e)
2013
+ {
2014
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
2015
+ cMaterial material = object.material;
2016
+
2017
+ diffusenessField.setFloat(material.factor);
2018
+ selfshadowField.setFloat(material.diffuseness);
2019
+
2020
+ materialtouched = true;
2021
+ applySelf();
2022
+ }
2023
+ });
2024
+ presetpanel.add(lambert);
2025
+
2026
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
2027
+ diffuse2.setToolTipText("Diffuse2");
2028
+ diffuse2.addMouseListener(new MouseAdapter()
2029
+ {
2030
+ public void mouseClicked(MouseEvent e)
2031
+ {
2032
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
2033
+ cMaterial material = object.material;
2034
+
2035
+ diffusenessField.setFloat(material.factor);
2036
+ selfshadowField.setFloat(material.diffuseness);
2037
+
2038
+ materialtouched = true;
2039
+ applySelf();
2040
+ }
2041
+ });
2042
+ presetpanel.add(diffuse2);
2043
+
2044
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
2045
+ diffusemoon.setToolTipText("Moon");
2046
+ diffusemoon.addMouseListener(new MouseAdapter()
2047
+ {
2048
+ public void mouseClicked(MouseEvent e)
2049
+ {
2050
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
2051
+ cMaterial material = object.material;
2052
+
2053
+ diffusenessField.setFloat(material.factor);
2054
+ selfshadowField.setFloat(material.diffuseness);
2055
+
2056
+ materialtouched = true;
2057
+ applySelf();
2058
+ }
2059
+ });
2060
+ presetpanel.add(diffusemoon);
2061
+
2062
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
2063
+ diffusemoon2.setToolTipText("Moon2");
2064
+ diffusemoon2.addMouseListener(new MouseAdapter()
2065
+ {
2066
+ public void mouseClicked(MouseEvent e)
2067
+ {
2068
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
2069
+ cMaterial material = object.material;
2070
+
2071
+ diffusenessField.setFloat(material.factor);
2072
+ selfshadowField.setFloat(material.diffuseness);
2073
+
2074
+ materialtouched = true;
2075
+ applySelf();
2076
+ }
2077
+ });
2078
+ presetpanel.add(diffusemoon2);
2079
+
2080
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
2081
+ diffusemoon3.setToolTipText("Moon3");
2082
+ diffusemoon3.addMouseListener(new MouseAdapter()
2083
+ {
2084
+ public void mouseClicked(MouseEvent e)
2085
+ {
2086
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2087
+ cMaterial material = object.material;
2088
+
2089
+ diffusenessField.setFloat(material.factor);
2090
+ selfshadowField.setFloat(material.diffuseness);
2091
+
2092
+ materialtouched = true;
2093
+ applySelf();
2094
+ }
2095
+ });
2096
+ presetpanel.add(diffusemoon3);
2097
+
2098
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
2099
+ diffusesheen.setToolTipText("Sheen");
2100
+ diffusesheen.addMouseListener(new MouseAdapter()
2101
+ {
2102
+ public void mouseClicked(MouseEvent e)
2103
+ {
2104
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2105
+ cMaterial material = object.material;
2106
+
2107
+ sheenField.setFloat(material.sheen);
2108
+
2109
+ materialtouched = true;
2110
+ applySelf();
2111
+ }
2112
+ });
2113
+ presetpanel.add(diffusesheen);
2114
+
2115
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
2116
+ rough.setToolTipText("Rough metal");
2117
+ rough.addMouseListener(new MouseAdapter()
2118
+ {
2119
+ public void mouseClicked(MouseEvent e)
2120
+ {
2121
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2122
+ cMaterial material = object.material;
2123
+
2124
+ shininessField.setFloat(material.shininess);
2125
+ velvetField.setFloat(material.velvet);
2126
+
2127
+ materialtouched = true;
2128
+ applySelf();
2129
+ }
2130
+ });
2131
+ presetpanel.add(rough);
2132
+
2133
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
2134
+ rough2.setToolTipText("Medium metal");
2135
+ rough2.addMouseListener(new MouseAdapter()
2136
+ {
2137
+ public void mouseClicked(MouseEvent e)
2138
+ {
2139
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2140
+ cMaterial material = object.material;
2141
+
2142
+ shininessField.setFloat(material.shininess);
2143
+ lightareaField.setFloat(material.lightarea);
2144
+
2145
+ materialtouched = true;
2146
+ applySelf();
2147
+ }
2148
+ });
2149
+ presetpanel.add(rough2);
2150
+
2151
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
2152
+ shini0.setToolTipText("Shiny");
2153
+ shini0.addMouseListener(new MouseAdapter()
2154
+ {
2155
+ public void mouseClicked(MouseEvent e)
2156
+ {
2157
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2158
+ cMaterial material = object.material;
2159
+
2160
+ shininessField.setFloat(material.shininess);
2161
+ lightareaField.setFloat(material.lightarea);
2162
+
2163
+ materialtouched = true;
2164
+ applySelf();
2165
+ }
2166
+ });
2167
+ presetpanel.add(shini0);
2168
+
2169
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
2170
+ shini1.setToolTipText("Shiny2");
2171
+ shini1.addMouseListener(new MouseAdapter()
2172
+ {
2173
+ public void mouseClicked(MouseEvent e)
2174
+ {
2175
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2176
+ cMaterial material = object.material;
2177
+
2178
+ shininessField.setFloat(material.shininess);
2179
+ lightareaField.setFloat(material.lightarea);
2180
+
2181
+ materialtouched = true;
2182
+ applySelf();
2183
+ }
2184
+ });
2185
+ presetpanel.add(shini1);
2186
+
2187
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
2188
+ shini2.setToolTipText("Shiny3");
2189
+ shini2.addMouseListener(new MouseAdapter()
2190
+ {
2191
+ public void mouseClicked(MouseEvent e)
2192
+ {
2193
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2194
+ cMaterial material = object.material;
2195
+
2196
+ shininessField.setFloat(material.shininess);
2197
+ lightareaField.setFloat(material.lightarea);
2198
+
2199
+ materialtouched = true;
2200
+ applySelf();
2201
+ }
2202
+ });
2203
+ presetpanel.add(shini2);
2204
+
2205
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
2206
+ aniso.setToolTipText("AnisoU");
2207
+ aniso.addMouseListener(new MouseAdapter()
2208
+ {
2209
+ public void mouseClicked(MouseEvent e)
2210
+ {
2211
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2212
+ cMaterial material = object.material;
2213
+
2214
+ anisoField.setFloat(material.aniso);
2215
+ anisoVField.setFloat(material.anisoV);
2216
+
2217
+ materialtouched = true;
2218
+ applySelf();
2219
+ }
2220
+ });
2221
+ presetpanel.add(aniso);
2222
+
2223
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
2224
+ aniso2.setToolTipText("AnisoV");
2225
+ aniso2.addMouseListener(new MouseAdapter()
2226
+ {
2227
+ public void mouseClicked(MouseEvent e)
2228
+ {
2229
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2230
+ cMaterial material = object.material;
2231
+
2232
+ anisoField.setFloat(material.aniso);
2233
+ anisoVField.setFloat(material.anisoV);
2234
+
2235
+ materialtouched = true;
2236
+ applySelf();
2237
+ }
2238
+ });
2239
+ presetpanel.add(aniso2);
2240
+
2241
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
2242
+ aniso3.setToolTipText("AnisoUV");
2243
+ aniso3.addMouseListener(new MouseAdapter()
2244
+ {
2245
+ public void mouseClicked(MouseEvent e)
2246
+ {
2247
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2248
+ cMaterial material = object.material;
2249
+
2250
+ anisoField.setFloat(material.aniso);
2251
+ anisoVField.setFloat(material.anisoV);
2252
+
2253
+ materialtouched = true;
2254
+ applySelf();
2255
+ }
2256
+ });
2257
+ presetpanel.add(aniso3);
2258
+
2259
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
2260
+ velvet0.setToolTipText("Velvet");
2261
+ velvet0.addMouseListener(new MouseAdapter()
2262
+ {
2263
+ public void mouseClicked(MouseEvent e)
2264
+ {
2265
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2266
+ cMaterial material = object.material;
2267
+
2268
+ diffusenessField.setFloat(material.factor);
2269
+ selfshadowField.setFloat(material.diffuseness);
2270
+ sheenField.setFloat(material.sheen);
2271
+ shininessField.setFloat(material.shininess);
2272
+ velvetField.setFloat(material.velvet);
2273
+ shiftField.setFloat(material.shift);
2274
+
2275
+ materialtouched = true;
2276
+ applySelf();
2277
+ }
2278
+ });
2279
+ presetpanel.add(velvet0);
2280
+
2281
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
2282
+ bump0.setToolTipText("Bump texture");
2283
+ bump0.addMouseListener(new MouseAdapter()
2284
+ {
2285
+ public void mouseClicked(MouseEvent e)
2286
+ {
2287
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2288
+ cMaterial material = object.material;
2289
+
2290
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2291
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2292
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2293
+
2294
+ materialtouched = true;
2295
+ applySelf();
2296
+ }
2297
+ });
2298
+ presetpanel.add(bump0);
2299
+
2300
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
2301
+ borderShader.setToolTipText("Border fade");
2302
+ borderShader.addMouseListener(new MouseAdapter()
2303
+ {
2304
+ public void mouseClicked(MouseEvent e)
2305
+ {
2306
+ borderfadeField.setFloat(0.5);
2307
+ opacityField.setFloat(0.75);
2308
+
2309
+ materialtouched = true;
2310
+ applySelf();
2311
+ }
2312
+ });
2313
+ presetpanel.add(borderShader);
2314
+
2315
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
2316
+ halo.setToolTipText("Halo");
2317
+ halo.addMouseListener(new MouseAdapter()
2318
+ {
2319
+ public void mouseClicked(MouseEvent e)
2320
+ {
2321
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2322
+ cMaterial material = object.material;
2323
+
2324
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2325
+
2326
+ materialtouched = true;
2327
+ applySelf();
2328
+ }
2329
+ });
2330
+ presetpanel.add(halo);
2331
+
2332
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
2333
+ candle.setToolTipText("Candle");
2334
+ candle.addMouseListener(new MouseAdapter()
2335
+ {
2336
+ public void mouseClicked(MouseEvent e)
2337
+ {
2338
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2339
+ cMaterial material = object.material;
2340
+
2341
+ subsurfaceField.setFloat(material.subsurface);
2342
+ shadowbiasField.setFloat(material.shadowbias);
2343
+ ambientField.setFloat(material.ambient);
2344
+ specularField.setFloat(material.specular);
2345
+ lightareaField.setFloat(material.lightarea);
2346
+ shininessField.setFloat(material.shininess);
2347
+
2348
+ materialtouched = true;
2349
+ applySelf();
2350
+ }
2351
+ });
2352
+ presetpanel.add(candle);
2353
+
2354
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
2355
+ shadowShader.setToolTipText("Shadow");
2356
+ shadowShader.addMouseListener(new MouseAdapter()
2357
+ {
2358
+ public void mouseClicked(MouseEvent e)
2359
+ {
2360
+ diffuseField.setFloat(0.001);
2361
+ ambientField.setFloat(0.001);
2362
+ cameraField.setFloat(0.001);
2363
+ specularField.setFloat(0.001);
2364
+ fakedepthField.setFloat(0.001);
2365
+ opacityField.setFloat(0.6);
2366
+
2367
+ materialtouched = true;
2368
+ applySelf();
2369
+ }
2370
+ });
2371
+ presetpanel.add(shadowShader);
2372
+
2373
+ cGridBag panel = new cGridBag().setVertical(true);
2374
+
2375
+ presetpanel.preferredWidth = 1;
2376
+
2377
+ materialpanel.add(presetpanel);
2378
+ materialpanel.add(panel);
2379
+
2380
+ panel.preferredWidth = 8;
2381
+
2382
+ /*
14412383 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14422384 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1443
- */
2385
+ */
14442386
14452387 cGridBag editBar = new cGridBag().setVertical(false);
14462388
1447
- editBar.add(createMaterialButton = new cButton("Create", !GrafreeD.NIMBUSLAF)); // , aConstraints);
2389
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
14482390 createMaterialButton.setToolTipText("Create material");
14492391
14502392 /*
14512393 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14522394 */
14532395
1454
- editBar.add(clearMaterialButton = new cButton("Clear", !GrafreeD.NIMBUSLAF)); // , aConstraints);
2396
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
14552397 clearMaterialButton.setToolTipText("Clear material");
14562398
1457
- editBar.add(resetSlidersButton = new cButton("Reset", !GrafreeD.NIMBUSLAF)); // , aConstraints);
1458
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1459
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
2399
+ if (Globals.ADVANCED)
2400
+ {
2401
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
2402
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
2403
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
2404
+ }
14602405
14612406 editBar.preferredHeight = 15;
14622407
....@@ -1471,45 +2416,61 @@
14712416 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14722417
14732418 cGridBag colorSection = new cGridBag().setVertical(true);
2419
+
2420
+ cGridBag huepanel = new cGridBag();
2421
+ cGridBag huelabel = new cGridBag();
2422
+ cLabel hue = GetLabel("icons/hue.png", false);
2423
+ hue.fit = true;
2424
+
2425
+ hue.addMouseListener(new MouseAdapter()
2426
+ {
2427
+ public void mousePressed(MouseEvent e)
2428
+ {
2429
+ int x = e.getX();
2430
+
2431
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2432
+ }
2433
+ });
2434
+
2435
+ huelabel.add(hue);
2436
+ huelabel.preferredWidth = 20;
2437
+ huepanel.add(new cGridBag()); // Label
2438
+ huepanel.add(huelabel); // Field/slider
2439
+
2440
+ huepanel.preferredHeight = 7;
2441
+
2442
+ colorSection.add(huepanel);
14742443
14752444 cGridBag color = new cGridBag();
1476
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1477
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1478
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2445
+
2446
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2447
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2448
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2449
+
14792450 //colorField.preferredWidth = 200;
14802451 colorSection.add(color);
14812452
14822453 cGridBag modulation = new cGridBag();
14832454 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14842455 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1485
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2456
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14862457 colorSection.add(modulation);
14872458
2459
+ cGridBag opacity = new cGridBag();
2460
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2461
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2462
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2463
+ colorSection.add(opacity);
2464
+
2465
+ colorSection.add(GetSeparator());
2466
+
14882467 cGridBag texture = new cGridBag();
14892468 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14902469 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14912470 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14922471 colorSection.add(texture);
14932472
1494
- cGridBag anisoU = new cGridBag();
1495
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1496
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1497
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1498
- colorSection.add(anisoU);
1499
-
1500
- cGridBag anisoV = new cGridBag();
1501
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1502
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1503
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1504
- colorSection.add(anisoV);
1505
-
1506
- cGridBag shadowbias = new cGridBag();
1507
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1508
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1509
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1510
- colorSection.add(shadowbias);
1511
-
1512
- panel.add(new JSeparator());
2473
+ panel.add(GetSeparator());
15132474
15142475 panel.add(colorSection);
15152476
....@@ -1559,7 +2520,13 @@
15592520 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15602521 diffuseSection.add(fakedepth);
15612522
1562
- panel.add(new JSeparator());
2523
+ cGridBag shadowbias = new cGridBag();
2524
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2525
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2526
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2527
+ diffuseSection.add(shadowbias);
2528
+
2529
+ panel.add(GetSeparator());
15632530
15642531 panel.add(diffuseSection);
15652532
....@@ -1609,42 +2576,48 @@
16092576 // aConstraints.gridy += 1;
16102577 // aConstraints.gridwidth = 1;
16112578
2579
+ cGridBag anisoU = new cGridBag();
2580
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2581
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2582
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2583
+ specularSection.add(anisoU);
16122584
1613
- panel.add(new JSeparator());
2585
+ cGridBag anisoV = new cGridBag();
2586
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2587
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2588
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2589
+ specularSection.add(anisoV);
2590
+
2591
+
2592
+ panel.add(GetSeparator());
16142593
16152594 panel.add(specularSection);
16162595
16172596 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16182597
1619
- cGridBag globalSection = new cGridBag().setVertical(true);
2598
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16202599
16212600 cGridBag camera = new cGridBag();
16222601 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16232602 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16242603 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1625
- globalSection.add(camera);
2604
+ colorSection.add(camera);
16262605
16272606 cGridBag ambient = new cGridBag();
16282607 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16292608 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16302609 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1631
- globalSection.add(ambient);
2610
+ colorSection.add(ambient);
16322611
16332612 cGridBag backlit = new cGridBag();
16342613 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16352614 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16362615 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1637
- globalSection.add(backlit);
2616
+ colorSection.add(backlit);
16382617
1639
- cGridBag opacity = new cGridBag();
1640
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1641
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1642
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1643
- globalSection.add(opacity);
1644
-
1645
- panel.add(new JSeparator());
2618
+ //panel.add(new JSeparator());
16462619
1647
- panel.add(globalSection);
2620
+ //panel.add(globalSection);
16482621
16492622 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16502623
....@@ -1686,7 +2659,7 @@
16862659 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16872660 textureSection.add(opacityPower);
16882661
1689
- panel.add(new JSeparator());
2662
+ panel.add(GetSeparator());
16902663
16912664 panel.add(textureSection);
16922665
....@@ -1725,12 +2698,15 @@
17252698 opacityPowerField.addChangeListener(this);
17262699 /**/
17272700
1728
- resetSlidersButton.addActionListener(this);
17292701 clearMaterialButton.addActionListener(this);
17302702 createMaterialButton.addActionListener(this);
1731
-
1732
- propagateToggle.addItemListener(this);
1733
- multiplyToggle.addItemListener(this);
2703
+
2704
+ if (Globals.ADVANCED)
2705
+ {
2706
+ resetSlidersButton.addActionListener(this);
2707
+ propagateToggle.addItemListener(this);
2708
+ multiplyToggle.addItemListener(this);
2709
+ }
17342710 }
17352711
17362712 void DropFile(java.io.File[] files, boolean textures)
....@@ -1748,8 +2724,9 @@
17482724 // 3D models
17492725 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17502726 {
1751
- lastConverter = new com.jmex.model.converters.MaxToJme();
1752
- LoadFile(filename, lastConverter);
2727
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2728
+ //LoadFile(filename, lastConverter);
2729
+ LoadObjFile(filename); // New 3ds loader
17532730 continue;
17542731 }
17552732 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1901,7 +2878,7 @@
19012878
19022879 //? flashIt = false;
19032880 CameraPane pane = (CameraPane) cameraView;
1904
- pane.clickStart(location.x, location.y, 0);
2881
+ pane.clickStart(location.x, location.y, 0, 0);
19052882 pane.clickEnd(location.x, location.y, 0, true);
19062883
19072884 if (group.selection.size() == 1)
....@@ -1950,6 +2927,7 @@
19502927 e2.printStackTrace();
19512928 }
19522929 }
2930
+
19532931 LoadJMEThread loadThread;
19542932
19552933 class LoadJMEThread extends Thread
....@@ -2007,6 +2985,7 @@
20072985 //LoadFile0(filename, converter);
20082986 }
20092987 }
2988
+
20102989 LoadOBJThread loadObjThread;
20112990
20122991 class LoadOBJThread extends Thread
....@@ -2085,19 +3064,19 @@
20853064
20863065 void LoadObjFile(String fullname)
20873066 {
2088
- /*
3067
+ System.out.println("Loading " + fullname);
3068
+ /**/
20893069 //lastFilename = fullname;
20903070 if(loadObjThread == null)
20913071 {
2092
- loadObjThread = new LoadOBJThread();
2093
- loadObjThread.start();
3072
+ loadObjThread = new LoadOBJThread();
3073
+ loadObjThread.start();
20943074 }
20953075
20963076 loadObjThread.add(fullname);
2097
- */
3077
+ /**/
20983078
2099
- System.out.println("Loading " + fullname);
2100
- makeSomething(new FileObject(fullname, true), true);
3079
+ //makeSomething(new FileObject(fullname, true), true);
21013080 }
21023081
21033082 void LoadGFDFile(String fullname)
....@@ -2358,11 +3337,11 @@
23583337
23593338 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23603339 {
2361
- if (GrafreeD.standAlone)
3340
+ if (Grafreed.standAlone)
23623341 {
23633342 /**/
23643343 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2365
- browser.show();
3344
+ browser.setVisible(true);
23663345 String filename = browser.getFile();
23673346 if (filename != null && filename.length() > 0)
23683347 {
....@@ -2473,6 +3452,7 @@
24733452 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24743453 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24753454 }
3455
+
24763456 //cJME.count++;
24773457 //cJME.count %= 12;
24783458 if (gc)
....@@ -2656,6 +3636,7 @@
26563636 }
26573637 }
26583638 }
3639
+
26593640 cFileSystemPane FSPane;
26603641
26613642 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2665,7 +3646,7 @@
26653646
26663647 freezematerial = true;
26673648 colorField.setFloat(mat.color);
2668
- modulationField.setFloat(mat.modulation);
3649
+ saturationField.setFloat(mat.modulation);
26693650 metalnessField.setFloat(mat.metalness);
26703651 diffuseField.setFloat(mat.diffuse);
26713652 specularField.setFloat(mat.specular);
....@@ -2709,11 +3690,14 @@
27093690 }
27103691 }
27113692 }
3693
+
27123694 freezematerial = false;
27133695 }
27143696
27153697 void SetMaterial(Object3D object)
27163698 {
3699
+ latestObject = object;
3700
+
27173701 cMaterial mat = object.material;
27183702
27193703 if (mat == null)
....@@ -2722,33 +3706,10 @@
27223706 return;
27233707 }
27243708
2725
- multiplyToggle.setSelected(mat.multiply);
2726
-
2727
- assert (object.projectedVertices != null);
2728
-
2729
- if (object.projectedVertices.length <= 2)
2730
- {
2731
- // Side effect...
2732
- Object3D.cVector2[] keep = object.projectedVertices;
2733
- object.projectedVertices = new Object3D.cVector2[3];
2734
- for (int i = 0; i < 3; i++)
2735
- {
2736
- if (i < keep.length)
2737
- {
2738
- object.projectedVertices[i] = keep[i];
2739
- } else
2740
- {
2741
- object.projectedVertices[i] = new Object3D.cVector2();
2742
- }
2743
- /*
2744
- if(keep.length == 0)
2745
- object.projectedVertices[0] = new Object3D.cVector2();
2746
- else
2747
- object.projectedVertices[0] = keep[0];
2748
- object.projectedVertices[1] = new Object3D.cVector2();
2749
- */
2750
- }
2751
- }
3709
+ if (multiplyToggle != null)
3710
+ multiplyToggle.setSelected(mat.multiply);
3711
+
3712
+ AllocProjectedVertices(object);
27523713
27533714 SetMaterial(mat, object.projectedVertices);
27543715 }
....@@ -2824,12 +3785,17 @@
28243785 // }
28253786
28263787 /**/
2827
- if (deselect)
3788
+ if (deselect || child == null)
28283789 {
28293790 //group.deselectAll();
28303791 //freeze = true;
28313792 GetTree().clearSelection();
28323793 //freeze = false;
3794
+
3795
+ if (child == null)
3796
+ {
3797
+ return;
3798
+ }
28333799 }
28343800
28353801 //group.addSelectee(child);
....@@ -2863,6 +3829,17 @@
28633829 public void itemStateChanged(ItemEvent event)
28643830 {
28653831 // System.out.println("Propagate = " + propagate);
3832
+ if (event.getSource() == pinButton)
3833
+ {
3834
+ copy.pinned ^= true;
3835
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3836
+ {
3837
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3838
+ copy.CloseUI();
3839
+ //copy.editWindow.refreshContents();
3840
+ }
3841
+ }
3842
+ else
28663843 if (event.getSource() == propagateToggle)
28673844 {
28683845 propagate ^= true;
....@@ -2898,7 +3875,7 @@
28983875 cameraView.ToggleDL();
28993876 cameraView.repaint();
29003877 return;
2901
- } else if (event.getSource() == toggleTextureItem)
3878
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29023879 {
29033880 cameraView.ToggleTexture();
29043881 // june 2013 copy.HardTouch();
....@@ -2937,9 +3914,9 @@
29373914 frame.validate();
29383915
29393916 return;
2940
- } else if (event.getSource() == toggleRandomItem)
3917
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29413918 {
2942
- cameraView.ToggleRandom();
3919
+ cameraView.ToggleSwitch();
29433920 cameraView.repaint();
29443921 return;
29453922 } else if (event.getSource() == toggleHandleItem)
....@@ -2967,12 +3944,17 @@
29673944 } else if (event.getSource() == liveCB)
29683945 {
29693946 copy.live ^= true;
3947
+ objEditor.refreshContents(true); // To show item colors
3948
+ return;
3949
+ } else if (event.getSource() == selectableCB)
3950
+ {
3951
+ copy.dontselect ^= true;
29703952 return;
29713953 } else if (event.getSource() == hideCB)
29723954 {
29733955 copy.hide ^= true;
29743956 copy.Touch(); // display list issue
2975
- objEditor.refreshContents();
3957
+ objEditor.refreshContents(true); // To show item colors
29763958 return;
29773959 } else if (event.getSource() == link2masterCB)
29783960 {
....@@ -2982,6 +3964,7 @@
29823964 if (event.getSource() == randomCB)
29833965 {
29843966 copy.random ^= true;
3967
+ objEditor.refreshContents();
29853968 return;
29863969 }
29873970 if (event.getSource() == speedupCB)
....@@ -3005,8 +3988,9 @@
30053988
30063989 public void actionPerformed(ActionEvent event)
30073990 {
3991
+ Object source = event.getSource();
30083992 // SCRIPT DIALOG
3009
- if (event.getSource() == okbutton)
3993
+ if (source == okbutton)
30103994 {
30113995 textpanel.setVisible(false);
30123996 textpanel.remove(textarea);
....@@ -3018,7 +4002,7 @@
30184002 textarea = null;
30194003 textpanel = null;
30204004 }
3021
- if (event.getSource() == cancelbutton)
4005
+ if (source == cancelbutton)
30224006 {
30234007 textpanel.setVisible(false);
30244008 textpanel.remove(textarea);
....@@ -3030,50 +4014,50 @@
30304014 //applySelf();
30314015 //client.refreshEditWindow();
30324016 //refreshContents();
3033
- if (event.getSource() == nameField)
4017
+ if (source == nameField)
30344018 {
30354019 //System.out.println("ObjEditor " + event);
30364020 applySelf0(true);
30374021 //parent.applySelf();
3038
- objEditor.refreshContents();
3039
- } else if (event.getSource() == resetButton)
4022
+ // conflicts with requestFocus objEditor.refreshContents();
4023
+ } else if (source == resetButton)
30404024 {
30414025 CameraPane.fullreset = true;
30424026 copy.Reset(); // ResetMeshes();
30434027 copy.Touch();
30444028 objEditor.refreshContents();
3045
- } else if (event.getSource() == stepItem)
4029
+ } else if (source == stepItem)
30464030 {
30474031 //cameraView.ONESTEP = true;
30484032 Globals.ONESTEP = true;
30494033 cameraView.repaint();
30504034 return;
3051
- } else if (event.getSource() == stepButton)
4035
+ } else if (source == stepButton)
30524036 {
30534037 copy.Step();
30544038 copy.Touch();
30554039 objEditor.refreshContents();
3056
- } else if (event.getSource() == slowerButton)
4040
+ } else if (source == slowerButton)
30574041 {
30584042 copy.Slower();
30594043 copy.Touch();
30604044 objEditor.refreshContents();
3061
- } else if (event.getSource() == fasterButton)
4045
+ } else if (source == fasterButton)
30624046 {
30634047 copy.Faster();
30644048 copy.Touch();
30654049 objEditor.refreshContents();
3066
- } else if (event.getSource() == remarkButton)
4050
+ } else if (source == remarkButton)
30674051 {
30684052 copy.Remark();
30694053 copy.Touch();
30704054 objEditor.refreshContents();
3071
- } else if (event.getSource() == stepAllButton)
4055
+ } else if (source == stepAllButton)
30724056 {
30734057 copy.StepAll();
30744058 copy.Touch();
30754059 objEditor.refreshContents();
3076
- } else if (event.getSource() == resetAllButton)
4060
+ } else if (source == resetAllButton)
30774061 {
30784062 //CameraPane.fullreset = true;
30794063 copy.ResetAll(); // ResetMeshes();
....@@ -3106,53 +4090,79 @@
31064090 // Close();
31074091 // }
31084092 // else
3109
- if (event.getSource() == resetSlidersButton)
4093
+ if (source == resetSlidersButton)
31104094 {
31114095 ResetSliders();
3112
- } else if (event.getSource() == clearMaterialButton)
4096
+ } else if (source == clearMaterialButton)
31134097 {
31144098 ClearMaterial();
3115
- } else if (event.getSource() == createMaterialButton)
4099
+ } else if (source == createMaterialButton)
31164100 {
31174101 CreateMaterial();
3118
- } else if (event.getSource() == clearPanelButton)
4102
+ } else if (source == clearPanelButton)
31194103 {
31204104 copy.ClearUI();
31214105 refreshContents(true);
3122
- } /*
3123
- }
3124
-
3125
- public boolean action(Event event, Object arg)
3126
- {
3127
- */ else if (event.getSource() == closeItem)
4106
+ } else if (source == importGFDItem)
4107
+ {
4108
+ ImportGFD();
4109
+ } else
4110
+ if (source == importVRMLX3DItem)
4111
+ {
4112
+ ImportVRMLX3D();
4113
+ } else
4114
+ if (source == import3DSItem)
4115
+ {
4116
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
4117
+ } else
4118
+ if (source == importOBJItem)
4119
+ {
4120
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
4121
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
4122
+ browser.setVisible(true);
4123
+ String filename = browser.getFile();
4124
+ if (filename != null && filename.length() > 0)
4125
+ {
4126
+ String fullname = browser.getDirectory() + filename;
4127
+ makeSomething(ReadOBJ(fullname), true);
4128
+ }
4129
+ } else
4130
+ if (source == closeItem)
31284131 {
31294132 Close();
31304133 //return true;
3131
- } else if (event.getSource() == loadItem)
4134
+ } else if (source == openItem)
31324135 {
3133
- load();
4136
+ Open();
31344137 //return true;
3135
- } else if (event.getSource() == saveItem)
4138
+ } else if (source == newItem)
4139
+ {
4140
+ New();
4141
+ } else if (source == saveItem)
31364142 {
31374143 save();
31384144 //return true;
3139
- } else if (event.getSource() == saveAsItem)
4145
+ } else if (source == saveAsItem)
31404146 {
31414147 saveAs();
31424148 //return true;
3143
- } else if (event.getSource() == reexportItem)
4149
+ } else if (source == reexportItem)
31444150 {
31454151 reexport();
31464152 //return true;
3147
- } else if (event.getSource() == exportAsItem)
4153
+ } else if (source == exportAsItem)
31484154 {
31494155 export();
31504156 //return true;
3151
- } else if (event.getSource() == povItem)
4157
+ } else if (source == povItem)
31524158 {
31534159 generatePOV();
31544160 //return true;
3155
- } else if (event.getSource() == zBufferItem)
4161
+ } else if (event.getSource() == archiveItem)
4162
+ {
4163
+ cTools.Archive(frame);
4164
+ return;
4165
+ } else if (source == zBufferItem)
31564166 {
31574167 try
31584168 {
....@@ -3174,21 +4184,8 @@
31744184 cameraView.repaint();
31754185 //return true;
31764186 }
3177
- */ else if (event.getSource() == editCameraItem)
3178
- {
3179
- cameraView.ProtectCamera();
3180
- cameraView.repaint();
3181
- return;
3182
- } else if (event.getSource() == revertCameraItem)
3183
- {
3184
- cameraView.RevertCamera();
3185
- cameraView.repaint();
3186
- return;
3187
-// } else if (event.getSource() == textureButton)
3188
-// {
3189
-// return; // true;
3190
- } else // combos...
3191
- if (event.getSource() == texresMenu)
4187
+ */ else // combos...
4188
+ if (source == texresMenu)
31924189 {
31934190 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31944191 copy.texres = texresMenu.getSelectedIndex();
....@@ -3200,12 +4197,499 @@
32004197 }
32014198 }
32024199
4200
+ void New()
4201
+ {
4202
+ while (copy.Size() > 0)
4203
+ {
4204
+ copy.remove(0);
4205
+ }
4206
+
4207
+ copy.selection.clear();
4208
+
4209
+ ResetModel();
4210
+ SetupViews();
4211
+ objEditor.refreshContents();
4212
+ }
4213
+
4214
+ static public byte[] Compress(Object3D o)
4215
+ {
4216
+ // Slower to actually compress.
4217
+ try
4218
+ {
4219
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4220
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4221
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
4222
+
4223
+ Object3D parent = o.parent;
4224
+ o.parent = null;
4225
+
4226
+ out.writeObject(o);
4227
+
4228
+ o.parent = parent;
4229
+
4230
+ out.flush();
4231
+
4232
+ baos //zstream
4233
+ .close();
4234
+ out.close();
4235
+
4236
+ byte[] bytes = baos.toByteArray();
4237
+
4238
+ System.out.println("save #bytes = " + bytes.length);
4239
+ return bytes;
4240
+ } catch (Exception e)
4241
+ {
4242
+ System.err.println(e);
4243
+ return null;
4244
+ }
4245
+ }
4246
+
4247
+ static public Object Uncompress(byte[] bytes)
4248
+ {
4249
+ System.out.println("restore #bytes = " + bytes.length);
4250
+ try
4251
+ {
4252
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4253
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4254
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
4255
+ Object obj = in.readObject();
4256
+
4257
+ bais //istream
4258
+ .close();
4259
+ in.close();
4260
+
4261
+ return obj;
4262
+ } catch (Exception e)
4263
+ {
4264
+ System.err.println(e);
4265
+ return null;
4266
+ }
4267
+ }
4268
+
4269
+ static public Object clone(Object o)
4270
+ {
4271
+ try
4272
+ {
4273
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4274
+ ObjectOutputStream out = new ObjectOutputStream(baos);
4275
+
4276
+ out.writeObject(o);
4277
+
4278
+ out.flush();
4279
+ out.close();
4280
+
4281
+ byte[] bytes = baos.toByteArray();
4282
+
4283
+ System.out.println("clone = " + bytes.length);
4284
+
4285
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4286
+ ObjectInputStream in = new ObjectInputStream(bais);
4287
+ Object obj = in.readObject();
4288
+ in.close();
4289
+
4290
+ return obj;
4291
+ } catch (Exception e)
4292
+ {
4293
+ System.err.println(e);
4294
+ return null;
4295
+ }
4296
+ }
4297
+
4298
+ cRadio GetCurrentTab()
4299
+ {
4300
+ cRadio ab;
4301
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4302
+ {
4303
+ ab = (cRadio)e.nextElement();
4304
+ if(ab.GetObject() == copy)
4305
+ {
4306
+ return ab;
4307
+ }
4308
+ }
4309
+
4310
+ return null;
4311
+ }
4312
+
4313
+
4314
+ public void Save()
4315
+ {
4316
+ //Save(true);
4317
+ Replace();
4318
+ SetVersionStates();
4319
+ }
4320
+
4321
+ private boolean Equal(byte[] compress, byte[] name)
4322
+ {
4323
+ if (compress.length != name.length)
4324
+ {
4325
+ return false;
4326
+ }
4327
+
4328
+ for (int i=compress.length; --i>=0;)
4329
+ {
4330
+ if (compress[i] != name[i])
4331
+ return false;
4332
+ }
4333
+
4334
+ return true;
4335
+ }
4336
+
4337
+ void DeleteVersion()
4338
+ {
4339
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4340
+ {
4341
+ copy.versionlist[i] = copy.versionlist[i+1];
4342
+ }
4343
+
4344
+ if (copy.versionlist[copy.versionindex] == null)
4345
+ copy.versionindex -= 1;
4346
+
4347
+ if (copy.versionindex != -1)
4348
+ CopyChanged();
4349
+
4350
+ SetVersionStates();
4351
+ }
4352
+
4353
+ public boolean Save(boolean user)
4354
+ {
4355
+ System.err.println("Save");
4356
+ Replace();
4357
+
4358
+ //cRadio tab = GetCurrentTab();
4359
+
4360
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
4361
+
4362
+ boolean thesame = false;
4363
+
4364
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4365
+// {
4366
+// thesame = true;
4367
+// }
4368
+
4369
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
4370
+ if (!thesame)
4371
+ {
4372
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4373
+ {
4374
+ copy.versionlist[i] = copy.versionlist[i-1];
4375
+ }
4376
+
4377
+ //tab.user[tab.versionindex] = user;
4378
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4379
+
4380
+ copy.versionlist[++copy.versionindex] = compress;
4381
+
4382
+ // if (increment)
4383
+ // tab.versionindex++;
4384
+ }
4385
+
4386
+ //copy.RestoreBigData(versiontable);
4387
+
4388
+ //assert(hashtable.isEmpty());
4389
+
4390
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4391
+// {
4392
+// //tab.user[i] = false;
4393
+// copy.versionlist[i] = null;
4394
+// }
4395
+
4396
+ SetVersionStates();
4397
+
4398
+ // test save
4399
+ if (false)
4400
+ {
4401
+ try
4402
+ {
4403
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
4404
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
4405
+
4406
+ p.writeObject(copy);
4407
+
4408
+ p.flush();
4409
+
4410
+ ostream.close();
4411
+ } catch (Exception e)
4412
+ {
4413
+ e.printStackTrace();
4414
+ }
4415
+ }
4416
+
4417
+ return !thesame;
4418
+ }
4419
+
4420
+ boolean flashIt = true;
4421
+
4422
+ void RefreshSelection()
4423
+ {
4424
+ Object3D selection = new Object3D();
4425
+
4426
+ for (int i = 0; i < copy.selection.size(); i++)
4427
+ {
4428
+ Object3D elem = copy.selection.elementAt(i);
4429
+
4430
+ Object3D obj = copy.GetObject(elem.GetUUID());
4431
+
4432
+ if (obj == null)
4433
+ {
4434
+ copy.selection.remove(i--);
4435
+ }
4436
+ else
4437
+ {
4438
+ selection.add(obj);
4439
+ copy.selection.setElementAt(obj, i);
4440
+ }
4441
+ }
4442
+
4443
+ flashIt = false;
4444
+ GetTree().clearSelection();
4445
+ for (int i = 0; i < selection.size(); i++)
4446
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4447
+ flashIt = true;
4448
+
4449
+ //refreshContents(false);
4450
+ }
4451
+
4452
+ void CopyChanged()
4453
+ {
4454
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4455
+
4456
+ SetVersionStates();
4457
+
4458
+ boolean temp = CameraPane.SWITCH;
4459
+ CameraPane.SWITCH = false;
4460
+
4461
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
4462
+
4463
+ copy.clear();
4464
+
4465
+ copy.skyboxname = obj.skyboxname;
4466
+ copy.skyboxext = obj.skyboxext;
4467
+
4468
+ for (int i=0; i<obj.Size(); i++)
4469
+ {
4470
+ copy.add(obj.get(i));
4471
+ }
4472
+
4473
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
4474
+
4475
+ CameraPane.SWITCH = temp;
4476
+
4477
+ RefreshSelection();
4478
+ //assert(hashtable.isEmpty());
4479
+
4480
+ copy.Touch();
4481
+
4482
+ ResetModel();
4483
+ copy.HardTouch(); // recompile?
4484
+
4485
+ cRadio ab;
4486
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4487
+ {
4488
+ ab = (cRadio)e.nextElement();
4489
+ Object3D test = copy.GetObject(ab.object.GetUUID());
4490
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
4491
+ if (test != null)
4492
+ {
4493
+ test.editWindow = ab.object.editWindow;
4494
+ ab.object = test;
4495
+ }
4496
+ }
4497
+
4498
+ refreshContents(true);
4499
+ }
4500
+
4501
+ cButton previousVersionButton;
4502
+ cButton restoreButton;
4503
+ cButton replaceButton;
4504
+ cButton nextVersionButton;
4505
+ cButton saveVersionButton;
4506
+ cButton deleteVersionButton;
4507
+
4508
+ boolean muteSlider;
4509
+
4510
+ int VersionCount()
4511
+ {
4512
+ int count = 0;
4513
+
4514
+ for (int i = copy.versionlist.length; --i >= 0;)
4515
+ {
4516
+ if (copy.versionlist[i] != null)
4517
+ count++;
4518
+ }
4519
+
4520
+ return count;
4521
+ }
4522
+
4523
+ public cGridBag versionSliderPane;
4524
+
4525
+ void SetVersionStates()
4526
+ {
4527
+ //if (true)
4528
+ // return;
4529
+
4530
+ //cRadio tab = GetCurrentTab();
4531
+
4532
+ if (copy.versionlist == null)
4533
+ {
4534
+ saveVersionButton.setEnabled(false);
4535
+ restoreButton.setEnabled(false);
4536
+ replaceButton.setEnabled(false);
4537
+ previousVersionButton.setEnabled(false);
4538
+ nextVersionButton.setEnabled(false);
4539
+ deleteVersionButton.setEnabled(false);
4540
+ versionSliderPane.setVisible(false);
4541
+ }
4542
+ else
4543
+ {
4544
+ restoreButton.setEnabled(copy.versionindex != -1);
4545
+ replaceButton.setEnabled(copy.versionindex != -1);
4546
+
4547
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4548
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4549
+
4550
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4551
+ //copy.versionlist[copy.versionindex + 1] != null);
4552
+
4553
+ muteSlider = true;
4554
+ versionSlider.setMinimum(0);
4555
+ versionSlider.setMaximum(VersionCount() - 1);
4556
+ versionSlider.setInteger(copy.versionindex);
4557
+ versionSlider.setEnabled(copy.versionindex != -1);
4558
+ muteSlider = false;
4559
+
4560
+ versionSliderPane.setVisible(true);
4561
+ }
4562
+ }
4563
+
4564
+ public boolean PreviousVersion()
4565
+ {
4566
+ // Option?
4567
+ Replace();
4568
+
4569
+ System.err.println("Undo");
4570
+
4571
+ //cRadio tab = GetCurrentTab();
4572
+
4573
+ if (copy.versionindex == 0)
4574
+ {
4575
+ java.awt.Toolkit.getDefaultToolkit().beep();
4576
+ return false;
4577
+ }
4578
+
4579
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4580
+// {
4581
+// if (Save(false))
4582
+// tab.versionindex -= 1;
4583
+// else
4584
+// {
4585
+// if (tab.versionindex <= 0)
4586
+// return false;
4587
+// else
4588
+// tab.versionindex -= 1;
4589
+// }
4590
+// }
4591
+
4592
+ copy.versionindex -= 1;
4593
+
4594
+ CopyChanged();
4595
+
4596
+ return true;
4597
+ }
4598
+
4599
+ public boolean Restore()
4600
+ {
4601
+ System.err.println("Restore");
4602
+
4603
+ //cRadio tab = GetCurrentTab();
4604
+
4605
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4606
+ {
4607
+ java.awt.Toolkit.getDefaultToolkit().beep();
4608
+ return false;
4609
+ }
4610
+
4611
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4612
+ CopyChanged();
4613
+
4614
+ return true;
4615
+ }
4616
+
4617
+ public boolean Replace()
4618
+ {
4619
+ //System.err.println("Replace");
4620
+
4621
+ //cRadio tab = GetCurrentTab();
4622
+
4623
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4624
+ {
4625
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4626
+ return false;
4627
+ }
4628
+
4629
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4630
+
4631
+ return true;
4632
+ }
4633
+
4634
+ public void NextVersion()
4635
+ {
4636
+ // Option?
4637
+ Replace();
4638
+
4639
+ //cRadio tab = GetCurrentTab();
4640
+
4641
+ if (copy.versionlist[copy.versionindex + 1] == null)
4642
+ {
4643
+ java.awt.Toolkit.getDefaultToolkit().beep();
4644
+ return;
4645
+ }
4646
+
4647
+ copy.versionindex += 1;
4648
+
4649
+ CopyChanged();
4650
+
4651
+ //if (!tab.user[tab.versionindex])
4652
+ // tab.graphs[tab.versionindex] = null;
4653
+ }
4654
+
4655
+ void ImportGFD()
4656
+ {
4657
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
4658
+ browser.show();
4659
+ String filename = browser.getFile();
4660
+ if (filename != null && filename.length() > 0)
4661
+ {
4662
+ String fullname = browser.getDirectory() + filename;
4663
+
4664
+ //Object3D readobj =
4665
+ objEditor.ReadGFD(fullname, objEditor);
4666
+ //makeSomething(readobj);
4667
+ }
4668
+ }
4669
+
4670
+ void ImportVRMLX3D()
4671
+ {
4672
+ if (Grafreed.standAlone)
4673
+ {
4674
+ /**/
4675
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
4676
+ browser.show();
4677
+ String filename = browser.getFile();
4678
+ if (filename != null && filename.length() > 0)
4679
+ {
4680
+ String fullname = browser.getDirectory() + filename;
4681
+ LoadVRMLX3D(fullname);
4682
+ }
4683
+ /**/
4684
+ }
4685
+ }
4686
+
32034687 void ToggleAnimation()
32044688 {
32054689 if (!Globals.ANIMATION)
32064690 {
32074691 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3208
- browser.show();
4692
+ browser.setVisible(true);
32094693 String filename = browser.getFile();
32104694 if (filename != null && filename.length() > 0)
32114695 {
....@@ -3215,8 +4699,8 @@
32154699
32164700 Globals.ANIMATION ^= true;
32174701
3218
- GrafreeD.wav.cursor = 0;
3219
- GrafreeD.wav.loop = 0;
4702
+ Grafreed.wav.cursor = 0;
4703
+ Grafreed.wav.loop = 0;
32204704 }
32214705 } else
32224706 {
....@@ -3237,7 +4721,6 @@
32374721 callee.refreshContents();
32384722 } else
32394723 {
3240
- new Exception().printStackTrace();
32414724 System.exit(0);
32424725 }
32434726 }
....@@ -3267,7 +4750,7 @@
32674750 void CreateMaterial()
32684751 {
32694752 //copy.ClearMaterial(); // PATCH
3270
- copy.CreateMaterialS(multiplyToggle.isSelected());
4753
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32714754 if (copy.selection.size() > 0)
32724755 //SetMaterial(copy);
32734756 {
....@@ -3318,7 +4801,7 @@
33184801 assert false;
33194802 }
33204803
3321
- void EditSelection()
4804
+ void EditSelection(boolean newWindow)
33224805 {
33234806 }
33244807
....@@ -3326,11 +4809,11 @@
33264809 {
33274810 copy.ResetBlockLoop(); // temporary problem
33284811
3329
- boolean random = CameraPane.RANDOM;
3330
- CameraPane.RANDOM = false; // parse everything
4812
+ boolean random = CameraPane.SWITCH;
4813
+ CameraPane.SWITCH = false; // parse everything
33314814 copy.ResetDisplayList();
33324815 copy.HardTouch();
3333
- CameraPane.RANDOM = random;
4816
+ CameraPane.SWITCH = random;
33344817 }
33354818
33364819 // public void applySelf()
....@@ -3360,6 +4843,12 @@
33604843 // else
33614844 // applySelf(true);
33624845 // }
4846
+
4847
+ boolean Equal(double a, double b)
4848
+ {
4849
+ return Math.abs(a - b) < 0.001;
4850
+ }
4851
+
33634852 void applySelf0(boolean name)
33644853 {
33654854 if (name)
....@@ -3377,7 +4866,7 @@
33774866 //copy.material = new cMaterial(copy.GetMaterial());
33784867
33794868 current.color = (float) colorField.getFloat();
3380
- current.modulation = (float) modulationField.getFloat();
4869
+ current.modulation = (float) saturationField.getFloat();
33814870 current.metalness = (float) metalnessField.getFloat();
33824871 current.diffuse = (float) diffuseField.getFloat();
33834872 current.specular = (float) specularField.getFloat();
....@@ -3404,6 +4893,59 @@
34044893 {
34054894 //System.out.println("Propagate = " + propagate);
34064895 copy.UpdateMaterial(anchor, current, propagate);
4896
+
4897
+ if (copy.material != null)
4898
+ {
4899
+ cMaterial mat = copy.material;
4900
+
4901
+ if (!Equal(colorField.getFloat(), mat.color))
4902
+ colorField.SetToolTipValue((mat.color));
4903
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4904
+ saturationField.SetToolTipValue((mat.modulation));
4905
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4906
+ metalnessField.SetToolTipValue((mat.metalness));
4907
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4908
+ diffuseField.SetToolTipValue((mat.diffuse));
4909
+ if (!Equal(specularField.getFloat(), mat.specular))
4910
+ specularField.SetToolTipValue((mat.specular));
4911
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4912
+ shininessField.SetToolTipValue((mat.shininess));
4913
+ if (!Equal(shiftField.getFloat(), mat.shift))
4914
+ shiftField.SetToolTipValue((mat.shift));
4915
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4916
+ ambientField.SetToolTipValue((mat.ambient));
4917
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4918
+ lightareaField.SetToolTipValue((mat.lightarea));
4919
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4920
+ diffusenessField.SetToolTipValue((mat.factor));
4921
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4922
+ velvetField.SetToolTipValue((mat.velvet));
4923
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4924
+ sheenField.SetToolTipValue((mat.sheen));
4925
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4926
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4927
+ if (!Equal(backlitField.getFloat(), mat.bump))
4928
+ backlitField.SetToolTipValue((mat.bump));
4929
+ if (!Equal(anisoField.getFloat(), mat.aniso))
4930
+ anisoField.SetToolTipValue((mat.aniso));
4931
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
4932
+ anisoVField.SetToolTipValue((mat.anisoV));
4933
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
4934
+ cameraField.SetToolTipValue((mat.cameralight));
4935
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
4936
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4937
+ if (!Equal(shadowField.getFloat(), mat.shadow))
4938
+ shadowField.SetToolTipValue((mat.shadow));
4939
+ if (!Equal(textureField.getFloat(), mat.texture))
4940
+ textureField.SetToolTipValue((mat.texture));
4941
+ if (!Equal(opacityField.getFloat(), mat.opacity))
4942
+ opacityField.SetToolTipValue((mat.opacity));
4943
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
4944
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4945
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
4946
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
4947
+ }
4948
+
34074949 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34084950 {
34094951 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3432,9 +4974,28 @@
34324974 //copy.Touch();
34334975 }
34344976
4977
+ cNumberSlider versionSlider;
4978
+
34354979 public void stateChanged(ChangeEvent e)
34364980 {
3437
- // assert(false);
4981
+ // assert(false);
4982
+ if (e.getSource() == versionSlider)
4983
+ {
4984
+ if (muteSlider)
4985
+ return;
4986
+
4987
+ Replace();
4988
+
4989
+ int version = versionSlider.getInteger();
4990
+
4991
+ if (version != -1 && copy.versionlist[version] != null)
4992
+ {
4993
+ copy.versionindex = version;
4994
+ CopyChanged();
4995
+ }
4996
+
4997
+ return;
4998
+ }
34384999
34395000 if (freezematerial)
34405001 {
....@@ -3470,6 +5031,12 @@
34705031 {
34715032 //System.out.println("stateChanged = " + this);
34725033 materialtouched = true;
5034
+
5035
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
5036
+ {
5037
+ saturationField.setFloat(1);
5038
+ }
5039
+
34735040 applySelf();
34745041 //System.out.println("this = " + this);
34755042 //System.out.println("PARENT = " + parent);
....@@ -3519,7 +5086,7 @@
35195086 }
35205087
35215088 if (normalpushField != null)
3522
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
5089
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35235090 }
35245091
35255092 void SnapObject()
....@@ -3769,6 +5336,7 @@
37695336 {
37705337 if (GetTree() != null)
37715338 {
5339
+ GetTree().revalidate();
37725340 GetTree().repaint();
37735341 }
37745342
....@@ -3777,12 +5345,19 @@
37775345 ctrlPanel.validate(); // ? new
37785346 ctrlPanel.repaint();
37795347 }
5348
+
5349
+ if (previousVersionButton != null && copy.versionlist != null)
5350
+ SetVersionStates();
5351
+
5352
+ cameraView.requestFocusInWindow();
37805353 }
37815354
37825355 static TweenManager tweenManager = new TweenManager();
37835356
37845357 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37855358 {
5359
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5360
+ Save();
37865361 //Tween.set(thing, 0).target(1).start(tweenManager);
37875362 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37885363 // if (thing instanceof GenericJointDemo)
....@@ -3806,7 +5381,7 @@
38065381 // group = (Composite) group.get(0);
38075382 // }
38085383
3809
- System.out.println("makeSomething of " + thing);
5384
+ //System.out.println("makeSomething of " + thing);
38105385
38115386 /*
38125387 if (deselect && jList != null)
....@@ -3869,6 +5444,12 @@
38695444 {
38705445 ResetModel();
38715446 Select(thing.GetTreePath(), true, false); // unselect... false);
5447
+
5448
+ if (thing.Size() == 0)
5449
+ {
5450
+ //EditSelection(false);
5451
+ }
5452
+
38725453 refreshContents();
38735454 }
38745455
....@@ -3986,6 +5567,7 @@
39865567 }
39875568 }
39885569 }
5570
+
39895571 LoadGFDThread loadGFDThread;
39905572
39915573 void ReadGFD(String fullname, iCallBack cb)
....@@ -4005,8 +5587,10 @@
40055587
40065588 try
40075589 {
5590
+ // Try compressed version first.
40085591 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4009
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5592
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
5593
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40105594
40115595 readobj = (Object3D) p.readObject();
40125596 istream.close();
....@@ -4014,7 +5598,22 @@
40145598 readobj.ResetDisplayList();
40155599 } catch (Exception e)
40165600 {
4017
- e.printStackTrace();
5601
+ if (!e.toString().contains("GZIP"))
5602
+ e.printStackTrace();
5603
+
5604
+ try
5605
+ {
5606
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
5607
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5608
+
5609
+ readobj = (Object3D) p.readObject();
5610
+ istream.close();
5611
+
5612
+ readobj.ResetDisplayList();
5613
+ } catch (Exception e2)
5614
+ {
5615
+ e2.printStackTrace();
5616
+ }
40185617 }
40195618 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40205619 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4060,6 +5659,12 @@
40605659
40615660 void LoadIt(Object obj)
40625661 {
5662
+ if (obj == null)
5663
+ {
5664
+ // Invalid file
5665
+ return;
5666
+ }
5667
+
40635668 System.out.println("Loaded " + obj);
40645669 //new Exception().printStackTrace();
40655670 Object3D readobj = (Object3D) obj;
....@@ -4069,10 +5674,14 @@
40695674
40705675 if (readobj != null)
40715676 {
5677
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5678
+ // Save();
40725679 try
40735680 {
40745681 //readobj.deepCopySelf(copy);
40755682 copy.clear(); // june 2014
5683
+ copy.skyboxname = readobj.skyboxname;
5684
+ copy.skyboxext = readobj.skyboxext;
40765685 for (int i = 0; i < readobj.size(); i++)
40775686 {
40785687 Object3D child = readobj.get(i); // reserve(i);
....@@ -4113,6 +5722,7 @@
41135722 }
41145723 } catch (ClassCastException e)
41155724 {
5725
+ e.printStackTrace();
41165726 assert (false);
41175727 Composite c = (Composite) copy;
41185728 c.children.clear();
....@@ -4123,17 +5733,32 @@
41235733 c.addChild(csg);
41245734 }
41255735
5736
+ copy.versionlist = readobj.versionlist;
5737
+ copy.versionindex = readobj.versionindex;
5738
+ copy.versiontable = readobj.versiontable;
5739
+
5740
+ if (copy.versionlist == null)
5741
+ {
5742
+ // Backward compatibility
5743
+ copy.versionlist = new Object3D[100];
5744
+ copy.versionindex = -1;
5745
+
5746
+ //Save(true);
5747
+ }
5748
+
5749
+ //? SetUndoStates();
5750
+
41265751 ResetModel();
41275752 copy.HardTouch(); // recompile?
41285753 refreshContents();
41295754 }
41305755 }
41315756
4132
- void load() // throws ClassNotFoundException
5757
+ void Open() // throws ClassNotFoundException
41335758 {
4134
- if (GrafreeD.standAlone)
5759
+ if (Grafreed.standAlone)
41355760 {
4136
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5761
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
41375762 browser.show();
41385763 String filename = browser.getFile();
41395764 if (filename != null && filename.length() > 0)
....@@ -4210,6 +5835,8 @@
42105835
42115836 void save()
42125837 {
5838
+ Replace();
5839
+
42135840 if (lastname == null)
42145841 {
42155842 return;
....@@ -4218,11 +5845,13 @@
42185845 try
42195846 {
42205847 FileOutputStream ostream = new FileOutputStream(lastname);
4221
- ObjectOutputStream p = new ObjectOutputStream(ostream);
5848
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5849
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42225850
42235851 p.writeObject(copy);
42245852 p.flush();
42255853
5854
+ zstream.close();
42265855 ostream.close();
42275856
42285857 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4230,19 +5859,23 @@
42305859 //ps.print(buffer.toString());
42315860 } catch (IOException e)
42325861 {
5862
+ e.printStackTrace();
42335863 }
42345864 }
5865
+
42355866 String lastname;
42365867
42375868 void saveAs()
42385869 {
4239
- if (GrafreeD.standAlone)
5870
+ if (Grafreed.standAlone)
42405871 {
42415872 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42425873 browser.setVisible(true);
42435874 String filename = browser.getFile();
42445875 if (filename != null && filename.length() > 0)
42455876 {
5877
+ if (!filename.endsWith(".gfd"))
5878
+ filename += ".gfd";
42465879 lastname = browser.getDirectory() + filename;
42475880 save();
42485881 }
....@@ -4341,13 +5974,13 @@
43415974 try
43425975 {
43435976 FileOutputStream ostream = new FileOutputStream(filename);
4344
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4345
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
5977
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5978
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43465979
43475980 Object3D objectparent = obj.parent;
43485981 obj.parent = null;
43495982
4350
- Object3D object = (Object3D) GrafreeD.clone(obj);
5983
+ Object3D object = (Object3D) Grafreed.clone(obj);
43515984
43525985 obj.parent = objectparent;
43535986
....@@ -4359,8 +5992,8 @@
43595992 p.writeObject(object);
43605993 p.flush();
43615994
5995
+ zstream.close();
43625996 ostream.close();
4363
- // zstream.close();
43645997
43655998 // group.selection.get(0).parent = parent;
43665999 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4381,7 +6014,7 @@
43816014 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43826015 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43836016 copy.generatePOV(buffer);
4384
- if (GrafreeD.standAlone)
6017
+ if (Grafreed.standAlone)
43856018 {
43866019 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43876020 browser.show();
....@@ -4407,19 +6040,18 @@
44076040 Object3D client;
44086041 Object3D copy;
44096042 MenuBar menuBar;
4410
- Menu windowMenu;
4411
- MenuItem loadItem;
6043
+ Menu fileMenu;
6044
+ MenuItem newItem;
6045
+ MenuItem openItem;
44126046 MenuItem saveItem;
44136047 MenuItem saveAsItem;
44146048 MenuItem exportAsItem;
44156049 MenuItem reexportItem;
44166050 MenuItem povItem;
44176051 MenuItem closeItem;
4418
- Menu cameraMenu;
6052
+
44196053 CheckboxMenuItem zBufferItem;
44206054 //MenuItem normalLensItem;
4421
- MenuItem editCameraItem;
4422
- MenuItem revertCameraItem;
44236055 MenuItem stepItem;
44246056 CheckboxMenuItem toggleLiveItem;
44256057 CheckboxMenuItem toggleFullScreenItem;
....@@ -4430,25 +6062,41 @@
44306062 CheckboxMenuItem toggleFootContactItem;
44316063 CheckboxMenuItem toggleDLItem;
44326064 CheckboxMenuItem toggleTextureItem;
4433
- CheckboxMenuItem toggleRandomItem;
6065
+ CheckboxMenuItem toggleSwitchItem;
44346066 CheckboxMenuItem toggleRootItem;
44356067 CheckboxMenuItem animationItem;
6068
+ MenuItem archiveItem;
44366069 CheckboxMenuItem toggleHandleItem;
44376070 CheckboxMenuItem togglePaintItem;
44386071 JSplitPane mainPanel;
44396072 JScrollPane scrollpane;
6073
+
44406074 JPanel toolbarPanel;
6075
+
44416076 cGridBag treePanel;
6077
+
44426078 JPanel radioPanel;
44436079 ButtonGroup buttonGroup;
4444
- cGridBag ctrlPanel;
6080
+
6081
+ cGridBag toolboxPanel;
6082
+ cGridBag skyboxPanel;
44456083 cGridBag materialPanel;
6084
+ cGridBag ctrlPanel;
6085
+
44466086 JScrollPane infoPanel;
6087
+
44476088 cGridBag optionsPanel;
6089
+
44486090 JTabbedPane objectPanel;
6091
+ boolean materialFlushed;
6092
+ Object3D latestObject;
6093
+
6094
+ cGridBag transformPanel;
44496095 cGridBag XYZPanel;
6096
+
44506097 JSplitPane gridPanel;
44516098 JSplitPane bigPanel;
6099
+
44526100 cGridBag bigThree;
44536101 cGridBag scenePanel;
44546102 cGridBag centralPanel;
....@@ -4506,7 +6154,7 @@
45066154 JLabel colorLabel;
45076155 cNumberSlider colorField;
45086156 JLabel modulationLabel;
4509
- cNumberSlider modulationField;
6157
+ cNumberSlider saturationField;
45106158 JLabel metalnessLabel;
45116159 cNumberSlider metalnessField;
45126160 JLabel diffuseLabel;
....@@ -4537,6 +6185,7 @@
45376185 cNumberSlider anisoField;
45386186 JLabel anisoVLabel;
45396187 cNumberSlider anisoVField;
6188
+
45406189 JLabel cameraLabel;
45416190 cNumberSlider cameraField;
45426191 JLabel selfshadowLabel;
....@@ -4551,6 +6200,7 @@
45516200 cNumberSlider fakedepthField;
45526201 JLabel shadowbiasLabel;
45536202 cNumberSlider shadowbiasField;
6203
+
45546204 JLabel bumpLabel;
45556205 cNumberSlider bumpField;
45566206 JLabel noiseLabel;
....@@ -4563,8 +6213,13 @@
45636213 cNumberSlider fogField;
45646214 JLabel opacityPowerLabel;
45656215 cNumberSlider opacityPowerField;
4566
- JTree jTree;
6216
+ cTree jTree;
45676217 //ObjectUI parent;
45686218
45696219 cNumberSlider normalpushField;
6220
+
6221
+ private MenuItem importGFDItem;
6222
+ private MenuItem importVRMLX3DItem;
6223
+ private MenuItem import3DSItem;
6224
+ private MenuItem importOBJItem;
45706225 }