Normand Briere
2019-08-15 33504fc9a180903aace77613264550754fba5706
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,128 @@
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
+ return new cButton(icon, border);
87
+ }
88
+
89
+ cLabel GetLabel(String name, boolean border)
90
+ {
91
+ //ImageIcon icon = GetIcon(name);
92
+ return new cLabel(GetImage(name), border);
93
+ }
94
+
95
+ cToggleButton GetToggleButton(String name, boolean border)
96
+ {
97
+ ImageIcon icon = GetIcon(name);
98
+ return new cToggleButton(icon, border);
99
+ }
100
+
101
+ cCheckBox GetCheckBox(String name, boolean border)
102
+ {
103
+ ImageIcon icon = GetIcon(name);
104
+ return new cCheckBox(icon, border);
105
+ }
106
+
107
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
108
+
109
+ ImageIcon GetIcon(String name)
110
+ {
111
+ javax.swing.ImageIcon iconCache = icons.get(name);
112
+ if (iconCache != null)
113
+ {
114
+ return iconCache;
115
+ }
116
+
117
+ try
118
+ {
119
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
120
+
121
+// if (image.getWidth() > 48 && image.getHeight() > 48)
122
+// {
123
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
124
+// Graphics2D g = resized.createGraphics();
125
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
126
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
127
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
128
+// g.dispose();
129
+//
130
+// image = resized;
131
+// }
132
+
133
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
134
+
135
+ icons.put(name, icon);
136
+
137
+ return icon;
138
+ }
139
+ catch (Exception e)
140
+ {
141
+ //icons.put(name, null);
142
+ return null;
143
+ }
144
+ }
145
+
146
+ BufferedImage GetImage(String name)
147
+ {
148
+ try
149
+ {
150
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
151
+
152
+ return image;
153
+ }
154
+ catch (Exception e)
155
+ {
156
+ return null;
157
+ }
158
+ }
38159
39160 // SCRIPT
40161
....@@ -145,7 +266,7 @@
145266
146267 objEditor.ctrlPanel.remove(namePanel);
147268
148
- if (!GroupEditor.allparams)
269
+ if (!allparams)
149270 return;
150271
151272 // objEditor.ctrlPanel.remove(liveCB);
....@@ -168,7 +289,8 @@
168289 // objEditor.ctrlPanel.remove(remarkButton);
169290
170291 objEditor.ctrlPanel.remove(setupPanel);
171
- objEditor.ctrlPanel.remove(commandsPanel);
292
+ objEditor.ctrlPanel.remove(setupPanel2);
293
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
172294 objEditor.ctrlPanel.remove(pushPanel);
173295 //objEditor.ctrlPanel.remove(fillPanel);
174296
....@@ -216,6 +338,14 @@
216338 client = inClient;
217339 copy = client;
218340
341
+// if (copy.versionlist == null)
342
+// {
343
+// copy.versionlist = new Object3D[100];
344
+// copy.versionindex = -1;
345
+//
346
+// callee.Save(true);
347
+// }
348
+
219349 // "this" is not called: SetupUI2(objEditor);
220350 }
221351
....@@ -229,6 +359,14 @@
229359 client = inClient;
230360 copy = client;
231361
362
+ if (copy.versionlist == null)
363
+ {
364
+ copy.versionlist = new Object3D[100];
365
+ copy.versionindex = -1;
366
+
367
+// Save(true);
368
+ }
369
+
232370 SetupUI2(callee.GetEditor());
233371 }
234372
....@@ -243,6 +381,7 @@
243381 //localCopy.parent = null;
244382
245383 frame = new JFrame();
384
+ frame.setUndecorated(false);
246385 objEditor = this;
247386 this.callee = callee;
248387
....@@ -260,6 +399,14 @@
260399 copy = localCopy;
261400 copy.editWindow = this;
262401
402
+// if (copy.versionlist == null)
403
+// {
404
+// copy.versionlist = new Object3D[100];
405
+// copy.versionindex = -1;
406
+//
407
+// Save(true);
408
+// }
409
+
263410 SetupMenu();
264411
265412 //SetupName(objEditor); // new
....@@ -273,28 +420,49 @@
273420 return frame.action(event, obj);
274421 }
275422
423
+ // Cannot work without static
424
+ static boolean allparams = true;
425
+
426
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
427
+
276428 void SetupMenu()
277429 {
278430 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..."));
431
+ menuBar.add(fileMenu = new Menu("File"));
432
+ fileMenu.add(newItem = new MenuItem("New"));
433
+ fileMenu.add(openItem = new MenuItem("Open..."));
434
+
435
+ //oe.menuBar.add(menu = new Menu("Include"));
436
+ Menu menu = new Menu("Import");
437
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
438
+ importOBJItem.addActionListener(this);
439
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
440
+ import3DSItem.addActionListener(this);
441
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
442
+ importVRMLX3DItem.addActionListener(this);
443
+ menu.add("-");
444
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
445
+ importGFDItem.addActionListener(this);
446
+ fileMenu.add(menu);
447
+ fileMenu.add("-");
448
+
449
+ fileMenu.add(saveItem = new MenuItem("Save"));
450
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
284451 //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("-");
452
+ fileMenu.add("-");
453
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
454
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
455
+ fileMenu.add("-");
289456 if (client.parent != null)
290457 {
291
- windowMenu.add(closeItem = new MenuItem("Close"));
458
+ fileMenu.add(closeItem = new MenuItem("Close"));
292459 } else
293460 {
294
- windowMenu.add(closeItem = new MenuItem("Exit"));
461
+ fileMenu.add(closeItem = new MenuItem("Exit"));
295462 }
296463
297
- loadItem.addActionListener(this);
464
+ newItem.addActionListener(this);
465
+ openItem.addActionListener(this);
298466 saveItem.addActionListener(this);
299467 saveAsItem.addActionListener(this);
300468 exportAsItem.addActionListener(this);
....@@ -302,100 +470,103 @@
302470 //povItem.addActionListener(this);
303471 closeItem.addActionListener(this);
304472
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
- if (Globals.ADVANCED)
323
- {
324
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
325
- toggleLiveItem.addItemListener(this);
326
- toggleLiveItem.setState(Globals.isLIVE());
327
-
328
- cameraMenu.add(stepItem = new MenuItem("Step"));
329
- stepItem.addActionListener(this);
330
- // cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
331
- // toggleDLItem.addItemListener(this);
332
- // toggleDLItem.setState(false);
333
-
334
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
335
- toggleRenderItem.addItemListener(this);
336
- toggleRenderItem.setState(!CameraPane.frozen);
337
-
338
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
339
- toggleDebugItem.addItemListener(this);
340
- toggleDebugItem.setState(CameraPane.DEBUG);
341
-
342
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
343
- toggleFrustumItem.addItemListener(this);
344
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
345
-
346
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
347
- toggleFootContactItem.addItemListener(this);
348
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
349
-
350
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
351
- toggleTimelineItem.addItemListener(this);
352
- }
353
-
354
- cameraMenu.add(toggleSwitchItem = new CheckboxMenuItem("Switch"));
355
- toggleSwitchItem.addItemListener(this);
356
- toggleSwitchItem.setState(CameraPane.SWITCH);
357
-
358
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
359
- toggleHandleItem.addItemListener(this);
360
- toggleHandleItem.setState(CameraPane.HANDLES);
361
-
362
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
363
- togglePaintItem.addItemListener(this);
364
- togglePaintItem.setState(CameraPane.PAINTMODE);
365
-
366
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
367
-// toggleRootItem.addItemListener(this);
368
-// toggleRootItem.setState(false);
369
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
370
-// animationItem.addItemListener(this);
371
-// animationItem.setState(CameraPane.ANIMATION);
372
- cameraMenu.add("-");
373
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
374
- editCameraItem.addActionListener(this);
375
-
376473 objectPanel = new JTabbedPane();
474
+
475
+ ChangeListener changeListener = new ChangeListener()
476
+ {
477
+ //String name;
478
+
479
+ public void stateChanged(ChangeEvent changeEvent)
480
+ {
481
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
482
+// {
483
+// if (latestObject != null)
484
+// {
485
+// refreshContents(true);
486
+// SetMaterial(latestObject);
487
+// }
488
+//
489
+// materialFlushed = true;
490
+// }
491
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
492
+// {
493
+// if (listUI.size() == 0)
494
+// EditSelection(false);
495
+// }
496
+
497
+// if (objectPanel.getSelectedIndex() == 4)
498
+// {
499
+// name = copy.skyboxname;
500
+//
501
+// if (name == null)
502
+// {
503
+// name = "";
504
+// }
505
+//
506
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
507
+// copy.skyboxext = "jpg";
508
+// }
509
+// else
510
+// {
511
+// if (name != null)
512
+// {
513
+// if (name.equals(""))
514
+// {
515
+// copy.skyboxname = null;
516
+// copy.skyboxext = null;
517
+// }
518
+// else
519
+// {
520
+// copy.skyboxname = name;
521
+// }
522
+// }
523
+// }
524
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
525
+
526
+// refreshContents(false); // To refresh Info tab
527
+ cameraView.repaint();
528
+ }
529
+ };
530
+ objectPanel.addChangeListener(changeListener);
531
+
377532 toolbarPanel = new JPanel();
378533 toolbarPanel.setName("Toolbar");
534
+
379535 treePanel = new cGridBag();
380536 treePanel.setName("Tree");
537
+
538
+ editPanel = new cGridBag().setVertical(true);
539
+ //editPanel.setName("Edit");
540
+
381541 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
382
- ctrlPanel.setName("Edit");
383
- materialPanel = new cGridBag().setVertical(true);
384
- materialPanel.setName("Material");
542
+
543
+ editCommandsPanel = new cGridBag();
544
+ editPanel.add(editCommandsPanel);
545
+ editPanel.add(ctrlPanel);
546
+
547
+ toolboxPanel = new cGridBag().setVertical(true);
548
+ //toolboxPanel.setName("Toolbox");
549
+
550
+ skyboxPanel = new cGridBag().setVertical(true);
551
+
552
+ materialPanel = new cGridBag().setVertical(false);
553
+ //materialPanel.setName("Material");
554
+
385555 /*JTextPane*/
386556 infoarea = createTextPane();
387557 doc = infoarea.getStyledDocument();
388558
389559 infoarea.setEditable(true);
390560 SetText();
561
+
391562 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
392563 // infoarea.setOpaque(false);
393564 // //infoarea.setForeground(textcolor);
394565 // TEXTAREA infoarea.setLineWrap(true);
395566 // TEXTAREA infoarea.setWrapStyleWord(true);
396567 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
397
- infoPanel.setPreferredSize(new Dimension(50, 200));
398
- infoPanel.setName("Info");
568
+ infoPanel.setPreferredSize(new Dimension(1, 1));
569
+ //infoPanel.setName("Info");
399570 //infoPanel.setLayout(new BorderLayout());
400571 //infoPanel.add(createTextPane());
401572
....@@ -406,7 +577,14 @@
406577 mainPanel.setDividerSize(9);
407578 mainPanel.setDividerLocation(0.5); //1.0);
408579 mainPanel.setResizeWeight(0.5);
409
-
580
+
581
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
582
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
583
+ divider.setDividerSize(15);
584
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
585
+
586
+ mainPanel.setUI(new BasicSplitPaneUI());
587
+
410588 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
411589 //mainPanel.setLayout(new GridBagLayout());
412590 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -474,10 +652,10 @@
474652 e.printStackTrace();
475653 }
476654
477
- String selection = infoarea.getText();
478
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
479
- java.awt.datatransfer.Clipboard clipboard =
480
- Toolkit.getDefaultToolkit().getSystemClipboard();
655
+// String selection = infoarea.getText();
656
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
657
+// java.awt.datatransfer.Clipboard clipboard =
658
+// Toolkit.getDefaultToolkit().getSystemClipboard();
481659 //clipboard.setContents(data, data);
482660 }
483661
....@@ -500,13 +678,13 @@
500678 //SendInfo("Name:", "bold");
501679 if (sel.GetTextures() != null || debug)
502680 {
503
- si.SendInfo(sel.toString(), "bold");
681
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
504682 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
505683 if (sel.Size() > 0)
506684 {
507685 si.SendInfo("#children = " + sel.Size(), "regular");
508686 }
509
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
687
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
510688 if (debug)
511689 {
512690 try
....@@ -548,7 +726,7 @@
548726 }
549727 if (sel.support != null)
550728 {
551
- si.SendInfo(" support: " + sel.support, "regular");
729
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
552730 }
553731 if (sel.scriptnode != null)
554732 {
....@@ -637,21 +815,158 @@
637815 }
638816 }
639817
818
+//static GraphicsDevice device = GraphicsEnvironment
819
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
820
+
821
+ Rectangle keeprect;
822
+ cRadio radio;
823
+
824
+cButton keepButton;
825
+ cButton twoButton; // Full 3D
826
+ cButton sixButton;
827
+ cButton threeButton;
828
+ cButton sevenButton;
829
+ cButton fourButton; // full panel
830
+ cButton oneButton; // full XYZ
831
+ //cButton currentLayout;
832
+
833
+ boolean maximized;
834
+
835
+ cButton fullscreenLayout;
836
+ cButton expandedLayout;
837
+
838
+ void Minimize()
839
+ {
840
+ frame.setState(Frame.ICONIFIED);
841
+ frame.validate();
842
+ }
843
+
844
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
845
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
846
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
847
+ void Maximize()
848
+ {
849
+ if (CameraPane.FULLSCREEN)
850
+ {
851
+ ToggleFullScreen();
852
+ }
853
+
854
+ if (maximized)
855
+ {
856
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
857
+ }
858
+ else
859
+ {
860
+ keeprect = frame.getBounds();
861
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
862
+// Dimension rect2 = frame.getToolkit().getScreenSize();
863
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
864
+// frame.setState(Frame.MAXIMIZED_BOTH);
865
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
866
+ }
867
+
868
+ maximized ^= true;
869
+
870
+ frame.validate();
871
+ }
872
+
873
+ cButton minButton;
874
+ cButton maxButton;
875
+ cButton fullButton;
876
+ cButton collapseButton;
877
+ cButton maximize3DButton;
878
+
640879 void ToggleFullScreen()
641880 {
642
- if (CameraPane.FULLSCREEN)
881
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
882
+
883
+ cameraView.ToggleFullScreen();
884
+
885
+ if (!CameraPane.FULLSCREEN)
643886 {
644
- frame.getContentPane().remove(/*"Center",*/bigThree);
645
- framePanel.add(bigThree);
646
- frame.getContentPane().add(/*"Center",*/framePanel);
887
+ device.setFullScreenWindow(null);
888
+ frame.dispose();
889
+ frame.setUndecorated(false);
890
+ frame.validate();
891
+ frame.setVisible(true);
892
+
893
+ //frame.setVisible(false);
894
+// frame.removeNotify();
895
+// frame.setUndecorated(false);
896
+// frame.addNotify();
897
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
898
+
899
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
900
+// X framePanel.add(bigThree);
901
+// X frame.getContentPane().add(/*"Center",*/framePanel);
902
+// framePanel.setDividerLocation(46); // icons are 24x24
903
+
904
+ //frame.setVisible(true);
905
+// radio.layout = keepButton;
906
+ //theFrame = null;
907
+ keepButton = null;
908
+// radio.layout.doClick();
909
+
647910 } else
648911 {
649
- frame.getContentPane().remove(/*"Center",*/framePanel);
650
- framePanel.remove(bigThree);
651
- frame.getContentPane().add(/*"Center",*/bigThree);
912
+ keepButton = radio.layout;
913
+ //keeprect = frame.getBounds();
914
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
915
+// frame.getToolkit().getScreenSize().height);
916
+ //frame.setVisible(false);
917
+
918
+ frame.dispose();
919
+ frame.setUndecorated(true);
920
+ device.setFullScreenWindow(frame);
921
+ frame.validate();
922
+ frame.setVisible(true);
923
+// frame.removeNotify();
924
+// frame.setUndecorated(true);
925
+// frame.addNotify();
926
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
927
+// X framePanel.remove(bigThree);
928
+// X frame.getContentPane().add(/*"Center",*/bigThree);
929
+// framePanel.setDividerLocation(0);
930
+
931
+// radio.layout = fullscreenLayout;
932
+// radio.layout.doClick();
933
+ //frame.setVisible(true);
652934 }
653
- cameraView.ToggleFullScreen();
935
+ frame.validate();
936
+
937
+ cameraView.requestFocusInWindow();
654938 }
939
+
940
+ void CollapseToolbar()
941
+ {
942
+ framePanel.setDividerLocation(0);
943
+ //frame.validate();
944
+
945
+ cameraView.requestFocusInWindow();
946
+ }
947
+
948
+ private Object3D Duplicate(Object3D object)
949
+ {
950
+ boolean temp = CameraPane.SWITCH;
951
+ CameraPane.SWITCH = false;
952
+
953
+ object.ExtractBigData(versiontable);
954
+ // if (copy == client)
955
+
956
+ Object3D versions[] = object.versionlist;
957
+ object.versionlist = null;
958
+
959
+ //byte[] compress = Compress(copy);
960
+ Object3D compress = (Object3D)Grafreed.clone(object);
961
+
962
+ object.versionlist = versions;
963
+
964
+ object.RestoreBigData(versiontable);
965
+
966
+ CameraPane.SWITCH = temp;
967
+
968
+ return compress;
969
+ }
655970
656971 private JTextPane createTextPane()
657972 {
....@@ -751,7 +1066,7 @@
7511066 protected static ImageIcon createImageIcon(String path,
7521067 String description)
7531068 {
754
- java.net.URL imgURL = GrafreeD.class.getResource(path);
1069
+ java.net.URL imgURL = Grafreed.class.getResource(path);
7551070 if (imgURL != null)
7561071 {
7571072 return new ImageIcon(imgURL, description);
....@@ -774,6 +1089,7 @@
7741089 {
7751090 SetupMaterial(materialPanel);
7761091 }
1092
+
7771093 //SetupName();
7781094 //SetupViews();
7791095 }
....@@ -783,6 +1099,7 @@
7831099 // NumberSlider vDivsField;
7841100 // JCheckBox endcaps;
7851101 JCheckBox liveCB;
1102
+ JCheckBox selectableCB;
7861103 JCheckBox hideCB;
7871104 JCheckBox link2masterCB;
7881105 JCheckBox markCB;
....@@ -790,7 +1107,12 @@
7901107 JCheckBox speedupCB;
7911108 JCheckBox rewindCB;
7921109 JCheckBox flipVCB;
1110
+
1111
+ cCheckBox toggleTextureCB;
1112
+ cCheckBox toggleSwitchCB;
1113
+
7931114 JComboBox texresMenu;
1115
+
7941116 JButton resetButton;
7951117 JButton stepButton;
7961118 JButton stepAllButton;
....@@ -799,9 +1121,13 @@
7991121 JButton fasterButton;
8001122 JButton remarkButton;
8011123
1124
+ cGridBag editPanel;
1125
+ cGridBag editCommandsPanel;
1126
+
8021127 cGridBag namePanel;
8031128 cGridBag setupPanel;
804
- cGridBag commandsPanel;
1129
+ cGridBag setupPanel2;
1130
+ cGridBag objectCommandsPanel;
8051131 cGridBag pushPanel;
8061132 cGridBag fillPanel;
8071133
....@@ -972,62 +1298,84 @@
9721298
9731299 namePanel = new cGridBag();
9741300
1301
+ //if (copy.pinned)
1302
+ {
1303
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1304
+ pinButton.setSelected(copy.pinned);
1305
+ cGridBag t = new cGridBag();
1306
+ t.preferredWidth = 2;
1307
+ t.add(pinButton);
1308
+ namePanel.add(t);
1309
+
1310
+ pinButton.addItemListener(this);
1311
+ }
1312
+
9751313 nameField = AddText(namePanel, copy.GetName());
976
- namePanel.add(nameField);
1314
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9771315 oe.ctrlPanel.add(namePanel);
9781316
9791317 oe.ctrlPanel.Return();
9801318
981
- if (!GroupEditor.allparams)
1319
+ if (!allparams)
9821320 return;
9831321
9841322 setupPanel = new cGridBag().setVertical(false);
9851323
9861324 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
9871325 liveCB.setToolTipText("Animate object");
1326
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1327
+ selectableCB.setToolTipText("Make object selectable");
1328
+// Return();
1329
+
9881330 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9891331 hideCB.setToolTipText("Hide object");
990
-// Return();
9911332 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
992
- markCB.setToolTipText("Set the animation target transform");
1333
+ markCB.setToolTipText("As animation target transform");
9931334
994
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1335
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1336
+
1337
+ setupPanel2 = new cGridBag().setVertical(false);
1338
+
1339
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9951340 rewindCB.setToolTipText("Rewind animation");
9961341
997
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
998
- randomCB.setToolTipText("Option for switch node");
1342
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1343
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9991344
1345
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1346
+ link2masterCB.setToolTipText("Attach to support");
1347
+
10001348 if (Globals.ADVANCED)
10011349 {
1002
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
1003
- link2masterCB.setToolTipText("Attach to support");
1004
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1350
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10051351 speedupCB.setToolTipText("Option motion capture");
10061352 }
10071353
10081354 oe.ctrlPanel.add(setupPanel);
10091355 oe.ctrlPanel.Return();
1356
+ oe.ctrlPanel.add(setupPanel2);
1357
+ oe.ctrlPanel.Return();
10101358
1011
- commandsPanel = new cGridBag().setVertical(false);
1359
+ objectCommandsPanel = new cGridBag().setVertical(false);
10121360
1013
- resetButton = AddButton(commandsPanel, "Reset");
1361
+ resetButton = AddButton(objectCommandsPanel, "Reset");
10141362 resetButton.setToolTipText("Jump to frame zero");
1015
- stepButton = AddButton(commandsPanel, "Step");
1363
+ stepButton = AddButton(objectCommandsPanel, "Step");
10161364 stepButton.setToolTipText("Step one frame");
10171365 // resetAllButton = AddButton(oe, "Reset All");
10181366 // stepAllButton = AddButton(oe, "Step All");
10191367 // Return();
1020
- slowerButton = AddButton(commandsPanel, "Slow");
1368
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
10211369 slowerButton.setToolTipText("Decrease animation speed");
1022
- fasterButton = AddButton(commandsPanel, "Fast");
1370
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
10231371 fasterButton.setToolTipText("Increase animation speed");
1024
- remarkButton = AddButton(commandsPanel, "Remark");
1372
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
10251373 remarkButton.setToolTipText("Set the current transform as the target");
10261374
1027
- oe.ctrlPanel.add(commandsPanel);
1375
+ oe.ctrlPanel.add(objectCommandsPanel);
10281376 oe.ctrlPanel.Return();
10291377
1030
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1378
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
10311379 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
10321380 //Return();
10331381
....@@ -1230,8 +1578,11 @@
12301578 //worldPanel.setName("World");
12311579 centralPanel = new cGridBag();
12321580 centralPanel.preferredWidth = 20;
1233
- timelinePanel = new JPanel(new BorderLayout());
1234
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1581
+
1582
+ if (Globals.ADVANCED)
1583
+ {
1584
+ timelinePanel = new JPanel(new BorderLayout());
1585
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
12351586
12361587 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
12371588 cameraPanel.setContinuousLayout(true);
....@@ -1240,7 +1591,10 @@
12401591 // cameraPanel.setDividerSize(9);
12411592 cameraPanel.setResizeWeight(1.0);
12421593
1594
+ }
1595
+
12431596 centralPanel.add(cameraView);
1597
+ centralPanel.setFocusable(true);
12441598 //frame.setJMenuBar(timelineMenubar);
12451599 //centralPanel.add(timelinePanel);
12461600
....@@ -1266,6 +1620,7 @@
12661620 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12671621 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12681622 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1623
+ //XYZPanel.setName("XYZ");
12691624
12701625 /*
12711626 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1303,13 +1658,29 @@
13031658 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
13041659 //tmp.setName("Edit");
13051660 objectPanel.add(materialPanel);
1661
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1662
+ objectPanel.setToolTipTextAt(0, "Material");
1663
+
1664
+ objectPanel.add(toolboxPanel);
1665
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1666
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1667
+
1668
+ objectPanel.add(skyboxPanel);
1669
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1670
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1671
+
13061672 // JPanel north = new JPanel(new BorderLayout());
13071673 // north.setName("Edit");
13081674 // north.add(ctrlPanel, BorderLayout.NORTH);
13091675 // objectPanel.add(north);
1310
- objectPanel.add(ctrlPanel);
1311
- objectPanel.add(infoPanel);
1312
-
1676
+ objectPanel.add(editPanel);
1677
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1678
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1679
+
1680
+ objectPanel.add(XYZPanel);
1681
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1682
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1683
+
13131684 /*
13141685 aConstraints.gridx = 0;
13151686 aConstraints.gridwidth = 1;
....@@ -1317,7 +1688,7 @@
13171688 aConstraints.gridy += 1;
13181689 aConstraints.gridwidth = 1;
13191690 mainPanel.add(objectPanel, aConstraints);
1320
- */
1691
+ */
13211692
13221693 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
13231694 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1329,14 +1700,12 @@
13291700 scrollpane.addMouseWheelListener(this); // Default not fast enough
13301701
13311702 /*JTabbedPane*/ scenePanel = new cGridBag();
1332
- scenePanel.preferredWidth = 7;
1703
+ scenePanel.preferredWidth = 5;
13331704
13341705 JTabbedPane tabbedPane = new JTabbedPane();
13351706 tabbedPane.add(scrollpane);
13361707
1337
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1338
-
1339
- optionsPanel = new cGridBag().setVertical(true);
1708
+ optionsPanel = new cGridBag().setVertical(false);
13401709
13411710 optionsPanel.setName("Options");
13421711
....@@ -1344,8 +1713,15 @@
13441713
13451714 tabbedPane.add(optionsPanel);
13461715
1716
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1717
+
13471718 scenePanel.add(tabbedPane);
13481719
1720
+ //if (Globals.ADVANCED)
1721
+// tabbedPane.add(infoPanel);
1722
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1723
+// tabbedPane.setToolTipTextAt(3, "Information");
1724
+
13491725 /*
13501726 cTree jTree = new cTree(null);
13511727 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1407,7 +1783,7 @@
14071783 bigThree = new cGridBag();
14081784 bigThree.addComponent(scenePanel);
14091785 bigThree.addComponent(centralPanel);
1410
- bigThree.addComponent(XYZPanel);
1786
+ //bigThree.addComponent(XYZPanel);
14111787
14121788 // // SIDE EFFECT!!!
14131789 // aConstraints.gridx = 0;
....@@ -1416,16 +1792,33 @@
14161792 // aConstraints.gridheight = 1;
14171793
14181794 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1419
- framePanel.setContinuousLayout(true);
1420
- framePanel.setOneTouchExpandable(true);
1421
- framePanel.setDividerLocation(0.8);
1795
+
1796
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1797
+ new java.beans.PropertyChangeListener()
1798
+ {
1799
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1800
+ {
1801
+ if ((Integer)pce.getOldValue() == 1)
1802
+ {
1803
+ if (radio.layout != expandedLayout)
1804
+ {
1805
+ radio.layout = expandedLayout;
1806
+ radio.layout.doClick();
1807
+ }
1808
+ }
1809
+ }
1810
+ });
1811
+
1812
+ framePanel.setContinuousLayout(false);
1813
+ framePanel.setOneTouchExpandable(false);
1814
+ //.setDividerLocation(0.8);
14221815 //framePanel.setDividerSize(15);
14231816 //framePanel.setResizeWeight(0.15);
14241817 framePanel.setName("Frame");
14251818
14261819 frame.getContentPane().setLayout(new BorderLayout());
14271820 /**/
1428
- JTabbedPane worldPane = new JTabbedPane();
1821
+ //JTabbedPane worldPane = new JTabbedPane();
14291822 //worldPane.add(bigPanel);
14301823 //worldPane.add(worldPanel);
14311824 /**/
....@@ -1435,15 +1828,19 @@
14351828
14361829 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14371830
1438
- frame.setSize(1024, 768);
1439
- frame.show();
1440
-
1831
+ frame.setSize(1280, 860);
1832
+
1833
+ cameraView.requestFocusInWindow();
1834
+
14411835 gridPanel.setDividerLocation(1.0);
1836
+
1837
+ frame.validate();
1838
+
1839
+ frame.setVisible(true);
14421840
14431841 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14441842 frame.addWindowListener(new WindowAdapter()
14451843 {
1446
-
14471844 public void windowClosing(WindowEvent e)
14481845 {
14491846 Close();
....@@ -1466,28 +1863,434 @@
14661863 ctrlPanel.removeAll();
14671864 }
14681865
1469
- void SetupMaterial(cGridBag panel)
1866
+ void SetupMaterial(cGridBag materialpanel)
14701867 {
1471
- /*
1868
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1869
+
1870
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1871
+ skin.setToolTipText("Skin");
1872
+ skin.addMouseListener(new MouseAdapter()
1873
+ {
1874
+ public void mouseClicked(MouseEvent e)
1875
+ {
1876
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1877
+ cMaterial material = object.material;
1878
+
1879
+ // Skin
1880
+ colorField.setFloat(material.color);
1881
+ saturationField.setFloat(material.modulation);
1882
+ subsurfaceField.setFloat(material.subsurface);
1883
+ selfshadowField.setFloat(material.diffuseness);
1884
+ diffusenessField.setFloat(material.factor);
1885
+ shininessField.setFloat(material.shininess);
1886
+ shadowbiasField.setFloat(material.shadowbias);
1887
+ diffuseField.setFloat(material.diffuse);
1888
+ specularField.setFloat(material.specular);
1889
+
1890
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1891
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1892
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1893
+
1894
+ materialtouched = true;
1895
+ applySelf();
1896
+ }
1897
+ });
1898
+ presetpanel.add(skin);
1899
+
1900
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1901
+ lambert.setToolTipText("Diffuse");
1902
+ lambert.addMouseListener(new MouseAdapter()
1903
+ {
1904
+ public void mouseClicked(MouseEvent e)
1905
+ {
1906
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1907
+ cMaterial material = object.material;
1908
+
1909
+ diffusenessField.setFloat(material.factor);
1910
+ selfshadowField.setFloat(material.diffuseness);
1911
+
1912
+ materialtouched = true;
1913
+ applySelf();
1914
+ }
1915
+ });
1916
+ presetpanel.add(lambert);
1917
+
1918
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1919
+ diffuse2.setToolTipText("Diffuse2");
1920
+ diffuse2.addMouseListener(new MouseAdapter()
1921
+ {
1922
+ public void mouseClicked(MouseEvent e)
1923
+ {
1924
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1925
+ cMaterial material = object.material;
1926
+
1927
+ diffusenessField.setFloat(material.factor);
1928
+ selfshadowField.setFloat(material.diffuseness);
1929
+
1930
+ materialtouched = true;
1931
+ applySelf();
1932
+ }
1933
+ });
1934
+ presetpanel.add(diffuse2);
1935
+
1936
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1937
+ diffusemoon.setToolTipText("Moon");
1938
+ diffusemoon.addMouseListener(new MouseAdapter()
1939
+ {
1940
+ public void mouseClicked(MouseEvent e)
1941
+ {
1942
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1943
+ cMaterial material = object.material;
1944
+
1945
+ diffusenessField.setFloat(material.factor);
1946
+ selfshadowField.setFloat(material.diffuseness);
1947
+
1948
+ materialtouched = true;
1949
+ applySelf();
1950
+ }
1951
+ });
1952
+ presetpanel.add(diffusemoon);
1953
+
1954
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1955
+ diffusemoon2.setToolTipText("Moon2");
1956
+ diffusemoon2.addMouseListener(new MouseAdapter()
1957
+ {
1958
+ public void mouseClicked(MouseEvent e)
1959
+ {
1960
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1961
+ cMaterial material = object.material;
1962
+
1963
+ diffusenessField.setFloat(material.factor);
1964
+ selfshadowField.setFloat(material.diffuseness);
1965
+
1966
+ materialtouched = true;
1967
+ applySelf();
1968
+ }
1969
+ });
1970
+ presetpanel.add(diffusemoon2);
1971
+
1972
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1973
+ diffusemoon3.setToolTipText("Moon3");
1974
+ diffusemoon3.addMouseListener(new MouseAdapter()
1975
+ {
1976
+ public void mouseClicked(MouseEvent e)
1977
+ {
1978
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1979
+ cMaterial material = object.material;
1980
+
1981
+ diffusenessField.setFloat(material.factor);
1982
+ selfshadowField.setFloat(material.diffuseness);
1983
+
1984
+ materialtouched = true;
1985
+ applySelf();
1986
+ }
1987
+ });
1988
+ presetpanel.add(diffusemoon3);
1989
+
1990
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1991
+ diffusesheen.setToolTipText("Sheen");
1992
+ diffusesheen.addMouseListener(new MouseAdapter()
1993
+ {
1994
+ public void mouseClicked(MouseEvent e)
1995
+ {
1996
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1997
+ cMaterial material = object.material;
1998
+
1999
+ sheenField.setFloat(material.sheen);
2000
+
2001
+ materialtouched = true;
2002
+ applySelf();
2003
+ }
2004
+ });
2005
+ presetpanel.add(diffusesheen);
2006
+
2007
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2008
+ rough.setToolTipText("Rough metal");
2009
+ rough.addMouseListener(new MouseAdapter()
2010
+ {
2011
+ public void mouseClicked(MouseEvent e)
2012
+ {
2013
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2014
+ cMaterial material = object.material;
2015
+
2016
+ shininessField.setFloat(material.shininess);
2017
+ velvetField.setFloat(material.velvet);
2018
+
2019
+ materialtouched = true;
2020
+ applySelf();
2021
+ }
2022
+ });
2023
+ presetpanel.add(rough);
2024
+
2025
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2026
+ rough2.setToolTipText("Medium metal");
2027
+ rough2.addMouseListener(new MouseAdapter()
2028
+ {
2029
+ public void mouseClicked(MouseEvent e)
2030
+ {
2031
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2032
+ cMaterial material = object.material;
2033
+
2034
+ shininessField.setFloat(material.shininess);
2035
+ lightareaField.setFloat(material.lightarea);
2036
+
2037
+ materialtouched = true;
2038
+ applySelf();
2039
+ }
2040
+ });
2041
+ presetpanel.add(rough2);
2042
+
2043
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2044
+ shini0.setToolTipText("Shiny");
2045
+ shini0.addMouseListener(new MouseAdapter()
2046
+ {
2047
+ public void mouseClicked(MouseEvent e)
2048
+ {
2049
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2050
+ cMaterial material = object.material;
2051
+
2052
+ shininessField.setFloat(material.shininess);
2053
+ lightareaField.setFloat(material.lightarea);
2054
+
2055
+ materialtouched = true;
2056
+ applySelf();
2057
+ }
2058
+ });
2059
+ presetpanel.add(shini0);
2060
+
2061
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2062
+ shini1.setToolTipText("Shiny2");
2063
+ shini1.addMouseListener(new MouseAdapter()
2064
+ {
2065
+ public void mouseClicked(MouseEvent e)
2066
+ {
2067
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2068
+ cMaterial material = object.material;
2069
+
2070
+ shininessField.setFloat(material.shininess);
2071
+ lightareaField.setFloat(material.lightarea);
2072
+
2073
+ materialtouched = true;
2074
+ applySelf();
2075
+ }
2076
+ });
2077
+ presetpanel.add(shini1);
2078
+
2079
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2080
+ shini2.setToolTipText("Shiny3");
2081
+ shini2.addMouseListener(new MouseAdapter()
2082
+ {
2083
+ public void mouseClicked(MouseEvent e)
2084
+ {
2085
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2086
+ cMaterial material = object.material;
2087
+
2088
+ shininessField.setFloat(material.shininess);
2089
+ lightareaField.setFloat(material.lightarea);
2090
+
2091
+ materialtouched = true;
2092
+ applySelf();
2093
+ }
2094
+ });
2095
+ presetpanel.add(shini2);
2096
+
2097
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2098
+ aniso.setToolTipText("AnisoU");
2099
+ aniso.addMouseListener(new MouseAdapter()
2100
+ {
2101
+ public void mouseClicked(MouseEvent e)
2102
+ {
2103
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2104
+ cMaterial material = object.material;
2105
+
2106
+ anisoField.setFloat(material.aniso);
2107
+ anisoVField.setFloat(material.anisoV);
2108
+
2109
+ materialtouched = true;
2110
+ applySelf();
2111
+ }
2112
+ });
2113
+ presetpanel.add(aniso);
2114
+
2115
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2116
+ aniso2.setToolTipText("AnisoV");
2117
+ aniso2.addMouseListener(new MouseAdapter()
2118
+ {
2119
+ public void mouseClicked(MouseEvent e)
2120
+ {
2121
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2122
+ cMaterial material = object.material;
2123
+
2124
+ anisoField.setFloat(material.aniso);
2125
+ anisoVField.setFloat(material.anisoV);
2126
+
2127
+ materialtouched = true;
2128
+ applySelf();
2129
+ }
2130
+ });
2131
+ presetpanel.add(aniso2);
2132
+
2133
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2134
+ aniso3.setToolTipText("AnisoUV");
2135
+ aniso3.addMouseListener(new MouseAdapter()
2136
+ {
2137
+ public void mouseClicked(MouseEvent e)
2138
+ {
2139
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2140
+ cMaterial material = object.material;
2141
+
2142
+ anisoField.setFloat(material.aniso);
2143
+ anisoVField.setFloat(material.anisoV);
2144
+
2145
+ materialtouched = true;
2146
+ applySelf();
2147
+ }
2148
+ });
2149
+ presetpanel.add(aniso3);
2150
+
2151
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2152
+ velvet0.setToolTipText("Velvet");
2153
+ velvet0.addMouseListener(new MouseAdapter()
2154
+ {
2155
+ public void mouseClicked(MouseEvent e)
2156
+ {
2157
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2158
+ cMaterial material = object.material;
2159
+
2160
+ diffusenessField.setFloat(material.factor);
2161
+ selfshadowField.setFloat(material.diffuseness);
2162
+ sheenField.setFloat(material.sheen);
2163
+ shininessField.setFloat(material.shininess);
2164
+ velvetField.setFloat(material.velvet);
2165
+ shiftField.setFloat(material.shift);
2166
+
2167
+ materialtouched = true;
2168
+ applySelf();
2169
+ }
2170
+ });
2171
+ presetpanel.add(velvet0);
2172
+
2173
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2174
+ bump0.setToolTipText("Bump texture");
2175
+ bump0.addMouseListener(new MouseAdapter()
2176
+ {
2177
+ public void mouseClicked(MouseEvent e)
2178
+ {
2179
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2180
+ cMaterial material = object.material;
2181
+
2182
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2183
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2184
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2185
+
2186
+ materialtouched = true;
2187
+ applySelf();
2188
+ }
2189
+ });
2190
+ presetpanel.add(bump0);
2191
+
2192
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2193
+ borderShader.setToolTipText("Border fade");
2194
+ borderShader.addMouseListener(new MouseAdapter()
2195
+ {
2196
+ public void mouseClicked(MouseEvent e)
2197
+ {
2198
+ borderfadeField.setFloat(0.5);
2199
+ opacityField.setFloat(0.6);
2200
+
2201
+ materialtouched = true;
2202
+ applySelf();
2203
+ }
2204
+ });
2205
+ presetpanel.add(borderShader);
2206
+
2207
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2208
+ halo.setToolTipText("Halo");
2209
+ halo.addMouseListener(new MouseAdapter()
2210
+ {
2211
+ public void mouseClicked(MouseEvent e)
2212
+ {
2213
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2214
+ cMaterial material = object.material;
2215
+
2216
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2217
+
2218
+ materialtouched = true;
2219
+ applySelf();
2220
+ }
2221
+ });
2222
+ presetpanel.add(halo);
2223
+
2224
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2225
+ candle.setToolTipText("Candle");
2226
+ candle.addMouseListener(new MouseAdapter()
2227
+ {
2228
+ public void mouseClicked(MouseEvent e)
2229
+ {
2230
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2231
+ cMaterial material = object.material;
2232
+
2233
+ subsurfaceField.setFloat(material.subsurface);
2234
+ shadowbiasField.setFloat(material.shadowbias);
2235
+ ambientField.setFloat(material.ambient);
2236
+ specularField.setFloat(material.specular);
2237
+ lightareaField.setFloat(material.lightarea);
2238
+ shininessField.setFloat(material.shininess);
2239
+
2240
+ materialtouched = true;
2241
+ applySelf();
2242
+ }
2243
+ });
2244
+ presetpanel.add(candle);
2245
+
2246
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2247
+ shadowShader.setToolTipText("Shadow");
2248
+ shadowShader.addMouseListener(new MouseAdapter()
2249
+ {
2250
+ public void mouseClicked(MouseEvent e)
2251
+ {
2252
+ diffuseField.setFloat(0.001);
2253
+ ambientField.setFloat(0.001);
2254
+ cameraField.setFloat(0.001);
2255
+ specularField.setFloat(0.001);
2256
+ fakedepthField.setFloat(0.001);
2257
+ opacityField.setFloat(0.6);
2258
+
2259
+ materialtouched = true;
2260
+ applySelf();
2261
+ }
2262
+ });
2263
+ presetpanel.add(shadowShader);
2264
+
2265
+ cGridBag panel = new cGridBag().setVertical(true);
2266
+
2267
+ presetpanel.preferredWidth = 1;
2268
+
2269
+ materialpanel.add(presetpanel);
2270
+ materialpanel.add(panel);
2271
+
2272
+ panel.preferredWidth = 8;
2273
+
2274
+ /*
14722275 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14732276 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1474
- */
2277
+ */
14752278
14762279 cGridBag editBar = new cGridBag().setVertical(false);
14772280
1478
- editBar.add(createMaterialButton = new cButton("Create", !GrafreeD.NIMBUSLAF)); // , aConstraints);
2281
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
14792282 createMaterialButton.setToolTipText("Create material");
14802283
14812284 /*
14822285 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14832286 */
14842287
1485
- editBar.add(clearMaterialButton = new cButton("Clear", !GrafreeD.NIMBUSLAF)); // , aConstraints);
2288
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
14862289 clearMaterialButton.setToolTipText("Clear material");
14872290
14882291 if (Globals.ADVANCED)
14892292 {
1490
- editBar.add(resetSlidersButton = new cButton("Reset", !GrafreeD.NIMBUSLAF)); // , aConstraints);
2293
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
14912294 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
14922295 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
14932296 }
....@@ -1505,45 +2308,50 @@
15052308 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15062309
15072310 cGridBag colorSection = new cGridBag().setVertical(true);
2311
+
2312
+ cGridBag huepanel = new cGridBag();
2313
+ cGridBag huelabel = new cGridBag();
2314
+ skin = GetLabel("icons/hue.png", false);
2315
+ skin.fit = true;
2316
+ huelabel.add(skin);
2317
+ huelabel.preferredWidth = 20;
2318
+ huepanel.add(new cGridBag()); // Label
2319
+ huepanel.add(huelabel); // Field/slider
2320
+
2321
+ huepanel.preferredHeight = 7;
2322
+
2323
+ colorSection.add(huepanel);
15082324
15092325 cGridBag color = new cGridBag();
1510
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1511
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1512
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2326
+
2327
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2328
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2329
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2330
+
15132331 //colorField.preferredWidth = 200;
15142332 colorSection.add(color);
15152333
15162334 cGridBag modulation = new cGridBag();
15172335 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
15182336 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1519
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2337
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
15202338 colorSection.add(modulation);
15212339
2340
+ cGridBag opacity = new cGridBag();
2341
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2342
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2343
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2344
+ colorSection.add(opacity);
2345
+
2346
+ colorSection.add(GetSeparator());
2347
+
15222348 cGridBag texture = new cGridBag();
15232349 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
15242350 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15252351 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
15262352 colorSection.add(texture);
15272353
1528
- cGridBag anisoU = new cGridBag();
1529
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1530
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1531
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1532
- colorSection.add(anisoU);
1533
-
1534
- cGridBag anisoV = new cGridBag();
1535
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1536
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1537
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1538
- colorSection.add(anisoV);
1539
-
1540
- cGridBag shadowbias = new cGridBag();
1541
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1542
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1543
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1544
- colorSection.add(shadowbias);
1545
-
1546
- panel.add(new JSeparator());
2354
+ panel.add(GetSeparator());
15472355
15482356 panel.add(colorSection);
15492357
....@@ -1593,7 +2401,13 @@
15932401 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15942402 diffuseSection.add(fakedepth);
15952403
1596
- panel.add(new JSeparator());
2404
+ cGridBag shadowbias = new cGridBag();
2405
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2406
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2407
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2408
+ diffuseSection.add(shadowbias);
2409
+
2410
+ panel.add(GetSeparator());
15972411
15982412 panel.add(diffuseSection);
15992413
....@@ -1643,42 +2457,48 @@
16432457 // aConstraints.gridy += 1;
16442458 // aConstraints.gridwidth = 1;
16452459
2460
+ cGridBag anisoU = new cGridBag();
2461
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2462
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2463
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2464
+ specularSection.add(anisoU);
16462465
1647
- panel.add(new JSeparator());
2466
+ cGridBag anisoV = new cGridBag();
2467
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2468
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2469
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2470
+ specularSection.add(anisoV);
2471
+
2472
+
2473
+ panel.add(GetSeparator());
16482474
16492475 panel.add(specularSection);
16502476
16512477 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16522478
1653
- cGridBag globalSection = new cGridBag().setVertical(true);
2479
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16542480
16552481 cGridBag camera = new cGridBag();
16562482 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16572483 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16582484 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1659
- globalSection.add(camera);
2485
+ colorSection.add(camera);
16602486
16612487 cGridBag ambient = new cGridBag();
16622488 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16632489 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16642490 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1665
- globalSection.add(ambient);
2491
+ colorSection.add(ambient);
16662492
16672493 cGridBag backlit = new cGridBag();
16682494 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16692495 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16702496 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1671
- globalSection.add(backlit);
2497
+ colorSection.add(backlit);
16722498
1673
- cGridBag opacity = new cGridBag();
1674
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1675
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1676
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1677
- globalSection.add(opacity);
1678
-
1679
- panel.add(new JSeparator());
2499
+ //panel.add(new JSeparator());
16802500
1681
- panel.add(globalSection);
2501
+ //panel.add(globalSection);
16822502
16832503 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16842504
....@@ -1720,7 +2540,7 @@
17202540 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
17212541 textureSection.add(opacityPower);
17222542
1723
- panel.add(new JSeparator());
2543
+ panel.add(GetSeparator());
17242544
17252545 panel.add(textureSection);
17262546
....@@ -1785,8 +2605,9 @@
17852605 // 3D models
17862606 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17872607 {
1788
- lastConverter = new com.jmex.model.converters.MaxToJme();
1789
- LoadFile(filename, lastConverter);
2608
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2609
+ //LoadFile(filename, lastConverter);
2610
+ LoadObjFile(filename); // New 3ds loader
17902611 continue;
17912612 }
17922613 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1938,7 +2759,7 @@
19382759
19392760 //? flashIt = false;
19402761 CameraPane pane = (CameraPane) cameraView;
1941
- pane.clickStart(location.x, location.y, 0);
2762
+ pane.clickStart(location.x, location.y, 0, 0);
19422763 pane.clickEnd(location.x, location.y, 0, true);
19432764
19442765 if (group.selection.size() == 1)
....@@ -1987,6 +2808,7 @@
19872808 e2.printStackTrace();
19882809 }
19892810 }
2811
+
19902812 LoadJMEThread loadThread;
19912813
19922814 class LoadJMEThread extends Thread
....@@ -2044,6 +2866,7 @@
20442866 //LoadFile0(filename, converter);
20452867 }
20462868 }
2869
+
20472870 LoadOBJThread loadObjThread;
20482871
20492872 class LoadOBJThread extends Thread
....@@ -2122,19 +2945,19 @@
21222945
21232946 void LoadObjFile(String fullname)
21242947 {
2125
- /*
2948
+ System.out.println("Loading " + fullname);
2949
+ /**/
21262950 //lastFilename = fullname;
21272951 if(loadObjThread == null)
21282952 {
2129
- loadObjThread = new LoadOBJThread();
2130
- loadObjThread.start();
2953
+ loadObjThread = new LoadOBJThread();
2954
+ loadObjThread.start();
21312955 }
21322956
21332957 loadObjThread.add(fullname);
2134
- */
2958
+ /**/
21352959
2136
- System.out.println("Loading " + fullname);
2137
- makeSomething(new FileObject(fullname, true), true);
2960
+ //makeSomething(new FileObject(fullname, true), true);
21382961 }
21392962
21402963 void LoadGFDFile(String fullname)
....@@ -2395,11 +3218,11 @@
23953218
23963219 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23973220 {
2398
- if (GrafreeD.standAlone)
3221
+ if (Grafreed.standAlone)
23993222 {
24003223 /**/
24013224 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2402
- browser.show();
3225
+ browser.setVisible(true);
24033226 String filename = browser.getFile();
24043227 if (filename != null && filename.length() > 0)
24053228 {
....@@ -2510,6 +3333,7 @@
25103333 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
25113334 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
25123335 }
3336
+
25133337 //cJME.count++;
25143338 //cJME.count %= 12;
25153339 if (gc)
....@@ -2693,6 +3517,7 @@
26933517 }
26943518 }
26953519 }
3520
+
26963521 cFileSystemPane FSPane;
26973522
26983523 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2702,7 +3527,7 @@
27023527
27033528 freezematerial = true;
27043529 colorField.setFloat(mat.color);
2705
- modulationField.setFloat(mat.modulation);
3530
+ saturationField.setFloat(mat.modulation);
27063531 metalnessField.setFloat(mat.metalness);
27073532 diffuseField.setFloat(mat.diffuse);
27083533 specularField.setFloat(mat.specular);
....@@ -2746,11 +3571,14 @@
27463571 }
27473572 }
27483573 }
3574
+
27493575 freezematerial = false;
27503576 }
27513577
27523578 void SetMaterial(Object3D object)
27533579 {
3580
+ latestObject = object;
3581
+
27543582 cMaterial mat = object.material;
27553583
27563584 if (mat == null)
....@@ -2761,32 +3589,8 @@
27613589
27623590 if (multiplyToggle != null)
27633591 multiplyToggle.setSelected(mat.multiply);
2764
-
2765
- assert (object.projectedVertices != null);
2766
-
2767
- if (object.projectedVertices.length <= 2)
2768
- {
2769
- // Side effect...
2770
- Object3D.cVector2[] keep = object.projectedVertices;
2771
- object.projectedVertices = new Object3D.cVector2[3];
2772
- for (int i = 0; i < 3; i++)
2773
- {
2774
- if (i < keep.length)
2775
- {
2776
- object.projectedVertices[i] = keep[i];
2777
- } else
2778
- {
2779
- object.projectedVertices[i] = new Object3D.cVector2();
2780
- }
2781
- /*
2782
- if(keep.length == 0)
2783
- object.projectedVertices[0] = new Object3D.cVector2();
2784
- else
2785
- object.projectedVertices[0] = keep[0];
2786
- object.projectedVertices[1] = new Object3D.cVector2();
2787
- */
2788
- }
2789
- }
3592
+
3593
+ AllocProjectedVertices(object);
27903594
27913595 SetMaterial(mat, object.projectedVertices);
27923596 }
....@@ -2862,12 +3666,17 @@
28623666 // }
28633667
28643668 /**/
2865
- if (deselect)
3669
+ if (deselect || child == null)
28663670 {
28673671 //group.deselectAll();
28683672 //freeze = true;
28693673 GetTree().clearSelection();
28703674 //freeze = false;
3675
+
3676
+ if (child == null)
3677
+ {
3678
+ return;
3679
+ }
28713680 }
28723681
28733682 //group.addSelectee(child);
....@@ -2901,6 +3710,17 @@
29013710 public void itemStateChanged(ItemEvent event)
29023711 {
29033712 // System.out.println("Propagate = " + propagate);
3713
+ if (event.getSource() == pinButton)
3714
+ {
3715
+ copy.pinned ^= true;
3716
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3717
+ {
3718
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3719
+ copy.CloseUI();
3720
+ //copy.editWindow.refreshContents();
3721
+ }
3722
+ }
3723
+ else
29043724 if (event.getSource() == propagateToggle)
29053725 {
29063726 propagate ^= true;
....@@ -2936,7 +3756,7 @@
29363756 cameraView.ToggleDL();
29373757 cameraView.repaint();
29383758 return;
2939
- } else if (event.getSource() == toggleTextureItem)
3759
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29403760 {
29413761 cameraView.ToggleTexture();
29423762 // june 2013 copy.HardTouch();
....@@ -2975,9 +3795,9 @@
29753795 frame.validate();
29763796
29773797 return;
2978
- } else if (event.getSource() == toggleSwitchItem)
3798
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29793799 {
2980
- cameraView.ToggleRandom();
3800
+ cameraView.ToggleSwitch();
29813801 cameraView.repaint();
29823802 return;
29833803 } else if (event.getSource() == toggleHandleItem)
....@@ -3005,12 +3825,17 @@
30053825 } else if (event.getSource() == liveCB)
30063826 {
30073827 copy.live ^= true;
3828
+ objEditor.refreshContents(true); // To show item colors
3829
+ return;
3830
+ } else if (event.getSource() == selectableCB)
3831
+ {
3832
+ copy.dontselect ^= true;
30083833 return;
30093834 } else if (event.getSource() == hideCB)
30103835 {
30113836 copy.hide ^= true;
30123837 copy.Touch(); // display list issue
3013
- objEditor.refreshContents();
3838
+ objEditor.refreshContents(true); // To show item colors
30143839 return;
30153840 } else if (event.getSource() == link2masterCB)
30163841 {
....@@ -3044,8 +3869,9 @@
30443869
30453870 public void actionPerformed(ActionEvent event)
30463871 {
3872
+ Object source = event.getSource();
30473873 // SCRIPT DIALOG
3048
- if (event.getSource() == okbutton)
3874
+ if (source == okbutton)
30493875 {
30503876 textpanel.setVisible(false);
30513877 textpanel.remove(textarea);
....@@ -3057,7 +3883,7 @@
30573883 textarea = null;
30583884 textpanel = null;
30593885 }
3060
- if (event.getSource() == cancelbutton)
3886
+ if (source == cancelbutton)
30613887 {
30623888 textpanel.setVisible(false);
30633889 textpanel.remove(textarea);
....@@ -3069,50 +3895,50 @@
30693895 //applySelf();
30703896 //client.refreshEditWindow();
30713897 //refreshContents();
3072
- if (event.getSource() == nameField)
3898
+ if (source == nameField)
30733899 {
30743900 //System.out.println("ObjEditor " + event);
30753901 applySelf0(true);
30763902 //parent.applySelf();
30773903 objEditor.refreshContents();
3078
- } else if (event.getSource() == resetButton)
3904
+ } else if (source == resetButton)
30793905 {
30803906 CameraPane.fullreset = true;
30813907 copy.Reset(); // ResetMeshes();
30823908 copy.Touch();
30833909 objEditor.refreshContents();
3084
- } else if (event.getSource() == stepItem)
3910
+ } else if (source == stepItem)
30853911 {
30863912 //cameraView.ONESTEP = true;
30873913 Globals.ONESTEP = true;
30883914 cameraView.repaint();
30893915 return;
3090
- } else if (event.getSource() == stepButton)
3916
+ } else if (source == stepButton)
30913917 {
30923918 copy.Step();
30933919 copy.Touch();
30943920 objEditor.refreshContents();
3095
- } else if (event.getSource() == slowerButton)
3921
+ } else if (source == slowerButton)
30963922 {
30973923 copy.Slower();
30983924 copy.Touch();
30993925 objEditor.refreshContents();
3100
- } else if (event.getSource() == fasterButton)
3926
+ } else if (source == fasterButton)
31013927 {
31023928 copy.Faster();
31033929 copy.Touch();
31043930 objEditor.refreshContents();
3105
- } else if (event.getSource() == remarkButton)
3931
+ } else if (source == remarkButton)
31063932 {
31073933 copy.Remark();
31083934 copy.Touch();
31093935 objEditor.refreshContents();
3110
- } else if (event.getSource() == stepAllButton)
3936
+ } else if (source == stepAllButton)
31113937 {
31123938 copy.StepAll();
31133939 copy.Touch();
31143940 objEditor.refreshContents();
3115
- } else if (event.getSource() == resetAllButton)
3941
+ } else if (source == resetAllButton)
31163942 {
31173943 //CameraPane.fullreset = true;
31183944 copy.ResetAll(); // ResetMeshes();
....@@ -3145,53 +3971,79 @@
31453971 // Close();
31463972 // }
31473973 // else
3148
- if (event.getSource() == resetSlidersButton)
3974
+ if (source == resetSlidersButton)
31493975 {
31503976 ResetSliders();
3151
- } else if (event.getSource() == clearMaterialButton)
3977
+ } else if (source == clearMaterialButton)
31523978 {
31533979 ClearMaterial();
3154
- } else if (event.getSource() == createMaterialButton)
3980
+ } else if (source == createMaterialButton)
31553981 {
31563982 CreateMaterial();
3157
- } else if (event.getSource() == clearPanelButton)
3983
+ } else if (source == clearPanelButton)
31583984 {
31593985 copy.ClearUI();
31603986 refreshContents(true);
3161
- } /*
3162
- }
3163
-
3164
- public boolean action(Event event, Object arg)
3165
- {
3166
- */ else if (event.getSource() == closeItem)
3987
+ } else if (source == importGFDItem)
3988
+ {
3989
+ ImportGFD();
3990
+ } else
3991
+ if (source == importVRMLX3DItem)
3992
+ {
3993
+ ImportVRMLX3D();
3994
+ } else
3995
+ if (source == import3DSItem)
3996
+ {
3997
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3998
+ } else
3999
+ if (source == importOBJItem)
4000
+ {
4001
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
4002
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
4003
+ browser.setVisible(true);
4004
+ String filename = browser.getFile();
4005
+ if (filename != null && filename.length() > 0)
4006
+ {
4007
+ String fullname = browser.getDirectory() + filename;
4008
+ makeSomething(ReadOBJ(fullname), true);
4009
+ }
4010
+ } else
4011
+ if (source == closeItem)
31674012 {
31684013 Close();
31694014 //return true;
3170
- } else if (event.getSource() == loadItem)
4015
+ } else if (source == openItem)
31714016 {
3172
- load();
4017
+ Open();
31734018 //return true;
3174
- } else if (event.getSource() == saveItem)
4019
+ } else if (source == newItem)
4020
+ {
4021
+ New();
4022
+ } else if (source == saveItem)
31754023 {
31764024 save();
31774025 //return true;
3178
- } else if (event.getSource() == saveAsItem)
4026
+ } else if (source == saveAsItem)
31794027 {
31804028 saveAs();
31814029 //return true;
3182
- } else if (event.getSource() == reexportItem)
4030
+ } else if (source == reexportItem)
31834031 {
31844032 reexport();
31854033 //return true;
3186
- } else if (event.getSource() == exportAsItem)
4034
+ } else if (source == exportAsItem)
31874035 {
31884036 export();
31894037 //return true;
3190
- } else if (event.getSource() == povItem)
4038
+ } else if (source == povItem)
31914039 {
31924040 generatePOV();
31934041 //return true;
3194
- } else if (event.getSource() == zBufferItem)
4042
+ } else if (event.getSource() == archiveItem)
4043
+ {
4044
+ cTools.Archive(frame);
4045
+ return;
4046
+ } else if (source == zBufferItem)
31954047 {
31964048 try
31974049 {
....@@ -3213,21 +4065,8 @@
32134065 cameraView.repaint();
32144066 //return true;
32154067 }
3216
- */ else if (event.getSource() == editCameraItem)
3217
- {
3218
- cameraView.ProtectCamera();
3219
- cameraView.repaint();
3220
- return;
3221
- } else if (event.getSource() == revertCameraItem)
3222
- {
3223
- cameraView.RevertCamera();
3224
- cameraView.repaint();
3225
- return;
3226
-// } else if (event.getSource() == textureButton)
3227
-// {
3228
-// return; // true;
3229
- } else // combos...
3230
- if (event.getSource() == texresMenu)
4068
+ */ else // combos...
4069
+ if (source == texresMenu)
32314070 {
32324071 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
32334072 copy.texres = texresMenu.getSelectedIndex();
....@@ -3239,6 +4078,471 @@
32394078 }
32404079 }
32414080
4081
+ void New()
4082
+ {
4083
+ while (copy.Size() > 1)
4084
+ {
4085
+ copy.remove(1);
4086
+ }
4087
+
4088
+ ResetModel();
4089
+ objEditor.refreshContents();
4090
+ }
4091
+
4092
+ static public byte[] Compress(Object3D o)
4093
+ {
4094
+ // Slower to actually compress.
4095
+ try
4096
+ {
4097
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4098
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4099
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
4100
+
4101
+ Object3D parent = o.parent;
4102
+ o.parent = null;
4103
+
4104
+ out.writeObject(o);
4105
+
4106
+ o.parent = parent;
4107
+
4108
+ out.flush();
4109
+
4110
+ baos //zstream
4111
+ .close();
4112
+ out.close();
4113
+
4114
+ byte[] bytes = baos.toByteArray();
4115
+
4116
+ System.out.println("save #bytes = " + bytes.length);
4117
+ return bytes;
4118
+ } catch (Exception e)
4119
+ {
4120
+ System.err.println(e);
4121
+ return null;
4122
+ }
4123
+ }
4124
+
4125
+ static public Object Uncompress(byte[] bytes)
4126
+ {
4127
+ System.out.println("restore #bytes = " + bytes.length);
4128
+ try
4129
+ {
4130
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4131
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4132
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
4133
+ Object obj = in.readObject();
4134
+
4135
+ bais //istream
4136
+ .close();
4137
+ in.close();
4138
+
4139
+ return obj;
4140
+ } catch (Exception e)
4141
+ {
4142
+ System.err.println(e);
4143
+ return null;
4144
+ }
4145
+ }
4146
+
4147
+ static public Object clone(Object o)
4148
+ {
4149
+ try
4150
+ {
4151
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4152
+ ObjectOutputStream out = new ObjectOutputStream(baos);
4153
+
4154
+ out.writeObject(o);
4155
+
4156
+ out.flush();
4157
+ out.close();
4158
+
4159
+ byte[] bytes = baos.toByteArray();
4160
+
4161
+ System.out.println("clone = " + bytes.length);
4162
+
4163
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4164
+ ObjectInputStream in = new ObjectInputStream(bais);
4165
+ Object obj = in.readObject();
4166
+ in.close();
4167
+
4168
+ return obj;
4169
+ } catch (Exception e)
4170
+ {
4171
+ System.err.println(e);
4172
+ return null;
4173
+ }
4174
+ }
4175
+
4176
+ cRadio GetCurrentTab()
4177
+ {
4178
+ cRadio ab;
4179
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4180
+ {
4181
+ ab = (cRadio)e.nextElement();
4182
+ if(ab.GetObject() == copy)
4183
+ {
4184
+ return ab;
4185
+ }
4186
+ }
4187
+
4188
+ return null;
4189
+ }
4190
+
4191
+
4192
+ public void Save()
4193
+ {
4194
+ //Save(true);
4195
+ Replace();
4196
+ SetVersionStates();
4197
+ }
4198
+
4199
+ private boolean Equal(byte[] compress, byte[] name)
4200
+ {
4201
+ if (compress.length != name.length)
4202
+ {
4203
+ return false;
4204
+ }
4205
+
4206
+ for (int i=compress.length; --i>=0;)
4207
+ {
4208
+ if (compress[i] != name[i])
4209
+ return false;
4210
+ }
4211
+
4212
+ return true;
4213
+ }
4214
+
4215
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4216
+
4217
+ void DeleteVersion()
4218
+ {
4219
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4220
+ {
4221
+ copy.versionlist[i] = copy.versionlist[i+1];
4222
+ }
4223
+
4224
+ CopyChanged();
4225
+
4226
+ SetVersionStates();
4227
+ }
4228
+
4229
+ public boolean Save(boolean user)
4230
+ {
4231
+ System.err.println("Save");
4232
+ Replace();
4233
+
4234
+ //cRadio tab = GetCurrentTab();
4235
+
4236
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
4237
+
4238
+ boolean thesame = false;
4239
+
4240
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4241
+// {
4242
+// thesame = true;
4243
+// }
4244
+
4245
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
4246
+ if (!thesame)
4247
+ {
4248
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4249
+ {
4250
+ copy.versionlist[i] = copy.versionlist[i-1];
4251
+ }
4252
+
4253
+ //tab.user[tab.versionindex] = user;
4254
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4255
+
4256
+ copy.versionlist[++copy.versionindex] = compress;
4257
+
4258
+ // if (increment)
4259
+ // tab.versionindex++;
4260
+ }
4261
+
4262
+ //copy.RestoreBigData(versiontable);
4263
+
4264
+ //assert(hashtable.isEmpty());
4265
+
4266
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4267
+// {
4268
+// //tab.user[i] = false;
4269
+// copy.versionlist[i] = null;
4270
+// }
4271
+
4272
+ SetVersionStates();
4273
+
4274
+ // test save
4275
+ if (false)
4276
+ {
4277
+ try
4278
+ {
4279
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
4280
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
4281
+
4282
+ p.writeObject(copy);
4283
+
4284
+ p.flush();
4285
+
4286
+ ostream.close();
4287
+ } catch (Exception e)
4288
+ {
4289
+ e.printStackTrace();
4290
+ }
4291
+ }
4292
+
4293
+ return !thesame;
4294
+ }
4295
+
4296
+ boolean flashIt = true;
4297
+
4298
+ void RefreshSelection()
4299
+ {
4300
+ Object3D selection = new Object3D();
4301
+
4302
+ for (int i = 0; i < copy.selection.size(); i++)
4303
+ {
4304
+ Object3D elem = copy.selection.elementAt(i);
4305
+
4306
+ Object3D obj = copy.GetObject(elem.GetUUID());
4307
+
4308
+ if (obj == null)
4309
+ {
4310
+ copy.selection.remove(i--);
4311
+ }
4312
+ else
4313
+ {
4314
+ selection.add(obj);
4315
+ copy.selection.setElementAt(obj, i);
4316
+ }
4317
+ }
4318
+
4319
+ flashIt = false;
4320
+ GetTree().clearSelection();
4321
+ for (int i = 0; i < selection.size(); i++)
4322
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4323
+ flashIt = true;
4324
+
4325
+ //refreshContents(false);
4326
+ }
4327
+
4328
+ void CopyChanged()
4329
+ {
4330
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4331
+
4332
+ SetVersionStates();
4333
+
4334
+ boolean temp = CameraPane.SWITCH;
4335
+ CameraPane.SWITCH = false;
4336
+
4337
+ copy.ExtractBigData(versiontable);
4338
+
4339
+ copy.clear();
4340
+
4341
+ copy.skyboxname = obj.skyboxname;
4342
+ copy.skyboxext = obj.skyboxext;
4343
+
4344
+ for (int i=0; i<obj.Size(); i++)
4345
+ {
4346
+ copy.add(obj.get(i));
4347
+ }
4348
+
4349
+ copy.RestoreBigData(versiontable);
4350
+
4351
+ CameraPane.SWITCH = temp;
4352
+
4353
+ RefreshSelection();
4354
+ //assert(hashtable.isEmpty());
4355
+
4356
+ copy.Touch();
4357
+
4358
+ ResetModel();
4359
+ copy.HardTouch(); // recompile?
4360
+
4361
+ cRadio ab;
4362
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4363
+ {
4364
+ ab = (cRadio)e.nextElement();
4365
+ Object3D test = copy.GetObject(ab.object.GetUUID());
4366
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
4367
+ if (test != null)
4368
+ {
4369
+ test.editWindow = ab.object.editWindow;
4370
+ ab.object = test;
4371
+ }
4372
+ }
4373
+
4374
+ refreshContents(true);
4375
+ }
4376
+
4377
+ cButton previousVersionButton;
4378
+ cButton restoreButton;
4379
+ cButton replaceButton;
4380
+ cButton nextVersionButton;
4381
+ cButton saveVersionButton;
4382
+ cButton deleteVersionButton;
4383
+
4384
+ boolean muteSlider;
4385
+
4386
+ int VersionCount()
4387
+ {
4388
+ int count = 0;
4389
+
4390
+ for (int i = copy.versionlist.length; --i >= 0;)
4391
+ {
4392
+ if (copy.versionlist[i] != null)
4393
+ count++;
4394
+ }
4395
+
4396
+ return count;
4397
+ }
4398
+
4399
+ void SetVersionStates()
4400
+ {
4401
+ //if (true)
4402
+ // return;
4403
+
4404
+ //cRadio tab = GetCurrentTab();
4405
+
4406
+ restoreButton.setEnabled(copy.versionindex != -1);
4407
+ replaceButton.setEnabled(copy.versionindex != -1);
4408
+
4409
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4410
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4411
+
4412
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4413
+ copy.versionlist[copy.versionindex + 1] != null);
4414
+
4415
+ muteSlider = true;
4416
+ versionSlider.setMinimum(0);
4417
+ versionSlider.setMaximum(VersionCount() - 1);
4418
+ versionSlider.setInteger(copy.versionindex);
4419
+ versionSlider.setEnabled(copy.versionindex != -1);
4420
+ muteSlider = false;
4421
+ }
4422
+
4423
+ public boolean PreviousVersion()
4424
+ {
4425
+ // Option?
4426
+ Replace();
4427
+
4428
+ System.err.println("Undo");
4429
+
4430
+ //cRadio tab = GetCurrentTab();
4431
+
4432
+ if (copy.versionindex == 0)
4433
+ {
4434
+ java.awt.Toolkit.getDefaultToolkit().beep();
4435
+ return false;
4436
+ }
4437
+
4438
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4439
+// {
4440
+// if (Save(false))
4441
+// tab.versionindex -= 1;
4442
+// else
4443
+// {
4444
+// if (tab.versionindex <= 0)
4445
+// return false;
4446
+// else
4447
+// tab.versionindex -= 1;
4448
+// }
4449
+// }
4450
+
4451
+ copy.versionindex -= 1;
4452
+
4453
+ CopyChanged();
4454
+
4455
+ return true;
4456
+ }
4457
+
4458
+ public boolean Restore()
4459
+ {
4460
+ System.err.println("Restore");
4461
+
4462
+ //cRadio tab = GetCurrentTab();
4463
+
4464
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4465
+ {
4466
+ java.awt.Toolkit.getDefaultToolkit().beep();
4467
+ return false;
4468
+ }
4469
+
4470
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4471
+ CopyChanged();
4472
+
4473
+ return true;
4474
+ }
4475
+
4476
+ public boolean Replace()
4477
+ {
4478
+ System.err.println("Replace");
4479
+
4480
+ //cRadio tab = GetCurrentTab();
4481
+
4482
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4483
+ {
4484
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4485
+ return false;
4486
+ }
4487
+
4488
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4489
+
4490
+ return true;
4491
+ }
4492
+
4493
+ public void NextVersion()
4494
+ {
4495
+ // Option?
4496
+ Replace();
4497
+
4498
+ //cRadio tab = GetCurrentTab();
4499
+
4500
+ if (copy.versionlist[copy.versionindex + 1] == null)
4501
+ {
4502
+ java.awt.Toolkit.getDefaultToolkit().beep();
4503
+ return;
4504
+ }
4505
+
4506
+ copy.versionindex += 1;
4507
+
4508
+ CopyChanged();
4509
+
4510
+ //if (!tab.user[tab.versionindex])
4511
+ // tab.graphs[tab.versionindex] = null;
4512
+ }
4513
+
4514
+ void ImportGFD()
4515
+ {
4516
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
4517
+ browser.show();
4518
+ String filename = browser.getFile();
4519
+ if (filename != null && filename.length() > 0)
4520
+ {
4521
+ String fullname = browser.getDirectory() + filename;
4522
+
4523
+ //Object3D readobj =
4524
+ objEditor.ReadGFD(fullname, objEditor);
4525
+ //makeSomething(readobj);
4526
+ }
4527
+ }
4528
+
4529
+ void ImportVRMLX3D()
4530
+ {
4531
+ if (Grafreed.standAlone)
4532
+ {
4533
+ /**/
4534
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
4535
+ browser.show();
4536
+ String filename = browser.getFile();
4537
+ if (filename != null && filename.length() > 0)
4538
+ {
4539
+ String fullname = browser.getDirectory() + filename;
4540
+ LoadVRMLX3D(fullname);
4541
+ }
4542
+ /**/
4543
+ }
4544
+ }
4545
+
32424546 void ToggleAnimation()
32434547 {
32444548 if (!Globals.ANIMATION)
....@@ -3254,8 +4558,8 @@
32544558
32554559 Globals.ANIMATION ^= true;
32564560
3257
- GrafreeD.wav.cursor = 0;
3258
- GrafreeD.wav.loop = 0;
4561
+ Grafreed.wav.cursor = 0;
4562
+ Grafreed.wav.loop = 0;
32594563 }
32604564 } else
32614565 {
....@@ -3276,7 +4580,6 @@
32764580 callee.refreshContents();
32774581 } else
32784582 {
3279
- new Exception().printStackTrace();
32804583 System.exit(0);
32814584 }
32824585 }
....@@ -3357,7 +4660,7 @@
33574660 assert false;
33584661 }
33594662
3360
- void EditSelection()
4663
+ void EditSelection(boolean newWindow)
33614664 {
33624665 }
33634666
....@@ -3416,7 +4719,7 @@
34164719 //copy.material = new cMaterial(copy.GetMaterial());
34174720
34184721 current.color = (float) colorField.getFloat();
3419
- current.modulation = (float) modulationField.getFloat();
4722
+ current.modulation = (float) saturationField.getFloat();
34204723 current.metalness = (float) metalnessField.getFloat();
34214724 current.diffuse = (float) diffuseField.getFloat();
34224725 current.specular = (float) specularField.getFloat();
....@@ -3443,6 +4746,36 @@
34434746 {
34444747 //System.out.println("Propagate = " + propagate);
34454748 copy.UpdateMaterial(anchor, current, propagate);
4749
+
4750
+ if (copy.material != null)
4751
+ {
4752
+ cMaterial mat = copy.material;
4753
+
4754
+ colorField.SetToolTipValue((mat.color));
4755
+ saturationField.SetToolTipValue((mat.modulation));
4756
+ metalnessField.SetToolTipValue((mat.metalness));
4757
+ diffuseField.SetToolTipValue((mat.diffuse));
4758
+ specularField.SetToolTipValue((mat.specular));
4759
+ shininessField.SetToolTipValue((mat.shininess));
4760
+ shiftField.SetToolTipValue((mat.shift));
4761
+ ambientField.SetToolTipValue((mat.ambient));
4762
+ lightareaField.SetToolTipValue((mat.lightarea));
4763
+ diffusenessField.SetToolTipValue((mat.factor));
4764
+ velvetField.SetToolTipValue((mat.velvet));
4765
+ sheenField.SetToolTipValue((mat.sheen));
4766
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4767
+ backlitField.SetToolTipValue((mat.bump));
4768
+ anisoField.SetToolTipValue((mat.aniso));
4769
+ anisoVField.SetToolTipValue((mat.anisoV));
4770
+ cameraField.SetToolTipValue((mat.cameralight));
4771
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4772
+ shadowField.SetToolTipValue((mat.shadow));
4773
+ textureField.SetToolTipValue((mat.texture));
4774
+ opacityField.SetToolTipValue((mat.opacity));
4775
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4776
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
4777
+ }
4778
+
34464779 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34474780 {
34484781 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3471,9 +4804,28 @@
34714804 //copy.Touch();
34724805 }
34734806
4807
+ cNumberSlider versionSlider;
4808
+
34744809 public void stateChanged(ChangeEvent e)
34754810 {
34764811 // assert(false);
4812
+ if (e.getSource() == versionSlider)
4813
+ {
4814
+ if (muteSlider)
4815
+ return;
4816
+
4817
+ Replace();
4818
+
4819
+ int version = versionSlider.getInteger();
4820
+
4821
+ if (version != -1 && copy.versionlist[version] != null)
4822
+ {
4823
+ copy.versionindex = version;
4824
+ CopyChanged();
4825
+ }
4826
+
4827
+ return;
4828
+ }
34774829
34784830 if (freezematerial)
34794831 {
....@@ -3509,6 +4861,12 @@
35094861 {
35104862 //System.out.println("stateChanged = " + this);
35114863 materialtouched = true;
4864
+
4865
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4866
+ {
4867
+ saturationField.setFloat(1);
4868
+ }
4869
+
35124870 applySelf();
35134871 //System.out.println("this = " + this);
35144872 //System.out.println("PARENT = " + parent);
....@@ -3558,7 +4916,7 @@
35584916 }
35594917
35604918 if (normalpushField != null)
3561
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4919
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35624920 }
35634921
35644922 void SnapObject()
....@@ -3808,6 +5166,7 @@
38085166 {
38095167 if (GetTree() != null)
38105168 {
5169
+ GetTree().revalidate();
38115170 GetTree().repaint();
38125171 }
38135172
....@@ -3816,12 +5175,17 @@
38165175 ctrlPanel.validate(); // ? new
38175176 ctrlPanel.repaint();
38185177 }
5178
+
5179
+ if (previousVersionButton != null && copy.versionlist != null)
5180
+ SetVersionStates();
38195181 }
38205182
38215183 static TweenManager tweenManager = new TweenManager();
38225184
38235185 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
38245186 {
5187
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5188
+ Save();
38255189 //Tween.set(thing, 0).target(1).start(tweenManager);
38265190 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
38275191 // if (thing instanceof GenericJointDemo)
....@@ -3908,6 +5272,12 @@
39085272 {
39095273 ResetModel();
39105274 Select(thing.GetTreePath(), true, false); // unselect... false);
5275
+
5276
+ if (thing.Size() == 0)
5277
+ {
5278
+ //EditSelection(false);
5279
+ }
5280
+
39115281 refreshContents();
39125282 }
39135283
....@@ -4025,6 +5395,7 @@
40255395 }
40265396 }
40275397 }
5398
+
40285399 LoadGFDThread loadGFDThread;
40295400
40305401 void ReadGFD(String fullname, iCallBack cb)
....@@ -4044,8 +5415,10 @@
40445415
40455416 try
40465417 {
5418
+ // Try compressed version first.
40475419 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4048
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5420
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
5421
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40495422
40505423 readobj = (Object3D) p.readObject();
40515424 istream.close();
....@@ -4053,7 +5426,22 @@
40535426 readobj.ResetDisplayList();
40545427 } catch (Exception e)
40555428 {
4056
- e.printStackTrace();
5429
+ if (!e.toString().contains("GZIP"))
5430
+ e.printStackTrace();
5431
+
5432
+ try
5433
+ {
5434
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
5435
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5436
+
5437
+ readobj = (Object3D) p.readObject();
5438
+ istream.close();
5439
+
5440
+ readobj.ResetDisplayList();
5441
+ } catch (Exception e2)
5442
+ {
5443
+ e2.printStackTrace();
5444
+ }
40575445 }
40585446 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40595447 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4099,6 +5487,12 @@
40995487
41005488 void LoadIt(Object obj)
41015489 {
5490
+ if (obj == null)
5491
+ {
5492
+ // Invalid file
5493
+ return;
5494
+ }
5495
+
41025496 System.out.println("Loaded " + obj);
41035497 //new Exception().printStackTrace();
41045498 Object3D readobj = (Object3D) obj;
....@@ -4108,10 +5502,14 @@
41085502
41095503 if (readobj != null)
41105504 {
5505
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5506
+ // Save();
41115507 try
41125508 {
41135509 //readobj.deepCopySelf(copy);
41145510 copy.clear(); // june 2014
5511
+ copy.skyboxname = readobj.skyboxname;
5512
+ copy.skyboxext = readobj.skyboxext;
41155513 for (int i = 0; i < readobj.size(); i++)
41165514 {
41175515 Object3D child = readobj.get(i); // reserve(i);
....@@ -4152,6 +5550,7 @@
41525550 }
41535551 } catch (ClassCastException e)
41545552 {
5553
+ e.printStackTrace();
41555554 assert (false);
41565555 Composite c = (Composite) copy;
41575556 c.children.clear();
....@@ -4162,17 +5561,31 @@
41625561 c.addChild(csg);
41635562 }
41645563
5564
+ copy.versionlist = readobj.versionlist;
5565
+ copy.versionindex = readobj.versionindex;
5566
+
5567
+ if (copy.versionlist == null)
5568
+ {
5569
+ // Backward compatibility
5570
+ copy.versionlist = new Object3D[100];
5571
+ copy.versionindex = -1;
5572
+
5573
+ //Save(true);
5574
+ }
5575
+
5576
+ //? SetUndoStates();
5577
+
41655578 ResetModel();
41665579 copy.HardTouch(); // recompile?
41675580 refreshContents();
41685581 }
41695582 }
41705583
4171
- void load() // throws ClassNotFoundException
5584
+ void Open() // throws ClassNotFoundException
41725585 {
4173
- if (GrafreeD.standAlone)
5586
+ if (Grafreed.standAlone)
41745587 {
4175
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5588
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
41765589 browser.show();
41775590 String filename = browser.getFile();
41785591 if (filename != null && filename.length() > 0)
....@@ -4249,6 +5662,8 @@
42495662
42505663 void save()
42515664 {
5665
+ Replace();
5666
+
42525667 if (lastname == null)
42535668 {
42545669 return;
....@@ -4257,11 +5672,13 @@
42575672 try
42585673 {
42595674 FileOutputStream ostream = new FileOutputStream(lastname);
4260
- ObjectOutputStream p = new ObjectOutputStream(ostream);
5675
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5676
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42615677
42625678 p.writeObject(copy);
42635679 p.flush();
42645680
5681
+ zstream.close();
42655682 ostream.close();
42665683
42675684 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4269,19 +5686,23 @@
42695686 //ps.print(buffer.toString());
42705687 } catch (IOException e)
42715688 {
5689
+ e.printStackTrace();
42725690 }
42735691 }
5692
+
42745693 String lastname;
42755694
42765695 void saveAs()
42775696 {
4278
- if (GrafreeD.standAlone)
5697
+ if (Grafreed.standAlone)
42795698 {
42805699 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42815700 browser.setVisible(true);
42825701 String filename = browser.getFile();
42835702 if (filename != null && filename.length() > 0)
42845703 {
5704
+ if (!filename.endsWith(".gfd"))
5705
+ filename += ".gfd";
42855706 lastname = browser.getDirectory() + filename;
42865707 save();
42875708 }
....@@ -4380,13 +5801,13 @@
43805801 try
43815802 {
43825803 FileOutputStream ostream = new FileOutputStream(filename);
4383
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4384
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
5804
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5805
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43855806
43865807 Object3D objectparent = obj.parent;
43875808 obj.parent = null;
43885809
4389
- Object3D object = (Object3D) GrafreeD.clone(obj);
5810
+ Object3D object = (Object3D) Grafreed.clone(obj);
43905811
43915812 obj.parent = objectparent;
43925813
....@@ -4398,8 +5819,8 @@
43985819 p.writeObject(object);
43995820 p.flush();
44005821
5822
+ zstream.close();
44015823 ostream.close();
4402
- // zstream.close();
44035824
44045825 // group.selection.get(0).parent = parent;
44055826 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4420,7 +5841,7 @@
44205841 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
44215842 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
44225843 copy.generatePOV(buffer);
4423
- if (GrafreeD.standAlone)
5844
+ if (Grafreed.standAlone)
44245845 {
44255846 FileDialog browser = new FileDialog(frame, "Export POV", 1);
44265847 browser.show();
....@@ -4446,19 +5867,18 @@
44465867 Object3D client;
44475868 Object3D copy;
44485869 MenuBar menuBar;
4449
- Menu windowMenu;
4450
- MenuItem loadItem;
5870
+ Menu fileMenu;
5871
+ MenuItem newItem;
5872
+ MenuItem openItem;
44515873 MenuItem saveItem;
44525874 MenuItem saveAsItem;
44535875 MenuItem exportAsItem;
44545876 MenuItem reexportItem;
44555877 MenuItem povItem;
44565878 MenuItem closeItem;
4457
- Menu cameraMenu;
5879
+
44585880 CheckboxMenuItem zBufferItem;
44595881 //MenuItem normalLensItem;
4460
- MenuItem editCameraItem;
4461
- MenuItem revertCameraItem;
44625882 MenuItem stepItem;
44635883 CheckboxMenuItem toggleLiveItem;
44645884 CheckboxMenuItem toggleFullScreenItem;
....@@ -4472,22 +5892,37 @@
44725892 CheckboxMenuItem toggleSwitchItem;
44735893 CheckboxMenuItem toggleRootItem;
44745894 CheckboxMenuItem animationItem;
5895
+ MenuItem archiveItem;
44755896 CheckboxMenuItem toggleHandleItem;
44765897 CheckboxMenuItem togglePaintItem;
44775898 JSplitPane mainPanel;
44785899 JScrollPane scrollpane;
5900
+
44795901 JPanel toolbarPanel;
5902
+
44805903 cGridBag treePanel;
5904
+
44815905 JPanel radioPanel;
44825906 ButtonGroup buttonGroup;
4483
- cGridBag ctrlPanel;
5907
+
5908
+ cGridBag toolboxPanel;
5909
+ cGridBag skyboxPanel;
44845910 cGridBag materialPanel;
5911
+ cGridBag ctrlPanel;
5912
+
44855913 JScrollPane infoPanel;
5914
+
44865915 cGridBag optionsPanel;
5916
+
44875917 JTabbedPane objectPanel;
5918
+ boolean materialFlushed;
5919
+ Object3D latestObject;
5920
+
44885921 cGridBag XYZPanel;
5922
+
44895923 JSplitPane gridPanel;
44905924 JSplitPane bigPanel;
5925
+
44915926 cGridBag bigThree;
44925927 cGridBag scenePanel;
44935928 cGridBag centralPanel;
....@@ -4545,7 +5980,7 @@
45455980 JLabel colorLabel;
45465981 cNumberSlider colorField;
45475982 JLabel modulationLabel;
4548
- cNumberSlider modulationField;
5983
+ cNumberSlider saturationField;
45495984 JLabel metalnessLabel;
45505985 cNumberSlider metalnessField;
45515986 JLabel diffuseLabel;
....@@ -4576,6 +6011,7 @@
45766011 cNumberSlider anisoField;
45776012 JLabel anisoVLabel;
45786013 cNumberSlider anisoVField;
6014
+
45796015 JLabel cameraLabel;
45806016 cNumberSlider cameraField;
45816017 JLabel selfshadowLabel;
....@@ -4590,6 +6026,7 @@
45906026 cNumberSlider fakedepthField;
45916027 JLabel shadowbiasLabel;
45926028 cNumberSlider shadowbiasField;
6029
+
45936030 JLabel bumpLabel;
45946031 cNumberSlider bumpField;
45956032 JLabel noiseLabel;
....@@ -4602,8 +6039,13 @@
46026039 cNumberSlider fogField;
46036040 JLabel opacityPowerLabel;
46046041 cNumberSlider opacityPowerField;
4605
- JTree jTree;
6042
+ cTree jTree;
46066043 //ObjectUI parent;
46076044
46086045 cNumberSlider normalpushField;
6046
+
6047
+ private MenuItem importGFDItem;
6048
+ private MenuItem importVRMLX3DItem;
6049
+ private MenuItem import3DSItem;
6050
+ private MenuItem importOBJItem;
46096051 }