Normand Briere
2019-08-18 480ad70047e54b2b92f974e6c2ac5a6c0bdc5a5c
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,146 @@
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 Composite CreateCameras()
76
+ {
77
+ Composite cams = new cTemplate();
78
+ cams.name = "Cameras";
79
+ copy.insertElementAt(cams, 0);
80
+
81
+ cams.addChild(new Camera());
82
+ cams.addChild(new Camera(1));
83
+ cams.addChild(new Camera(2));
84
+ cams.addChild(new Camera(3));
85
+ cams.addChild(new Camera(4));
86
+
87
+ return cams;
88
+ }
89
+
90
+ public cGridBag GetSeparator()
91
+ {
92
+ cGridBag separator = new cGridBag();
93
+ separator.add(new JSeparator());
94
+ separator.preferredHeight = 5;
95
+ return separator;
96
+ }
97
+
98
+ cButton GetButton(String name, boolean border)
99
+ {
100
+ ImageIcon icon = GetIcon(name);
101
+ if (icon != null || name.contains("/"))
102
+ return new cButton(icon, border);
103
+ else
104
+ return new cButton(name, border);
105
+ }
106
+
107
+ cLabel GetLabel(String name, boolean border)
108
+ {
109
+ //ImageIcon icon = GetIcon(name);
110
+ return new cLabel(GetImage(name), border);
111
+ }
112
+
113
+ cToggleButton GetToggleButton(String name, boolean border)
114
+ {
115
+ ImageIcon icon = GetIcon(name);
116
+ return new cToggleButton(icon, border);
117
+ }
118
+
119
+ cCheckBox GetCheckBox(String name, boolean border)
120
+ {
121
+ ImageIcon icon = GetIcon(name);
122
+ return new cCheckBox(icon, border);
123
+ }
124
+
125
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
126
+
127
+ static ImageIcon GetIcon(String name)
128
+ {
129
+ javax.swing.ImageIcon iconCache = icons.get(name);
130
+ if (iconCache != null)
131
+ {
132
+ return iconCache;
133
+ }
134
+
135
+ try
136
+ {
137
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
138
+
139
+// if (image.getWidth() > 48 && image.getHeight() > 48)
140
+// {
141
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
142
+// Graphics2D g = resized.createGraphics();
143
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
144
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
145
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
146
+// g.dispose();
147
+//
148
+// image = resized;
149
+// }
150
+
151
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
152
+
153
+ icons.put(name, icon);
154
+
155
+ return icon;
156
+ }
157
+ catch (Exception e)
158
+ {
159
+ //icons.put(name, null);
160
+ return null;
161
+ }
162
+ }
163
+
164
+ BufferedImage GetImage(String name)
165
+ {
166
+ try
167
+ {
168
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
169
+
170
+ return image;
171
+ }
172
+ catch (Exception e)
173
+ {
174
+ return null;
175
+ }
176
+ }
38177
39178 // SCRIPT
40179
....@@ -143,7 +282,9 @@
143282 //nameField.removeActionListener(this);
144283 // objEditor.ctrlPanel.remove(nameField);
145284
146
- if (!GroupEditor.allparams)
285
+ objEditor.ctrlPanel.remove(namePanel);
286
+
287
+ if (!allparams)
147288 return;
148289
149290 // objEditor.ctrlPanel.remove(liveCB);
....@@ -165,9 +306,9 @@
165306 // objEditor.ctrlPanel.remove(fasterButton);
166307 // objEditor.ctrlPanel.remove(remarkButton);
167308
168
- objEditor.ctrlPanel.remove(namePanel);
169309 objEditor.ctrlPanel.remove(setupPanel);
170
- objEditor.ctrlPanel.remove(commandsPanel);
310
+ objEditor.ctrlPanel.remove(setupPanel2);
311
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
171312 objEditor.ctrlPanel.remove(pushPanel);
172313 //objEditor.ctrlPanel.remove(fillPanel);
173314
....@@ -215,6 +356,14 @@
215356 client = inClient;
216357 copy = client;
217358
359
+// if (copy.versionlist == null)
360
+// {
361
+// copy.versionlist = new Object3D[100];
362
+// copy.versionindex = -1;
363
+//
364
+// callee.Save(true);
365
+// }
366
+
218367 // "this" is not called: SetupUI2(objEditor);
219368 }
220369
....@@ -228,6 +377,14 @@
228377 client = inClient;
229378 copy = client;
230379
380
+ if (copy.versionlist == null)
381
+ {
382
+ copy.versionlist = new Object3D[100];
383
+ copy.versionindex = -1;
384
+
385
+// Save(true);
386
+ }
387
+
231388 SetupUI2(callee.GetEditor());
232389 }
233390
....@@ -242,13 +399,15 @@
242399 //localCopy.parent = null;
243400
244401 frame = new JFrame();
402
+ frame.setUndecorated(false);
245403 objEditor = this;
246404 this.callee = callee;
247405
248406 //parent = p;
249407
250408 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
251
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
409
+ if (Globals.DEBUG)
410
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
252411 //gd.setFullScreenWindow(this);
253412 //setResizable(false);
254413 //if (!isDisplayable())
....@@ -259,6 +418,14 @@
259418 copy = localCopy;
260419 copy.editWindow = this;
261420
421
+// if (copy.versionlist == null)
422
+// {
423
+// copy.versionlist = new Object3D[100];
424
+// copy.versionindex = -1;
425
+//
426
+// Save(true);
427
+// }
428
+
262429 SetupMenu();
263430
264431 //SetupName(objEditor); // new
....@@ -272,28 +439,52 @@
272439 return frame.action(event, obj);
273440 }
274441
442
+ // Cannot work without static
443
+ static boolean allparams = true;
444
+
445
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
446
+
447
+ // This is to refresh the UI of the material panel.
448
+ boolean patchMaterial;
449
+
275450 void SetupMenu()
276451 {
277452 frame.setMenuBar(menuBar = new MenuBar());
278
- menuBar.add(windowMenu = new Menu("File"));
279
- windowMenu.add(loadItem = new MenuItem("Load..."));
280
- windowMenu.add("-");
281
- windowMenu.add(saveItem = new MenuItem("Save"));
282
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
453
+ menuBar.add(fileMenu = new Menu("File"));
454
+ fileMenu.add(newItem = new MenuItem("New"));
455
+ fileMenu.add(openItem = new MenuItem("Open..."));
456
+
457
+ //oe.menuBar.add(menu = new Menu("Include"));
458
+ Menu menu = new Menu("Import");
459
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
460
+ importOBJItem.addActionListener(this);
461
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
462
+ import3DSItem.addActionListener(this);
463
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
464
+ importVRMLX3DItem.addActionListener(this);
465
+ menu.add("-");
466
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
467
+ importGFDItem.addActionListener(this);
468
+ fileMenu.add(menu);
469
+ fileMenu.add("-");
470
+
471
+ fileMenu.add(saveItem = new MenuItem("Save"));
472
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
283473 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
284
- windowMenu.add("-");
285
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
286
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
287
- windowMenu.add("-");
474
+ fileMenu.add("-");
475
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
476
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
477
+ fileMenu.add("-");
288478 if (client.parent != null)
289479 {
290
- windowMenu.add(closeItem = new MenuItem("Close"));
480
+ fileMenu.add(closeItem = new MenuItem("Close"));
291481 } else
292482 {
293
- windowMenu.add(closeItem = new MenuItem("Exit"));
483
+ fileMenu.add(closeItem = new MenuItem("Exit"));
294484 }
295485
296
- loadItem.addActionListener(this);
486
+ newItem.addActionListener(this);
487
+ openItem.addActionListener(this);
297488 saveItem.addActionListener(this);
298489 saveAsItem.addActionListener(this);
299490 exportAsItem.addActionListener(this);
....@@ -301,82 +492,103 @@
301492 //povItem.addActionListener(this);
302493 closeItem.addActionListener(this);
303494
304
- menuBar.add(cameraMenu = new Menu("View"));
305
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
306
- //zBufferItem.addActionListener(this);
307
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
308
- //normalLensItem.addActionListener(this);
309
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
310
- revertCameraItem.addActionListener(this);
311
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
312
- toggleTimelineItem.addItemListener(this);
313
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
314
- toggleFullScreenItem.addItemListener(this);
315
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
316
- cameraMenu.add("-");
317
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
318
- toggleTextureItem.addItemListener(this);
319
- toggleTextureItem.setState(CameraPane.textureon);
320
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
321
- toggleLiveItem.addItemListener(this);
322
- toggleLiveItem.setState(Globals.isLIVE());
323
- cameraMenu.add(stepItem = new MenuItem("Step"));
324
- stepItem.addActionListener(this);
325
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
326
-// toggleDLItem.addItemListener(this);
327
-// toggleDLItem.setState(false);
328
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
329
- toggleRenderItem.addItemListener(this);
330
- toggleRenderItem.setState(!CameraPane.frozen);
331
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
332
- toggleDebugItem.addItemListener(this);
333
- toggleDebugItem.setState(CameraPane.DEBUG);
334
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
335
- toggleFrustumItem.addItemListener(this);
336
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
337
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
338
- toggleFootContactItem.addItemListener(this);
339
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
340
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
341
- toggleRandomItem.addItemListener(this);
342
- toggleRandomItem.setState(CameraPane.RANDOM);
343
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
344
- toggleHandleItem.addItemListener(this);
345
- toggleHandleItem.setState(CameraPane.HANDLES);
346
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
347
- togglePaintItem.addItemListener(this);
348
- togglePaintItem.setState(CameraPane.PAINTMODE);
349
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
350
-// toggleRootItem.addItemListener(this);
351
-// toggleRootItem.setState(false);
352
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
353
-// animationItem.addItemListener(this);
354
-// animationItem.setState(CameraPane.ANIMATION);
355
- cameraMenu.add("-");
356
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
357
- editCameraItem.addActionListener(this);
358
-
359495 objectPanel = new JTabbedPane();
496
+
497
+ ChangeListener changeListener = new ChangeListener()
498
+ {
499
+ //String name;
500
+
501
+ public void stateChanged(ChangeEvent changeEvent)
502
+ {
503
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
504
+// {
505
+// if (latestObject != null)
506
+// {
507
+// refreshContents(true);
508
+// SetMaterial(latestObject);
509
+// }
510
+//
511
+// materialFlushed = true;
512
+// }
513
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
514
+// {
515
+// if (listUI.size() == 0)
516
+// EditSelection(false);
517
+// }
518
+
519
+// if (objectPanel.getSelectedIndex() == 4)
520
+// {
521
+// name = copy.skyboxname;
522
+//
523
+// if (name == null)
524
+// {
525
+// name = "";
526
+// }
527
+//
528
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
529
+// copy.skyboxext = "jpg";
530
+// }
531
+// else
532
+// {
533
+// if (name != null)
534
+// {
535
+// if (name.equals(""))
536
+// {
537
+// copy.skyboxname = null;
538
+// copy.skyboxext = null;
539
+// }
540
+// else
541
+// {
542
+// copy.skyboxname = name;
543
+// }
544
+// }
545
+// }
546
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
547
+
548
+// refreshContents(false); // To refresh Info tab
549
+ cameraView.repaint();
550
+ }
551
+ };
552
+ objectPanel.addChangeListener(changeListener);
553
+
360554 toolbarPanel = new JPanel();
361555 toolbarPanel.setName("Toolbar");
362
- treePanel = new JPanel();
556
+
557
+ treePanel = new cGridBag();
363558 treePanel.setName("Tree");
559
+
560
+ editPanel = new cGridBag().setVertical(true);
561
+ //editPanel.setName("Edit");
562
+
364563 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
365
- ctrlPanel.setName("Edit");
366
- materialPanel = new cGridBag().setVertical(true);
367
- materialPanel.setName("Material");
564
+
565
+ editCommandsPanel = new cGridBag();
566
+ editPanel.add(editCommandsPanel);
567
+ editPanel.add(ctrlPanel);
568
+
569
+ toolboxPanel = new cGridBag().setVertical(true);
570
+ //toolboxPanel.setName("Toolbox");
571
+
572
+ skyboxPanel = new cGridBag().setVertical(true);
573
+
574
+ materialPanel = new cGridBag().setVertical(false);
575
+ //materialPanel.setName("Material");
576
+
368577 /*JTextPane*/
369578 infoarea = createTextPane();
579
+ doc = infoarea.getStyledDocument();
580
+
370581 infoarea.setEditable(true);
371582 SetText();
583
+
372584 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
373585 // infoarea.setOpaque(false);
374586 // //infoarea.setForeground(textcolor);
375
- infoarea.setLineWrap(true);
376
- infoarea.setWrapStyleWord(true);
587
+// TEXTAREA infoarea.setLineWrap(true);
588
+// TEXTAREA infoarea.setWrapStyleWord(true);
377589 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
378
- infoPanel.setPreferredSize(new Dimension(50, 200));
379
- infoPanel.setName("Info");
590
+ infoPanel.setPreferredSize(new Dimension(1, 1));
591
+ //infoPanel.setName("Info");
380592 //infoPanel.setLayout(new BorderLayout());
381593 //infoPanel.add(createTextPane());
382594
....@@ -384,14 +596,21 @@
384596 mainPanel.setName("Main");
385597 mainPanel.setContinuousLayout(true);
386598 mainPanel.setOneTouchExpandable(true);
387
- mainPanel.setDividerLocation(1.0);
388599 mainPanel.setDividerSize(9);
389
- mainPanel.setResizeWeight(0);
390
-
600
+ mainPanel.setDividerLocation(0.5); //1.0);
601
+ mainPanel.setResizeWeight(0.5);
602
+
603
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
604
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
605
+ divider.setDividerSize(15);
606
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
607
+
608
+ mainPanel.setUI(new BasicSplitPaneUI());
609
+
391610 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
392611 //mainPanel.setLayout(new GridBagLayout());
393612 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
394
- treePanel.setLayout(new GridBagLayout());
613
+// treePanel.setLayout(new GridBagLayout());
395614 //ctrlPanel.setLayout(new GridBagLayout());
396615 //materialPanel.setLayout(new GridBagLayout());
397616
....@@ -432,7 +651,7 @@
432651 static String newline = "\n";
433652 protected static final String buttonString = "JButton";
434653 StyledDocument doc;
435
- JTextArea infoarea;
654
+ JTextPane infoarea;
436655
437656 void ClearInfo()
438657 {
....@@ -455,10 +674,10 @@
455674 e.printStackTrace();
456675 }
457676
458
- String selection = infoarea.getText();
459
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
460
- java.awt.datatransfer.Clipboard clipboard =
461
- Toolkit.getDefaultToolkit().getSystemClipboard();
677
+// String selection = infoarea.getText();
678
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
679
+// java.awt.datatransfer.Clipboard clipboard =
680
+// Toolkit.getDefaultToolkit().getSystemClipboard();
462681 //clipboard.setContents(data, data);
463682 }
464683
....@@ -481,13 +700,13 @@
481700 //SendInfo("Name:", "bold");
482701 if (sel.GetTextures() != null || debug)
483702 {
484
- si.SendInfo(sel.toString(), "bold");
703
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
485704 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
486705 if (sel.Size() > 0)
487706 {
488707 si.SendInfo("#children = " + sel.Size(), "regular");
489708 }
490
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
709
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
491710 if (debug)
492711 {
493712 try
....@@ -499,7 +718,10 @@
499718 }
500719
501720 if (full)
502
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
721
+ {
722
+ si.SendInfo(" BBox min: " + minima, "regular");
723
+ si.SendInfo(" BBox max: " + maxima, "regular");
724
+ }
503725
504726 if (sel.bRep != null)
505727 {
....@@ -526,7 +748,7 @@
526748 }
527749 if (sel.support != null)
528750 {
529
- si.SendInfo(" support: " + sel.support, "regular");
751
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
530752 }
531753 if (sel.scriptnode != null)
532754 {
....@@ -597,6 +819,9 @@
597819 {
598820 CameraPane.pointflow = (PointFlow) sel;
599821 }
822
+
823
+ si.SendInfo("_____________________", "regular");
824
+ si.SendInfo("", "regular");
600825 }
601826 }
602827
....@@ -612,68 +837,216 @@
612837 }
613838 }
614839
840
+//static GraphicsDevice device = GraphicsEnvironment
841
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
842
+
843
+ Rectangle keeprect;
844
+ cRadio radio;
845
+
846
+cButton keepButton;
847
+ cButton twoButton; // Full 3D
848
+ cButton sixButton;
849
+ cButton threeButton;
850
+ cButton sevenButton;
851
+ cButton fourButton; // full panel
852
+ cButton oneButton; // full XYZ
853
+ //cButton currentLayout;
854
+
855
+ boolean maximized;
856
+
857
+ cButton fullscreenLayout;
858
+ cButton expandedLayout;
859
+
860
+ void Minimize()
861
+ {
862
+ frame.setState(Frame.ICONIFIED);
863
+ frame.validate();
864
+ }
865
+
866
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
867
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
868
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
869
+ void Maximize()
870
+ {
871
+ if (CameraPane.FULLSCREEN)
872
+ {
873
+ ToggleFullScreen();
874
+ }
875
+
876
+ if (maximized)
877
+ {
878
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
879
+ }
880
+ else
881
+ {
882
+ keeprect = frame.getBounds();
883
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
884
+// Dimension rect2 = frame.getToolkit().getScreenSize();
885
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
886
+// frame.setState(Frame.MAXIMIZED_BOTH);
887
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
888
+ }
889
+
890
+ maximized ^= true;
891
+
892
+ frame.validate();
893
+ }
894
+
895
+ cButton minButton;
896
+ cButton maxButton;
897
+ cButton fullButton;
898
+ cButton collapseButton;
899
+ cButton maximize3DButton;
900
+
615901 void ToggleFullScreen()
616902 {
617
- if (CameraPane.FULLSCREEN)
903
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
904
+
905
+ cameraView.ToggleFullScreen();
906
+
907
+ if (!CameraPane.FULLSCREEN)
618908 {
619
- frame.getContentPane().remove(/*"Center",*/bigThree);
620
- framePanel.add(bigThree);
621
- frame.getContentPane().add(/*"Center",*/framePanel);
909
+ device.setFullScreenWindow(null);
910
+ frame.dispose();
911
+ frame.setUndecorated(false);
912
+ frame.validate();
913
+ frame.setVisible(true);
914
+
915
+ //frame.setVisible(false);
916
+// frame.removeNotify();
917
+// frame.setUndecorated(false);
918
+// frame.addNotify();
919
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
920
+
921
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
922
+// X framePanel.add(bigThree);
923
+// X frame.getContentPane().add(/*"Center",*/framePanel);
924
+// framePanel.setDividerLocation(46); // icons are 24x24
925
+
926
+ //frame.setVisible(true);
927
+// radio.layout = keepButton;
928
+ //theFrame = null;
929
+ keepButton = null;
930
+// radio.layout.doClick();
931
+
622932 } else
623933 {
624
- frame.getContentPane().remove(/*"Center",*/framePanel);
625
- framePanel.remove(bigThree);
626
- frame.getContentPane().add(/*"Center",*/bigThree);
934
+ keepButton = radio.layout;
935
+ //keeprect = frame.getBounds();
936
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
937
+// frame.getToolkit().getScreenSize().height);
938
+ //frame.setVisible(false);
939
+
940
+ frame.dispose();
941
+ frame.setUndecorated(true);
942
+ device.setFullScreenWindow(frame);
943
+ frame.validate();
944
+ frame.setVisible(true);
945
+// frame.removeNotify();
946
+// frame.setUndecorated(true);
947
+// frame.addNotify();
948
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
949
+// X framePanel.remove(bigThree);
950
+// X frame.getContentPane().add(/*"Center",*/bigThree);
951
+// framePanel.setDividerLocation(0);
952
+
953
+// radio.layout = fullscreenLayout;
954
+// radio.layout.doClick();
955
+ //frame.setVisible(true);
627956 }
628
- cameraView.ToggleFullScreen();
957
+ frame.validate();
958
+
959
+ cameraView.requestFocusInWindow();
629960 }
630961
631
- private JTextArea createTextPane()
962
+ void CollapseToolbar()
963
+ {
964
+ framePanel.setDividerLocation(0);
965
+ //frame.validate();
966
+
967
+ cameraView.requestFocusInWindow();
968
+ }
969
+
970
+ private Object3D Duplicate(Object3D object)
632971 {
633
- String[] initString =
634
- {
635
- "This is an editable JTextPane, ", //regular
636
- "another ", //italic
637
- "styled ", //bold
638
- "text ", //small
639
- "component, ", //large
640
- "which supports embedded components..." + newline,//regular
641
- " " + newline, //button
642
- "...and embedded icons..." + newline, //regular
643
- " ", //icon
644
- newline + "JTextPane is a subclass of JEditorPane that "
645
- + "uses a StyledEditorKit and StyledDocument, and provides "
646
- + "cover methods for interacting with those objects."
647
- };
972
+ boolean temp = CameraPane.SWITCH;
973
+ CameraPane.SWITCH = false;
974
+
975
+ if (Grafreed.grafreed.universe.versiontable == null)
976
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
977
+
978
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
979
+ // if (copy == client)
980
+
981
+ Object3D versions[] = object.versionlist;
982
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
983
+ object.versionlist = null;
984
+ object.versiontable = null;
985
+
986
+ Object3D parent = object.parent;
987
+ object.parent = null;
988
+
989
+ //byte[] compress = Compress(copy);
990
+ Object3D compress = (Object3D)Grafreed.clone(object);
991
+
992
+ object.parent = parent;
993
+
994
+ object.versionlist = versions;
995
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
996
+
997
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
998
+
999
+ CameraPane.SWITCH = temp;
1000
+
1001
+ return compress;
1002
+ }
6481003
649
- String[] initStyles =
650
- {
651
- "regular", "italic", "bold", "small", "large",
652
- "regular", "button", "regular", "icon",
653
- "regular"
654
- };
1004
+ private JTextPane createTextPane()
1005
+ {
1006
+// TEXTAREA String[] initString =
1007
+// {
1008
+// "This is an editable JTextPane, ", //regular
1009
+// "another ", //italic
1010
+// "styled ", //bold
1011
+// "text ", //small
1012
+// "component, ", //large
1013
+// "which supports embedded components..." + newline,//regular
1014
+// " " + newline, //button
1015
+// "...and embedded icons..." + newline, //regular
1016
+// " ", //icon
1017
+// newline + "JTextPane is a subclass of JEditorPane that "
1018
+// + "uses a StyledEditorKit and StyledDocument, and provides "
1019
+// + "cover methods for interacting with those objects."
1020
+// };
1021
+//
1022
+// String[] initStyles =
1023
+// {
1024
+// "regular", "italic", "bold", "small", "large",
1025
+// "regular", "button", "regular", "icon",
1026
+// "regular"
1027
+// };
1028
+//
1029
+// JTextPane textPane = new JTextPane();
1030
+// textPane.setEditable(true);
1031
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
1032
+// addStylesToDocument(doc);
1033
+//
1034
+// try
1035
+// {
1036
+// for (int j = 0; j < 2; j++)
1037
+// {
1038
+// for (int i = 0; i < initString.length; i++)
1039
+// {
1040
+// doc.insertString(doc.getLength(), initString[i],
1041
+// doc.getStyle(initStyles[i]));
1042
+// }
1043
+// }
1044
+// } catch (BadLocationException ble)
1045
+// {
1046
+// System.err.println("Couldn't insert initial text into text pane.");
1047
+// }
6551048
656
- JTextPane textPane = new JTextPane();
657
- textPane.setEditable(true);
658
- /*StyledDocument*/ doc = textPane.getStyledDocument();
659
- addStylesToDocument(doc);
660
-
661
- try
662
- {
663
- for (int j = 0; j < 2; j++)
664
- {
665
- for (int i = 0; i < initString.length; i++)
666
- {
667
- doc.insertString(doc.getLength(), initString[i],
668
- doc.getStyle(initStyles[i]));
669
- }
670
- }
671
- } catch (BadLocationException ble)
672
- {
673
- System.err.println("Couldn't insert initial text into text pane.");
674
- }
675
-
676
- return new JTextArea(); // textPane;
1049
+ return new JTextPane(); // textPane;
6771050 }
6781051
6791052 protected void addStylesToDocument(StyledDocument doc)
....@@ -726,7 +1099,7 @@
7261099 protected static ImageIcon createImageIcon(String path,
7271100 String description)
7281101 {
729
- java.net.URL imgURL = GrafreeD.class.getResource(path);
1102
+ java.net.URL imgURL = Grafreed.class.getResource(path);
7301103 if (imgURL != null)
7311104 {
7321105 return new ImageIcon(imgURL, description);
....@@ -749,6 +1122,7 @@
7491122 {
7501123 SetupMaterial(materialPanel);
7511124 }
1125
+
7521126 //SetupName();
7531127 //SetupViews();
7541128 }
....@@ -758,6 +1132,7 @@
7581132 // NumberSlider vDivsField;
7591133 // JCheckBox endcaps;
7601134 JCheckBox liveCB;
1135
+ JCheckBox selectableCB;
7611136 JCheckBox hideCB;
7621137 JCheckBox link2masterCB;
7631138 JCheckBox markCB;
....@@ -765,7 +1140,12 @@
7651140 JCheckBox speedupCB;
7661141 JCheckBox rewindCB;
7671142 JCheckBox flipVCB;
1143
+
1144
+ cCheckBox toggleTextureCB;
1145
+ cCheckBox toggleSwitchCB;
1146
+
7681147 JComboBox texresMenu;
1148
+
7691149 JButton resetButton;
7701150 JButton stepButton;
7711151 JButton stepAllButton;
....@@ -774,9 +1154,13 @@
7741154 JButton fasterButton;
7751155 JButton remarkButton;
7761156
1157
+ cGridBag editPanel;
1158
+ cGridBag editCommandsPanel;
1159
+
7771160 cGridBag namePanel;
7781161 cGridBag setupPanel;
779
- cGridBag commandsPanel;
1162
+ cGridBag setupPanel2;
1163
+ cGridBag objectCommandsPanel;
7801164 cGridBag pushPanel;
7811165 cGridBag fillPanel;
7821166
....@@ -943,52 +1327,88 @@
9431327
9441328 void SetupUI2(ObjEditor oe)
9451329 {
946
-// oe.aConstraints.weightx = 0;
947
-// oe.aConstraints.weighty = 0;
948
-// oe.aConstraints.gridx = 0;
949
-// oe.aConstraints.gridy = 0;
9501330 //SetupName(oe);
9511331
9521332 namePanel = new cGridBag();
9531333
1334
+ //if (copy.pinned)
1335
+ {
1336
+ pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
1337
+ pinButton.setSelected(copy.pinned);
1338
+ cGridBag t = new cGridBag();
1339
+ t.preferredWidth = 2;
1340
+ t.add(pinButton);
1341
+ namePanel.add(t);
1342
+
1343
+ pinButton.addItemListener(this);
1344
+ }
1345
+
9541346 nameField = AddText(namePanel, copy.GetName());
955
- namePanel.add(nameField);
1347
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9561348 oe.ctrlPanel.add(namePanel);
9571349
9581350 oe.ctrlPanel.Return();
9591351
960
- if (!GroupEditor.allparams)
1352
+ if (!allparams)
9611353 return;
9621354
9631355 setupPanel = new cGridBag().setVertical(false);
9641356
9651357 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
966
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
967
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1358
+ liveCB.setToolTipText("Animate object");
1359
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1360
+ markCB.setToolTipText("Set target transform");
1361
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1362
+ selectableCB.setToolTipText("Make object selectable");
9681363 // Return();
969
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
970
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
971
- randomCB = AddCheckBox(setupPanel, "Rand", copy.random);
1364
+
1365
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1366
+ hideCB.setToolTipText("Hide object");
1367
+
1368
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1369
+
1370
+ setupPanel2 = new cGridBag().setVertical(false);
1371
+
1372
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1373
+ rewindCB.setToolTipText("Rewind animation");
1374
+
1375
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1376
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9721377
1378
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1379
+ link2masterCB.setToolTipText("Attach to support");
1380
+
1381
+ if (Globals.ADVANCED)
1382
+ {
1383
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1384
+ speedupCB.setToolTipText("Option motion capture");
1385
+ }
1386
+
9731387 oe.ctrlPanel.add(setupPanel);
9741388 oe.ctrlPanel.Return();
1389
+ oe.ctrlPanel.add(setupPanel2);
1390
+ oe.ctrlPanel.Return();
9751391
976
- commandsPanel = new cGridBag().setVertical(false);
1392
+ objectCommandsPanel = new cGridBag().setVertical(false);
9771393
978
- resetButton = AddButton(commandsPanel, "Reset");
979
- stepButton = AddButton(commandsPanel, "Step");
1394
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1395
+ resetButton.setToolTipText("Jump to frame zero");
1396
+ stepButton = AddButton(objectCommandsPanel, "Step");
1397
+ stepButton.setToolTipText("Step one frame");
9801398 // resetAllButton = AddButton(oe, "Reset All");
9811399 // stepAllButton = AddButton(oe, "Step All");
982
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
9831400 // Return();
984
- slowerButton = AddButton(commandsPanel, "Slow");
985
- fasterButton = AddButton(commandsPanel, "Fast");
986
- remarkButton = AddButton(commandsPanel, "Remark");
1401
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1402
+ slowerButton.setToolTipText("Decrease animation speed");
1403
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1404
+ fasterButton.setToolTipText("Increase animation speed");
1405
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1406
+ remarkButton.setToolTipText("Set the current transform as the target");
9871407
988
- oe.ctrlPanel.add(commandsPanel);
1408
+ oe.ctrlPanel.add(objectCommandsPanel);
9891409 oe.ctrlPanel.Return();
9901410
991
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1411
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
9921412 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
9931413 //Return();
9941414
....@@ -1145,22 +1565,9 @@
11451565
11461566 if (cam == null || !(copy.get(0) instanceof cGroup))
11471567 {
1148
- System.out.println("CREATE CAMERAS");
1149
- cams = new cTemplate();
1150
- cams.name = "Cameras";
1151
- copy.insertElementAt(cams, 0);
1152
- //cams.parent = copy;
1153
-
1154
- cam = new Camera(); // LA.newVector(3, 2, 1));
1155
- cams.addChild(cam);
1156
- cam = new Camera(1);
1157
- cams.addChild(cam);
1158
- cam = new Camera(2);
1159
- cams.addChild(cam);
1160
- cam = new Camera(3);
1161
- cams.addChild(cam);
1162
- cam = new Camera(4); // Light
1163
- cams.addChild(cam);
1568
+ if (Globals.DEBUG)
1569
+ System.out.println("CREATE CAMERAS");
1570
+ cams = CreateCameras();
11641571 } else
11651572 {
11661573 cams = (cGroup) copy.get(0);
....@@ -1191,8 +1598,11 @@
11911598 //worldPanel.setName("World");
11921599 centralPanel = new cGridBag();
11931600 centralPanel.preferredWidth = 20;
1194
- timelinePanel = new JPanel(new BorderLayout());
1195
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1601
+
1602
+ if (Globals.ADVANCED)
1603
+ {
1604
+ timelinePanel = new JPanel(new BorderLayout());
1605
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11961606
11971607 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11981608 cameraPanel.setContinuousLayout(true);
....@@ -1201,7 +1611,10 @@
12011611 // cameraPanel.setDividerSize(9);
12021612 cameraPanel.setResizeWeight(1.0);
12031613
1614
+ }
1615
+
12041616 centralPanel.add(cameraView);
1617
+ centralPanel.setFocusable(true);
12051618 //frame.setJMenuBar(timelineMenubar);
12061619 //centralPanel.add(timelinePanel);
12071620
....@@ -1220,6 +1633,45 @@
12201633 //frontView.object = copy;
12211634 //sideView.object = copy;
12221635
1636
+ transformPanel = new cGridBag().setVertical(true);
1637
+
1638
+ cGridBag resetTransformPanel = new cGridBag();
1639
+
1640
+ resetTransformPanel.preferredHeight = 2;
1641
+
1642
+ cButton resetTransform = GetButton("Reset all", !Globals.NIMBUSLAF);
1643
+ resetTransform.setToolTipText("Reset Translation, Rotation and Scale");
1644
+ resetTransform.addMouseListener(new MouseAdapter()
1645
+ {
1646
+ public void mouseClicked(MouseEvent e)
1647
+ {
1648
+ ResetTransform();
1649
+ }
1650
+ });
1651
+ resetTransformPanel.add(resetTransform);
1652
+
1653
+ resetTransform = GetButton("T only", !Globals.NIMBUSLAF);
1654
+ resetTransform.setToolTipText("Reset Translation only");
1655
+ resetTransform.addMouseListener(new MouseAdapter()
1656
+ {
1657
+ public void mouseClicked(MouseEvent e)
1658
+ {
1659
+ ResetTransform(1);
1660
+ }
1661
+ });
1662
+ resetTransformPanel.add(resetTransform);
1663
+
1664
+ resetTransform = GetButton("RS only", !Globals.NIMBUSLAF);
1665
+ resetTransform.setToolTipText("Reset Rotation and Scale only");
1666
+ resetTransform.addMouseListener(new MouseAdapter()
1667
+ {
1668
+ public void mouseClicked(MouseEvent e)
1669
+ {
1670
+ ResetTransform(2);
1671
+ }
1672
+ });
1673
+ resetTransformPanel.add(resetTransform);
1674
+
12231675 XYZPanel = new cGridBag().setVertical(true);
12241676 //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
12251677
....@@ -1227,7 +1679,11 @@
12271679 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12281680 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12291681 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1682
+ //XYZPanel.setName("XYZ");
12301683
1684
+ transformPanel.add(resetTransformPanel);
1685
+ transformPanel.add(XYZPanel);
1686
+
12311687 /*
12321688 gridPanel = new JPanel(); //new BorderLayout());
12331689 gridPanel.setLayout(new GridLayout(1, 2));
....@@ -1235,12 +1691,12 @@
12351691 gridPanel.add(cameraView);
12361692 gridPanel.add(XYZPanel);
12371693 */
1238
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1239
- gridPanel.setContinuousLayout(true);
1240
- gridPanel.setOneTouchExpandable(true);
1241
- gridPanel.setDividerLocation(1.0);
1242
- gridPanel.setDividerSize(9);
1243
- gridPanel.setResizeWeight(0.85);
1694
+// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
1695
+// gridPanel.setContinuousLayout(true);
1696
+// gridPanel.setOneTouchExpandable(true);
1697
+// gridPanel.setDividerLocation(1.0);
1698
+// gridPanel.setDividerSize(9);
1699
+// gridPanel.setResizeWeight(0.85);
12441700
12451701 // aConstraints.weighty = 0;
12461702 //System.out.println("THIS = " + this);
....@@ -1263,14 +1719,34 @@
12631719
12641720 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12651721 //tmp.setName("Edit");
1722
+ objectPanel.add(skyboxPanel);
1723
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1724
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1725
+
1726
+ objectPanel.add(toolboxPanel);
1727
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1728
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1729
+
12661730 objectPanel.add(materialPanel);
1731
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1732
+ objectPanel.setToolTipTextAt(2, "Material");
1733
+
12671734 // JPanel north = new JPanel(new BorderLayout());
12681735 // north.setName("Edit");
12691736 // north.add(ctrlPanel, BorderLayout.NORTH);
12701737 // objectPanel.add(north);
1271
- objectPanel.add(ctrlPanel);
1272
- objectPanel.add(infoPanel);
1273
-
1738
+ objectPanel.add(editPanel);
1739
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
1740
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1741
+
1742
+ objectPanel.add(transformPanel);
1743
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1744
+ objectPanel.setToolTipTextAt(4, "TRS transform");
1745
+
1746
+ patchMaterial = true;
1747
+ cameraView.patchMaterial = this;
1748
+ objectPanel.setSelectedIndex(2);
1749
+
12741750 /*
12751751 aConstraints.gridx = 0;
12761752 aConstraints.gridwidth = 1;
....@@ -1278,7 +1754,7 @@
12781754 aConstraints.gridy += 1;
12791755 aConstraints.gridwidth = 1;
12801756 mainPanel.add(objectPanel, aConstraints);
1281
- */
1757
+ */
12821758
12831759 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12841760 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1290,22 +1766,62 @@
12901766 scrollpane.addMouseWheelListener(this); // Default not fast enough
12911767
12921768 /*JTabbedPane*/ scenePanel = new cGridBag();
1293
- scenePanel.preferredWidth = 7;
1769
+ scenePanel.preferredWidth = 6;
12941770
12951771 JTabbedPane tabbedPane = new JTabbedPane();
12961772 tabbedPane.add(scrollpane);
12971773
1298
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1299
-
1300
- optionsPanel = new cGridBag().setVertical(true);
1774
+ optionsPanel = new cGridBag().setVertical(false);
13011775
13021776 optionsPanel.setName("Options");
13031777
13041778 AddOptions(optionsPanel); //, aConstraints);
13051779
1780
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1781
+
13061782 tabbedPane.add(optionsPanel);
13071783
13081784 scenePanel.add(tabbedPane);
1785
+
1786
+ cGridBag creditsPanel = new cGridBag().setVertical(true);
1787
+ creditsPanel.setName("Credits");
1788
+
1789
+ cLabel ogaLabel = new cLabel(" Most Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1790
+ creditsPanel.add(ogaLabel);
1791
+
1792
+ cButton opengameartButton;
1793
+ creditsPanel.add(opengameartButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1794
+ opengameartButton.setToolTipText("https://opengameart.org");
1795
+
1796
+ opengameartButton.addMouseListener(new MouseAdapter()
1797
+ {
1798
+ public void mouseClicked(MouseEvent e)
1799
+ {
1800
+ try
1801
+ {
1802
+ Desktop.getDesktop().browse(new java.net.URI("https://opengameart.org/"));
1803
+ } catch (Exception e1)
1804
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1805
+ {
1806
+ e1.printStackTrace();
1807
+ }
1808
+ }
1809
+ });
1810
+
1811
+ for (int i=10; --i>=0;)
1812
+ {
1813
+ creditsPanel.add(new cGridBag());
1814
+ }
1815
+
1816
+ tabbedPane.add(creditsPanel);
1817
+ tabbedPane.setToolTipTextAt(3, "Credits");
1818
+
1819
+ if (Globals.ADVANCED)
1820
+ {
1821
+ tabbedPane.add(infoPanel);
1822
+ tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1823
+ tabbedPane.setToolTipTextAt(4, "Information");
1824
+ }
13091825
13101826 /*
13111827 cTree jTree = new cTree(null);
....@@ -1327,13 +1843,13 @@
13271843 jtp.add(tree);
13281844 */
13291845
1330
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1331
- bigPanel.setContinuousLayout(true);
1332
- bigPanel.setOneTouchExpandable(true);
1333
- bigPanel.setDividerLocation(0.8);
1334
- bigPanel.setDividerSize(15);
1335
- bigPanel.setResizeWeight(0.15);
1336
- bigPanel.setName("Scene");
1846
+// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
1847
+// bigPanel.setContinuousLayout(true);
1848
+// bigPanel.setOneTouchExpandable(true);
1849
+// bigPanel.setDividerLocation(0.8);
1850
+// bigPanel.setDividerSize(15);
1851
+// bigPanel.setResizeWeight(0.15);
1852
+// bigPanel.setName("Scene");
13371853
13381854 //bigPanel.setLayout(new BorderLayout());
13391855 //bigPanel.setSize(new Dimension(10,10));
....@@ -1368,7 +1884,7 @@
13681884 bigThree = new cGridBag();
13691885 bigThree.addComponent(scenePanel);
13701886 bigThree.addComponent(centralPanel);
1371
- bigThree.addComponent(XYZPanel);
1887
+ //bigThree.addComponent(XYZPanel);
13721888
13731889 // // SIDE EFFECT!!!
13741890 // aConstraints.gridx = 0;
....@@ -1377,16 +1893,33 @@
13771893 // aConstraints.gridheight = 1;
13781894
13791895 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1380
- framePanel.setContinuousLayout(true);
1381
- framePanel.setOneTouchExpandable(true);
1382
- framePanel.setDividerLocation(0.8);
1896
+
1897
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1898
+ new java.beans.PropertyChangeListener()
1899
+ {
1900
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1901
+ {
1902
+ if ((Integer)pce.getOldValue() == 1)
1903
+ {
1904
+ if (radio.layout != expandedLayout)
1905
+ {
1906
+ radio.layout = expandedLayout;
1907
+ radio.layout.doClick();
1908
+ }
1909
+ }
1910
+ }
1911
+ });
1912
+
1913
+ framePanel.setContinuousLayout(false);
1914
+ framePanel.setOneTouchExpandable(false);
1915
+ //.setDividerLocation(0.8);
13831916 //framePanel.setDividerSize(15);
13841917 //framePanel.setResizeWeight(0.15);
13851918 framePanel.setName("Frame");
13861919
13871920 frame.getContentPane().setLayout(new BorderLayout());
13881921 /**/
1389
- JTabbedPane worldPane = new JTabbedPane();
1922
+ //JTabbedPane worldPane = new JTabbedPane();
13901923 //worldPane.add(bigPanel);
13911924 //worldPane.add(worldPanel);
13921925 /**/
....@@ -1396,15 +1929,19 @@
13961929
13971930 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13981931
1399
- frame.setSize(1024, 768);
1400
- frame.show();
1932
+ frame.setSize(1280, 860);
1933
+
1934
+ cameraView.requestFocusInWindow();
1935
+
1936
+// gridPanel.setDividerLocation(1.0);
1937
+
1938
+ frame.validate();
14011939
1402
- gridPanel.setDividerLocation(1.0);
1940
+ frame.setVisible(true);
14031941
14041942 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14051943 frame.addWindowListener(new WindowAdapter()
14061944 {
1407
-
14081945 public void windowClosing(WindowEvent e)
14091946 {
14101947 Close();
....@@ -1427,26 +1964,448 @@
14271964 ctrlPanel.removeAll();
14281965 }
14291966
1430
- void SetupMaterial(cGridBag panel)
1967
+ void SetupMaterial(cGridBag materialpanel)
14311968 {
1432
- /*
1969
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1970
+
1971
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
1972
+ skin.setToolTipText("Skin");
1973
+ skin.addMouseListener(new MouseAdapter()
1974
+ {
1975
+ public void mouseClicked(MouseEvent e)
1976
+ {
1977
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1978
+ cMaterial material = object.material;
1979
+
1980
+ // Skin
1981
+ colorField.setFloat(material.color);
1982
+ float saturation = material.modulation;
1983
+
1984
+ if (!cameraView.Skinshader)
1985
+ {
1986
+ saturation /= 1.5;
1987
+ }
1988
+
1989
+ saturationField.setFloat(saturation);
1990
+
1991
+ subsurfaceField.setFloat(material.subsurface);
1992
+ selfshadowField.setFloat(material.diffuseness);
1993
+ diffusenessField.setFloat(material.factor);
1994
+ shininessField.setFloat(material.shininess);
1995
+ shadowbiasField.setFloat(material.shadowbias);
1996
+ diffuseField.setFloat(material.diffuse);
1997
+ specularField.setFloat(material.specular);
1998
+
1999
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2000
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2001
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2002
+
2003
+ materialtouched = true;
2004
+ applySelf();
2005
+ }
2006
+ });
2007
+ presetpanel.add(skin);
2008
+
2009
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
2010
+ lambert.setToolTipText("Diffuse");
2011
+ lambert.addMouseListener(new MouseAdapter()
2012
+ {
2013
+ public void mouseClicked(MouseEvent e)
2014
+ {
2015
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
2016
+ cMaterial material = object.material;
2017
+
2018
+ diffusenessField.setFloat(material.factor);
2019
+ selfshadowField.setFloat(material.diffuseness);
2020
+
2021
+ materialtouched = true;
2022
+ applySelf();
2023
+ }
2024
+ });
2025
+ presetpanel.add(lambert);
2026
+
2027
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
2028
+ diffuse2.setToolTipText("Diffuse2");
2029
+ diffuse2.addMouseListener(new MouseAdapter()
2030
+ {
2031
+ public void mouseClicked(MouseEvent e)
2032
+ {
2033
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
2034
+ cMaterial material = object.material;
2035
+
2036
+ diffusenessField.setFloat(material.factor);
2037
+ selfshadowField.setFloat(material.diffuseness);
2038
+
2039
+ materialtouched = true;
2040
+ applySelf();
2041
+ }
2042
+ });
2043
+ presetpanel.add(diffuse2);
2044
+
2045
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
2046
+ diffusemoon.setToolTipText("Moon");
2047
+ diffusemoon.addMouseListener(new MouseAdapter()
2048
+ {
2049
+ public void mouseClicked(MouseEvent e)
2050
+ {
2051
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
2052
+ cMaterial material = object.material;
2053
+
2054
+ diffusenessField.setFloat(material.factor);
2055
+ selfshadowField.setFloat(material.diffuseness);
2056
+
2057
+ materialtouched = true;
2058
+ applySelf();
2059
+ }
2060
+ });
2061
+ presetpanel.add(diffusemoon);
2062
+
2063
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
2064
+ diffusemoon2.setToolTipText("Moon2");
2065
+ diffusemoon2.addMouseListener(new MouseAdapter()
2066
+ {
2067
+ public void mouseClicked(MouseEvent e)
2068
+ {
2069
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
2070
+ cMaterial material = object.material;
2071
+
2072
+ diffusenessField.setFloat(material.factor);
2073
+ selfshadowField.setFloat(material.diffuseness);
2074
+
2075
+ materialtouched = true;
2076
+ applySelf();
2077
+ }
2078
+ });
2079
+ presetpanel.add(diffusemoon2);
2080
+
2081
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
2082
+ diffusemoon3.setToolTipText("Moon3");
2083
+ diffusemoon3.addMouseListener(new MouseAdapter()
2084
+ {
2085
+ public void mouseClicked(MouseEvent e)
2086
+ {
2087
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2088
+ cMaterial material = object.material;
2089
+
2090
+ diffusenessField.setFloat(material.factor);
2091
+ selfshadowField.setFloat(material.diffuseness);
2092
+
2093
+ materialtouched = true;
2094
+ applySelf();
2095
+ }
2096
+ });
2097
+ presetpanel.add(diffusemoon3);
2098
+
2099
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
2100
+ diffusesheen.setToolTipText("Sheen");
2101
+ diffusesheen.addMouseListener(new MouseAdapter()
2102
+ {
2103
+ public void mouseClicked(MouseEvent e)
2104
+ {
2105
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2106
+ cMaterial material = object.material;
2107
+
2108
+ sheenField.setFloat(material.sheen);
2109
+
2110
+ materialtouched = true;
2111
+ applySelf();
2112
+ }
2113
+ });
2114
+ presetpanel.add(diffusesheen);
2115
+
2116
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
2117
+ rough.setToolTipText("Rough metal");
2118
+ rough.addMouseListener(new MouseAdapter()
2119
+ {
2120
+ public void mouseClicked(MouseEvent e)
2121
+ {
2122
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2123
+ cMaterial material = object.material;
2124
+
2125
+ shininessField.setFloat(material.shininess);
2126
+ velvetField.setFloat(material.velvet);
2127
+
2128
+ materialtouched = true;
2129
+ applySelf();
2130
+ }
2131
+ });
2132
+ presetpanel.add(rough);
2133
+
2134
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
2135
+ rough2.setToolTipText("Medium metal");
2136
+ rough2.addMouseListener(new MouseAdapter()
2137
+ {
2138
+ public void mouseClicked(MouseEvent e)
2139
+ {
2140
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2141
+ cMaterial material = object.material;
2142
+
2143
+ shininessField.setFloat(material.shininess);
2144
+ lightareaField.setFloat(material.lightarea);
2145
+
2146
+ materialtouched = true;
2147
+ applySelf();
2148
+ }
2149
+ });
2150
+ presetpanel.add(rough2);
2151
+
2152
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
2153
+ shini0.setToolTipText("Shiny");
2154
+ shini0.addMouseListener(new MouseAdapter()
2155
+ {
2156
+ public void mouseClicked(MouseEvent e)
2157
+ {
2158
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2159
+ cMaterial material = object.material;
2160
+
2161
+ shininessField.setFloat(material.shininess);
2162
+ lightareaField.setFloat(material.lightarea);
2163
+
2164
+ materialtouched = true;
2165
+ applySelf();
2166
+ }
2167
+ });
2168
+ presetpanel.add(shini0);
2169
+
2170
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
2171
+ shini1.setToolTipText("Shiny2");
2172
+ shini1.addMouseListener(new MouseAdapter()
2173
+ {
2174
+ public void mouseClicked(MouseEvent e)
2175
+ {
2176
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2177
+ cMaterial material = object.material;
2178
+
2179
+ shininessField.setFloat(material.shininess);
2180
+ lightareaField.setFloat(material.lightarea);
2181
+
2182
+ materialtouched = true;
2183
+ applySelf();
2184
+ }
2185
+ });
2186
+ presetpanel.add(shini1);
2187
+
2188
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
2189
+ shini2.setToolTipText("Shiny3");
2190
+ shini2.addMouseListener(new MouseAdapter()
2191
+ {
2192
+ public void mouseClicked(MouseEvent e)
2193
+ {
2194
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2195
+ cMaterial material = object.material;
2196
+
2197
+ shininessField.setFloat(material.shininess);
2198
+ lightareaField.setFloat(material.lightarea);
2199
+
2200
+ materialtouched = true;
2201
+ applySelf();
2202
+ }
2203
+ });
2204
+ presetpanel.add(shini2);
2205
+
2206
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
2207
+ aniso.setToolTipText("AnisoU");
2208
+ aniso.addMouseListener(new MouseAdapter()
2209
+ {
2210
+ public void mouseClicked(MouseEvent e)
2211
+ {
2212
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2213
+ cMaterial material = object.material;
2214
+
2215
+ anisoField.setFloat(material.aniso);
2216
+ anisoVField.setFloat(material.anisoV);
2217
+
2218
+ materialtouched = true;
2219
+ applySelf();
2220
+ }
2221
+ });
2222
+ presetpanel.add(aniso);
2223
+
2224
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
2225
+ aniso2.setToolTipText("AnisoV");
2226
+ aniso2.addMouseListener(new MouseAdapter()
2227
+ {
2228
+ public void mouseClicked(MouseEvent e)
2229
+ {
2230
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2231
+ cMaterial material = object.material;
2232
+
2233
+ anisoField.setFloat(material.aniso);
2234
+ anisoVField.setFloat(material.anisoV);
2235
+
2236
+ materialtouched = true;
2237
+ applySelf();
2238
+ }
2239
+ });
2240
+ presetpanel.add(aniso2);
2241
+
2242
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
2243
+ aniso3.setToolTipText("AnisoUV");
2244
+ aniso3.addMouseListener(new MouseAdapter()
2245
+ {
2246
+ public void mouseClicked(MouseEvent e)
2247
+ {
2248
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2249
+ cMaterial material = object.material;
2250
+
2251
+ anisoField.setFloat(material.aniso);
2252
+ anisoVField.setFloat(material.anisoV);
2253
+
2254
+ materialtouched = true;
2255
+ applySelf();
2256
+ }
2257
+ });
2258
+ presetpanel.add(aniso3);
2259
+
2260
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
2261
+ velvet0.setToolTipText("Velvet");
2262
+ velvet0.addMouseListener(new MouseAdapter()
2263
+ {
2264
+ public void mouseClicked(MouseEvent e)
2265
+ {
2266
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2267
+ cMaterial material = object.material;
2268
+
2269
+ diffusenessField.setFloat(material.factor);
2270
+ selfshadowField.setFloat(material.diffuseness);
2271
+ sheenField.setFloat(material.sheen);
2272
+ shininessField.setFloat(material.shininess);
2273
+ velvetField.setFloat(material.velvet);
2274
+ shiftField.setFloat(material.shift);
2275
+
2276
+ materialtouched = true;
2277
+ applySelf();
2278
+ }
2279
+ });
2280
+ presetpanel.add(velvet0);
2281
+
2282
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
2283
+ bump0.setToolTipText("Bump texture");
2284
+ bump0.addMouseListener(new MouseAdapter()
2285
+ {
2286
+ public void mouseClicked(MouseEvent e)
2287
+ {
2288
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2289
+ cMaterial material = object.material;
2290
+
2291
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2292
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2293
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2294
+
2295
+ materialtouched = true;
2296
+ applySelf();
2297
+ }
2298
+ });
2299
+ presetpanel.add(bump0);
2300
+
2301
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
2302
+ borderShader.setToolTipText("Border fade");
2303
+ borderShader.addMouseListener(new MouseAdapter()
2304
+ {
2305
+ public void mouseClicked(MouseEvent e)
2306
+ {
2307
+ borderfadeField.setFloat(0.5);
2308
+ opacityField.setFloat(0.75);
2309
+
2310
+ materialtouched = true;
2311
+ applySelf();
2312
+ }
2313
+ });
2314
+ presetpanel.add(borderShader);
2315
+
2316
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
2317
+ halo.setToolTipText("Halo");
2318
+ halo.addMouseListener(new MouseAdapter()
2319
+ {
2320
+ public void mouseClicked(MouseEvent e)
2321
+ {
2322
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2323
+ cMaterial material = object.material;
2324
+
2325
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2326
+
2327
+ materialtouched = true;
2328
+ applySelf();
2329
+ }
2330
+ });
2331
+ presetpanel.add(halo);
2332
+
2333
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
2334
+ candle.setToolTipText("Candle");
2335
+ candle.addMouseListener(new MouseAdapter()
2336
+ {
2337
+ public void mouseClicked(MouseEvent e)
2338
+ {
2339
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2340
+ cMaterial material = object.material;
2341
+
2342
+ subsurfaceField.setFloat(material.subsurface);
2343
+ shadowbiasField.setFloat(material.shadowbias);
2344
+ ambientField.setFloat(material.ambient);
2345
+ specularField.setFloat(material.specular);
2346
+ lightareaField.setFloat(material.lightarea);
2347
+ shininessField.setFloat(material.shininess);
2348
+
2349
+ materialtouched = true;
2350
+ applySelf();
2351
+ }
2352
+ });
2353
+ presetpanel.add(candle);
2354
+
2355
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
2356
+ shadowShader.setToolTipText("Shadow");
2357
+ shadowShader.addMouseListener(new MouseAdapter()
2358
+ {
2359
+ public void mouseClicked(MouseEvent e)
2360
+ {
2361
+ diffuseField.setFloat(0.001);
2362
+ ambientField.setFloat(0.001);
2363
+ cameraField.setFloat(0.001);
2364
+ specularField.setFloat(0.001);
2365
+ fakedepthField.setFloat(0.001);
2366
+ opacityField.setFloat(0.6);
2367
+
2368
+ materialtouched = true;
2369
+ applySelf();
2370
+ }
2371
+ });
2372
+ presetpanel.add(shadowShader);
2373
+
2374
+ cGridBag panel = new cGridBag().setVertical(true);
2375
+
2376
+ presetpanel.preferredWidth = 1;
2377
+
2378
+ materialpanel.add(presetpanel);
2379
+ materialpanel.add(panel);
2380
+
2381
+ panel.preferredWidth = 8;
2382
+
2383
+ /*
14332384 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14342385 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1435
- */
2386
+ */
14362387
14372388 cGridBag editBar = new cGridBag().setVertical(false);
14382389
1439
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
2390
+ editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
2391
+ createMaterialButton.setToolTipText("Create material");
14402392
14412393 /*
14422394 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14432395 */
14442396
1445
- editBar.add(clearMaterialButton = new cButton("Clear")); // , aConstraints);
1446
- editBar.add(resetSlidersButton = new cButton("Reset")); // , aConstraints);
1447
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1448
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
2397
+ editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
2398
+ clearMaterialButton.setToolTipText("Clear material");
2399
+
2400
+ if (Globals.ADVANCED)
2401
+ {
2402
+ editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
2403
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
2404
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
2405
+ }
14492406
2407
+ editBar.preferredHeight = 15;
2408
+
14502409 panel.add(editBar);
14512410
14522411 /**/
....@@ -1458,45 +2417,61 @@
14582417 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14592418
14602419 cGridBag colorSection = new cGridBag().setVertical(true);
2420
+
2421
+ cGridBag huepanel = new cGridBag();
2422
+ cGridBag huelabel = new cGridBag();
2423
+ cLabel hue = GetLabel("icons/hue.png", false);
2424
+ hue.fit = true;
2425
+
2426
+ hue.addMouseListener(new MouseAdapter()
2427
+ {
2428
+ public void mousePressed(MouseEvent e)
2429
+ {
2430
+ int x = e.getX();
2431
+
2432
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2433
+ }
2434
+ });
2435
+
2436
+ huelabel.add(hue);
2437
+ huelabel.preferredWidth = 20;
2438
+ huepanel.add(new cGridBag()); // Label
2439
+ huepanel.add(huelabel); // Field/slider
2440
+
2441
+ huepanel.preferredHeight = 7;
2442
+
2443
+ colorSection.add(huepanel);
14612444
14622445 cGridBag color = new cGridBag();
1463
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1464
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1465
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2446
+
2447
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2448
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2449
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2450
+
14662451 //colorField.preferredWidth = 200;
14672452 colorSection.add(color);
14682453
14692454 cGridBag modulation = new cGridBag();
14702455 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14712456 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1472
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2457
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14732458 colorSection.add(modulation);
14742459
2460
+ cGridBag opacity = new cGridBag();
2461
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2462
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2463
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2464
+ colorSection.add(opacity);
2465
+
2466
+ colorSection.add(GetSeparator());
2467
+
14752468 cGridBag texture = new cGridBag();
14762469 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14772470 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14782471 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14792472 colorSection.add(texture);
14802473
1481
- cGridBag anisoU = new cGridBag();
1482
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1483
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1484
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1485
- colorSection.add(anisoU);
1486
-
1487
- cGridBag anisoV = new cGridBag();
1488
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1489
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1490
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1491
- colorSection.add(anisoV);
1492
-
1493
- cGridBag shadowbias = new cGridBag();
1494
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1495
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1496
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1497
- colorSection.add(shadowbias);
1498
-
1499
- panel.add(new JSeparator());
2474
+ panel.add(GetSeparator());
15002475
15012476 panel.add(colorSection);
15022477
....@@ -1546,7 +2521,13 @@
15462521 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15472522 diffuseSection.add(fakedepth);
15482523
1549
- panel.add(new JSeparator());
2524
+ cGridBag shadowbias = new cGridBag();
2525
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2526
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2527
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2528
+ diffuseSection.add(shadowbias);
2529
+
2530
+ panel.add(GetSeparator());
15502531
15512532 panel.add(diffuseSection);
15522533
....@@ -1596,42 +2577,48 @@
15962577 // aConstraints.gridy += 1;
15972578 // aConstraints.gridwidth = 1;
15982579
2580
+ cGridBag anisoU = new cGridBag();
2581
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2582
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2583
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2584
+ specularSection.add(anisoU);
15992585
1600
- panel.add(new JSeparator());
2586
+ cGridBag anisoV = new cGridBag();
2587
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2588
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2589
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2590
+ specularSection.add(anisoV);
2591
+
2592
+
2593
+ panel.add(GetSeparator());
16012594
16022595 panel.add(specularSection);
16032596
16042597 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16052598
1606
- cGridBag globalSection = new cGridBag().setVertical(true);
2599
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16072600
16082601 cGridBag camera = new cGridBag();
16092602 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16102603 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16112604 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1612
- globalSection.add(camera);
2605
+ colorSection.add(camera);
16132606
16142607 cGridBag ambient = new cGridBag();
16152608 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16162609 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16172610 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1618
- globalSection.add(ambient);
2611
+ colorSection.add(ambient);
16192612
16202613 cGridBag backlit = new cGridBag();
16212614 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16222615 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16232616 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1624
- globalSection.add(backlit);
2617
+ colorSection.add(backlit);
16252618
1626
- cGridBag opacity = new cGridBag();
1627
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1628
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1629
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1630
- globalSection.add(opacity);
1631
-
1632
- panel.add(new JSeparator());
2619
+ //panel.add(new JSeparator());
16332620
1634
- panel.add(globalSection);
2621
+ //panel.add(globalSection);
16352622
16362623 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16372624
....@@ -1673,7 +2660,7 @@
16732660 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16742661 textureSection.add(opacityPower);
16752662
1676
- panel.add(new JSeparator());
2663
+ panel.add(GetSeparator());
16772664
16782665 panel.add(textureSection);
16792666
....@@ -1712,12 +2699,15 @@
17122699 opacityPowerField.addChangeListener(this);
17132700 /**/
17142701
1715
- resetSlidersButton.addActionListener(this);
17162702 clearMaterialButton.addActionListener(this);
17172703 createMaterialButton.addActionListener(this);
1718
-
1719
- propagateToggle.addItemListener(this);
1720
- multiplyToggle.addItemListener(this);
2704
+
2705
+ if (Globals.ADVANCED)
2706
+ {
2707
+ resetSlidersButton.addActionListener(this);
2708
+ propagateToggle.addItemListener(this);
2709
+ multiplyToggle.addItemListener(this);
2710
+ }
17212711 }
17222712
17232713 void DropFile(java.io.File[] files, boolean textures)
....@@ -1735,8 +2725,9 @@
17352725 // 3D models
17362726 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17372727 {
1738
- lastConverter = new com.jmex.model.converters.MaxToJme();
1739
- LoadFile(filename, lastConverter);
2728
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2729
+ //LoadFile(filename, lastConverter);
2730
+ LoadObjFile(filename); // New 3ds loader
17402731 continue;
17412732 }
17422733 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1888,7 +2879,7 @@
18882879
18892880 //? flashIt = false;
18902881 CameraPane pane = (CameraPane) cameraView;
1891
- pane.clickStart(location.x, location.y, 0);
2882
+ pane.clickStart(location.x, location.y, 0, 0);
18922883 pane.clickEnd(location.x, location.y, 0, true);
18932884
18942885 if (group.selection.size() == 1)
....@@ -1937,6 +2928,7 @@
19372928 e2.printStackTrace();
19382929 }
19392930 }
2931
+
19402932 LoadJMEThread loadThread;
19412933
19422934 class LoadJMEThread extends Thread
....@@ -1994,6 +2986,7 @@
19942986 //LoadFile0(filename, converter);
19952987 }
19962988 }
2989
+
19972990 LoadOBJThread loadObjThread;
19982991
19992992 class LoadOBJThread extends Thread
....@@ -2072,19 +3065,19 @@
20723065
20733066 void LoadObjFile(String fullname)
20743067 {
2075
- /*
3068
+ System.out.println("Loading " + fullname);
3069
+ /**/
20763070 //lastFilename = fullname;
20773071 if(loadObjThread == null)
20783072 {
2079
- loadObjThread = new LoadOBJThread();
2080
- loadObjThread.start();
3073
+ loadObjThread = new LoadOBJThread();
3074
+ loadObjThread.start();
20813075 }
20823076
20833077 loadObjThread.add(fullname);
2084
- */
3078
+ /**/
20853079
2086
- System.out.println("Loading " + fullname);
2087
- makeSomething(new FileObject(fullname, true), true);
3080
+ //makeSomething(new FileObject(fullname, true), true);
20883081 }
20893082
20903083 void LoadGFDFile(String fullname)
....@@ -2345,11 +3338,11 @@
23453338
23463339 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23473340 {
2348
- if (GrafreeD.standAlone)
3341
+ if (Grafreed.standAlone)
23493342 {
23503343 /**/
23513344 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2352
- browser.show();
3345
+ browser.setVisible(true);
23533346 String filename = browser.getFile();
23543347 if (filename != null && filename.length() > 0)
23553348 {
....@@ -2460,6 +3453,7 @@
24603453 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24613454 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24623455 }
3456
+
24633457 //cJME.count++;
24643458 //cJME.count %= 12;
24653459 if (gc)
....@@ -2643,6 +3637,7 @@
26433637 }
26443638 }
26453639 }
3640
+
26463641 cFileSystemPane FSPane;
26473642
26483643 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2652,7 +3647,7 @@
26523647
26533648 freezematerial = true;
26543649 colorField.setFloat(mat.color);
2655
- modulationField.setFloat(mat.modulation);
3650
+ saturationField.setFloat(mat.modulation);
26563651 metalnessField.setFloat(mat.metalness);
26573652 diffuseField.setFloat(mat.diffuse);
26583653 specularField.setFloat(mat.specular);
....@@ -2696,11 +3691,14 @@
26963691 }
26973692 }
26983693 }
3694
+
26993695 freezematerial = false;
27003696 }
27013697
27023698 void SetMaterial(Object3D object)
27033699 {
3700
+ latestObject = object;
3701
+
27043702 cMaterial mat = object.material;
27053703
27063704 if (mat == null)
....@@ -2709,33 +3707,10 @@
27093707 return;
27103708 }
27113709
2712
- multiplyToggle.setSelected(mat.multiply);
2713
-
2714
- assert (object.projectedVertices != null);
2715
-
2716
- if (object.projectedVertices.length <= 2)
2717
- {
2718
- // Side effect...
2719
- Object3D.cVector2[] keep = object.projectedVertices;
2720
- object.projectedVertices = new Object3D.cVector2[3];
2721
- for (int i = 0; i < 3; i++)
2722
- {
2723
- if (i < keep.length)
2724
- {
2725
- object.projectedVertices[i] = keep[i];
2726
- } else
2727
- {
2728
- object.projectedVertices[i] = new Object3D.cVector2();
2729
- }
2730
- /*
2731
- if(keep.length == 0)
2732
- object.projectedVertices[0] = new Object3D.cVector2();
2733
- else
2734
- object.projectedVertices[0] = keep[0];
2735
- object.projectedVertices[1] = new Object3D.cVector2();
2736
- */
2737
- }
2738
- }
3710
+ if (multiplyToggle != null)
3711
+ multiplyToggle.setSelected(mat.multiply);
3712
+
3713
+ AllocProjectedVertices(object);
27393714
27403715 SetMaterial(mat, object.projectedVertices);
27413716 }
....@@ -2811,12 +3786,17 @@
28113786 // }
28123787
28133788 /**/
2814
- if (deselect)
3789
+ if (deselect || child == null)
28153790 {
28163791 //group.deselectAll();
28173792 //freeze = true;
28183793 GetTree().clearSelection();
28193794 //freeze = false;
3795
+
3796
+ if (child == null)
3797
+ {
3798
+ return;
3799
+ }
28203800 }
28213801
28223802 //group.addSelectee(child);
....@@ -2850,6 +3830,17 @@
28503830 public void itemStateChanged(ItemEvent event)
28513831 {
28523832 // System.out.println("Propagate = " + propagate);
3833
+ if (event.getSource() == pinButton)
3834
+ {
3835
+ copy.pinned ^= true;
3836
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3837
+ {
3838
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3839
+ copy.CloseUI();
3840
+ //copy.editWindow.refreshContents();
3841
+ }
3842
+ }
3843
+ else
28533844 if (event.getSource() == propagateToggle)
28543845 {
28553846 propagate ^= true;
....@@ -2885,7 +3876,7 @@
28853876 cameraView.ToggleDL();
28863877 cameraView.repaint();
28873878 return;
2888
- } else if (event.getSource() == toggleTextureItem)
3879
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28893880 {
28903881 cameraView.ToggleTexture();
28913882 // june 2013 copy.HardTouch();
....@@ -2924,9 +3915,9 @@
29243915 frame.validate();
29253916
29263917 return;
2927
- } else if (event.getSource() == toggleRandomItem)
3918
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29283919 {
2929
- cameraView.ToggleRandom();
3920
+ cameraView.ToggleSwitch();
29303921 cameraView.repaint();
29313922 return;
29323923 } else if (event.getSource() == toggleHandleItem)
....@@ -2954,12 +3945,17 @@
29543945 } else if (event.getSource() == liveCB)
29553946 {
29563947 copy.live ^= true;
3948
+ objEditor.refreshContents(true); // To show item colors
3949
+ return;
3950
+ } else if (event.getSource() == selectableCB)
3951
+ {
3952
+ copy.dontselect ^= true;
29573953 return;
29583954 } else if (event.getSource() == hideCB)
29593955 {
29603956 copy.hide ^= true;
29613957 copy.Touch(); // display list issue
2962
- objEditor.refreshContents();
3958
+ objEditor.refreshContents(true); // To show item colors
29633959 return;
29643960 } else if (event.getSource() == link2masterCB)
29653961 {
....@@ -2969,6 +3965,7 @@
29693965 if (event.getSource() == randomCB)
29703966 {
29713967 copy.random ^= true;
3968
+ objEditor.refreshContents();
29723969 return;
29733970 }
29743971 if (event.getSource() == speedupCB)
....@@ -2992,8 +3989,9 @@
29923989
29933990 public void actionPerformed(ActionEvent event)
29943991 {
3992
+ Object source = event.getSource();
29953993 // SCRIPT DIALOG
2996
- if (event.getSource() == okbutton)
3994
+ if (source == okbutton)
29973995 {
29983996 textpanel.setVisible(false);
29993997 textpanel.remove(textarea);
....@@ -3005,7 +4003,7 @@
30054003 textarea = null;
30064004 textpanel = null;
30074005 }
3008
- if (event.getSource() == cancelbutton)
4006
+ if (source == cancelbutton)
30094007 {
30104008 textpanel.setVisible(false);
30114009 textpanel.remove(textarea);
....@@ -3017,50 +4015,50 @@
30174015 //applySelf();
30184016 //client.refreshEditWindow();
30194017 //refreshContents();
3020
- if (event.getSource() == nameField)
4018
+ if (source == nameField)
30214019 {
30224020 //System.out.println("ObjEditor " + event);
30234021 applySelf0(true);
30244022 //parent.applySelf();
3025
- objEditor.refreshContents();
3026
- } else if (event.getSource() == resetButton)
4023
+ // conflicts with requestFocus objEditor.refreshContents();
4024
+ } else if (source == resetButton)
30274025 {
30284026 CameraPane.fullreset = true;
30294027 copy.Reset(); // ResetMeshes();
30304028 copy.Touch();
30314029 objEditor.refreshContents();
3032
- } else if (event.getSource() == stepItem)
4030
+ } else if (source == stepItem)
30334031 {
30344032 //cameraView.ONESTEP = true;
30354033 Globals.ONESTEP = true;
30364034 cameraView.repaint();
30374035 return;
3038
- } else if (event.getSource() == stepButton)
4036
+ } else if (source == stepButton)
30394037 {
30404038 copy.Step();
30414039 copy.Touch();
30424040 objEditor.refreshContents();
3043
- } else if (event.getSource() == slowerButton)
4041
+ } else if (source == slowerButton)
30444042 {
30454043 copy.Slower();
30464044 copy.Touch();
30474045 objEditor.refreshContents();
3048
- } else if (event.getSource() == fasterButton)
4046
+ } else if (source == fasterButton)
30494047 {
30504048 copy.Faster();
30514049 copy.Touch();
30524050 objEditor.refreshContents();
3053
- } else if (event.getSource() == remarkButton)
4051
+ } else if (source == remarkButton)
30544052 {
30554053 copy.Remark();
30564054 copy.Touch();
30574055 objEditor.refreshContents();
3058
- } else if (event.getSource() == stepAllButton)
4056
+ } else if (source == stepAllButton)
30594057 {
30604058 copy.StepAll();
30614059 copy.Touch();
30624060 objEditor.refreshContents();
3063
- } else if (event.getSource() == resetAllButton)
4061
+ } else if (source == resetAllButton)
30644062 {
30654063 //CameraPane.fullreset = true;
30664064 copy.ResetAll(); // ResetMeshes();
....@@ -3093,53 +4091,79 @@
30934091 // Close();
30944092 // }
30954093 // else
3096
- if (event.getSource() == resetSlidersButton)
4094
+ if (source == resetSlidersButton)
30974095 {
30984096 ResetSliders();
3099
- } else if (event.getSource() == clearMaterialButton)
4097
+ } else if (source == clearMaterialButton)
31004098 {
31014099 ClearMaterial();
3102
- } else if (event.getSource() == createMaterialButton)
4100
+ } else if (source == createMaterialButton)
31034101 {
31044102 CreateMaterial();
3105
- } else if (event.getSource() == clearPanelButton)
4103
+ } else if (source == clearPanelButton)
31064104 {
31074105 copy.ClearUI();
31084106 refreshContents(true);
3109
- } /*
3110
- }
3111
-
3112
- public boolean action(Event event, Object arg)
3113
- {
3114
- */ else if (event.getSource() == closeItem)
4107
+ } else if (source == importGFDItem)
4108
+ {
4109
+ ImportGFD();
4110
+ } else
4111
+ if (source == importVRMLX3DItem)
4112
+ {
4113
+ ImportVRMLX3D();
4114
+ } else
4115
+ if (source == import3DSItem)
4116
+ {
4117
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
4118
+ } else
4119
+ if (source == importOBJItem)
4120
+ {
4121
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
4122
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
4123
+ browser.setVisible(true);
4124
+ String filename = browser.getFile();
4125
+ if (filename != null && filename.length() > 0)
4126
+ {
4127
+ String fullname = browser.getDirectory() + filename;
4128
+ makeSomething(ReadOBJ(fullname), true);
4129
+ }
4130
+ } else
4131
+ if (source == closeItem)
31154132 {
31164133 Close();
31174134 //return true;
3118
- } else if (event.getSource() == loadItem)
4135
+ } else if (source == openItem)
31194136 {
3120
- load();
4137
+ Open();
31214138 //return true;
3122
- } else if (event.getSource() == saveItem)
4139
+ } else if (source == newItem)
4140
+ {
4141
+ New();
4142
+ } else if (source == saveItem)
31234143 {
31244144 save();
31254145 //return true;
3126
- } else if (event.getSource() == saveAsItem)
4146
+ } else if (source == saveAsItem)
31274147 {
31284148 saveAs();
31294149 //return true;
3130
- } else if (event.getSource() == reexportItem)
4150
+ } else if (source == reexportItem)
31314151 {
31324152 reexport();
31334153 //return true;
3134
- } else if (event.getSource() == exportAsItem)
4154
+ } else if (source == exportAsItem)
31354155 {
31364156 export();
31374157 //return true;
3138
- } else if (event.getSource() == povItem)
4158
+ } else if (source == povItem)
31394159 {
31404160 generatePOV();
31414161 //return true;
3142
- } else if (event.getSource() == zBufferItem)
4162
+ } else if (event.getSource() == archiveItem)
4163
+ {
4164
+ cTools.Archive(frame);
4165
+ return;
4166
+ } else if (source == zBufferItem)
31434167 {
31444168 try
31454169 {
....@@ -3161,21 +4185,8 @@
31614185 cameraView.repaint();
31624186 //return true;
31634187 }
3164
- */ else if (event.getSource() == editCameraItem)
3165
- {
3166
- cameraView.ProtectCamera();
3167
- cameraView.repaint();
3168
- return;
3169
- } else if (event.getSource() == revertCameraItem)
3170
- {
3171
- cameraView.RevertCamera();
3172
- cameraView.repaint();
3173
- return;
3174
-// } else if (event.getSource() == textureButton)
3175
-// {
3176
-// return; // true;
3177
- } else // combos...
3178
- if (event.getSource() == texresMenu)
4188
+ */ else // combos...
4189
+ if (source == texresMenu)
31794190 {
31804191 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31814192 copy.texres = texresMenu.getSelectedIndex();
....@@ -3187,12 +4198,503 @@
31874198 }
31884199 }
31894200
4201
+ void New()
4202
+ {
4203
+ while (copy.Size() > 0)
4204
+ {
4205
+ copy.remove(0);
4206
+ }
4207
+
4208
+ copy.selection.clear();
4209
+
4210
+ if (copy == Grafreed.grafreed.universe)
4211
+ {
4212
+ CreateCameras();
4213
+ cameraView.SetCamera(GetCamera(copy, 0));
4214
+ }
4215
+ ResetModel();
4216
+ objEditor.refreshContents();
4217
+ }
4218
+
4219
+ static public byte[] Compress(Object3D o)
4220
+ {
4221
+ // Slower to actually compress.
4222
+ try
4223
+ {
4224
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4225
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4226
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
4227
+
4228
+ Object3D parent = o.parent;
4229
+ o.parent = null;
4230
+
4231
+ out.writeObject(o);
4232
+
4233
+ o.parent = parent;
4234
+
4235
+ out.flush();
4236
+
4237
+ baos //zstream
4238
+ .close();
4239
+ out.close();
4240
+
4241
+ byte[] bytes = baos.toByteArray();
4242
+
4243
+ System.out.println("save #bytes = " + bytes.length);
4244
+ return bytes;
4245
+ } catch (Exception e)
4246
+ {
4247
+ System.err.println(e);
4248
+ return null;
4249
+ }
4250
+ }
4251
+
4252
+ static public Object Uncompress(byte[] bytes)
4253
+ {
4254
+ System.out.println("restore #bytes = " + bytes.length);
4255
+ try
4256
+ {
4257
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4258
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4259
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
4260
+ Object obj = in.readObject();
4261
+
4262
+ bais //istream
4263
+ .close();
4264
+ in.close();
4265
+
4266
+ return obj;
4267
+ } catch (Exception e)
4268
+ {
4269
+ System.err.println(e);
4270
+ return null;
4271
+ }
4272
+ }
4273
+
4274
+ static public Object clone(Object o)
4275
+ {
4276
+ try
4277
+ {
4278
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4279
+ ObjectOutputStream out = new ObjectOutputStream(baos);
4280
+
4281
+ out.writeObject(o);
4282
+
4283
+ out.flush();
4284
+ out.close();
4285
+
4286
+ byte[] bytes = baos.toByteArray();
4287
+
4288
+ System.out.println("clone = " + bytes.length);
4289
+
4290
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4291
+ ObjectInputStream in = new ObjectInputStream(bais);
4292
+ Object obj = in.readObject();
4293
+ in.close();
4294
+
4295
+ return obj;
4296
+ } catch (Exception e)
4297
+ {
4298
+ System.err.println(e);
4299
+ return null;
4300
+ }
4301
+ }
4302
+
4303
+ cRadio GetCurrentTab()
4304
+ {
4305
+ cRadio ab;
4306
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4307
+ {
4308
+ ab = (cRadio)e.nextElement();
4309
+ if(ab.GetObject() == copy)
4310
+ {
4311
+ return ab;
4312
+ }
4313
+ }
4314
+
4315
+ return null;
4316
+ }
4317
+
4318
+
4319
+ public void Save()
4320
+ {
4321
+ //Save(true);
4322
+ Replace();
4323
+ SetVersionStates();
4324
+ }
4325
+
4326
+ private boolean Equal(byte[] compress, byte[] name)
4327
+ {
4328
+ if (compress.length != name.length)
4329
+ {
4330
+ return false;
4331
+ }
4332
+
4333
+ for (int i=compress.length; --i>=0;)
4334
+ {
4335
+ if (compress[i] != name[i])
4336
+ return false;
4337
+ }
4338
+
4339
+ return true;
4340
+ }
4341
+
4342
+ void DeleteVersion()
4343
+ {
4344
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4345
+ {
4346
+ copy.versionlist[i] = copy.versionlist[i+1];
4347
+ }
4348
+
4349
+ if (copy.versionlist[copy.versionindex] == null)
4350
+ copy.versionindex -= 1;
4351
+
4352
+ if (copy.versionindex != -1)
4353
+ CopyChanged();
4354
+
4355
+ SetVersionStates();
4356
+ }
4357
+
4358
+ public boolean Save(boolean user)
4359
+ {
4360
+ System.err.println("Save");
4361
+ Replace();
4362
+
4363
+ //cRadio tab = GetCurrentTab();
4364
+
4365
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
4366
+
4367
+ boolean thesame = false;
4368
+
4369
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4370
+// {
4371
+// thesame = true;
4372
+// }
4373
+
4374
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
4375
+ if (!thesame)
4376
+ {
4377
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4378
+ {
4379
+ copy.versionlist[i] = copy.versionlist[i-1];
4380
+ }
4381
+
4382
+ //tab.user[tab.versionindex] = user;
4383
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4384
+
4385
+ copy.versionlist[++copy.versionindex] = compress;
4386
+
4387
+ // if (increment)
4388
+ // tab.versionindex++;
4389
+ }
4390
+
4391
+ //copy.RestoreBigData(versiontable);
4392
+
4393
+ //assert(hashtable.isEmpty());
4394
+
4395
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4396
+// {
4397
+// //tab.user[i] = false;
4398
+// copy.versionlist[i] = null;
4399
+// }
4400
+
4401
+ SetVersionStates();
4402
+
4403
+ // test save
4404
+ if (false)
4405
+ {
4406
+ try
4407
+ {
4408
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
4409
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
4410
+
4411
+ p.writeObject(copy);
4412
+
4413
+ p.flush();
4414
+
4415
+ ostream.close();
4416
+ } catch (Exception e)
4417
+ {
4418
+ e.printStackTrace();
4419
+ }
4420
+ }
4421
+
4422
+ return !thesame;
4423
+ }
4424
+
4425
+ boolean flashIt = true;
4426
+
4427
+ void RefreshSelection()
4428
+ {
4429
+ Object3D selection = new Object3D();
4430
+
4431
+ for (int i = 0; i < copy.selection.size(); i++)
4432
+ {
4433
+ Object3D elem = copy.selection.elementAt(i);
4434
+
4435
+ Object3D obj = copy.GetObject(elem.GetUUID());
4436
+
4437
+ if (obj == null)
4438
+ {
4439
+ copy.selection.remove(i--);
4440
+ }
4441
+ else
4442
+ {
4443
+ selection.add(obj);
4444
+ copy.selection.setElementAt(obj, i);
4445
+ }
4446
+ }
4447
+
4448
+ flashIt = false;
4449
+ GetTree().clearSelection();
4450
+ for (int i = 0; i < selection.size(); i++)
4451
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4452
+ flashIt = true;
4453
+
4454
+ //refreshContents(false);
4455
+ }
4456
+
4457
+ void CopyChanged()
4458
+ {
4459
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4460
+
4461
+ SetVersionStates();
4462
+
4463
+ boolean temp = CameraPane.SWITCH;
4464
+ CameraPane.SWITCH = false;
4465
+
4466
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
4467
+
4468
+ copy.clear();
4469
+
4470
+ copy.skyboxname = obj.skyboxname;
4471
+ copy.skyboxext = obj.skyboxext;
4472
+
4473
+ for (int i=0; i<obj.Size(); i++)
4474
+ {
4475
+ copy.add(obj.get(i));
4476
+ }
4477
+
4478
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
4479
+
4480
+ CameraPane.SWITCH = temp;
4481
+
4482
+ RefreshSelection();
4483
+ //assert(hashtable.isEmpty());
4484
+
4485
+ copy.Touch();
4486
+
4487
+ ResetModel();
4488
+ copy.HardTouch(); // recompile?
4489
+
4490
+ cRadio ab;
4491
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4492
+ {
4493
+ ab = (cRadio)e.nextElement();
4494
+ Object3D test = copy.GetObject(ab.object.GetUUID());
4495
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
4496
+ if (test != null)
4497
+ {
4498
+ test.editWindow = ab.object.editWindow;
4499
+ ab.object = test;
4500
+ }
4501
+ }
4502
+
4503
+ refreshContents(true);
4504
+ }
4505
+
4506
+ cButton previousVersionButton;
4507
+ cButton restoreButton;
4508
+ cButton replaceButton;
4509
+ cButton nextVersionButton;
4510
+ cButton saveVersionButton;
4511
+ cButton deleteVersionButton;
4512
+
4513
+ boolean muteSlider;
4514
+
4515
+ int VersionCount()
4516
+ {
4517
+ int count = 0;
4518
+
4519
+ for (int i = copy.versionlist.length; --i >= 0;)
4520
+ {
4521
+ if (copy.versionlist[i] != null)
4522
+ count++;
4523
+ }
4524
+
4525
+ return count;
4526
+ }
4527
+
4528
+ public cGridBag versionSliderPane;
4529
+
4530
+ void SetVersionStates()
4531
+ {
4532
+ //if (true)
4533
+ // return;
4534
+
4535
+ //cRadio tab = GetCurrentTab();
4536
+
4537
+ if (copy.versionlist == null)
4538
+ {
4539
+ saveVersionButton.setEnabled(false);
4540
+ restoreButton.setEnabled(false);
4541
+ replaceButton.setEnabled(false);
4542
+ previousVersionButton.setEnabled(false);
4543
+ nextVersionButton.setEnabled(false);
4544
+ deleteVersionButton.setEnabled(false);
4545
+ versionSliderPane.setVisible(false);
4546
+ }
4547
+ else
4548
+ {
4549
+ restoreButton.setEnabled(copy.versionindex != -1);
4550
+ replaceButton.setEnabled(copy.versionindex != -1);
4551
+
4552
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4553
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4554
+
4555
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4556
+ //copy.versionlist[copy.versionindex + 1] != null);
4557
+
4558
+ muteSlider = true;
4559
+ versionSlider.setMinimum(0);
4560
+ versionSlider.setMaximum(VersionCount() - 1);
4561
+ versionSlider.setInteger(copy.versionindex);
4562
+ versionSlider.setEnabled(copy.versionindex != -1);
4563
+ muteSlider = false;
4564
+
4565
+ versionSliderPane.setVisible(true);
4566
+ }
4567
+ }
4568
+
4569
+ public boolean PreviousVersion()
4570
+ {
4571
+ // Option?
4572
+ Replace();
4573
+
4574
+ System.err.println("Undo");
4575
+
4576
+ //cRadio tab = GetCurrentTab();
4577
+
4578
+ if (copy.versionindex == 0)
4579
+ {
4580
+ java.awt.Toolkit.getDefaultToolkit().beep();
4581
+ return false;
4582
+ }
4583
+
4584
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4585
+// {
4586
+// if (Save(false))
4587
+// tab.versionindex -= 1;
4588
+// else
4589
+// {
4590
+// if (tab.versionindex <= 0)
4591
+// return false;
4592
+// else
4593
+// tab.versionindex -= 1;
4594
+// }
4595
+// }
4596
+
4597
+ copy.versionindex -= 1;
4598
+
4599
+ CopyChanged();
4600
+
4601
+ return true;
4602
+ }
4603
+
4604
+ public boolean Restore()
4605
+ {
4606
+ System.err.println("Restore");
4607
+
4608
+ //cRadio tab = GetCurrentTab();
4609
+
4610
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4611
+ {
4612
+ java.awt.Toolkit.getDefaultToolkit().beep();
4613
+ return false;
4614
+ }
4615
+
4616
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4617
+ CopyChanged();
4618
+
4619
+ return true;
4620
+ }
4621
+
4622
+ public boolean Replace()
4623
+ {
4624
+ //System.err.println("Replace");
4625
+
4626
+ //cRadio tab = GetCurrentTab();
4627
+
4628
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4629
+ {
4630
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4631
+ return false;
4632
+ }
4633
+
4634
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4635
+
4636
+ return true;
4637
+ }
4638
+
4639
+ public void NextVersion()
4640
+ {
4641
+ // Option?
4642
+ Replace();
4643
+
4644
+ //cRadio tab = GetCurrentTab();
4645
+
4646
+ if (copy.versionlist[copy.versionindex + 1] == null)
4647
+ {
4648
+ java.awt.Toolkit.getDefaultToolkit().beep();
4649
+ return;
4650
+ }
4651
+
4652
+ copy.versionindex += 1;
4653
+
4654
+ CopyChanged();
4655
+
4656
+ //if (!tab.user[tab.versionindex])
4657
+ // tab.graphs[tab.versionindex] = null;
4658
+ }
4659
+
4660
+ void ImportGFD()
4661
+ {
4662
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
4663
+ browser.show();
4664
+ String filename = browser.getFile();
4665
+ if (filename != null && filename.length() > 0)
4666
+ {
4667
+ String fullname = browser.getDirectory() + filename;
4668
+
4669
+ //Object3D readobj =
4670
+ objEditor.ReadGFD(fullname, objEditor);
4671
+ //makeSomething(readobj);
4672
+ }
4673
+ }
4674
+
4675
+ void ImportVRMLX3D()
4676
+ {
4677
+ if (Grafreed.standAlone)
4678
+ {
4679
+ /**/
4680
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
4681
+ browser.show();
4682
+ String filename = browser.getFile();
4683
+ if (filename != null && filename.length() > 0)
4684
+ {
4685
+ String fullname = browser.getDirectory() + filename;
4686
+ LoadVRMLX3D(fullname);
4687
+ }
4688
+ /**/
4689
+ }
4690
+ }
4691
+
31904692 void ToggleAnimation()
31914693 {
31924694 if (!Globals.ANIMATION)
31934695 {
31944696 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3195
- browser.show();
4697
+ browser.setVisible(true);
31964698 String filename = browser.getFile();
31974699 if (filename != null && filename.length() > 0)
31984700 {
....@@ -3202,8 +4704,8 @@
32024704
32034705 Globals.ANIMATION ^= true;
32044706
3205
- GrafreeD.wav.cursor = 0;
3206
- GrafreeD.wav.loop = 0;
4707
+ Grafreed.wav.cursor = 0;
4708
+ Grafreed.wav.loop = 0;
32074709 }
32084710 } else
32094711 {
....@@ -3224,7 +4726,6 @@
32244726 callee.refreshContents();
32254727 } else
32264728 {
3227
- new Exception().printStackTrace();
32284729 System.exit(0);
32294730 }
32304731 }
....@@ -3254,7 +4755,7 @@
32544755 void CreateMaterial()
32554756 {
32564757 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
4758
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32584759 if (copy.selection.size() > 0)
32594760 //SetMaterial(copy);
32604761 {
....@@ -3305,7 +4806,7 @@
33054806 assert false;
33064807 }
33074808
3308
- void EditSelection()
4809
+ void EditSelection(boolean newWindow)
33094810 {
33104811 }
33114812
....@@ -3313,11 +4814,11 @@
33134814 {
33144815 copy.ResetBlockLoop(); // temporary problem
33154816
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
4817
+ boolean random = CameraPane.SWITCH;
4818
+ CameraPane.SWITCH = false; // parse everything
33184819 copy.ResetDisplayList();
33194820 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
4821
+ CameraPane.SWITCH = random;
33214822 }
33224823
33234824 // public void applySelf()
....@@ -3347,6 +4848,12 @@
33474848 // else
33484849 // applySelf(true);
33494850 // }
4851
+
4852
+ boolean Equal(double a, double b)
4853
+ {
4854
+ return Math.abs(a - b) < 0.001;
4855
+ }
4856
+
33504857 void applySelf0(boolean name)
33514858 {
33524859 if (name)
....@@ -3364,7 +4871,7 @@
33644871 //copy.material = new cMaterial(copy.GetMaterial());
33654872
33664873 current.color = (float) colorField.getFloat();
3367
- current.modulation = (float) modulationField.getFloat();
4874
+ current.modulation = (float) saturationField.getFloat();
33684875 current.metalness = (float) metalnessField.getFloat();
33694876 current.diffuse = (float) diffuseField.getFloat();
33704877 current.specular = (float) specularField.getFloat();
....@@ -3391,6 +4898,59 @@
33914898 {
33924899 //System.out.println("Propagate = " + propagate);
33934900 copy.UpdateMaterial(anchor, current, propagate);
4901
+
4902
+ if (copy.material != null)
4903
+ {
4904
+ cMaterial mat = copy.material;
4905
+
4906
+ if (!Equal(colorField.getFloat(), mat.color))
4907
+ colorField.SetToolTipValue((mat.color));
4908
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4909
+ saturationField.SetToolTipValue((mat.modulation));
4910
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4911
+ metalnessField.SetToolTipValue((mat.metalness));
4912
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4913
+ diffuseField.SetToolTipValue((mat.diffuse));
4914
+ if (!Equal(specularField.getFloat(), mat.specular))
4915
+ specularField.SetToolTipValue((mat.specular));
4916
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4917
+ shininessField.SetToolTipValue((mat.shininess));
4918
+ if (!Equal(shiftField.getFloat(), mat.shift))
4919
+ shiftField.SetToolTipValue((mat.shift));
4920
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4921
+ ambientField.SetToolTipValue((mat.ambient));
4922
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4923
+ lightareaField.SetToolTipValue((mat.lightarea));
4924
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4925
+ diffusenessField.SetToolTipValue((mat.factor));
4926
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4927
+ velvetField.SetToolTipValue((mat.velvet));
4928
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4929
+ sheenField.SetToolTipValue((mat.sheen));
4930
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4931
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4932
+ if (!Equal(backlitField.getFloat(), mat.bump))
4933
+ backlitField.SetToolTipValue((mat.bump));
4934
+ if (!Equal(anisoField.getFloat(), mat.aniso))
4935
+ anisoField.SetToolTipValue((mat.aniso));
4936
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
4937
+ anisoVField.SetToolTipValue((mat.anisoV));
4938
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
4939
+ cameraField.SetToolTipValue((mat.cameralight));
4940
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
4941
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4942
+ if (!Equal(shadowField.getFloat(), mat.shadow))
4943
+ shadowField.SetToolTipValue((mat.shadow));
4944
+ if (!Equal(textureField.getFloat(), mat.texture))
4945
+ textureField.SetToolTipValue((mat.texture));
4946
+ if (!Equal(opacityField.getFloat(), mat.opacity))
4947
+ opacityField.SetToolTipValue((mat.opacity));
4948
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
4949
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4950
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
4951
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
4952
+ }
4953
+
33944954 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33954955 {
33964956 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3419,9 +4979,28 @@
34194979 //copy.Touch();
34204980 }
34214981
4982
+ cNumberSlider versionSlider;
4983
+
34224984 public void stateChanged(ChangeEvent e)
34234985 {
3424
- // assert(false);
4986
+ // assert(false);
4987
+ if (e.getSource() == versionSlider)
4988
+ {
4989
+ if (muteSlider)
4990
+ return;
4991
+
4992
+ Replace();
4993
+
4994
+ int version = versionSlider.getInteger();
4995
+
4996
+ if (version != -1 && copy.versionlist[version] != null)
4997
+ {
4998
+ copy.versionindex = version;
4999
+ CopyChanged();
5000
+ }
5001
+
5002
+ return;
5003
+ }
34255004
34265005 if (freezematerial)
34275006 {
....@@ -3457,6 +5036,12 @@
34575036 {
34585037 //System.out.println("stateChanged = " + this);
34595038 materialtouched = true;
5039
+
5040
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
5041
+ {
5042
+ saturationField.setFloat(1);
5043
+ }
5044
+
34605045 applySelf();
34615046 //System.out.println("this = " + this);
34625047 //System.out.println("PARENT = " + parent);
....@@ -3506,7 +5091,7 @@
35065091 }
35075092
35085093 if (normalpushField != null)
3509
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
5094
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35105095 }
35115096
35125097 void SnapObject()
....@@ -3756,6 +5341,7 @@
37565341 {
37575342 if (GetTree() != null)
37585343 {
5344
+ GetTree().revalidate();
37595345 GetTree().repaint();
37605346 }
37615347
....@@ -3764,12 +5350,19 @@
37645350 ctrlPanel.validate(); // ? new
37655351 ctrlPanel.repaint();
37665352 }
5353
+
5354
+ if (previousVersionButton != null && copy.versionlist != null)
5355
+ SetVersionStates();
5356
+
5357
+ cameraView.requestFocusInWindow();
37675358 }
37685359
37695360 static TweenManager tweenManager = new TweenManager();
37705361
37715362 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37725363 {
5364
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5365
+ Save();
37735366 //Tween.set(thing, 0).target(1).start(tweenManager);
37745367 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37755368 // if (thing instanceof GenericJointDemo)
....@@ -3793,7 +5386,7 @@
37935386 // group = (Composite) group.get(0);
37945387 // }
37955388
3796
- System.out.println("makeSomething of " + thing);
5389
+ //System.out.println("makeSomething of " + thing);
37975390
37985391 /*
37995392 if (deselect && jList != null)
....@@ -3856,6 +5449,12 @@
38565449 {
38575450 ResetModel();
38585451 Select(thing.GetTreePath(), true, false); // unselect... false);
5452
+
5453
+ if (thing.Size() == 0)
5454
+ {
5455
+ //EditSelection(false);
5456
+ }
5457
+
38595458 refreshContents();
38605459 }
38615460
....@@ -3973,6 +5572,7 @@
39735572 }
39745573 }
39755574 }
5575
+
39765576 LoadGFDThread loadGFDThread;
39775577
39785578 void ReadGFD(String fullname, iCallBack cb)
....@@ -3992,8 +5592,10 @@
39925592
39935593 try
39945594 {
5595
+ // Try compressed version first.
39955596 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3996
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5597
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
5598
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39975599
39985600 readobj = (Object3D) p.readObject();
39995601 istream.close();
....@@ -4001,7 +5603,22 @@
40015603 readobj.ResetDisplayList();
40025604 } catch (Exception e)
40035605 {
4004
- e.printStackTrace();
5606
+ if (!e.toString().contains("GZIP"))
5607
+ e.printStackTrace();
5608
+
5609
+ try
5610
+ {
5611
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
5612
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5613
+
5614
+ readobj = (Object3D) p.readObject();
5615
+ istream.close();
5616
+
5617
+ readobj.ResetDisplayList();
5618
+ } catch (Exception e2)
5619
+ {
5620
+ e2.printStackTrace();
5621
+ }
40055622 }
40065623 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40075624 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4047,6 +5664,12 @@
40475664
40485665 void LoadIt(Object obj)
40495666 {
5667
+ if (obj == null)
5668
+ {
5669
+ // Invalid file
5670
+ return;
5671
+ }
5672
+
40505673 System.out.println("Loaded " + obj);
40515674 //new Exception().printStackTrace();
40525675 Object3D readobj = (Object3D) obj;
....@@ -4056,10 +5679,14 @@
40565679
40575680 if (readobj != null)
40585681 {
5682
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5683
+ // Save();
40595684 try
40605685 {
40615686 //readobj.deepCopySelf(copy);
40625687 copy.clear(); // june 2014
5688
+ copy.skyboxname = readobj.skyboxname;
5689
+ copy.skyboxext = readobj.skyboxext;
40635690 for (int i = 0; i < readobj.size(); i++)
40645691 {
40655692 Object3D child = readobj.get(i); // reserve(i);
....@@ -4100,6 +5727,7 @@
41005727 }
41015728 } catch (ClassCastException e)
41025729 {
5730
+ e.printStackTrace();
41035731 assert (false);
41045732 Composite c = (Composite) copy;
41055733 c.children.clear();
....@@ -4110,17 +5738,32 @@
41105738 c.addChild(csg);
41115739 }
41125740
5741
+ copy.versionlist = readobj.versionlist;
5742
+ copy.versionindex = readobj.versionindex;
5743
+ copy.versiontable = readobj.versiontable;
5744
+
5745
+ if (copy.versionlist == null)
5746
+ {
5747
+ // Backward compatibility
5748
+ copy.versionlist = new Object3D[100];
5749
+ copy.versionindex = -1;
5750
+
5751
+ //Save(true);
5752
+ }
5753
+
5754
+ //? SetUndoStates();
5755
+
41135756 ResetModel();
41145757 copy.HardTouch(); // recompile?
41155758 refreshContents();
41165759 }
41175760 }
41185761
4119
- void load() // throws ClassNotFoundException
5762
+ void Open() // throws ClassNotFoundException
41205763 {
4121
- if (GrafreeD.standAlone)
5764
+ if (Grafreed.standAlone)
41225765 {
4123
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5766
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
41245767 browser.show();
41255768 String filename = browser.getFile();
41265769 if (filename != null && filename.length() > 0)
....@@ -4197,6 +5840,8 @@
41975840
41985841 void save()
41995842 {
5843
+ Replace();
5844
+
42005845 if (lastname == null)
42015846 {
42025847 return;
....@@ -4205,11 +5850,13 @@
42055850 try
42065851 {
42075852 FileOutputStream ostream = new FileOutputStream(lastname);
4208
- ObjectOutputStream p = new ObjectOutputStream(ostream);
5853
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5854
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42095855
42105856 p.writeObject(copy);
42115857 p.flush();
42125858
5859
+ zstream.close();
42135860 ostream.close();
42145861
42155862 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4217,19 +5864,23 @@
42175864 //ps.print(buffer.toString());
42185865 } catch (IOException e)
42195866 {
5867
+ e.printStackTrace();
42205868 }
42215869 }
5870
+
42225871 String lastname;
42235872
42245873 void saveAs()
42255874 {
4226
- if (GrafreeD.standAlone)
5875
+ if (Grafreed.standAlone)
42275876 {
42285877 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42295878 browser.setVisible(true);
42305879 String filename = browser.getFile();
42315880 if (filename != null && filename.length() > 0)
42325881 {
5882
+ if (!filename.endsWith(".gfd"))
5883
+ filename += ".gfd";
42335884 lastname = browser.getDirectory() + filename;
42345885 save();
42355886 }
....@@ -4328,13 +5979,13 @@
43285979 try
43295980 {
43305981 FileOutputStream ostream = new FileOutputStream(filename);
4331
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4332
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
5982
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5983
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43335984
43345985 Object3D objectparent = obj.parent;
43355986 obj.parent = null;
43365987
4337
- Object3D object = (Object3D) GrafreeD.clone(obj);
5988
+ Object3D object = (Object3D) Grafreed.clone(obj);
43385989
43395990 obj.parent = objectparent;
43405991
....@@ -4346,8 +5997,8 @@
43465997 p.writeObject(object);
43475998 p.flush();
43485999
6000
+ zstream.close();
43496001 ostream.close();
4350
- // zstream.close();
43516002
43526003 // group.selection.get(0).parent = parent;
43536004 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4368,7 +6019,7 @@
43686019 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43696020 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43706021 copy.generatePOV(buffer);
4371
- if (GrafreeD.standAlone)
6022
+ if (Grafreed.standAlone)
43726023 {
43736024 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43746025 browser.show();
....@@ -4394,19 +6045,18 @@
43946045 Object3D client;
43956046 Object3D copy;
43966047 MenuBar menuBar;
4397
- Menu windowMenu;
4398
- MenuItem loadItem;
6048
+ Menu fileMenu;
6049
+ MenuItem newItem;
6050
+ MenuItem openItem;
43996051 MenuItem saveItem;
44006052 MenuItem saveAsItem;
44016053 MenuItem exportAsItem;
44026054 MenuItem reexportItem;
44036055 MenuItem povItem;
44046056 MenuItem closeItem;
4405
- Menu cameraMenu;
6057
+
44066058 CheckboxMenuItem zBufferItem;
44076059 //MenuItem normalLensItem;
4408
- MenuItem editCameraItem;
4409
- MenuItem revertCameraItem;
44106060 MenuItem stepItem;
44116061 CheckboxMenuItem toggleLiveItem;
44126062 CheckboxMenuItem toggleFullScreenItem;
....@@ -4417,25 +6067,41 @@
44176067 CheckboxMenuItem toggleFootContactItem;
44186068 CheckboxMenuItem toggleDLItem;
44196069 CheckboxMenuItem toggleTextureItem;
4420
- CheckboxMenuItem toggleRandomItem;
6070
+ CheckboxMenuItem toggleSwitchItem;
44216071 CheckboxMenuItem toggleRootItem;
44226072 CheckboxMenuItem animationItem;
6073
+ MenuItem archiveItem;
44236074 CheckboxMenuItem toggleHandleItem;
44246075 CheckboxMenuItem togglePaintItem;
44256076 JSplitPane mainPanel;
44266077 JScrollPane scrollpane;
6078
+
44276079 JPanel toolbarPanel;
4428
- JPanel treePanel;
6080
+
6081
+ cGridBag treePanel;
6082
+
44296083 JPanel radioPanel;
44306084 ButtonGroup buttonGroup;
4431
- cGridBag ctrlPanel;
6085
+
6086
+ cGridBag toolboxPanel;
6087
+ cGridBag skyboxPanel;
44326088 cGridBag materialPanel;
6089
+ cGridBag ctrlPanel;
6090
+
44336091 JScrollPane infoPanel;
6092
+
44346093 cGridBag optionsPanel;
6094
+
44356095 JTabbedPane objectPanel;
6096
+ boolean materialFlushed;
6097
+ Object3D latestObject;
6098
+
6099
+ cGridBag transformPanel;
44366100 cGridBag XYZPanel;
6101
+
44376102 JSplitPane gridPanel;
44386103 JSplitPane bigPanel;
6104
+
44396105 cGridBag bigThree;
44406106 cGridBag scenePanel;
44416107 cGridBag centralPanel;
....@@ -4493,7 +6159,7 @@
44936159 JLabel colorLabel;
44946160 cNumberSlider colorField;
44956161 JLabel modulationLabel;
4496
- cNumberSlider modulationField;
6162
+ cNumberSlider saturationField;
44976163 JLabel metalnessLabel;
44986164 cNumberSlider metalnessField;
44996165 JLabel diffuseLabel;
....@@ -4524,6 +6190,7 @@
45246190 cNumberSlider anisoField;
45256191 JLabel anisoVLabel;
45266192 cNumberSlider anisoVField;
6193
+
45276194 JLabel cameraLabel;
45286195 cNumberSlider cameraField;
45296196 JLabel selfshadowLabel;
....@@ -4538,6 +6205,7 @@
45386205 cNumberSlider fakedepthField;
45396206 JLabel shadowbiasLabel;
45406207 cNumberSlider shadowbiasField;
6208
+
45416209 JLabel bumpLabel;
45426210 cNumberSlider bumpField;
45436211 JLabel noiseLabel;
....@@ -4550,8 +6218,13 @@
45506218 cNumberSlider fogField;
45516219 JLabel opacityPowerLabel;
45526220 cNumberSlider opacityPowerField;
4553
- JTree jTree;
6221
+ cTree jTree;
45546222 //ObjectUI parent;
45556223
45566224 cNumberSlider normalpushField;
6225
+
6226
+ private MenuItem importGFDItem;
6227
+ private MenuItem importVRMLX3DItem;
6228
+ private MenuItem import3DSItem;
6229
+ private MenuItem importOBJItem;
45576230 }