Normand Briere
2019-08-15 24a2a946b35279605e645349bd6b82e9e60aac88
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,99 @@
3034 iSendInfo
3135 //KeyListener
3236 {
37
+ public cToggleButton pinButton;
3338 boolean timeline;
3439 boolean wasFullScreen;
3540
3641 GroupEditor callee;
3742 JFrame frame;
43
+
44
+ static ObjEditor theFrame;
45
+
46
+ public cGridBag GetSeparator()
47
+ {
48
+ cGridBag separator = new cGridBag();
49
+ separator.add(new JSeparator());
50
+ separator.preferredHeight = 5;
51
+ return separator;
52
+ }
53
+
54
+ cButton GetButton(String name, boolean border)
55
+ {
56
+ ImageIcon icon = GetIcon(name);
57
+ return new cButton(icon, border);
58
+ }
59
+
60
+ cLabel GetLabel(String name, boolean border)
61
+ {
62
+ //ImageIcon icon = GetIcon(name);
63
+ return new cLabel(GetImage(name), border);
64
+ }
65
+
66
+ cToggleButton GetToggleButton(String name, boolean border)
67
+ {
68
+ ImageIcon icon = GetIcon(name);
69
+ return new cToggleButton(icon, border);
70
+ }
71
+
72
+ cCheckBox GetCheckBox(String name, boolean border)
73
+ {
74
+ ImageIcon icon = GetIcon(name);
75
+ return new cCheckBox(icon, border);
76
+ }
77
+
78
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
79
+
80
+ ImageIcon GetIcon(String name)
81
+ {
82
+ javax.swing.ImageIcon iconCache = icons.get(name);
83
+ if (iconCache != null)
84
+ {
85
+ return iconCache;
86
+ }
87
+
88
+ try
89
+ {
90
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
91
+
92
+// if (image.getWidth() > 48 && image.getHeight() > 48)
93
+// {
94
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
95
+// Graphics2D g = resized.createGraphics();
96
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
97
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
98
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
99
+// g.dispose();
100
+//
101
+// image = resized;
102
+// }
103
+
104
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
105
+
106
+ icons.put(name, icon);
107
+
108
+ return icon;
109
+ }
110
+ catch (Exception e)
111
+ {
112
+ //icons.put(name, null);
113
+ return null;
114
+ }
115
+ }
116
+
117
+ BufferedImage GetImage(String name)
118
+ {
119
+ try
120
+ {
121
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
122
+
123
+ return image;
124
+ }
125
+ catch (Exception e)
126
+ {
127
+ return null;
128
+ }
129
+ }
38130
39131 // SCRIPT
40132
....@@ -145,7 +237,7 @@
145237
146238 objEditor.ctrlPanel.remove(namePanel);
147239
148
- if (!GroupEditor.allparams)
240
+ if (!allparams)
149241 return;
150242
151243 // objEditor.ctrlPanel.remove(liveCB);
....@@ -168,7 +260,8 @@
168260 // objEditor.ctrlPanel.remove(remarkButton);
169261
170262 objEditor.ctrlPanel.remove(setupPanel);
171
- objEditor.ctrlPanel.remove(commandsPanel);
263
+ objEditor.ctrlPanel.remove(setupPanel2);
264
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
172265 objEditor.ctrlPanel.remove(pushPanel);
173266 //objEditor.ctrlPanel.remove(fillPanel);
174267
....@@ -216,6 +309,14 @@
216309 client = inClient;
217310 copy = client;
218311
312
+// if (copy.versionlist == null)
313
+// {
314
+// copy.versionlist = new Object3D[100];
315
+// copy.versionindex = -1;
316
+//
317
+// callee.Save(true);
318
+// }
319
+
219320 // "this" is not called: SetupUI2(objEditor);
220321 }
221322
....@@ -229,6 +330,14 @@
229330 client = inClient;
230331 copy = client;
231332
333
+ if (copy.versionlist == null)
334
+ {
335
+ copy.versionlist = new Object3D[100];
336
+ copy.versionindex = -1;
337
+
338
+// Save(true);
339
+ }
340
+
232341 SetupUI2(callee.GetEditor());
233342 }
234343
....@@ -243,6 +352,7 @@
243352 //localCopy.parent = null;
244353
245354 frame = new JFrame();
355
+ frame.setUndecorated(false);
246356 objEditor = this;
247357 this.callee = callee;
248358
....@@ -260,6 +370,14 @@
260370 copy = localCopy;
261371 copy.editWindow = this;
262372
373
+// if (copy.versionlist == null)
374
+// {
375
+// copy.versionlist = new Object3D[100];
376
+// copy.versionindex = -1;
377
+//
378
+// Save(true);
379
+// }
380
+
263381 SetupMenu();
264382
265383 //SetupName(objEditor); // new
....@@ -273,28 +391,49 @@
273391 return frame.action(event, obj);
274392 }
275393
394
+ // Cannot work without static
395
+ static boolean allparams = true;
396
+
397
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
398
+
276399 void SetupMenu()
277400 {
278401 frame.setMenuBar(menuBar = new MenuBar());
279
- menuBar.add(windowMenu = new Menu("File"));
280
- windowMenu.add(loadItem = new MenuItem("Load..."));
281
- windowMenu.add("-");
282
- windowMenu.add(saveItem = new MenuItem("Save"));
283
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
402
+ menuBar.add(fileMenu = new Menu("File"));
403
+ fileMenu.add(newItem = new MenuItem("New"));
404
+ fileMenu.add(openItem = new MenuItem("Open..."));
405
+
406
+ //oe.menuBar.add(menu = new Menu("Include"));
407
+ Menu menu = new Menu("Import");
408
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
409
+ importOBJItem.addActionListener(this);
410
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
411
+ import3DSItem.addActionListener(this);
412
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
413
+ importVRMLX3DItem.addActionListener(this);
414
+ menu.add("-");
415
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
416
+ importGFDItem.addActionListener(this);
417
+ fileMenu.add(menu);
418
+ fileMenu.add("-");
419
+
420
+ fileMenu.add(saveItem = new MenuItem("Save"));
421
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
284422 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
285
- windowMenu.add("-");
286
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
287
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
288
- windowMenu.add("-");
423
+ fileMenu.add("-");
424
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
425
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
426
+ fileMenu.add("-");
289427 if (client.parent != null)
290428 {
291
- windowMenu.add(closeItem = new MenuItem("Close"));
429
+ fileMenu.add(closeItem = new MenuItem("Close"));
292430 } else
293431 {
294
- windowMenu.add(closeItem = new MenuItem("Exit"));
432
+ fileMenu.add(closeItem = new MenuItem("Exit"));
295433 }
296434
297
- loadItem.addActionListener(this);
435
+ newItem.addActionListener(this);
436
+ openItem.addActionListener(this);
298437 saveItem.addActionListener(this);
299438 saveAsItem.addActionListener(this);
300439 exportAsItem.addActionListener(this);
....@@ -302,101 +441,103 @@
302441 //povItem.addActionListener(this);
303442 closeItem.addActionListener(this);
304443
305
- menuBar.add(cameraMenu = new Menu("View"));
306
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
307
- //zBufferItem.addActionListener(this);
308
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
309
- //normalLensItem.addActionListener(this);
310
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
311
- revertCameraItem.addActionListener(this);
312
-
313
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
314
- toggleFullScreenItem.addItemListener(this);
315
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
316
- cameraMenu.add("-");
317
-
318
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
319
- toggleTextureItem.addItemListener(this);
320
- toggleTextureItem.setState(CameraPane.textureon);
321
-
322
- cameraMenu.add(toggleSwitchItem = new CheckboxMenuItem("Switch"));
323
- toggleSwitchItem.addItemListener(this);
324
- toggleSwitchItem.setState(CameraPane.SWITCH);
325
-
326
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
327
- toggleHandleItem.addItemListener(this);
328
- toggleHandleItem.setState(CameraPane.HANDLES);
329
-
330
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
331
- togglePaintItem.addItemListener(this);
332
- togglePaintItem.setState(CameraPane.PAINTMODE);
333
-
334
- if (Globals.ADVANCED)
335
- {
336
- cameraMenu.add("-");
337
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
338
- toggleLiveItem.addItemListener(this);
339
- toggleLiveItem.setState(Globals.isLIVE());
340
-
341
- cameraMenu.add(stepItem = new MenuItem("Step"));
342
- stepItem.addActionListener(this);
343
- // cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
344
- // toggleDLItem.addItemListener(this);
345
- // toggleDLItem.setState(false);
346
-
347
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
348
- toggleRenderItem.addItemListener(this);
349
- toggleRenderItem.setState(!CameraPane.frozen);
350
-
351
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
352
- toggleDebugItem.addItemListener(this);
353
- toggleDebugItem.setState(CameraPane.DEBUG);
354
-
355
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
356
- toggleFrustumItem.addItemListener(this);
357
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
358
-
359
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
360
- toggleFootContactItem.addItemListener(this);
361
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
362
-
363
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
364
- toggleTimelineItem.addItemListener(this);
365
- }
366
-
367
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
368
-// toggleRootItem.addItemListener(this);
369
-// toggleRootItem.setState(false);
370
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
371
-// animationItem.addItemListener(this);
372
-// animationItem.setState(CameraPane.ANIMATION);
373
- cameraMenu.add("-");
374
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
375
- editCameraItem.addActionListener(this);
376
-
377444 objectPanel = new JTabbedPane();
445
+
446
+ ChangeListener changeListener = new ChangeListener()
447
+ {
448
+ //String name;
449
+
450
+ public void stateChanged(ChangeEvent changeEvent)
451
+ {
452
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
453
+// {
454
+// if (latestObject != null)
455
+// {
456
+// refreshContents(true);
457
+// SetMaterial(latestObject);
458
+// }
459
+//
460
+// materialFlushed = true;
461
+// }
462
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
463
+// {
464
+// if (listUI.size() == 0)
465
+// EditSelection(false);
466
+// }
467
+
468
+// if (objectPanel.getSelectedIndex() == 4)
469
+// {
470
+// name = copy.skyboxname;
471
+//
472
+// if (name == null)
473
+// {
474
+// name = "";
475
+// }
476
+//
477
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
478
+// copy.skyboxext = "jpg";
479
+// }
480
+// else
481
+// {
482
+// if (name != null)
483
+// {
484
+// if (name.equals(""))
485
+// {
486
+// copy.skyboxname = null;
487
+// copy.skyboxext = null;
488
+// }
489
+// else
490
+// {
491
+// copy.skyboxname = name;
492
+// }
493
+// }
494
+// }
495
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
496
+
497
+// refreshContents(false); // To refresh Info tab
498
+ cameraView.repaint();
499
+ }
500
+ };
501
+ objectPanel.addChangeListener(changeListener);
502
+
378503 toolbarPanel = new JPanel();
379504 toolbarPanel.setName("Toolbar");
505
+
380506 treePanel = new cGridBag();
381507 treePanel.setName("Tree");
508
+
509
+ editPanel = new cGridBag().setVertical(true);
510
+ //editPanel.setName("Edit");
511
+
382512 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
383
- ctrlPanel.setName("Edit");
384
- materialPanel = new cGridBag().setVertical(true);
385
- materialPanel.setName("Material");
513
+
514
+ editCommandsPanel = new cGridBag();
515
+ editPanel.add(editCommandsPanel);
516
+ editPanel.add(ctrlPanel);
517
+
518
+ toolboxPanel = new cGridBag().setVertical(true);
519
+ //toolboxPanel.setName("Toolbox");
520
+
521
+ skyboxPanel = new cGridBag().setVertical(true);
522
+
523
+ materialPanel = new cGridBag().setVertical(false);
524
+ //materialPanel.setName("Material");
525
+
386526 /*JTextPane*/
387527 infoarea = createTextPane();
388528 doc = infoarea.getStyledDocument();
389529
390530 infoarea.setEditable(true);
391531 SetText();
532
+
392533 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
393534 // infoarea.setOpaque(false);
394535 // //infoarea.setForeground(textcolor);
395536 // TEXTAREA infoarea.setLineWrap(true);
396537 // TEXTAREA infoarea.setWrapStyleWord(true);
397538 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
398
- infoPanel.setPreferredSize(new Dimension(50, 200));
399
- infoPanel.setName("Info");
539
+ infoPanel.setPreferredSize(new Dimension(1, 1));
540
+ //infoPanel.setName("Info");
400541 //infoPanel.setLayout(new BorderLayout());
401542 //infoPanel.add(createTextPane());
402543
....@@ -407,7 +548,14 @@
407548 mainPanel.setDividerSize(9);
408549 mainPanel.setDividerLocation(0.5); //1.0);
409550 mainPanel.setResizeWeight(0.5);
410
-
551
+
552
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
553
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
554
+ divider.setDividerSize(15);
555
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
556
+
557
+ mainPanel.setUI(new BasicSplitPaneUI());
558
+
411559 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
412560 //mainPanel.setLayout(new GridBagLayout());
413561 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -475,10 +623,10 @@
475623 e.printStackTrace();
476624 }
477625
478
- String selection = infoarea.getText();
479
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
480
- java.awt.datatransfer.Clipboard clipboard =
481
- Toolkit.getDefaultToolkit().getSystemClipboard();
626
+// String selection = infoarea.getText();
627
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
628
+// java.awt.datatransfer.Clipboard clipboard =
629
+// Toolkit.getDefaultToolkit().getSystemClipboard();
482630 //clipboard.setContents(data, data);
483631 }
484632
....@@ -501,13 +649,13 @@
501649 //SendInfo("Name:", "bold");
502650 if (sel.GetTextures() != null || debug)
503651 {
504
- si.SendInfo(sel.toString(), "bold");
652
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
505653 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
506654 if (sel.Size() > 0)
507655 {
508656 si.SendInfo("#children = " + sel.Size(), "regular");
509657 }
510
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
658
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
511659 if (debug)
512660 {
513661 try
....@@ -549,7 +697,7 @@
549697 }
550698 if (sel.support != null)
551699 {
552
- si.SendInfo(" support: " + sel.support, "regular");
700
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
553701 }
554702 if (sel.scriptnode != null)
555703 {
....@@ -638,21 +786,158 @@
638786 }
639787 }
640788
789
+//static GraphicsDevice device = GraphicsEnvironment
790
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
791
+
792
+ Rectangle keeprect;
793
+ cRadio radio;
794
+
795
+cButton keepButton;
796
+ cButton twoButton; // Full 3D
797
+ cButton sixButton;
798
+ cButton threeButton;
799
+ cButton sevenButton;
800
+ cButton fourButton; // full panel
801
+ cButton oneButton; // full XYZ
802
+ //cButton currentLayout;
803
+
804
+ boolean maximized;
805
+
806
+ cButton fullscreenLayout;
807
+ cButton expandedLayout;
808
+
809
+ void Minimize()
810
+ {
811
+ frame.setState(Frame.ICONIFIED);
812
+ frame.validate();
813
+ }
814
+
815
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
816
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
817
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
818
+ void Maximize()
819
+ {
820
+ if (CameraPane.FULLSCREEN)
821
+ {
822
+ ToggleFullScreen();
823
+ }
824
+
825
+ if (maximized)
826
+ {
827
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
828
+ }
829
+ else
830
+ {
831
+ keeprect = frame.getBounds();
832
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
833
+// Dimension rect2 = frame.getToolkit().getScreenSize();
834
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
835
+// frame.setState(Frame.MAXIMIZED_BOTH);
836
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
837
+ }
838
+
839
+ maximized ^= true;
840
+
841
+ frame.validate();
842
+ }
843
+
844
+ cButton minButton;
845
+ cButton maxButton;
846
+ cButton fullButton;
847
+ cButton collapseButton;
848
+ cButton maximize3DButton;
849
+
641850 void ToggleFullScreen()
642851 {
643
- if (CameraPane.FULLSCREEN)
852
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
853
+
854
+ cameraView.ToggleFullScreen();
855
+
856
+ if (!CameraPane.FULLSCREEN)
644857 {
645
- frame.getContentPane().remove(/*"Center",*/bigThree);
646
- framePanel.add(bigThree);
647
- frame.getContentPane().add(/*"Center",*/framePanel);
858
+ device.setFullScreenWindow(null);
859
+ frame.dispose();
860
+ frame.setUndecorated(false);
861
+ frame.validate();
862
+ frame.setVisible(true);
863
+
864
+ //frame.setVisible(false);
865
+// frame.removeNotify();
866
+// frame.setUndecorated(false);
867
+// frame.addNotify();
868
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
869
+
870
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
871
+// X framePanel.add(bigThree);
872
+// X frame.getContentPane().add(/*"Center",*/framePanel);
873
+// framePanel.setDividerLocation(46); // icons are 24x24
874
+
875
+ //frame.setVisible(true);
876
+// radio.layout = keepButton;
877
+ //theFrame = null;
878
+ keepButton = null;
879
+// radio.layout.doClick();
880
+
648881 } else
649882 {
650
- frame.getContentPane().remove(/*"Center",*/framePanel);
651
- framePanel.remove(bigThree);
652
- frame.getContentPane().add(/*"Center",*/bigThree);
883
+ keepButton = radio.layout;
884
+ //keeprect = frame.getBounds();
885
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
886
+// frame.getToolkit().getScreenSize().height);
887
+ //frame.setVisible(false);
888
+
889
+ frame.dispose();
890
+ frame.setUndecorated(true);
891
+ device.setFullScreenWindow(frame);
892
+ frame.validate();
893
+ frame.setVisible(true);
894
+// frame.removeNotify();
895
+// frame.setUndecorated(true);
896
+// frame.addNotify();
897
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
898
+// X framePanel.remove(bigThree);
899
+// X frame.getContentPane().add(/*"Center",*/bigThree);
900
+// framePanel.setDividerLocation(0);
901
+
902
+// radio.layout = fullscreenLayout;
903
+// radio.layout.doClick();
904
+ //frame.setVisible(true);
653905 }
654
- cameraView.ToggleFullScreen();
906
+ frame.validate();
907
+
908
+ cameraView.requestFocusInWindow();
655909 }
910
+
911
+ void CollapseToolbar()
912
+ {
913
+ framePanel.setDividerLocation(0);
914
+ //frame.validate();
915
+
916
+ cameraView.requestFocusInWindow();
917
+ }
918
+
919
+ private Object3D Duplicate(Object3D object)
920
+ {
921
+ boolean temp = CameraPane.SWITCH;
922
+ CameraPane.SWITCH = false;
923
+
924
+ object.ExtractBigData(versiontable);
925
+ // if (copy == client)
926
+
927
+ Object3D versions[] = object.versionlist;
928
+ object.versionlist = null;
929
+
930
+ //byte[] compress = Compress(copy);
931
+ Object3D compress = (Object3D)Grafreed.clone(object);
932
+
933
+ object.versionlist = versions;
934
+
935
+ object.RestoreBigData(versiontable);
936
+
937
+ CameraPane.SWITCH = temp;
938
+
939
+ return compress;
940
+ }
656941
657942 private JTextPane createTextPane()
658943 {
....@@ -775,6 +1060,7 @@
7751060 {
7761061 SetupMaterial(materialPanel);
7771062 }
1063
+
7781064 //SetupName();
7791065 //SetupViews();
7801066 }
....@@ -784,6 +1070,7 @@
7841070 // NumberSlider vDivsField;
7851071 // JCheckBox endcaps;
7861072 JCheckBox liveCB;
1073
+ JCheckBox selectableCB;
7871074 JCheckBox hideCB;
7881075 JCheckBox link2masterCB;
7891076 JCheckBox markCB;
....@@ -791,7 +1078,12 @@
7911078 JCheckBox speedupCB;
7921079 JCheckBox rewindCB;
7931080 JCheckBox flipVCB;
1081
+
1082
+ cCheckBox toggleTextureCB;
1083
+ cCheckBox toggleSwitchCB;
1084
+
7941085 JComboBox texresMenu;
1086
+
7951087 JButton resetButton;
7961088 JButton stepButton;
7971089 JButton stepAllButton;
....@@ -800,9 +1092,13 @@
8001092 JButton fasterButton;
8011093 JButton remarkButton;
8021094
1095
+ cGridBag editPanel;
1096
+ cGridBag editCommandsPanel;
1097
+
8031098 cGridBag namePanel;
8041099 cGridBag setupPanel;
805
- cGridBag commandsPanel;
1100
+ cGridBag setupPanel2;
1101
+ cGridBag objectCommandsPanel;
8061102 cGridBag pushPanel;
8071103 cGridBag fillPanel;
8081104
....@@ -973,62 +1269,84 @@
9731269
9741270 namePanel = new cGridBag();
9751271
1272
+ //if (copy.pinned)
1273
+ {
1274
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1275
+ pinButton.setSelected(copy.pinned);
1276
+ cGridBag t = new cGridBag();
1277
+ t.preferredWidth = 2;
1278
+ t.add(pinButton);
1279
+ namePanel.add(t);
1280
+
1281
+ pinButton.addItemListener(this);
1282
+ }
1283
+
9761284 nameField = AddText(namePanel, copy.GetName());
977
- namePanel.add(nameField);
1285
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9781286 oe.ctrlPanel.add(namePanel);
9791287
9801288 oe.ctrlPanel.Return();
9811289
982
- if (!GroupEditor.allparams)
1290
+ if (!allparams)
9831291 return;
9841292
9851293 setupPanel = new cGridBag().setVertical(false);
9861294
9871295 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
9881296 liveCB.setToolTipText("Animate object");
1297
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1298
+ selectableCB.setToolTipText("Make object selectable");
1299
+// Return();
1300
+
9891301 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9901302 hideCB.setToolTipText("Hide object");
991
-// Return();
9921303 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
993
- markCB.setToolTipText("Set the animation target transform");
1304
+ markCB.setToolTipText("As animation target transform");
9941305
995
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1306
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1307
+
1308
+ setupPanel2 = new cGridBag().setVertical(false);
1309
+
1310
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9961311 rewindCB.setToolTipText("Rewind animation");
9971312
998
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
999
- randomCB.setToolTipText("Option for switch node");
1313
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1314
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
10001315
1316
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1317
+ link2masterCB.setToolTipText("Attach to support");
1318
+
10011319 if (Globals.ADVANCED)
10021320 {
1003
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
1004
- link2masterCB.setToolTipText("Attach to support");
1005
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1321
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10061322 speedupCB.setToolTipText("Option motion capture");
10071323 }
10081324
10091325 oe.ctrlPanel.add(setupPanel);
10101326 oe.ctrlPanel.Return();
1327
+ oe.ctrlPanel.add(setupPanel2);
1328
+ oe.ctrlPanel.Return();
10111329
1012
- commandsPanel = new cGridBag().setVertical(false);
1330
+ objectCommandsPanel = new cGridBag().setVertical(false);
10131331
1014
- resetButton = AddButton(commandsPanel, "Reset");
1332
+ resetButton = AddButton(objectCommandsPanel, "Reset");
10151333 resetButton.setToolTipText("Jump to frame zero");
1016
- stepButton = AddButton(commandsPanel, "Step");
1334
+ stepButton = AddButton(objectCommandsPanel, "Step");
10171335 stepButton.setToolTipText("Step one frame");
10181336 // resetAllButton = AddButton(oe, "Reset All");
10191337 // stepAllButton = AddButton(oe, "Step All");
10201338 // Return();
1021
- slowerButton = AddButton(commandsPanel, "Slow");
1339
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
10221340 slowerButton.setToolTipText("Decrease animation speed");
1023
- fasterButton = AddButton(commandsPanel, "Fast");
1341
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
10241342 fasterButton.setToolTipText("Increase animation speed");
1025
- remarkButton = AddButton(commandsPanel, "Remark");
1343
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
10261344 remarkButton.setToolTipText("Set the current transform as the target");
10271345
1028
- oe.ctrlPanel.add(commandsPanel);
1346
+ oe.ctrlPanel.add(objectCommandsPanel);
10291347 oe.ctrlPanel.Return();
10301348
1031
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1349
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
10321350 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
10331351 //Return();
10341352
....@@ -1231,8 +1549,11 @@
12311549 //worldPanel.setName("World");
12321550 centralPanel = new cGridBag();
12331551 centralPanel.preferredWidth = 20;
1234
- timelinePanel = new JPanel(new BorderLayout());
1235
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1552
+
1553
+ if (Globals.ADVANCED)
1554
+ {
1555
+ timelinePanel = new JPanel(new BorderLayout());
1556
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
12361557
12371558 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
12381559 cameraPanel.setContinuousLayout(true);
....@@ -1241,7 +1562,10 @@
12411562 // cameraPanel.setDividerSize(9);
12421563 cameraPanel.setResizeWeight(1.0);
12431564
1565
+ }
1566
+
12441567 centralPanel.add(cameraView);
1568
+ centralPanel.setFocusable(true);
12451569 //frame.setJMenuBar(timelineMenubar);
12461570 //centralPanel.add(timelinePanel);
12471571
....@@ -1267,6 +1591,7 @@
12671591 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12681592 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12691593 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1594
+ //XYZPanel.setName("XYZ");
12701595
12711596 /*
12721597 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1304,13 +1629,29 @@
13041629 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
13051630 //tmp.setName("Edit");
13061631 objectPanel.add(materialPanel);
1632
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1633
+ objectPanel.setToolTipTextAt(0, "Material");
1634
+
1635
+ objectPanel.add(toolboxPanel);
1636
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1637
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1638
+
1639
+ objectPanel.add(skyboxPanel);
1640
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1641
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1642
+
13071643 // JPanel north = new JPanel(new BorderLayout());
13081644 // north.setName("Edit");
13091645 // north.add(ctrlPanel, BorderLayout.NORTH);
13101646 // objectPanel.add(north);
1311
- objectPanel.add(ctrlPanel);
1312
- objectPanel.add(infoPanel);
1313
-
1647
+ objectPanel.add(editPanel);
1648
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1649
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1650
+
1651
+ objectPanel.add(XYZPanel);
1652
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1653
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1654
+
13141655 /*
13151656 aConstraints.gridx = 0;
13161657 aConstraints.gridwidth = 1;
....@@ -1318,7 +1659,7 @@
13181659 aConstraints.gridy += 1;
13191660 aConstraints.gridwidth = 1;
13201661 mainPanel.add(objectPanel, aConstraints);
1321
- */
1662
+ */
13221663
13231664 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
13241665 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1330,14 +1671,12 @@
13301671 scrollpane.addMouseWheelListener(this); // Default not fast enough
13311672
13321673 /*JTabbedPane*/ scenePanel = new cGridBag();
1333
- scenePanel.preferredWidth = 6;
1674
+ scenePanel.preferredWidth = 5;
13341675
13351676 JTabbedPane tabbedPane = new JTabbedPane();
13361677 tabbedPane.add(scrollpane);
13371678
1338
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1339
-
1340
- optionsPanel = new cGridBag().setVertical(true);
1679
+ optionsPanel = new cGridBag().setVertical(false);
13411680
13421681 optionsPanel.setName("Options");
13431682
....@@ -1345,8 +1684,15 @@
13451684
13461685 tabbedPane.add(optionsPanel);
13471686
1687
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1688
+
13481689 scenePanel.add(tabbedPane);
13491690
1691
+ //if (Globals.ADVANCED)
1692
+// tabbedPane.add(infoPanel);
1693
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1694
+// tabbedPane.setToolTipTextAt(3, "Information");
1695
+
13501696 /*
13511697 cTree jTree = new cTree(null);
13521698 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1408,7 +1754,7 @@
14081754 bigThree = new cGridBag();
14091755 bigThree.addComponent(scenePanel);
14101756 bigThree.addComponent(centralPanel);
1411
- bigThree.addComponent(XYZPanel);
1757
+ //bigThree.addComponent(XYZPanel);
14121758
14131759 // // SIDE EFFECT!!!
14141760 // aConstraints.gridx = 0;
....@@ -1417,16 +1763,33 @@
14171763 // aConstraints.gridheight = 1;
14181764
14191765 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1420
- framePanel.setContinuousLayout(true);
1421
- framePanel.setOneTouchExpandable(true);
1422
- framePanel.setDividerLocation(0.8);
1766
+
1767
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1768
+ new java.beans.PropertyChangeListener()
1769
+ {
1770
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1771
+ {
1772
+ if ((Integer)pce.getOldValue() == 1)
1773
+ {
1774
+ if (radio.layout != expandedLayout)
1775
+ {
1776
+ radio.layout = expandedLayout;
1777
+ radio.layout.doClick();
1778
+ }
1779
+ }
1780
+ }
1781
+ });
1782
+
1783
+ framePanel.setContinuousLayout(false);
1784
+ framePanel.setOneTouchExpandable(false);
1785
+ //.setDividerLocation(0.8);
14231786 //framePanel.setDividerSize(15);
14241787 //framePanel.setResizeWeight(0.15);
14251788 framePanel.setName("Frame");
14261789
14271790 frame.getContentPane().setLayout(new BorderLayout());
14281791 /**/
1429
- JTabbedPane worldPane = new JTabbedPane();
1792
+ //JTabbedPane worldPane = new JTabbedPane();
14301793 //worldPane.add(bigPanel);
14311794 //worldPane.add(worldPanel);
14321795 /**/
....@@ -1437,14 +1800,18 @@
14371800 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14381801
14391802 frame.setSize(1280, 860);
1440
- frame.setVisible(true);
1441
-
1803
+
1804
+ cameraView.requestFocusInWindow();
1805
+
14421806 gridPanel.setDividerLocation(1.0);
1807
+
1808
+ frame.validate();
1809
+
1810
+ frame.setVisible(true);
14431811
14441812 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14451813 frame.addWindowListener(new WindowAdapter()
14461814 {
1447
-
14481815 public void windowClosing(WindowEvent e)
14491816 {
14501817 Close();
....@@ -1467,12 +1834,403 @@
14671834 ctrlPanel.removeAll();
14681835 }
14691836
1470
- void SetupMaterial(cGridBag panel)
1837
+ void SetupMaterial(cGridBag materialpanel)
14711838 {
1472
- /*
1839
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1840
+
1841
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1842
+ skin.setToolTipText("Skin");
1843
+ skin.addMouseListener(new MouseAdapter()
1844
+ {
1845
+ public void mouseClicked(MouseEvent e)
1846
+ {
1847
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1848
+ cMaterial material = object.material;
1849
+
1850
+ // Skin
1851
+ colorField.setFloat(material.color);
1852
+ saturationField.setFloat(material.modulation);
1853
+ subsurfaceField.setFloat(material.subsurface);
1854
+ selfshadowField.setFloat(material.diffuseness);
1855
+ diffusenessField.setFloat(material.factor);
1856
+ shininessField.setFloat(material.shininess);
1857
+ shadowbiasField.setFloat(material.shadowbias);
1858
+ diffuseField.setFloat(material.diffuse);
1859
+ specularField.setFloat(material.specular);
1860
+
1861
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1862
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1863
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1864
+
1865
+ materialtouched = true;
1866
+ applySelf();
1867
+ }
1868
+ });
1869
+ presetpanel.add(skin);
1870
+
1871
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1872
+ lambert.setToolTipText("Diffuse");
1873
+ lambert.addMouseListener(new MouseAdapter()
1874
+ {
1875
+ public void mouseClicked(MouseEvent e)
1876
+ {
1877
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1878
+ cMaterial material = object.material;
1879
+
1880
+ diffusenessField.setFloat(material.factor);
1881
+ selfshadowField.setFloat(material.diffuseness);
1882
+
1883
+ materialtouched = true;
1884
+ applySelf();
1885
+ }
1886
+ });
1887
+ presetpanel.add(lambert);
1888
+
1889
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1890
+ diffuse2.setToolTipText("Diffuse2");
1891
+ diffuse2.addMouseListener(new MouseAdapter()
1892
+ {
1893
+ public void mouseClicked(MouseEvent e)
1894
+ {
1895
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1896
+ cMaterial material = object.material;
1897
+
1898
+ diffusenessField.setFloat(material.factor);
1899
+ selfshadowField.setFloat(material.diffuseness);
1900
+
1901
+ materialtouched = true;
1902
+ applySelf();
1903
+ }
1904
+ });
1905
+ presetpanel.add(diffuse2);
1906
+
1907
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1908
+ diffusemoon.setToolTipText("Moon");
1909
+ diffusemoon.addMouseListener(new MouseAdapter()
1910
+ {
1911
+ public void mouseClicked(MouseEvent e)
1912
+ {
1913
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1914
+ cMaterial material = object.material;
1915
+
1916
+ diffusenessField.setFloat(material.factor);
1917
+ selfshadowField.setFloat(material.diffuseness);
1918
+
1919
+ materialtouched = true;
1920
+ applySelf();
1921
+ }
1922
+ });
1923
+ presetpanel.add(diffusemoon);
1924
+
1925
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1926
+ diffusemoon2.setToolTipText("Moon2");
1927
+ diffusemoon2.addMouseListener(new MouseAdapter()
1928
+ {
1929
+ public void mouseClicked(MouseEvent e)
1930
+ {
1931
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1932
+ cMaterial material = object.material;
1933
+
1934
+ diffusenessField.setFloat(material.factor);
1935
+ selfshadowField.setFloat(material.diffuseness);
1936
+
1937
+ materialtouched = true;
1938
+ applySelf();
1939
+ }
1940
+ });
1941
+ presetpanel.add(diffusemoon2);
1942
+
1943
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1944
+ diffusemoon3.setToolTipText("Moon3");
1945
+ diffusemoon3.addMouseListener(new MouseAdapter()
1946
+ {
1947
+ public void mouseClicked(MouseEvent e)
1948
+ {
1949
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1950
+ cMaterial material = object.material;
1951
+
1952
+ diffusenessField.setFloat(material.factor);
1953
+ selfshadowField.setFloat(material.diffuseness);
1954
+
1955
+ materialtouched = true;
1956
+ applySelf();
1957
+ }
1958
+ });
1959
+ presetpanel.add(diffusemoon3);
1960
+
1961
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1962
+ diffusesheen.setToolTipText("Sheen");
1963
+ diffusesheen.addMouseListener(new MouseAdapter()
1964
+ {
1965
+ public void mouseClicked(MouseEvent e)
1966
+ {
1967
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1968
+ cMaterial material = object.material;
1969
+
1970
+ sheenField.setFloat(material.sheen);
1971
+
1972
+ materialtouched = true;
1973
+ applySelf();
1974
+ }
1975
+ });
1976
+ presetpanel.add(diffusesheen);
1977
+
1978
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1979
+ rough.setToolTipText("Rough metal");
1980
+ rough.addMouseListener(new MouseAdapter()
1981
+ {
1982
+ public void mouseClicked(MouseEvent e)
1983
+ {
1984
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1985
+ cMaterial material = object.material;
1986
+
1987
+ shininessField.setFloat(material.shininess);
1988
+ velvetField.setFloat(material.velvet);
1989
+
1990
+ materialtouched = true;
1991
+ applySelf();
1992
+ }
1993
+ });
1994
+ presetpanel.add(rough);
1995
+
1996
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
1997
+ rough2.setToolTipText("Medium metal");
1998
+ rough2.addMouseListener(new MouseAdapter()
1999
+ {
2000
+ public void mouseClicked(MouseEvent e)
2001
+ {
2002
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2003
+ cMaterial material = object.material;
2004
+
2005
+ shininessField.setFloat(material.shininess);
2006
+ lightareaField.setFloat(material.lightarea);
2007
+
2008
+ materialtouched = true;
2009
+ applySelf();
2010
+ }
2011
+ });
2012
+ presetpanel.add(rough2);
2013
+
2014
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2015
+ shini0.setToolTipText("Shiny");
2016
+ shini0.addMouseListener(new MouseAdapter()
2017
+ {
2018
+ public void mouseClicked(MouseEvent e)
2019
+ {
2020
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2021
+ cMaterial material = object.material;
2022
+
2023
+ shininessField.setFloat(material.shininess);
2024
+ lightareaField.setFloat(material.lightarea);
2025
+
2026
+ materialtouched = true;
2027
+ applySelf();
2028
+ }
2029
+ });
2030
+ presetpanel.add(shini0);
2031
+
2032
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2033
+ shini1.setToolTipText("Shiny2");
2034
+ shini1.addMouseListener(new MouseAdapter()
2035
+ {
2036
+ public void mouseClicked(MouseEvent e)
2037
+ {
2038
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2039
+ cMaterial material = object.material;
2040
+
2041
+ shininessField.setFloat(material.shininess);
2042
+ lightareaField.setFloat(material.lightarea);
2043
+
2044
+ materialtouched = true;
2045
+ applySelf();
2046
+ }
2047
+ });
2048
+ presetpanel.add(shini1);
2049
+
2050
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2051
+ shini2.setToolTipText("Shiny3");
2052
+ shini2.addMouseListener(new MouseAdapter()
2053
+ {
2054
+ public void mouseClicked(MouseEvent e)
2055
+ {
2056
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2057
+ cMaterial material = object.material;
2058
+
2059
+ shininessField.setFloat(material.shininess);
2060
+ lightareaField.setFloat(material.lightarea);
2061
+
2062
+ materialtouched = true;
2063
+ applySelf();
2064
+ }
2065
+ });
2066
+ presetpanel.add(shini2);
2067
+
2068
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2069
+ aniso.setToolTipText("AnisoU");
2070
+ aniso.addMouseListener(new MouseAdapter()
2071
+ {
2072
+ public void mouseClicked(MouseEvent e)
2073
+ {
2074
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2075
+ cMaterial material = object.material;
2076
+
2077
+ anisoField.setFloat(material.aniso);
2078
+ anisoVField.setFloat(material.anisoV);
2079
+
2080
+ materialtouched = true;
2081
+ applySelf();
2082
+ }
2083
+ });
2084
+ presetpanel.add(aniso);
2085
+
2086
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2087
+ aniso2.setToolTipText("AnisoV");
2088
+ aniso2.addMouseListener(new MouseAdapter()
2089
+ {
2090
+ public void mouseClicked(MouseEvent e)
2091
+ {
2092
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2093
+ cMaterial material = object.material;
2094
+
2095
+ anisoField.setFloat(material.aniso);
2096
+ anisoVField.setFloat(material.anisoV);
2097
+
2098
+ materialtouched = true;
2099
+ applySelf();
2100
+ }
2101
+ });
2102
+ presetpanel.add(aniso2);
2103
+
2104
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2105
+ aniso3.setToolTipText("AnisoUV");
2106
+ aniso3.addMouseListener(new MouseAdapter()
2107
+ {
2108
+ public void mouseClicked(MouseEvent e)
2109
+ {
2110
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2111
+ cMaterial material = object.material;
2112
+
2113
+ anisoField.setFloat(material.aniso);
2114
+ anisoVField.setFloat(material.anisoV);
2115
+
2116
+ materialtouched = true;
2117
+ applySelf();
2118
+ }
2119
+ });
2120
+ presetpanel.add(aniso3);
2121
+
2122
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2123
+ velvet0.setToolTipText("Velvet");
2124
+ velvet0.addMouseListener(new MouseAdapter()
2125
+ {
2126
+ public void mouseClicked(MouseEvent e)
2127
+ {
2128
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2129
+ cMaterial material = object.material;
2130
+
2131
+ diffusenessField.setFloat(material.factor);
2132
+ selfshadowField.setFloat(material.diffuseness);
2133
+ sheenField.setFloat(material.sheen);
2134
+ shininessField.setFloat(material.shininess);
2135
+ velvetField.setFloat(material.velvet);
2136
+ shiftField.setFloat(material.shift);
2137
+
2138
+ materialtouched = true;
2139
+ applySelf();
2140
+ }
2141
+ });
2142
+ presetpanel.add(velvet0);
2143
+
2144
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2145
+ bump0.setToolTipText("Bump texture");
2146
+ bump0.addMouseListener(new MouseAdapter()
2147
+ {
2148
+ public void mouseClicked(MouseEvent e)
2149
+ {
2150
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2151
+ cMaterial material = object.material;
2152
+
2153
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2154
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2155
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2156
+
2157
+ materialtouched = true;
2158
+ applySelf();
2159
+ }
2160
+ });
2161
+ presetpanel.add(bump0);
2162
+
2163
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2164
+ halo.setToolTipText("Halo");
2165
+ halo.addMouseListener(new MouseAdapter()
2166
+ {
2167
+ public void mouseClicked(MouseEvent e)
2168
+ {
2169
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2170
+ cMaterial material = object.material;
2171
+
2172
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2173
+
2174
+ materialtouched = true;
2175
+ applySelf();
2176
+ }
2177
+ });
2178
+ presetpanel.add(halo);
2179
+
2180
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2181
+ candle.setToolTipText("Candle");
2182
+ candle.addMouseListener(new MouseAdapter()
2183
+ {
2184
+ public void mouseClicked(MouseEvent e)
2185
+ {
2186
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2187
+ cMaterial material = object.material;
2188
+
2189
+ subsurfaceField.setFloat(material.subsurface);
2190
+ shadowbiasField.setFloat(material.shadowbias);
2191
+ ambientField.setFloat(material.ambient);
2192
+ specularField.setFloat(material.specular);
2193
+ lightareaField.setFloat(material.lightarea);
2194
+ shininessField.setFloat(material.shininess);
2195
+
2196
+ materialtouched = true;
2197
+ applySelf();
2198
+ }
2199
+ });
2200
+ presetpanel.add(candle);
2201
+
2202
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2203
+ shadowShader.setToolTipText("Shadow");
2204
+ shadowShader.addMouseListener(new MouseAdapter()
2205
+ {
2206
+ public void mouseClicked(MouseEvent e)
2207
+ {
2208
+ diffuseField.setFloat(0.001);
2209
+ ambientField.setFloat(0.001);
2210
+ cameraField.setFloat(0.001);
2211
+ specularField.setFloat(0.001);
2212
+ fakedepthField.setFloat(0.001);
2213
+ opacityField.setFloat(0.6);
2214
+
2215
+ materialtouched = true;
2216
+ applySelf();
2217
+ }
2218
+ });
2219
+ presetpanel.add(shadowShader);
2220
+
2221
+ cGridBag panel = new cGridBag().setVertical(true);
2222
+
2223
+ presetpanel.preferredWidth = 1;
2224
+
2225
+ materialpanel.add(presetpanel);
2226
+ materialpanel.add(panel);
2227
+
2228
+ panel.preferredWidth = 8;
2229
+
2230
+ /*
14732231 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14742232 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1475
- */
2233
+ */
14762234
14772235 cGridBag editBar = new cGridBag().setVertical(false);
14782236
....@@ -1506,45 +2264,50 @@
15062264 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15072265
15082266 cGridBag colorSection = new cGridBag().setVertical(true);
2267
+
2268
+ cGridBag huepanel = new cGridBag();
2269
+ cGridBag huelabel = new cGridBag();
2270
+ skin = GetLabel("icons/hue.png", false);
2271
+ skin.fit = true;
2272
+ huelabel.add(skin);
2273
+ huelabel.preferredWidth = 20;
2274
+ huepanel.add(new cGridBag()); // Label
2275
+ huepanel.add(huelabel); // Field/slider
2276
+
2277
+ huepanel.preferredHeight = 7;
2278
+
2279
+ colorSection.add(huepanel);
15092280
15102281 cGridBag color = new cGridBag();
1511
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1512
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1513
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2282
+
2283
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2284
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2285
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2286
+
15142287 //colorField.preferredWidth = 200;
15152288 colorSection.add(color);
15162289
15172290 cGridBag modulation = new cGridBag();
15182291 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
15192292 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1520
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2293
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
15212294 colorSection.add(modulation);
15222295
2296
+ cGridBag opacity = new cGridBag();
2297
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2298
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2299
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2300
+ colorSection.add(opacity);
2301
+
2302
+ colorSection.add(GetSeparator());
2303
+
15232304 cGridBag texture = new cGridBag();
15242305 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
15252306 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15262307 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
15272308 colorSection.add(texture);
15282309
1529
- cGridBag anisoU = new cGridBag();
1530
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1531
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1532
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1533
- colorSection.add(anisoU);
1534
-
1535
- cGridBag anisoV = new cGridBag();
1536
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1537
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1538
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1539
- colorSection.add(anisoV);
1540
-
1541
- cGridBag shadowbias = new cGridBag();
1542
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1543
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1544
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1545
- colorSection.add(shadowbias);
1546
-
1547
- panel.add(new JSeparator());
2310
+ panel.add(GetSeparator());
15482311
15492312 panel.add(colorSection);
15502313
....@@ -1594,7 +2357,13 @@
15942357 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15952358 diffuseSection.add(fakedepth);
15962359
1597
- panel.add(new JSeparator());
2360
+ cGridBag shadowbias = new cGridBag();
2361
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2362
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2363
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2364
+ diffuseSection.add(shadowbias);
2365
+
2366
+ panel.add(GetSeparator());
15982367
15992368 panel.add(diffuseSection);
16002369
....@@ -1644,42 +2413,48 @@
16442413 // aConstraints.gridy += 1;
16452414 // aConstraints.gridwidth = 1;
16462415
2416
+ cGridBag anisoU = new cGridBag();
2417
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2418
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2419
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2420
+ specularSection.add(anisoU);
16472421
1648
- panel.add(new JSeparator());
2422
+ cGridBag anisoV = new cGridBag();
2423
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2424
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2425
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2426
+ specularSection.add(anisoV);
2427
+
2428
+
2429
+ panel.add(GetSeparator());
16492430
16502431 panel.add(specularSection);
16512432
16522433 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16532434
1654
- cGridBag globalSection = new cGridBag().setVertical(true);
2435
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16552436
16562437 cGridBag camera = new cGridBag();
16572438 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16582439 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16592440 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1660
- globalSection.add(camera);
2441
+ colorSection.add(camera);
16612442
16622443 cGridBag ambient = new cGridBag();
16632444 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16642445 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16652446 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1666
- globalSection.add(ambient);
2447
+ colorSection.add(ambient);
16672448
16682449 cGridBag backlit = new cGridBag();
16692450 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16702451 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16712452 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1672
- globalSection.add(backlit);
2453
+ colorSection.add(backlit);
16732454
1674
- cGridBag opacity = new cGridBag();
1675
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1676
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1677
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1678
- globalSection.add(opacity);
1679
-
1680
- panel.add(new JSeparator());
2455
+ //panel.add(new JSeparator());
16812456
1682
- panel.add(globalSection);
2457
+ //panel.add(globalSection);
16832458
16842459 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16852460
....@@ -1721,7 +2496,7 @@
17212496 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
17222497 textureSection.add(opacityPower);
17232498
1724
- panel.add(new JSeparator());
2499
+ panel.add(GetSeparator());
17252500
17262501 panel.add(textureSection);
17272502
....@@ -1786,8 +2561,9 @@
17862561 // 3D models
17872562 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17882563 {
1789
- lastConverter = new com.jmex.model.converters.MaxToJme();
1790
- LoadFile(filename, lastConverter);
2564
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2565
+ //LoadFile(filename, lastConverter);
2566
+ LoadObjFile(filename); // New 3ds loader
17912567 continue;
17922568 }
17932569 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1988,6 +2764,7 @@
19882764 e2.printStackTrace();
19892765 }
19902766 }
2767
+
19912768 LoadJMEThread loadThread;
19922769
19932770 class LoadJMEThread extends Thread
....@@ -2045,6 +2822,7 @@
20452822 //LoadFile0(filename, converter);
20462823 }
20472824 }
2825
+
20482826 LoadOBJThread loadObjThread;
20492827
20502828 class LoadOBJThread extends Thread
....@@ -2123,19 +2901,19 @@
21232901
21242902 void LoadObjFile(String fullname)
21252903 {
2126
- /*
2904
+ System.out.println("Loading " + fullname);
2905
+ /**/
21272906 //lastFilename = fullname;
21282907 if(loadObjThread == null)
21292908 {
2130
- loadObjThread = new LoadOBJThread();
2131
- loadObjThread.start();
2909
+ loadObjThread = new LoadOBJThread();
2910
+ loadObjThread.start();
21322911 }
21332912
21342913 loadObjThread.add(fullname);
2135
- */
2914
+ /**/
21362915
2137
- System.out.println("Loading " + fullname);
2138
- makeSomething(new FileObject(fullname, true), true);
2916
+ //makeSomething(new FileObject(fullname, true), true);
21392917 }
21402918
21412919 void LoadGFDFile(String fullname)
....@@ -2511,6 +3289,7 @@
25113289 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
25123290 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
25133291 }
3292
+
25143293 //cJME.count++;
25153294 //cJME.count %= 12;
25163295 if (gc)
....@@ -2694,6 +3473,7 @@
26943473 }
26953474 }
26963475 }
3476
+
26973477 cFileSystemPane FSPane;
26983478
26993479 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2703,7 +3483,7 @@
27033483
27043484 freezematerial = true;
27053485 colorField.setFloat(mat.color);
2706
- modulationField.setFloat(mat.modulation);
3486
+ saturationField.setFloat(mat.modulation);
27073487 metalnessField.setFloat(mat.metalness);
27083488 diffuseField.setFloat(mat.diffuse);
27093489 specularField.setFloat(mat.specular);
....@@ -2747,11 +3527,14 @@
27473527 }
27483528 }
27493529 }
3530
+
27503531 freezematerial = false;
27513532 }
27523533
27533534 void SetMaterial(Object3D object)
27543535 {
3536
+ latestObject = object;
3537
+
27553538 cMaterial mat = object.material;
27563539
27573540 if (mat == null)
....@@ -2863,12 +3646,17 @@
28633646 // }
28643647
28653648 /**/
2866
- if (deselect)
3649
+ if (deselect || child == null)
28673650 {
28683651 //group.deselectAll();
28693652 //freeze = true;
28703653 GetTree().clearSelection();
28713654 //freeze = false;
3655
+
3656
+ if (child == null)
3657
+ {
3658
+ return;
3659
+ }
28723660 }
28733661
28743662 //group.addSelectee(child);
....@@ -2902,6 +3690,17 @@
29023690 public void itemStateChanged(ItemEvent event)
29033691 {
29043692 // System.out.println("Propagate = " + propagate);
3693
+ if (event.getSource() == pinButton)
3694
+ {
3695
+ copy.pinned ^= true;
3696
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3697
+ {
3698
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3699
+ copy.CloseUI();
3700
+ //copy.editWindow.refreshContents();
3701
+ }
3702
+ }
3703
+ else
29053704 if (event.getSource() == propagateToggle)
29063705 {
29073706 propagate ^= true;
....@@ -2937,7 +3736,7 @@
29373736 cameraView.ToggleDL();
29383737 cameraView.repaint();
29393738 return;
2940
- } else if (event.getSource() == toggleTextureItem)
3739
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29413740 {
29423741 cameraView.ToggleTexture();
29433742 // june 2013 copy.HardTouch();
....@@ -2976,9 +3775,9 @@
29763775 frame.validate();
29773776
29783777 return;
2979
- } else if (event.getSource() == toggleSwitchItem)
3778
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29803779 {
2981
- cameraView.ToggleRandom();
3780
+ cameraView.ToggleSwitch();
29823781 cameraView.repaint();
29833782 return;
29843783 } else if (event.getSource() == toggleHandleItem)
....@@ -3006,12 +3805,17 @@
30063805 } else if (event.getSource() == liveCB)
30073806 {
30083807 copy.live ^= true;
3808
+ objEditor.refreshContents(true); // To show item colors
3809
+ return;
3810
+ } else if (event.getSource() == selectableCB)
3811
+ {
3812
+ copy.dontselect ^= true;
30093813 return;
30103814 } else if (event.getSource() == hideCB)
30113815 {
30123816 copy.hide ^= true;
30133817 copy.Touch(); // display list issue
3014
- objEditor.refreshContents();
3818
+ objEditor.refreshContents(true); // To show item colors
30153819 return;
30163820 } else if (event.getSource() == link2masterCB)
30173821 {
....@@ -3045,8 +3849,9 @@
30453849
30463850 public void actionPerformed(ActionEvent event)
30473851 {
3852
+ Object source = event.getSource();
30483853 // SCRIPT DIALOG
3049
- if (event.getSource() == okbutton)
3854
+ if (source == okbutton)
30503855 {
30513856 textpanel.setVisible(false);
30523857 textpanel.remove(textarea);
....@@ -3058,7 +3863,7 @@
30583863 textarea = null;
30593864 textpanel = null;
30603865 }
3061
- if (event.getSource() == cancelbutton)
3866
+ if (source == cancelbutton)
30623867 {
30633868 textpanel.setVisible(false);
30643869 textpanel.remove(textarea);
....@@ -3070,50 +3875,50 @@
30703875 //applySelf();
30713876 //client.refreshEditWindow();
30723877 //refreshContents();
3073
- if (event.getSource() == nameField)
3878
+ if (source == nameField)
30743879 {
30753880 //System.out.println("ObjEditor " + event);
30763881 applySelf0(true);
30773882 //parent.applySelf();
30783883 objEditor.refreshContents();
3079
- } else if (event.getSource() == resetButton)
3884
+ } else if (source == resetButton)
30803885 {
30813886 CameraPane.fullreset = true;
30823887 copy.Reset(); // ResetMeshes();
30833888 copy.Touch();
30843889 objEditor.refreshContents();
3085
- } else if (event.getSource() == stepItem)
3890
+ } else if (source == stepItem)
30863891 {
30873892 //cameraView.ONESTEP = true;
30883893 Globals.ONESTEP = true;
30893894 cameraView.repaint();
30903895 return;
3091
- } else if (event.getSource() == stepButton)
3896
+ } else if (source == stepButton)
30923897 {
30933898 copy.Step();
30943899 copy.Touch();
30953900 objEditor.refreshContents();
3096
- } else if (event.getSource() == slowerButton)
3901
+ } else if (source == slowerButton)
30973902 {
30983903 copy.Slower();
30993904 copy.Touch();
31003905 objEditor.refreshContents();
3101
- } else if (event.getSource() == fasterButton)
3906
+ } else if (source == fasterButton)
31023907 {
31033908 copy.Faster();
31043909 copy.Touch();
31053910 objEditor.refreshContents();
3106
- } else if (event.getSource() == remarkButton)
3911
+ } else if (source == remarkButton)
31073912 {
31083913 copy.Remark();
31093914 copy.Touch();
31103915 objEditor.refreshContents();
3111
- } else if (event.getSource() == stepAllButton)
3916
+ } else if (source == stepAllButton)
31123917 {
31133918 copy.StepAll();
31143919 copy.Touch();
31153920 objEditor.refreshContents();
3116
- } else if (event.getSource() == resetAllButton)
3921
+ } else if (source == resetAllButton)
31173922 {
31183923 //CameraPane.fullreset = true;
31193924 copy.ResetAll(); // ResetMeshes();
....@@ -3146,53 +3951,79 @@
31463951 // Close();
31473952 // }
31483953 // else
3149
- if (event.getSource() == resetSlidersButton)
3954
+ if (source == resetSlidersButton)
31503955 {
31513956 ResetSliders();
3152
- } else if (event.getSource() == clearMaterialButton)
3957
+ } else if (source == clearMaterialButton)
31533958 {
31543959 ClearMaterial();
3155
- } else if (event.getSource() == createMaterialButton)
3960
+ } else if (source == createMaterialButton)
31563961 {
31573962 CreateMaterial();
3158
- } else if (event.getSource() == clearPanelButton)
3963
+ } else if (source == clearPanelButton)
31593964 {
31603965 copy.ClearUI();
31613966 refreshContents(true);
3162
- } /*
3163
- }
3164
-
3165
- public boolean action(Event event, Object arg)
3166
- {
3167
- */ else if (event.getSource() == closeItem)
3967
+ } else if (source == importGFDItem)
3968
+ {
3969
+ ImportGFD();
3970
+ } else
3971
+ if (source == importVRMLX3DItem)
3972
+ {
3973
+ ImportVRMLX3D();
3974
+ } else
3975
+ if (source == import3DSItem)
3976
+ {
3977
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3978
+ } else
3979
+ if (source == importOBJItem)
3980
+ {
3981
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3982
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3983
+ browser.setVisible(true);
3984
+ String filename = browser.getFile();
3985
+ if (filename != null && filename.length() > 0)
3986
+ {
3987
+ String fullname = browser.getDirectory() + filename;
3988
+ makeSomething(ReadOBJ(fullname), true);
3989
+ }
3990
+ } else
3991
+ if (source == closeItem)
31683992 {
31693993 Close();
31703994 //return true;
3171
- } else if (event.getSource() == loadItem)
3995
+ } else if (source == openItem)
31723996 {
3173
- load();
3997
+ Open();
31743998 //return true;
3175
- } else if (event.getSource() == saveItem)
3999
+ } else if (source == newItem)
4000
+ {
4001
+ New();
4002
+ } else if (source == saveItem)
31764003 {
31774004 save();
31784005 //return true;
3179
- } else if (event.getSource() == saveAsItem)
4006
+ } else if (source == saveAsItem)
31804007 {
31814008 saveAs();
31824009 //return true;
3183
- } else if (event.getSource() == reexportItem)
4010
+ } else if (source == reexportItem)
31844011 {
31854012 reexport();
31864013 //return true;
3187
- } else if (event.getSource() == exportAsItem)
4014
+ } else if (source == exportAsItem)
31884015 {
31894016 export();
31904017 //return true;
3191
- } else if (event.getSource() == povItem)
4018
+ } else if (source == povItem)
31924019 {
31934020 generatePOV();
31944021 //return true;
3195
- } else if (event.getSource() == zBufferItem)
4022
+ } else if (event.getSource() == archiveItem)
4023
+ {
4024
+ cTools.Archive(frame);
4025
+ return;
4026
+ } else if (source == zBufferItem)
31964027 {
31974028 try
31984029 {
....@@ -3214,21 +4045,8 @@
32144045 cameraView.repaint();
32154046 //return true;
32164047 }
3217
- */ else if (event.getSource() == editCameraItem)
3218
- {
3219
- cameraView.ProtectCamera();
3220
- cameraView.repaint();
3221
- return;
3222
- } else if (event.getSource() == revertCameraItem)
3223
- {
3224
- cameraView.RevertCamera();
3225
- cameraView.repaint();
3226
- return;
3227
-// } else if (event.getSource() == textureButton)
3228
-// {
3229
-// return; // true;
3230
- } else // combos...
3231
- if (event.getSource() == texresMenu)
4048
+ */ else // combos...
4049
+ if (source == texresMenu)
32324050 {
32334051 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
32344052 copy.texres = texresMenu.getSelectedIndex();
....@@ -3240,6 +4058,471 @@
32404058 }
32414059 }
32424060
4061
+ void New()
4062
+ {
4063
+ while (copy.Size() > 1)
4064
+ {
4065
+ copy.remove(1);
4066
+ }
4067
+
4068
+ ResetModel();
4069
+ objEditor.refreshContents();
4070
+ }
4071
+
4072
+ static public byte[] Compress(Object3D o)
4073
+ {
4074
+ // Slower to actually compress.
4075
+ try
4076
+ {
4077
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4078
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4079
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
4080
+
4081
+ Object3D parent = o.parent;
4082
+ o.parent = null;
4083
+
4084
+ out.writeObject(o);
4085
+
4086
+ o.parent = parent;
4087
+
4088
+ out.flush();
4089
+
4090
+ baos //zstream
4091
+ .close();
4092
+ out.close();
4093
+
4094
+ byte[] bytes = baos.toByteArray();
4095
+
4096
+ System.out.println("save #bytes = " + bytes.length);
4097
+ return bytes;
4098
+ } catch (Exception e)
4099
+ {
4100
+ System.err.println(e);
4101
+ return null;
4102
+ }
4103
+ }
4104
+
4105
+ static public Object Uncompress(byte[] bytes)
4106
+ {
4107
+ System.out.println("restore #bytes = " + bytes.length);
4108
+ try
4109
+ {
4110
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4111
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4112
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
4113
+ Object obj = in.readObject();
4114
+
4115
+ bais //istream
4116
+ .close();
4117
+ in.close();
4118
+
4119
+ return obj;
4120
+ } catch (Exception e)
4121
+ {
4122
+ System.err.println(e);
4123
+ return null;
4124
+ }
4125
+ }
4126
+
4127
+ static public Object clone(Object o)
4128
+ {
4129
+ try
4130
+ {
4131
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4132
+ ObjectOutputStream out = new ObjectOutputStream(baos);
4133
+
4134
+ out.writeObject(o);
4135
+
4136
+ out.flush();
4137
+ out.close();
4138
+
4139
+ byte[] bytes = baos.toByteArray();
4140
+
4141
+ System.out.println("clone = " + bytes.length);
4142
+
4143
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4144
+ ObjectInputStream in = new ObjectInputStream(bais);
4145
+ Object obj = in.readObject();
4146
+ in.close();
4147
+
4148
+ return obj;
4149
+ } catch (Exception e)
4150
+ {
4151
+ System.err.println(e);
4152
+ return null;
4153
+ }
4154
+ }
4155
+
4156
+ cRadio GetCurrentTab()
4157
+ {
4158
+ cRadio ab;
4159
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4160
+ {
4161
+ ab = (cRadio)e.nextElement();
4162
+ if(ab.GetObject() == copy)
4163
+ {
4164
+ return ab;
4165
+ }
4166
+ }
4167
+
4168
+ return null;
4169
+ }
4170
+
4171
+
4172
+ public void Save()
4173
+ {
4174
+ //Save(true);
4175
+ Replace();
4176
+ SetVersionStates();
4177
+ }
4178
+
4179
+ private boolean Equal(byte[] compress, byte[] name)
4180
+ {
4181
+ if (compress.length != name.length)
4182
+ {
4183
+ return false;
4184
+ }
4185
+
4186
+ for (int i=compress.length; --i>=0;)
4187
+ {
4188
+ if (compress[i] != name[i])
4189
+ return false;
4190
+ }
4191
+
4192
+ return true;
4193
+ }
4194
+
4195
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4196
+
4197
+ void DeleteVersion()
4198
+ {
4199
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4200
+ {
4201
+ copy.versionlist[i] = copy.versionlist[i+1];
4202
+ }
4203
+
4204
+ CopyChanged();
4205
+
4206
+ SetVersionStates();
4207
+ }
4208
+
4209
+ public boolean Save(boolean user)
4210
+ {
4211
+ System.err.println("Save");
4212
+ Replace();
4213
+
4214
+ //cRadio tab = GetCurrentTab();
4215
+
4216
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
4217
+
4218
+ boolean thesame = false;
4219
+
4220
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4221
+// {
4222
+// thesame = true;
4223
+// }
4224
+
4225
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
4226
+ if (!thesame)
4227
+ {
4228
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4229
+ {
4230
+ copy.versionlist[i] = copy.versionlist[i-1];
4231
+ }
4232
+
4233
+ //tab.user[tab.versionindex] = user;
4234
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4235
+
4236
+ copy.versionlist[++copy.versionindex] = compress;
4237
+
4238
+ // if (increment)
4239
+ // tab.versionindex++;
4240
+ }
4241
+
4242
+ //copy.RestoreBigData(versiontable);
4243
+
4244
+ //assert(hashtable.isEmpty());
4245
+
4246
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4247
+// {
4248
+// //tab.user[i] = false;
4249
+// copy.versionlist[i] = null;
4250
+// }
4251
+
4252
+ SetVersionStates();
4253
+
4254
+ // test save
4255
+ if (false)
4256
+ {
4257
+ try
4258
+ {
4259
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
4260
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
4261
+
4262
+ p.writeObject(copy);
4263
+
4264
+ p.flush();
4265
+
4266
+ ostream.close();
4267
+ } catch (Exception e)
4268
+ {
4269
+ e.printStackTrace();
4270
+ }
4271
+ }
4272
+
4273
+ return !thesame;
4274
+ }
4275
+
4276
+ boolean flashIt = true;
4277
+
4278
+ void RefreshSelection()
4279
+ {
4280
+ Object3D selection = new Object3D();
4281
+
4282
+ for (int i = 0; i < copy.selection.size(); i++)
4283
+ {
4284
+ Object3D elem = copy.selection.elementAt(i);
4285
+
4286
+ Object3D obj = copy.GetObject(elem.GetUUID());
4287
+
4288
+ if (obj == null)
4289
+ {
4290
+ copy.selection.remove(i--);
4291
+ }
4292
+ else
4293
+ {
4294
+ selection.add(obj);
4295
+ copy.selection.setElementAt(obj, i);
4296
+ }
4297
+ }
4298
+
4299
+ flashIt = false;
4300
+ GetTree().clearSelection();
4301
+ for (int i = 0; i < selection.size(); i++)
4302
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4303
+ flashIt = true;
4304
+
4305
+ //refreshContents(false);
4306
+ }
4307
+
4308
+ void CopyChanged()
4309
+ {
4310
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4311
+
4312
+ SetVersionStates();
4313
+
4314
+ boolean temp = CameraPane.SWITCH;
4315
+ CameraPane.SWITCH = false;
4316
+
4317
+ copy.ExtractBigData(versiontable);
4318
+
4319
+ copy.clear();
4320
+
4321
+ copy.skyboxname = obj.skyboxname;
4322
+ copy.skyboxext = obj.skyboxext;
4323
+
4324
+ for (int i=0; i<obj.Size(); i++)
4325
+ {
4326
+ copy.add(obj.get(i));
4327
+ }
4328
+
4329
+ copy.RestoreBigData(versiontable);
4330
+
4331
+ CameraPane.SWITCH = temp;
4332
+
4333
+ RefreshSelection();
4334
+ //assert(hashtable.isEmpty());
4335
+
4336
+ copy.Touch();
4337
+
4338
+ ResetModel();
4339
+ copy.HardTouch(); // recompile?
4340
+
4341
+ cRadio ab;
4342
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4343
+ {
4344
+ ab = (cRadio)e.nextElement();
4345
+ Object3D test = copy.GetObject(ab.object.GetUUID());
4346
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
4347
+ if (test != null)
4348
+ {
4349
+ test.editWindow = ab.object.editWindow;
4350
+ ab.object = test;
4351
+ }
4352
+ }
4353
+
4354
+ refreshContents(true);
4355
+ }
4356
+
4357
+ cButton previousVersionButton;
4358
+ cButton restoreButton;
4359
+ cButton replaceButton;
4360
+ cButton nextVersionButton;
4361
+ cButton saveVersionButton;
4362
+ cButton deleteVersionButton;
4363
+
4364
+ boolean muteSlider;
4365
+
4366
+ int VersionCount()
4367
+ {
4368
+ int count = 0;
4369
+
4370
+ for (int i = copy.versionlist.length; --i >= 0;)
4371
+ {
4372
+ if (copy.versionlist[i] != null)
4373
+ count++;
4374
+ }
4375
+
4376
+ return count;
4377
+ }
4378
+
4379
+ void SetVersionStates()
4380
+ {
4381
+ //if (true)
4382
+ // return;
4383
+
4384
+ //cRadio tab = GetCurrentTab();
4385
+
4386
+ restoreButton.setEnabled(copy.versionindex != -1);
4387
+ replaceButton.setEnabled(copy.versionindex != -1);
4388
+
4389
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4390
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4391
+
4392
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4393
+ copy.versionlist[copy.versionindex + 1] != null);
4394
+
4395
+ muteSlider = true;
4396
+ versionSlider.setMinimum(0);
4397
+ versionSlider.setMaximum(VersionCount() - 1);
4398
+ versionSlider.setInteger(copy.versionindex);
4399
+ versionSlider.setEnabled(copy.versionindex != -1);
4400
+ muteSlider = false;
4401
+ }
4402
+
4403
+ public boolean PreviousVersion()
4404
+ {
4405
+ // Option?
4406
+ Replace();
4407
+
4408
+ System.err.println("Undo");
4409
+
4410
+ //cRadio tab = GetCurrentTab();
4411
+
4412
+ if (copy.versionindex == 0)
4413
+ {
4414
+ java.awt.Toolkit.getDefaultToolkit().beep();
4415
+ return false;
4416
+ }
4417
+
4418
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4419
+// {
4420
+// if (Save(false))
4421
+// tab.versionindex -= 1;
4422
+// else
4423
+// {
4424
+// if (tab.versionindex <= 0)
4425
+// return false;
4426
+// else
4427
+// tab.versionindex -= 1;
4428
+// }
4429
+// }
4430
+
4431
+ copy.versionindex -= 1;
4432
+
4433
+ CopyChanged();
4434
+
4435
+ return true;
4436
+ }
4437
+
4438
+ public boolean Restore()
4439
+ {
4440
+ System.err.println("Restore");
4441
+
4442
+ //cRadio tab = GetCurrentTab();
4443
+
4444
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4445
+ {
4446
+ java.awt.Toolkit.getDefaultToolkit().beep();
4447
+ return false;
4448
+ }
4449
+
4450
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4451
+ CopyChanged();
4452
+
4453
+ return true;
4454
+ }
4455
+
4456
+ public boolean Replace()
4457
+ {
4458
+ System.err.println("Replace");
4459
+
4460
+ //cRadio tab = GetCurrentTab();
4461
+
4462
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4463
+ {
4464
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4465
+ return false;
4466
+ }
4467
+
4468
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4469
+
4470
+ return true;
4471
+ }
4472
+
4473
+ public void NextVersion()
4474
+ {
4475
+ // Option?
4476
+ Replace();
4477
+
4478
+ //cRadio tab = GetCurrentTab();
4479
+
4480
+ if (copy.versionlist[copy.versionindex + 1] == null)
4481
+ {
4482
+ java.awt.Toolkit.getDefaultToolkit().beep();
4483
+ return;
4484
+ }
4485
+
4486
+ copy.versionindex += 1;
4487
+
4488
+ CopyChanged();
4489
+
4490
+ //if (!tab.user[tab.versionindex])
4491
+ // tab.graphs[tab.versionindex] = null;
4492
+ }
4493
+
4494
+ void ImportGFD()
4495
+ {
4496
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
4497
+ browser.show();
4498
+ String filename = browser.getFile();
4499
+ if (filename != null && filename.length() > 0)
4500
+ {
4501
+ String fullname = browser.getDirectory() + filename;
4502
+
4503
+ //Object3D readobj =
4504
+ objEditor.ReadGFD(fullname, objEditor);
4505
+ //makeSomething(readobj);
4506
+ }
4507
+ }
4508
+
4509
+ void ImportVRMLX3D()
4510
+ {
4511
+ if (Grafreed.standAlone)
4512
+ {
4513
+ /**/
4514
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
4515
+ browser.show();
4516
+ String filename = browser.getFile();
4517
+ if (filename != null && filename.length() > 0)
4518
+ {
4519
+ String fullname = browser.getDirectory() + filename;
4520
+ LoadVRMLX3D(fullname);
4521
+ }
4522
+ /**/
4523
+ }
4524
+ }
4525
+
32434526 void ToggleAnimation()
32444527 {
32454528 if (!Globals.ANIMATION)
....@@ -3357,7 +4640,7 @@
33574640 assert false;
33584641 }
33594642
3360
- void EditSelection()
4643
+ void EditSelection(boolean newWindow)
33614644 {
33624645 }
33634646
....@@ -3416,7 +4699,7 @@
34164699 //copy.material = new cMaterial(copy.GetMaterial());
34174700
34184701 current.color = (float) colorField.getFloat();
3419
- current.modulation = (float) modulationField.getFloat();
4702
+ current.modulation = (float) saturationField.getFloat();
34204703 current.metalness = (float) metalnessField.getFloat();
34214704 current.diffuse = (float) diffuseField.getFloat();
34224705 current.specular = (float) specularField.getFloat();
....@@ -3449,7 +4732,7 @@
34494732 cMaterial mat = copy.material;
34504733
34514734 colorField.SetToolTipValue((mat.color));
3452
- modulationField.SetToolTipValue((mat.modulation));
4735
+ saturationField.SetToolTipValue((mat.modulation));
34534736 metalnessField.SetToolTipValue((mat.metalness));
34544737 diffuseField.SetToolTipValue((mat.diffuse));
34554738 specularField.SetToolTipValue((mat.specular));
....@@ -3501,9 +4784,28 @@
35014784 //copy.Touch();
35024785 }
35034786
4787
+ cNumberSlider versionSlider;
4788
+
35044789 public void stateChanged(ChangeEvent e)
35054790 {
35064791 // assert(false);
4792
+ if (e.getSource() == versionSlider)
4793
+ {
4794
+ if (muteSlider)
4795
+ return;
4796
+
4797
+ Replace();
4798
+
4799
+ int version = versionSlider.getInteger();
4800
+
4801
+ if (version != -1 && copy.versionlist[version] != null)
4802
+ {
4803
+ copy.versionindex = version;
4804
+ CopyChanged();
4805
+ }
4806
+
4807
+ return;
4808
+ }
35074809
35084810 if (freezematerial)
35094811 {
....@@ -3539,6 +4841,12 @@
35394841 {
35404842 //System.out.println("stateChanged = " + this);
35414843 materialtouched = true;
4844
+
4845
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4846
+ {
4847
+ saturationField.setFloat(1);
4848
+ }
4849
+
35424850 applySelf();
35434851 //System.out.println("this = " + this);
35444852 //System.out.println("PARENT = " + parent);
....@@ -3588,7 +4896,7 @@
35884896 }
35894897
35904898 if (normalpushField != null)
3591
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4899
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35924900 }
35934901
35944902 void SnapObject()
....@@ -3838,6 +5146,7 @@
38385146 {
38395147 if (GetTree() != null)
38405148 {
5149
+ GetTree().revalidate();
38415150 GetTree().repaint();
38425151 }
38435152
....@@ -3846,12 +5155,17 @@
38465155 ctrlPanel.validate(); // ? new
38475156 ctrlPanel.repaint();
38485157 }
5158
+
5159
+ if (previousVersionButton != null && copy.versionlist != null)
5160
+ SetVersionStates();
38495161 }
38505162
38515163 static TweenManager tweenManager = new TweenManager();
38525164
38535165 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
38545166 {
5167
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5168
+ Save();
38555169 //Tween.set(thing, 0).target(1).start(tweenManager);
38565170 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
38575171 // if (thing instanceof GenericJointDemo)
....@@ -3938,6 +5252,12 @@
39385252 {
39395253 ResetModel();
39405254 Select(thing.GetTreePath(), true, false); // unselect... false);
5255
+
5256
+ if (thing.Size() == 0)
5257
+ {
5258
+ //EditSelection(false);
5259
+ }
5260
+
39415261 refreshContents();
39425262 }
39435263
....@@ -4055,6 +5375,7 @@
40555375 }
40565376 }
40575377 }
5378
+
40585379 LoadGFDThread loadGFDThread;
40595380
40605381 void ReadGFD(String fullname, iCallBack cb)
....@@ -4074,8 +5395,10 @@
40745395
40755396 try
40765397 {
5398
+ // Try compressed version first.
40775399 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4078
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5400
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
5401
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40795402
40805403 readobj = (Object3D) p.readObject();
40815404 istream.close();
....@@ -4083,7 +5406,22 @@
40835406 readobj.ResetDisplayList();
40845407 } catch (Exception e)
40855408 {
4086
- e.printStackTrace();
5409
+ if (!e.toString().contains("GZIP"))
5410
+ e.printStackTrace();
5411
+
5412
+ try
5413
+ {
5414
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
5415
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5416
+
5417
+ readobj = (Object3D) p.readObject();
5418
+ istream.close();
5419
+
5420
+ readobj.ResetDisplayList();
5421
+ } catch (Exception e2)
5422
+ {
5423
+ e2.printStackTrace();
5424
+ }
40875425 }
40885426 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40895427 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4129,6 +5467,12 @@
41295467
41305468 void LoadIt(Object obj)
41315469 {
5470
+ if (obj == null)
5471
+ {
5472
+ // Invalid file
5473
+ return;
5474
+ }
5475
+
41325476 System.out.println("Loaded " + obj);
41335477 //new Exception().printStackTrace();
41345478 Object3D readobj = (Object3D) obj;
....@@ -4138,10 +5482,14 @@
41385482
41395483 if (readobj != null)
41405484 {
5485
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5486
+ // Save();
41415487 try
41425488 {
41435489 //readobj.deepCopySelf(copy);
41445490 copy.clear(); // june 2014
5491
+ copy.skyboxname = readobj.skyboxname;
5492
+ copy.skyboxext = readobj.skyboxext;
41455493 for (int i = 0; i < readobj.size(); i++)
41465494 {
41475495 Object3D child = readobj.get(i); // reserve(i);
....@@ -4182,6 +5530,7 @@
41825530 }
41835531 } catch (ClassCastException e)
41845532 {
5533
+ e.printStackTrace();
41855534 assert (false);
41865535 Composite c = (Composite) copy;
41875536 c.children.clear();
....@@ -4192,17 +5541,31 @@
41925541 c.addChild(csg);
41935542 }
41945543
5544
+ copy.versionlist = readobj.versionlist;
5545
+ copy.versionindex = readobj.versionindex;
5546
+
5547
+ if (copy.versionlist == null)
5548
+ {
5549
+ // Backward compatibility
5550
+ copy.versionlist = new Object3D[100];
5551
+ copy.versionindex = -1;
5552
+
5553
+ //Save(true);
5554
+ }
5555
+
5556
+ //? SetUndoStates();
5557
+
41955558 ResetModel();
41965559 copy.HardTouch(); // recompile?
41975560 refreshContents();
41985561 }
41995562 }
42005563
4201
- void load() // throws ClassNotFoundException
5564
+ void Open() // throws ClassNotFoundException
42025565 {
42035566 if (Grafreed.standAlone)
42045567 {
4205
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5568
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
42065569 browser.show();
42075570 String filename = browser.getFile();
42085571 if (filename != null && filename.length() > 0)
....@@ -4279,6 +5642,8 @@
42795642
42805643 void save()
42815644 {
5645
+ Replace();
5646
+
42825647 if (lastname == null)
42835648 {
42845649 return;
....@@ -4287,11 +5652,13 @@
42875652 try
42885653 {
42895654 FileOutputStream ostream = new FileOutputStream(lastname);
4290
- ObjectOutputStream p = new ObjectOutputStream(ostream);
5655
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5656
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42915657
42925658 p.writeObject(copy);
42935659 p.flush();
42945660
5661
+ zstream.close();
42955662 ostream.close();
42965663
42975664 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4299,8 +5666,10 @@
42995666 //ps.print(buffer.toString());
43005667 } catch (IOException e)
43015668 {
5669
+ e.printStackTrace();
43025670 }
43035671 }
5672
+
43045673 String lastname;
43055674
43065675 void saveAs()
....@@ -4312,6 +5681,8 @@
43125681 String filename = browser.getFile();
43135682 if (filename != null && filename.length() > 0)
43145683 {
5684
+ if (!filename.endsWith(".gfd"))
5685
+ filename += ".gfd";
43155686 lastname = browser.getDirectory() + filename;
43165687 save();
43175688 }
....@@ -4410,8 +5781,8 @@
44105781 try
44115782 {
44125783 FileOutputStream ostream = new FileOutputStream(filename);
4413
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4414
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
5784
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5785
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
44155786
44165787 Object3D objectparent = obj.parent;
44175788 obj.parent = null;
....@@ -4428,8 +5799,8 @@
44285799 p.writeObject(object);
44295800 p.flush();
44305801
5802
+ zstream.close();
44315803 ostream.close();
4432
- // zstream.close();
44335804
44345805 // group.selection.get(0).parent = parent;
44355806 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4476,19 +5847,18 @@
44765847 Object3D client;
44775848 Object3D copy;
44785849 MenuBar menuBar;
4479
- Menu windowMenu;
4480
- MenuItem loadItem;
5850
+ Menu fileMenu;
5851
+ MenuItem newItem;
5852
+ MenuItem openItem;
44815853 MenuItem saveItem;
44825854 MenuItem saveAsItem;
44835855 MenuItem exportAsItem;
44845856 MenuItem reexportItem;
44855857 MenuItem povItem;
44865858 MenuItem closeItem;
4487
- Menu cameraMenu;
5859
+
44885860 CheckboxMenuItem zBufferItem;
44895861 //MenuItem normalLensItem;
4490
- MenuItem editCameraItem;
4491
- MenuItem revertCameraItem;
44925862 MenuItem stepItem;
44935863 CheckboxMenuItem toggleLiveItem;
44945864 CheckboxMenuItem toggleFullScreenItem;
....@@ -4502,22 +5872,37 @@
45025872 CheckboxMenuItem toggleSwitchItem;
45035873 CheckboxMenuItem toggleRootItem;
45045874 CheckboxMenuItem animationItem;
5875
+ MenuItem archiveItem;
45055876 CheckboxMenuItem toggleHandleItem;
45065877 CheckboxMenuItem togglePaintItem;
45075878 JSplitPane mainPanel;
45085879 JScrollPane scrollpane;
5880
+
45095881 JPanel toolbarPanel;
5882
+
45105883 cGridBag treePanel;
5884
+
45115885 JPanel radioPanel;
45125886 ButtonGroup buttonGroup;
4513
- cGridBag ctrlPanel;
5887
+
5888
+ cGridBag toolboxPanel;
5889
+ cGridBag skyboxPanel;
45145890 cGridBag materialPanel;
5891
+ cGridBag ctrlPanel;
5892
+
45155893 JScrollPane infoPanel;
5894
+
45165895 cGridBag optionsPanel;
5896
+
45175897 JTabbedPane objectPanel;
5898
+ boolean materialFlushed;
5899
+ Object3D latestObject;
5900
+
45185901 cGridBag XYZPanel;
5902
+
45195903 JSplitPane gridPanel;
45205904 JSplitPane bigPanel;
5905
+
45215906 cGridBag bigThree;
45225907 cGridBag scenePanel;
45235908 cGridBag centralPanel;
....@@ -4575,7 +5960,7 @@
45755960 JLabel colorLabel;
45765961 cNumberSlider colorField;
45775962 JLabel modulationLabel;
4578
- cNumberSlider modulationField;
5963
+ cNumberSlider saturationField;
45795964 JLabel metalnessLabel;
45805965 cNumberSlider metalnessField;
45815966 JLabel diffuseLabel;
....@@ -4606,6 +5991,7 @@
46065991 cNumberSlider anisoField;
46075992 JLabel anisoVLabel;
46085993 cNumberSlider anisoVField;
5994
+
46095995 JLabel cameraLabel;
46105996 cNumberSlider cameraField;
46115997 JLabel selfshadowLabel;
....@@ -4620,6 +6006,7 @@
46206006 cNumberSlider fakedepthField;
46216007 JLabel shadowbiasLabel;
46226008 cNumberSlider shadowbiasField;
6009
+
46236010 JLabel bumpLabel;
46246011 cNumberSlider bumpField;
46256012 JLabel noiseLabel;
....@@ -4632,8 +6019,13 @@
46326019 cNumberSlider fogField;
46336020 JLabel opacityPowerLabel;
46346021 cNumberSlider opacityPowerField;
4635
- JTree jTree;
6022
+ cTree jTree;
46366023 //ObjectUI parent;
46376024
46386025 cNumberSlider normalpushField;
6026
+
6027
+ private MenuItem importGFDItem;
6028
+ private MenuItem importVRMLX3DItem;
6029
+ private MenuItem import3DSItem;
6030
+ private MenuItem importOBJItem;
46396031 }