Normand Briere
2019-08-17 5892f05411c3d4dce2d8a59e0966dc2e1843a971
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.*;
....@@ -14,10 +15,15 @@
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
1617
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1721 //import javax.media.opengl.GLCanvas;
1822
1923 import //weka.core.
2024 matrix.Matrix;
25
+
26
+import grafeme.ui.*;
2127
2228 class ObjEditor /*extends JFrame*/ implements iCallBack, ObjectUI,
2329 ActionListener, ChangeListener,
....@@ -28,7 +34,129 @@
2834 iSendInfo
2935 //KeyListener
3036 {
37
+ public cToggleButton pinButton;
38
+ boolean timeline;
39
+ boolean wasFullScreen;
3140
41
+ GroupEditor callee;
42
+ JFrame frame;
43
+
44
+ static ObjEditor theFrame;
45
+
46
+ public void AllocProjectedVertices(Object3D object)
47
+ {
48
+ assert (object.projectedVertices != null);
49
+
50
+ if (object.projectedVertices.length <= 2)
51
+ {
52
+ // Side effect...
53
+ Object3D.cVector2[] keep = object.projectedVertices;
54
+ object.projectedVertices = new Object3D.cVector2[3];
55
+ for (int i = 0; i < 3; i++)
56
+ {
57
+ if (i < keep.length)
58
+ {
59
+ object.projectedVertices[i] = keep[i];
60
+ } else
61
+ {
62
+ object.projectedVertices[i] = new Object3D.cVector2();
63
+ }
64
+ /*
65
+ if(keep.length == 0)
66
+ object.projectedVertices[0] = new Object3D.cVector2();
67
+ else
68
+ object.projectedVertices[0] = keep[0];
69
+ object.projectedVertices[1] = new Object3D.cVector2();
70
+ */
71
+ }
72
+ }
73
+ }
74
+
75
+ public cGridBag GetSeparator()
76
+ {
77
+ cGridBag separator = new cGridBag();
78
+ separator.add(new JSeparator());
79
+ separator.preferredHeight = 5;
80
+ return separator;
81
+ }
82
+
83
+ cButton GetButton(String name, boolean border)
84
+ {
85
+ ImageIcon icon = GetIcon(name);
86
+ return new cButton(icon, border);
87
+ }
88
+
89
+ cLabel GetLabel(String name, boolean border)
90
+ {
91
+ //ImageIcon icon = GetIcon(name);
92
+ return new cLabel(GetImage(name), border);
93
+ }
94
+
95
+ cToggleButton GetToggleButton(String name, boolean border)
96
+ {
97
+ ImageIcon icon = GetIcon(name);
98
+ return new cToggleButton(icon, border);
99
+ }
100
+
101
+ cCheckBox GetCheckBox(String name, boolean border)
102
+ {
103
+ ImageIcon icon = GetIcon(name);
104
+ return new cCheckBox(icon, border);
105
+ }
106
+
107
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
108
+
109
+ static ImageIcon GetIcon(String name)
110
+ {
111
+ javax.swing.ImageIcon iconCache = icons.get(name);
112
+ if (iconCache != null)
113
+ {
114
+ return iconCache;
115
+ }
116
+
117
+ try
118
+ {
119
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
120
+
121
+// if (image.getWidth() > 48 && image.getHeight() > 48)
122
+// {
123
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
124
+// Graphics2D g = resized.createGraphics();
125
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
126
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
127
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
128
+// g.dispose();
129
+//
130
+// image = resized;
131
+// }
132
+
133
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
134
+
135
+ icons.put(name, icon);
136
+
137
+ return icon;
138
+ }
139
+ catch (Exception e)
140
+ {
141
+ //icons.put(name, null);
142
+ return null;
143
+ }
144
+ }
145
+
146
+ BufferedImage GetImage(String name)
147
+ {
148
+ try
149
+ {
150
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
151
+
152
+ return image;
153
+ }
154
+ catch (Exception e)
155
+ {
156
+ return null;
157
+ }
158
+ }
159
+
32160 // SCRIPT
33161
34162 transient JFrame textpanel = null;
....@@ -119,51 +247,62 @@
119247 void keyPressed(int key, int modifiers)
120248 {
121249 System.out.println("KEY PRESSED");
122
- CameraPane.theRenderer.keyPressed(key, modifiers);
250
+ Globals.theRenderer.keyPressed(key, modifiers);
123251 }
124252 */
125253
126254 static GridBagConstraints aConstraints;
127255 static GridBagConstraints aWindowConstraints;
128
- GroupEditor callee;
129
- JFrame frame;
256
+
130257 static int GRIDWIDTH = 100; // 4;
131258
132259 public void closeUI()
133260 {
134261 //new Exception().printStackTrace();
135
- System.out.println("this = " + this);
136
- System.out.println("objEditor = " + objEditor);
262
+// System.out.println("this = " + this);
263
+// System.out.println("objEditor = " + objEditor);
137264 //nameField.removeActionListener(this);
138
- objEditor.ctrlPanel.remove(nameField);
265
+// objEditor.ctrlPanel.remove(nameField);
139266
140
- if (!GroupEditor.allparams)
267
+ objEditor.ctrlPanel.remove(namePanel);
268
+
269
+ if (!allparams)
141270 return;
142271
143
- objEditor.ctrlPanel.remove(liveCB);
144
- objEditor.ctrlPanel.remove(hideCB);
145
- objEditor.ctrlPanel.remove(markCB);
146
-
147
- objEditor.ctrlPanel.remove(randomCB);
148
- objEditor.ctrlPanel.remove(speedupCB);
149
- objEditor.ctrlPanel.remove(rewindCB);
150
-
151
- objEditor.ctrlPanel.remove(resetButton);
152
- objEditor.ctrlPanel.remove(stepButton);
153
-// objEditor.ctrlPanel.remove(stepAllButton);
154
-// objEditor.ctrlPanel.remove(resetAllButton);
155
- objEditor.ctrlPanel.remove(link2masterCB);
156
- //objEditor.ctrlPanel.remove(flipVCB);
157
- //objEditor.ctrlPanel.remove(texresMenu);
158
- objEditor.ctrlPanel.remove(slowerButton);
159
- objEditor.ctrlPanel.remove(fasterButton);
160
- objEditor.ctrlPanel.remove(remarkButton);
272
+// objEditor.ctrlPanel.remove(liveCB);
273
+// objEditor.ctrlPanel.remove(hideCB);
274
+// objEditor.ctrlPanel.remove(markCB);
275
+//
276
+// objEditor.ctrlPanel.remove(randomCB);
277
+// objEditor.ctrlPanel.remove(speedupCB);
278
+// objEditor.ctrlPanel.remove(rewindCB);
279
+//
280
+// objEditor.ctrlPanel.remove(resetButton);
281
+// objEditor.ctrlPanel.remove(stepButton);
282
+//// objEditor.ctrlPanel.remove(stepAllButton);
283
+//// objEditor.ctrlPanel.remove(resetAllButton);
284
+// objEditor.ctrlPanel.remove(link2masterCB);
285
+// //objEditor.ctrlPanel.remove(flipVCB);
286
+// //objEditor.ctrlPanel.remove(texresMenu);
287
+// objEditor.ctrlPanel.remove(slowerButton);
288
+// objEditor.ctrlPanel.remove(fasterButton);
289
+// objEditor.ctrlPanel.remove(remarkButton);
290
+
291
+ objEditor.ctrlPanel.remove(setupPanel);
292
+ objEditor.ctrlPanel.remove(setupPanel2);
293
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
294
+ objEditor.ctrlPanel.remove(pushPanel);
295
+ //objEditor.ctrlPanel.remove(fillPanel);
296
+
297
+ //Remove(normalpushField);
161298 }
162299
163300 public ObjEditor GetEditor()
164301 {
165302 return objEditor; //.GetEditor();
166303 }
304
+
305
+ // Sometimes myself, sometimes my callee's.
167306 ObjEditor objEditor;
168307
169308 /*
....@@ -199,6 +338,14 @@
199338 client = inClient;
200339 copy = client;
201340
341
+// if (copy.versionlist == null)
342
+// {
343
+// copy.versionlist = new Object3D[100];
344
+// copy.versionindex = -1;
345
+//
346
+// callee.Save(true);
347
+// }
348
+
202349 // "this" is not called: SetupUI2(objEditor);
203350 }
204351
....@@ -212,6 +359,14 @@
212359 client = inClient;
213360 copy = client;
214361
362
+ if (copy.versionlist == null)
363
+ {
364
+ copy.versionlist = new Object3D[100];
365
+ copy.versionindex = -1;
366
+
367
+// Save(true);
368
+ }
369
+
215370 SetupUI2(callee.GetEditor());
216371 }
217372
....@@ -226,23 +381,33 @@
226381 //localCopy.parent = null;
227382
228383 frame = new JFrame();
384
+ frame.setUndecorated(false);
229385 objEditor = this;
230386 this.callee = callee;
231387
232388 //parent = p;
233389
234390 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
235
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
391
+ if (Globals.DEBUG)
392
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
236393 //gd.setFullScreenWindow(this);
237394 //setResizable(false);
238395 //if (!isDisplayable())
239396 //setUndecorated(true);
240397
241
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
398
+ //System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
242399 client = inClient;
243400 copy = localCopy;
244401 copy.editWindow = this;
245402
403
+// if (copy.versionlist == null)
404
+// {
405
+// copy.versionlist = new Object3D[100];
406
+// copy.versionindex = -1;
407
+//
408
+// Save(true);
409
+// }
410
+
246411 SetupMenu();
247412
248413 //SetupName(objEditor); // new
....@@ -256,28 +421,52 @@
256421 return frame.action(event, obj);
257422 }
258423
424
+ // Cannot work without static
425
+ static boolean allparams = true;
426
+
427
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
428
+
429
+ // This is to refresh the UI of the material panel.
430
+ boolean patchMaterial;
431
+
259432 void SetupMenu()
260433 {
261434 frame.setMenuBar(menuBar = new MenuBar());
262
- menuBar.add(windowMenu = new Menu("File"));
263
- windowMenu.add(loadItem = new MenuItem("Load..."));
264
- windowMenu.add("-");
265
- windowMenu.add(saveItem = new MenuItem("Save"));
266
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
435
+ menuBar.add(fileMenu = new Menu("File"));
436
+ fileMenu.add(newItem = new MenuItem("New"));
437
+ fileMenu.add(openItem = new MenuItem("Open..."));
438
+
439
+ //oe.menuBar.add(menu = new Menu("Include"));
440
+ Menu menu = new Menu("Import");
441
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
442
+ importOBJItem.addActionListener(this);
443
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
444
+ import3DSItem.addActionListener(this);
445
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
446
+ importVRMLX3DItem.addActionListener(this);
447
+ menu.add("-");
448
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
449
+ importGFDItem.addActionListener(this);
450
+ fileMenu.add(menu);
451
+ fileMenu.add("-");
452
+
453
+ fileMenu.add(saveItem = new MenuItem("Save"));
454
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
267455 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
268
- windowMenu.add("-");
269
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
270
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
271
- windowMenu.add("-");
456
+ fileMenu.add("-");
457
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
458
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
459
+ fileMenu.add("-");
272460 if (client.parent != null)
273461 {
274
- windowMenu.add(closeItem = new MenuItem("Close"));
462
+ fileMenu.add(closeItem = new MenuItem("Close"));
275463 } else
276464 {
277
- windowMenu.add(closeItem = new MenuItem("Exit"));
465
+ fileMenu.add(closeItem = new MenuItem("Exit"));
278466 }
279467
280
- loadItem.addActionListener(this);
468
+ newItem.addActionListener(this);
469
+ openItem.addActionListener(this);
281470 saveItem.addActionListener(this);
282471 saveAsItem.addActionListener(this);
283472 exportAsItem.addActionListener(this);
....@@ -285,80 +474,103 @@
285474 //povItem.addActionListener(this);
286475 closeItem.addActionListener(this);
287476
288
- menuBar.add(cameraMenu = new Menu("View"));
289
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
290
- //zBufferItem.addActionListener(this);
291
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
292
- //normalLensItem.addActionListener(this);
293
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
294
- revertCameraItem.addActionListener(this);
295
- cameraMenu.add(toggleFullItem = new CheckboxMenuItem("Full Screen"));
296
- toggleFullItem.addItemListener(this);
297
- toggleFullItem.setState(CameraPane.FULLSCREEN);
298
- cameraMenu.add("-");
299
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
300
- toggleTextureItem.addItemListener(this);
301
- toggleTextureItem.setState(CameraPane.textureon);
302
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
303
- toggleLiveItem.addItemListener(this);
304
- toggleLiveItem.setState(CameraPane.isLIVE());
305
- cameraMenu.add(stepItem = new MenuItem("Step"));
306
- stepItem.addActionListener(this);
307
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
308
-// toggleDLItem.addItemListener(this);
309
-// toggleDLItem.setState(false);
310
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
311
- toggleRenderItem.addItemListener(this);
312
- toggleRenderItem.setState(!CameraPane.frozen);
313
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
314
- toggleDebugItem.addItemListener(this);
315
- toggleDebugItem.setState(CameraPane.DEBUG);
316
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
317
- toggleFrustumItem.addItemListener(this);
318
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
319
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
320
- toggleFootContactItem.addItemListener(this);
321
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
322
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
323
- toggleRandomItem.addItemListener(this);
324
- toggleRandomItem.setState(CameraPane.RANDOM);
325
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
326
- toggleHandleItem.addItemListener(this);
327
- toggleHandleItem.setState(CameraPane.HANDLES);
328
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
329
- togglePaintItem.addItemListener(this);
330
- togglePaintItem.setState(CameraPane.PAINTMODE);
331
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
332
-// toggleRootItem.addItemListener(this);
333
-// toggleRootItem.setState(false);
334
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
335
-// animationItem.addItemListener(this);
336
-// animationItem.setState(CameraPane.ANIMATION);
337
- cameraMenu.add("-");
338
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
339
- editCameraItem.addActionListener(this);
340
-
341477 objectPanel = new JTabbedPane();
478
+
479
+ ChangeListener changeListener = new ChangeListener()
480
+ {
481
+ //String name;
482
+
483
+ public void stateChanged(ChangeEvent changeEvent)
484
+ {
485
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
486
+// {
487
+// if (latestObject != null)
488
+// {
489
+// refreshContents(true);
490
+// SetMaterial(latestObject);
491
+// }
492
+//
493
+// materialFlushed = true;
494
+// }
495
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
496
+// {
497
+// if (listUI.size() == 0)
498
+// EditSelection(false);
499
+// }
500
+
501
+// if (objectPanel.getSelectedIndex() == 4)
502
+// {
503
+// name = copy.skyboxname;
504
+//
505
+// if (name == null)
506
+// {
507
+// name = "";
508
+// }
509
+//
510
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
511
+// copy.skyboxext = "jpg";
512
+// }
513
+// else
514
+// {
515
+// if (name != null)
516
+// {
517
+// if (name.equals(""))
518
+// {
519
+// copy.skyboxname = null;
520
+// copy.skyboxext = null;
521
+// }
522
+// else
523
+// {
524
+// copy.skyboxname = name;
525
+// }
526
+// }
527
+// }
528
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
529
+
530
+// refreshContents(false); // To refresh Info tab
531
+ cameraView.repaint();
532
+ }
533
+ };
534
+ objectPanel.addChangeListener(changeListener);
535
+
342536 toolbarPanel = new JPanel();
343537 toolbarPanel.setName("Toolbar");
344
- treePanel = new JPanel();
538
+
539
+ treePanel = new cGridBag();
345540 treePanel.setName("Tree");
346
- ctrlPanel = new JPanel(); // new GridBagLayout());
347
- ctrlPanel.setName("Edit");
348
- materialPanel = new JPanel();
349
- materialPanel.setName("Material");
541
+
542
+ editPanel = new cGridBag().setVertical(true);
543
+ //editPanel.setName("Edit");
544
+
545
+ ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
546
+
547
+ editCommandsPanel = new cGridBag();
548
+ editPanel.add(editCommandsPanel);
549
+ editPanel.add(ctrlPanel);
550
+
551
+ toolboxPanel = new cGridBag().setVertical(true);
552
+ //toolboxPanel.setName("Toolbox");
553
+
554
+ skyboxPanel = new cGridBag().setVertical(true);
555
+
556
+ materialPanel = new cGridBag().setVertical(false);
557
+ //materialPanel.setName("Material");
558
+
350559 /*JTextPane*/
351560 infoarea = createTextPane();
561
+ doc = infoarea.getStyledDocument();
562
+
352563 infoarea.setEditable(true);
353564 SetText();
565
+
354566 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
355567 // infoarea.setOpaque(false);
356568 // //infoarea.setForeground(textcolor);
357
- infoarea.setLineWrap(true);
358
- infoarea.setWrapStyleWord(true);
569
+// TEXTAREA infoarea.setLineWrap(true);
570
+// TEXTAREA infoarea.setWrapStyleWord(true);
359571 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
360
- infoPanel.setPreferredSize(new Dimension(50, 200));
361
- infoPanel.setName("Info");
572
+ infoPanel.setPreferredSize(new Dimension(1, 1));
573
+ //infoPanel.setName("Info");
362574 //infoPanel.setLayout(new BorderLayout());
363575 //infoPanel.add(createTextPane());
364576
....@@ -366,16 +578,23 @@
366578 mainPanel.setName("Main");
367579 mainPanel.setContinuousLayout(true);
368580 mainPanel.setOneTouchExpandable(true);
369
- mainPanel.setDividerLocation(1.0);
370581 mainPanel.setDividerSize(9);
371
- mainPanel.setResizeWeight(0);
372
-
582
+ mainPanel.setDividerLocation(0.5); //1.0);
583
+ mainPanel.setResizeWeight(0.5);
584
+
585
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
586
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
587
+ divider.setDividerSize(15);
588
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
589
+
590
+ mainPanel.setUI(new BasicSplitPaneUI());
591
+
373592 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
374593 //mainPanel.setLayout(new GridBagLayout());
375594 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
376
- treePanel.setLayout(new GridBagLayout());
377
- ctrlPanel.setLayout(new GridBagLayout());
378
- materialPanel.setLayout(new GridBagLayout());
595
+// treePanel.setLayout(new GridBagLayout());
596
+ //ctrlPanel.setLayout(new GridBagLayout());
597
+ //materialPanel.setLayout(new GridBagLayout());
379598
380599 aConstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
381600 GridBagConstraints.NORTHEAST, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0);
....@@ -414,7 +633,7 @@
414633 static String newline = "\n";
415634 protected static final String buttonString = "JButton";
416635 StyledDocument doc;
417
- JTextArea infoarea;
636
+ JTextPane infoarea;
418637
419638 void ClearInfo()
420639 {
....@@ -437,10 +656,10 @@
437656 e.printStackTrace();
438657 }
439658
440
- String selection = infoarea.getText();
441
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
442
- java.awt.datatransfer.Clipboard clipboard =
443
- Toolkit.getDefaultToolkit().getSystemClipboard();
659
+// String selection = infoarea.getText();
660
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
661
+// java.awt.datatransfer.Clipboard clipboard =
662
+// Toolkit.getDefaultToolkit().getSystemClipboard();
444663 //clipboard.setContents(data, data);
445664 }
446665
....@@ -463,13 +682,13 @@
463682 //SendInfo("Name:", "bold");
464683 if (sel.GetTextures() != null || debug)
465684 {
466
- si.SendInfo(sel.toString(), "bold");
685
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
467686 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
468687 if (sel.Size() > 0)
469688 {
470689 si.SendInfo("#children = " + sel.Size(), "regular");
471690 }
472
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
691
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
473692 if (debug)
474693 {
475694 try
....@@ -481,7 +700,10 @@
481700 }
482701
483702 if (full)
484
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
703
+ {
704
+ si.SendInfo(" BBox min: " + minima, "regular");
705
+ si.SendInfo(" BBox max: " + maxima, "regular");
706
+ }
485707
486708 if (sel.bRep != null)
487709 {
....@@ -508,7 +730,7 @@
508730 }
509731 if (sel.support != null)
510732 {
511
- si.SendInfo(" support: " + sel.support, "regular");
733
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
512734 }
513735 if (sel.scriptnode != null)
514736 {
....@@ -522,18 +744,18 @@
522744 maxima.y = sel.toParent[3][1];
523745 maxima.z = sel.toParent[3][2];
524746 si.SendInfo(" Orig: " + maxima, "regular");
525
- maxima.x = sel.globalTransform[3][0];
526
- maxima.y = sel.globalTransform[3][1];
527
- maxima.z = sel.globalTransform[3][2];
528
- if (full)
529
- si.SendInfo(" Global Orig: " + maxima, "regular");
530747 maxima.x = sel.toParent[0][0];
531748 maxima.y = sel.toParent[1][1];
532749 maxima.z = sel.toParent[2][2];
533750 si.SendInfo(" Scale: " + maxima, "regular");
534
- maxima.x = sel.globalTransform[0][0];
535
- maxima.y = sel.globalTransform[1][1];
536
- maxima.z = sel.globalTransform[2][2];
751
+ maxima.x = sel.globalTransform[3][0];
752
+ maxima.y = sel.globalTransform[3][1];
753
+ maxima.z = sel.globalTransform[3][2];
754
+ if (full)
755
+ si.SendInfo(" Global Orig: " + maxima, "regular");
756
+ maxima.x = sel.globalTransform[0][0];
757
+ maxima.y = sel.globalTransform[1][1];
758
+ maxima.z = sel.globalTransform[2][2];
537759 if (full)
538760 si.SendInfo(" Global Scale: " + maxima, "regular");
539761 }
....@@ -579,6 +801,9 @@
579801 {
580802 CameraPane.pointflow = (PointFlow) sel;
581803 }
804
+
805
+ si.SendInfo("_____________________", "regular");
806
+ si.SendInfo("", "regular");
582807 }
583808 }
584809
....@@ -594,52 +819,211 @@
594819 }
595820 }
596821
597
- private JTextArea createTextPane()
598
- {
599
- String[] initString =
600
- {
601
- "This is an editable JTextPane, ", //regular
602
- "another ", //italic
603
- "styled ", //bold
604
- "text ", //small
605
- "component, ", //large
606
- "which supports embedded components..." + newline,//regular
607
- " " + newline, //button
608
- "...and embedded icons..." + newline, //regular
609
- " ", //icon
610
- newline + "JTextPane is a subclass of JEditorPane that "
611
- + "uses a StyledEditorKit and StyledDocument, and provides "
612
- + "cover methods for interacting with those objects."
613
- };
822
+//static GraphicsDevice device = GraphicsEnvironment
823
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
614824
615
- String[] initStyles =
616
- {
617
- "regular", "italic", "bold", "small", "large",
618
- "regular", "button", "regular", "icon",
619
- "regular"
620
- };
825
+ Rectangle keeprect;
826
+ cRadio radio;
827
+
828
+cButton keepButton;
829
+ cButton twoButton; // Full 3D
830
+ cButton sixButton;
831
+ cButton threeButton;
832
+ cButton sevenButton;
833
+ cButton fourButton; // full panel
834
+ cButton oneButton; // full XYZ
835
+ //cButton currentLayout;
836
+
837
+ boolean maximized;
838
+
839
+ cButton fullscreenLayout;
840
+ cButton expandedLayout;
621841
622
- JTextPane textPane = new JTextPane();
623
- textPane.setEditable(true);
624
- /*StyledDocument*/ doc = textPane.getStyledDocument();
625
- addStylesToDocument(doc);
626
-
627
- try
842
+ void Minimize()
628843 {
629
- for (int j = 0; j < 2; j++)
844
+ frame.setState(Frame.ICONIFIED);
845
+ frame.validate();
846
+ }
847
+
848
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
849
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
850
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
851
+ void Maximize()
852
+ {
853
+ if (CameraPane.FULLSCREEN)
630854 {
631
- for (int i = 0; i < initString.length; i++)
632
- {
633
- doc.insertString(doc.getLength(), initString[i],
634
- doc.getStyle(initStyles[i]));
635
- }
855
+ ToggleFullScreen();
636856 }
637
- } catch (BadLocationException ble)
857
+
858
+ if (maximized)
859
+ {
860
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
861
+ }
862
+ else
863
+ {
864
+ keeprect = frame.getBounds();
865
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
866
+// Dimension rect2 = frame.getToolkit().getScreenSize();
867
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
868
+// frame.setState(Frame.MAXIMIZED_BOTH);
869
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
870
+ }
871
+
872
+ maximized ^= true;
873
+
874
+ frame.validate();
875
+ }
876
+
877
+ cButton minButton;
878
+ cButton maxButton;
879
+ cButton fullButton;
880
+ cButton collapseButton;
881
+ cButton maximize3DButton;
882
+
883
+ void ToggleFullScreen()
638884 {
639
- System.err.println("Couldn't insert initial text into text pane.");
885
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
886
+
887
+ cameraView.ToggleFullScreen();
888
+
889
+ if (!CameraPane.FULLSCREEN)
890
+ {
891
+ device.setFullScreenWindow(null);
892
+ frame.dispose();
893
+ frame.setUndecorated(false);
894
+ frame.validate();
895
+ frame.setVisible(true);
896
+
897
+ //frame.setVisible(false);
898
+// frame.removeNotify();
899
+// frame.setUndecorated(false);
900
+// frame.addNotify();
901
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
902
+
903
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
904
+// X framePanel.add(bigThree);
905
+// X frame.getContentPane().add(/*"Center",*/framePanel);
906
+// framePanel.setDividerLocation(46); // icons are 24x24
907
+
908
+ //frame.setVisible(true);
909
+// radio.layout = keepButton;
910
+ //theFrame = null;
911
+ keepButton = null;
912
+// radio.layout.doClick();
913
+
914
+ } else
915
+ {
916
+ keepButton = radio.layout;
917
+ //keeprect = frame.getBounds();
918
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
919
+// frame.getToolkit().getScreenSize().height);
920
+ //frame.setVisible(false);
921
+
922
+ frame.dispose();
923
+ frame.setUndecorated(true);
924
+ device.setFullScreenWindow(frame);
925
+ frame.validate();
926
+ frame.setVisible(true);
927
+// frame.removeNotify();
928
+// frame.setUndecorated(true);
929
+// frame.addNotify();
930
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
931
+// X framePanel.remove(bigThree);
932
+// X frame.getContentPane().add(/*"Center",*/bigThree);
933
+// framePanel.setDividerLocation(0);
934
+
935
+// radio.layout = fullscreenLayout;
936
+// radio.layout.doClick();
937
+ //frame.setVisible(true);
938
+ }
939
+ frame.validate();
940
+
941
+ cameraView.requestFocusInWindow();
640942 }
641943
642
- return new JTextArea(); // textPane;
944
+ void CollapseToolbar()
945
+ {
946
+ framePanel.setDividerLocation(0);
947
+ //frame.validate();
948
+
949
+ cameraView.requestFocusInWindow();
950
+ }
951
+
952
+ private Object3D Duplicate(Object3D object)
953
+ {
954
+ boolean temp = CameraPane.SWITCH;
955
+ CameraPane.SWITCH = false;
956
+
957
+ if (Grafreed.grafreed.universe.versiontable == null)
958
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
959
+
960
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
961
+ // if (copy == client)
962
+
963
+ Object3D versions[] = object.versionlist;
964
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
965
+ object.versionlist = null;
966
+ object.versiontable = null;
967
+
968
+ //byte[] compress = Compress(copy);
969
+ Object3D compress = (Object3D)Grafreed.clone(object);
970
+
971
+ object.versionlist = versions;
972
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
973
+
974
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
975
+
976
+ CameraPane.SWITCH = temp;
977
+
978
+ return compress;
979
+ }
980
+
981
+ private JTextPane createTextPane()
982
+ {
983
+// TEXTAREA String[] initString =
984
+// {
985
+// "This is an editable JTextPane, ", //regular
986
+// "another ", //italic
987
+// "styled ", //bold
988
+// "text ", //small
989
+// "component, ", //large
990
+// "which supports embedded components..." + newline,//regular
991
+// " " + newline, //button
992
+// "...and embedded icons..." + newline, //regular
993
+// " ", //icon
994
+// newline + "JTextPane is a subclass of JEditorPane that "
995
+// + "uses a StyledEditorKit and StyledDocument, and provides "
996
+// + "cover methods for interacting with those objects."
997
+// };
998
+//
999
+// String[] initStyles =
1000
+// {
1001
+// "regular", "italic", "bold", "small", "large",
1002
+// "regular", "button", "regular", "icon",
1003
+// "regular"
1004
+// };
1005
+//
1006
+// JTextPane textPane = new JTextPane();
1007
+// textPane.setEditable(true);
1008
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
1009
+// addStylesToDocument(doc);
1010
+//
1011
+// try
1012
+// {
1013
+// for (int j = 0; j < 2; j++)
1014
+// {
1015
+// for (int i = 0; i < initString.length; i++)
1016
+// {
1017
+// doc.insertString(doc.getLength(), initString[i],
1018
+// doc.getStyle(initStyles[i]));
1019
+// }
1020
+// }
1021
+// } catch (BadLocationException ble)
1022
+// {
1023
+// System.err.println("Couldn't insert initial text into text pane.");
1024
+// }
1025
+
1026
+ return new JTextPane(); // textPane;
6431027 }
6441028
6451029 protected void addStylesToDocument(StyledDocument doc)
....@@ -692,7 +1076,7 @@
6921076 protected static ImageIcon createImageIcon(String path,
6931077 String description)
6941078 {
695
- java.net.URL imgURL = GraphreeD.class.getResource(path);
1079
+ java.net.URL imgURL = Grafreed.class.getResource(path);
6961080 if (imgURL != null)
6971081 {
6981082 return new ImageIcon(imgURL, description);
....@@ -715,6 +1099,7 @@
7151099 {
7161100 SetupMaterial(materialPanel);
7171101 }
1102
+
7181103 //SetupName();
7191104 //SetupViews();
7201105 }
....@@ -724,6 +1109,7 @@
7241109 // NumberSlider vDivsField;
7251110 // JCheckBox endcaps;
7261111 JCheckBox liveCB;
1112
+ JCheckBox selectableCB;
7271113 JCheckBox hideCB;
7281114 JCheckBox link2masterCB;
7291115 JCheckBox markCB;
....@@ -731,7 +1117,12 @@
7311117 JCheckBox speedupCB;
7321118 JCheckBox rewindCB;
7331119 JCheckBox flipVCB;
1120
+
1121
+ cCheckBox toggleTextureCB;
1122
+ cCheckBox toggleSwitchCB;
1123
+
7341124 JComboBox texresMenu;
1125
+
7351126 JButton resetButton;
7361127 JButton stepButton;
7371128 JButton stepAllButton;
....@@ -739,115 +1130,87 @@
7391130 JButton slowerButton;
7401131 JButton fasterButton;
7411132 JButton remarkButton;
1133
+
1134
+ cGridBag editPanel;
1135
+ cGridBag editCommandsPanel;
1136
+
1137
+ cGridBag namePanel;
1138
+ cGridBag setupPanel;
1139
+ cGridBag setupPanel2;
1140
+ cGridBag objectCommandsPanel;
1141
+ cGridBag pushPanel;
1142
+ cGridBag fillPanel;
7421143
743
- JCheckBox AddCheckBox(ObjEditor oe, String label, boolean on)
1144
+ JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
7441145 {
7451146 JCheckBox cb;
7461147
747
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
748
- oe.aConstraints.gridwidth = 1; // 3;
749
-// oe.aConstraints.weightx = 1;
750
-// oe.aConstraints.anchor = GridBagConstraints.WEST;
751
- oe.ctrlPanel.add(cb = new JCheckBox(label, on), oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
1148
+ panel.add(cb = new JCheckBox(label, on)); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
7521149 cb.addItemListener(this);
753
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
754
- oe.aConstraints.gridwidth = 1;
755
- oe.aConstraints.gridx += 1;
7561150
7571151 return cb;
7581152 }
7591153
760
- cButton AddButton(ObjEditor oe, String label)
1154
+ cButton AddButton(cGridBag panel, String label)
7611155 {
7621156 cButton cb;
7631157
764
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
765
- oe.aConstraints.gridwidth = 1;
766
-// oe.aConstraints.weightx = 1;
767
-// oe.aConstraints.anchor = GridBagConstraints.WEST;
768
- oe.ctrlPanel.add(cb = new cButton(label), oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
1158
+ panel.add(cb = new cButton(label)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
7691159 cb.addActionListener(this);
770
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
771
- oe.aConstraints.gridwidth = 1;
772
- oe.aConstraints.gridx += 1;
7731160
7741161 return cb;
7751162 }
7761163
777
- JComboBox AddCombo(ObjEditor oe, java.util.Vector list, int item)
1164
+ JComboBox AddCombo(cGridBag panel, java.util.Vector list, int item)
7781165 {
7791166 JComboBox combo;
7801167
781
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
782
- oe.ctrlPanel.add(combo = new JComboBox(new cListModel(list, item)), oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
783
- oe.aConstraints.gridx += 1;
1168
+ panel.add(combo = new JComboBox(new cListModel(list, item))); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
7841169 combo.addActionListener(this);
7851170
7861171 return combo;
7871172 }
7881173
789
- NumberSlider AddSlider(JPanel ctrlPanel, String label, double min, double max, double current, double pow)
1174
+ cGridBag AddSlider(cGridBag panel, String label, double min, double max, double current, double pow)
7901175 {
791
- NumberSlider combo;
1176
+ cGridBag control = new cGridBag();
1177
+
1178
+ cNumberSlider combo;
7921179
7931180 JLabel jlabel = new JLabel(label);
794
-
795
- aConstraints.fill = GridBagConstraints.VERTICAL;
7961181 jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
797
- aConstraints.gridwidth = 2;
798
- ctrlPanel.add(jlabel, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
799
- aConstraints.gridx += 1;
800
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
801
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
802
- ctrlPanel.add(combo = new NumberSlider(min, max, pow), aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
803
- aConstraints.gridx += 1;
804
- aConstraints.gridwidth = 1;
805
-
1182
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
1183
+ control.add(combo = new cNumberSlider(this, min, max, pow)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8061184 combo.setFloat(current);
807
-
808
- combo.label = jlabel;
809
-
810
- combo.addChangeListener(this);
811
-
812
- return combo;
1185
+
1186
+ panel.add(control);
1187
+
1188
+ return control;
8131189 }
8141190
815
- NumberSlider AddSlider(JPanel ctrlPanel, String label, int min, int max, int current)
1191
+ cGridBag AddSlider(cGridBag panel, String label, int min, int max, int current)
8161192 {
817
- NumberSlider combo;
1193
+ cGridBag control = new cGridBag();
1194
+
1195
+ cNumberSlider combo;
8181196
8191197 JLabel jlabel = new JLabel(label);
820
-
821
- aConstraints.fill = GridBagConstraints.VERTICAL;
8221198 jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
823
- aConstraints.gridwidth = 2;
824
- ctrlPanel.add(jlabel, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
825
- aConstraints.gridx += 1;
826
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
827
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
828
- ctrlPanel.add(combo = new NumberSlider(min, max), aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
829
- aConstraints.gridx += 1;
830
- aConstraints.gridwidth = 1;
831
-
1199
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
1200
+ control.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8321201 combo.setInteger(current);
8331202
834
- combo.label = jlabel;
835
-
836
- combo.addChangeListener(this);
837
-
838
- return combo;
1203
+ panel.add(control);
1204
+
1205
+ return control;
8391206 }
8401207
841
- JTextArea AddText(JPanel ctrlPanel, String name)
1208
+ JTextArea AddText(cGridBag ctrlPanel, String name)
8421209 {
8431210 JTextArea text;
8441211
845
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
846
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
847
- ctrlPanel.add(text = new JTextArea(name), aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
1212
+ ctrlPanel.add(text = new JTextArea(name)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8481213 text.addCaretListener(this);
849
- aConstraints.gridx += 1;
850
- aConstraints.gridwidth = 1;
8511214
8521215 return text;
8531216 }
....@@ -877,9 +1240,16 @@
8771240 objEditor.ctrlPanel.remove(j);
8781241 }
8791242
1243
+ void Remove(cNumberSlider j)
1244
+ {
1245
+ j.removeChangeListener(this);
1246
+ //objEditor.ctrlPanel.remove(j.label);
1247
+ objEditor.ctrlPanel.remove(j);
1248
+ }
1249
+
8801250 /*
8811251 */
882
- void Return() // ObjEditor oe)
1252
+ void Return0() // ObjEditor oe)
8831253 {
8841254 aConstraints.gridy += 1;
8851255 aConstraints.gridx = 0;
....@@ -934,35 +1304,93 @@
9341304
9351305 void SetupUI2(ObjEditor oe)
9361306 {
937
-// oe.aConstraints.weightx = 0;
938
-// oe.aConstraints.weighty = 0;
939
-// oe.aConstraints.gridx = 0;
940
-// oe.aConstraints.gridy = 0;
941
- SetupName(oe);
1307
+ //SetupName(oe);
9421308
943
- if (!GroupEditor.allparams)
1309
+ namePanel = new cGridBag();
1310
+
1311
+ //if (copy.pinned)
1312
+ {
1313
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1314
+ pinButton.setSelected(copy.pinned);
1315
+ cGridBag t = new cGridBag();
1316
+ t.preferredWidth = 2;
1317
+ t.add(pinButton);
1318
+ namePanel.add(t);
1319
+
1320
+ pinButton.addItemListener(this);
1321
+ }
1322
+
1323
+ nameField = AddText(namePanel, copy.GetName());
1324
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
1325
+ oe.ctrlPanel.add(namePanel);
1326
+
1327
+ oe.ctrlPanel.Return();
1328
+
1329
+ if (!allparams)
9441330 return;
9451331
946
- liveCB = AddCheckBox(oe, "Live", copy.live);
947
- link2masterCB = AddCheckBox(oe, "Supp", copy.link2master);
948
- hideCB = AddCheckBox(oe, "Hide", copy.hide);
1332
+ setupPanel = new cGridBag().setVertical(false);
1333
+
1334
+ liveCB = AddCheckBox(setupPanel, "Live", copy.live);
1335
+ liveCB.setToolTipText("Animate object");
1336
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1337
+ markCB.setToolTipText("Set target transform");
1338
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1339
+ selectableCB.setToolTipText("Make object selectable");
9491340 // Return();
950
- markCB = AddCheckBox(oe, "Mark", copy.marked);
951
- rewindCB = AddCheckBox(oe, "Rew", copy.rewind);
952
- randomCB = AddCheckBox(oe, "Rand", copy.random);
953
- Return();
954
- resetButton = AddButton(oe, "Reset");
955
- stepButton = AddButton(oe, "Step");
1341
+
1342
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1343
+ hideCB.setToolTipText("Hide object");
1344
+
1345
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1346
+
1347
+ setupPanel2 = new cGridBag().setVertical(false);
1348
+
1349
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1350
+ rewindCB.setToolTipText("Rewind animation");
1351
+
1352
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1353
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
1354
+
1355
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1356
+ link2masterCB.setToolTipText("Attach to support");
1357
+
1358
+ if (Globals.ADVANCED)
1359
+ {
1360
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1361
+ speedupCB.setToolTipText("Option motion capture");
1362
+ }
1363
+
1364
+ oe.ctrlPanel.add(setupPanel);
1365
+ oe.ctrlPanel.Return();
1366
+ oe.ctrlPanel.add(setupPanel2);
1367
+ oe.ctrlPanel.Return();
1368
+
1369
+ objectCommandsPanel = new cGridBag().setVertical(false);
1370
+
1371
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1372
+ resetButton.setToolTipText("Jump to frame zero");
1373
+ stepButton = AddButton(objectCommandsPanel, "Step");
1374
+ stepButton.setToolTipText("Step one frame");
9561375 // resetAllButton = AddButton(oe, "Reset All");
9571376 // stepAllButton = AddButton(oe, "Step All");
958
- speedupCB = AddCheckBox(oe, "Speed", copy.speedup);
9591377 // Return();
960
- slowerButton = AddButton(oe, "Slow");
961
- fasterButton = AddButton(oe, "Fast");
962
- remarkButton = AddButton(oe, "Rem");
1378
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1379
+ slowerButton.setToolTipText("Decrease animation speed");
1380
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1381
+ fasterButton.setToolTipText("Increase animation speed");
1382
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1383
+ remarkButton.setToolTipText("Set the current transform as the target");
9631384
964
- Return();
1385
+ oe.ctrlPanel.add(objectCommandsPanel);
1386
+ oe.ctrlPanel.Return();
9651387
1388
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
1389
+ normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1390
+ //Return();
1391
+
1392
+ oe.ctrlPanel.Return();
1393
+
9661394 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
9671395 // ObjEditor.aConstraints.gridx += 1;
9681396
....@@ -1056,7 +1484,7 @@
10561484 oe.aConstraints.gridwidth = 1;
10571485 /**/
10581486 nameField = AddText(oe.ctrlPanel, copy.GetName());
1059
- Return();
1487
+ oe.ctrlPanel.Return();
10601488
10611489 //ctrlPanel.add(textureButton = new Button("Texture..."));
10621490 //textureButton.setEnabled(false);
....@@ -1107,13 +1535,14 @@
11071535 //frontScroll.setLabel("------------------------------ XZ (front) ---------------------------------------------------");
11081536 //sideScroll.setLabel("------------------------------- YZ (side) ---------------------------------------------------");
11091537
1110
-// GridBagConstraints gbc = (GridBagConstraints) GraphreeD.clone(aConstraints);
1538
+// GridBagConstraints gbc = (GridBagConstraints) GrafreeD.clone(aConstraints);
11111539 Camera cam = GetCamera(copy, 0);
11121540
11131541 Composite cams = null;
11141542
11151543 if (cam == null || !(copy.get(0) instanceof cGroup))
11161544 {
1545
+ if (Globals.DEBUG)
11171546 System.out.println("CREATE CAMERAS");
11181547 cams = new cTemplate();
11191548 cams.name = "Cameras";
....@@ -1158,10 +1587,28 @@
11581587 //JPanel worldPanel =
11591588 // new gov.nasa.worldwind.examples.ApplicationTemplate.AppPanel(null, true);
11601589 //worldPanel.setName("World");
1161
- /*JPanel*/ cameraPanel =
1162
- new JPanel(new BorderLayout());
1163
- cameraPanel.add(cameraView);
1590
+ centralPanel = new cGridBag();
1591
+ centralPanel.preferredWidth = 20;
1592
+
1593
+ if (Globals.ADVANCED)
1594
+ {
1595
+ timelinePanel = new JPanel(new BorderLayout());
1596
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11641597
1598
+ cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
1599
+ cameraPanel.setContinuousLayout(true);
1600
+ cameraPanel.setOneTouchExpandable(true);
1601
+// cameraPanel.setDividerLocation(0.9);
1602
+// cameraPanel.setDividerSize(9);
1603
+ cameraPanel.setResizeWeight(1.0);
1604
+
1605
+ }
1606
+
1607
+ centralPanel.add(cameraView);
1608
+ centralPanel.setFocusable(true);
1609
+ //frame.setJMenuBar(timelineMenubar);
1610
+ //centralPanel.add(timelinePanel);
1611
+
11651612 //topView.camera = ;
11661613 //frontView.camera = new Camera(2);
11671614 //sideView.camera = new Camera(3);
....@@ -1177,12 +1624,14 @@
11771624 //frontView.object = copy;
11781625 //sideView.object = copy;
11791626
1180
- XYZPanel = new JPanel();
1181
- XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
1627
+ XYZPanel = new cGridBag().setVertical(true);
1628
+ //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
11821629
1183
- XYZPanel.add(/*BorderLayout.SOUTH,*/sideView); // Scroll);
1184
- XYZPanel.add(/*BorderLayout.CENTER,*/frontView); // Scroll);
1185
- XYZPanel.add(/*BorderLayout.NORTH,*/topView); // Scroll);
1630
+ XYZPanel.preferredWidth = 5;
1631
+ XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
1632
+ XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
1633
+ XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1634
+ //XYZPanel.setName("XYZ");
11861635
11871636 /*
11881637 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1191,7 +1640,7 @@
11911640 gridPanel.add(cameraView);
11921641 gridPanel.add(XYZPanel);
11931642 */
1194
- gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, cameraPanel, XYZPanel); //new BorderLayout());
1643
+ gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout());
11951644 gridPanel.setContinuousLayout(true);
11961645 gridPanel.setOneTouchExpandable(true);
11971646 gridPanel.setDividerLocation(1.0);
....@@ -1219,13 +1668,34 @@
12191668
12201669 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12211670 //tmp.setName("Edit");
1222
- objectPanel.add(materialPanel);
1223
- JPanel north = new JPanel(new BorderLayout());
1224
- north.setName("Edit");
1225
- north.add(ctrlPanel, BorderLayout.NORTH);
1226
- objectPanel.add(north);
1227
- objectPanel.add(infoPanel);
1671
+ objectPanel.add(toolboxPanel);
1672
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1673
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
12281674
1675
+ objectPanel.add(materialPanel);
1676
+ objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1677
+ objectPanel.setToolTipTextAt(1, "Material");
1678
+
1679
+ objectPanel.add(skyboxPanel);
1680
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1681
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1682
+
1683
+// JPanel north = new JPanel(new BorderLayout());
1684
+// north.setName("Edit");
1685
+// north.add(ctrlPanel, BorderLayout.NORTH);
1686
+// objectPanel.add(north);
1687
+ objectPanel.add(editPanel);
1688
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1689
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1690
+
1691
+ objectPanel.add(XYZPanel);
1692
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1693
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1694
+
1695
+ patchMaterial = true;
1696
+ cameraView.patchMaterial = this;
1697
+ objectPanel.setSelectedIndex(1);
1698
+
12291699 /*
12301700 aConstraints.gridx = 0;
12311701 aConstraints.gridwidth = 1;
....@@ -1233,7 +1703,7 @@
12331703 aConstraints.gridy += 1;
12341704 aConstraints.gridwidth = 1;
12351705 mainPanel.add(objectPanel, aConstraints);
1236
- */
1706
+ */
12371707
12381708 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12391709 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1244,17 +1714,29 @@
12441714 scrollpane.setWheelScrollingEnabled(true);
12451715 scrollpane.addMouseWheelListener(this); // Default not fast enough
12461716
1247
- /*JTabbedPane*/ jtp = new JTabbedPane();
1248
- jtp.add(scrollpane);
1717
+ /*JTabbedPane*/ scenePanel = new cGridBag();
1718
+ scenePanel.preferredWidth = 6;
1719
+
1720
+ JTabbedPane tabbedPane = new JTabbedPane();
1721
+ tabbedPane.add(scrollpane);
12491722
1250
- jtp.add(FSPane = new cFileSystemPane(this));
1251
-
1252
- optionsPanel = new JPanel(new GridBagLayout());
1723
+ optionsPanel = new cGridBag().setVertical(false);
12531724
12541725 optionsPanel.setName("Options");
1255
- jtp.add(optionsPanel);
1726
+
1727
+ AddOptions(optionsPanel); //, aConstraints);
1728
+
1729
+ tabbedPane.add(optionsPanel);
1730
+
1731
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
12561732
1733
+ scenePanel.add(tabbedPane);
12571734
1735
+ //if (Globals.ADVANCED)
1736
+// tabbedPane.add(infoPanel);
1737
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1738
+// tabbedPane.setToolTipTextAt(3, "Information");
1739
+
12581740 /*
12591741 cTree jTree = new cTree(null);
12601742 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1275,7 +1757,7 @@
12751757 jtp.add(tree);
12761758 */
12771759
1278
- bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jtp, gridPanel);
1760
+ bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel);
12791761 bigPanel.setContinuousLayout(true);
12801762 bigPanel.setOneTouchExpandable(true);
12811763 bigPanel.setDividerLocation(0.8);
....@@ -1287,6 +1769,7 @@
12871769 //bigPanel.setSize(new Dimension(10,10));
12881770 //bigPanel.add(ctrlPanel);
12891771 //bigPanel.add(gridPanel);
1772
+ /**
12901773 bigThree = new JPanel();
12911774 //big.setLayout(new FlowLayout(FlowLayout.LEFT));
12921775 bigThree.setLayout(new GridBagLayout()); //1,3,5,5));
....@@ -1297,20 +1780,26 @@
12971780 aWindowConstraints.fill = GridBagConstraints.VERTICAL;
12981781 aWindowConstraints.weightx = 0;
12991782 aWindowConstraints.weighty = 1;
1300
- bigThree.add(jtp, aWindowConstraints);
1783
+ bigThree.add(scenePanel, aWindowConstraints);
13011784 aWindowConstraints.weightx = 1;
13021785 aWindowConstraints.gridwidth = 3;
13031786 // aConstraints.gridheight = 3;
13041787 aWindowConstraints.gridx = 1;
13051788 aWindowConstraints.fill = GridBagConstraints.BOTH;
1306
- bigThree.add(cameraPanel, aWindowConstraints);
1789
+ bigThree.add(centralPanel, aWindowConstraints);
13071790 aWindowConstraints.weightx = 0;
13081791 aWindowConstraints.gridx = 4;
13091792 aWindowConstraints.gridwidth = 1;
13101793 // aConstraints.gridheight = 3;
13111794 aWindowConstraints.fill = GridBagConstraints.VERTICAL;
13121795 bigThree.add(XYZPanel, aWindowConstraints);
1796
+ /**/
13131797
1798
+ bigThree = new cGridBag();
1799
+ bigThree.addComponent(scenePanel);
1800
+ bigThree.addComponent(centralPanel);
1801
+ //bigThree.addComponent(XYZPanel);
1802
+
13141803 // // SIDE EFFECT!!!
13151804 // aConstraints.gridx = 0;
13161805 // aConstraints.gridy = 0;
....@@ -1318,33 +1807,55 @@
13181807 // aConstraints.gridheight = 1;
13191808
13201809 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1321
- framePanel.setContinuousLayout(true);
1322
- framePanel.setOneTouchExpandable(true);
1323
- framePanel.setDividerLocation(0.8);
1810
+
1811
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1812
+ new java.beans.PropertyChangeListener()
1813
+ {
1814
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1815
+ {
1816
+ if ((Integer)pce.getOldValue() == 1)
1817
+ {
1818
+ if (radio.layout != expandedLayout)
1819
+ {
1820
+ radio.layout = expandedLayout;
1821
+ radio.layout.doClick();
1822
+ }
1823
+ }
1824
+ }
1825
+ });
1826
+
1827
+ framePanel.setContinuousLayout(false);
1828
+ framePanel.setOneTouchExpandable(false);
1829
+ //.setDividerLocation(0.8);
13241830 //framePanel.setDividerSize(15);
13251831 //framePanel.setResizeWeight(0.15);
13261832 framePanel.setName("Frame");
13271833
13281834 frame.getContentPane().setLayout(new BorderLayout());
13291835 /**/
1330
- JTabbedPane worldPane = new JTabbedPane();
1836
+ //JTabbedPane worldPane = new JTabbedPane();
13311837 //worldPane.add(bigPanel);
13321838 //worldPane.add(worldPanel);
13331839 /**/
1334
- frame.getContentPane().add(/*"Center",*/framePanel);
1840
+ //frame.getContentPane().add(/*"Center",*/framePanel);
1841
+ frame.add(/*"Center",*/framePanel);
13351842 //frame.getContentPane().add(/*"Center",*/ worldPane);
13361843
1337
-// aConstraints = gbc; // (GridBagConstraints) GraphreeD.clone(gbc);
1844
+// aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13381845
1339
- frame.setSize(800, 600);
1340
- frame.show();
1341
-
1846
+ frame.setSize(1280, 860);
1847
+
1848
+ cameraView.requestFocusInWindow();
1849
+
13421850 gridPanel.setDividerLocation(1.0);
1851
+
1852
+ frame.validate();
1853
+
1854
+ frame.setVisible(true);
13431855
13441856 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13451857 frame.addWindowListener(new WindowAdapter()
13461858 {
1347
-
13481859 public void windowClosing(WindowEvent e)
13491860 {
13501861 Close();
....@@ -1352,6 +1863,10 @@
13521863 });
13531864 }
13541865
1866
+ void AddOptions(cGridBag panel) //, GridBagConstraints constraints)
1867
+ {
1868
+ }
1869
+
13551870 JTree GetTree()
13561871 {
13571872 return objEditor.jTree;
....@@ -1363,260 +1878,609 @@
13631878 ctrlPanel.removeAll();
13641879 }
13651880
1366
- void SetupMaterial(JPanel ctrlPanel)
1881
+ void SetupMaterial(cGridBag materialpanel)
13671882 {
1368
- aConstraints.weighty = 0;
1369
- //aConstraints.weightx = 1;
1370
- /*
1883
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1884
+
1885
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1886
+ skin.setToolTipText("Skin");
1887
+ skin.addMouseListener(new MouseAdapter()
1888
+ {
1889
+ public void mouseClicked(MouseEvent e)
1890
+ {
1891
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1892
+ cMaterial material = object.material;
1893
+
1894
+ // Skin
1895
+ colorField.setFloat(material.color);
1896
+ float saturation = material.modulation;
1897
+
1898
+ if (!cameraView.Skinshader)
1899
+ {
1900
+ saturation /= 1.5;
1901
+ }
1902
+
1903
+ saturationField.setFloat(saturation);
1904
+
1905
+ subsurfaceField.setFloat(material.subsurface);
1906
+ selfshadowField.setFloat(material.diffuseness);
1907
+ diffusenessField.setFloat(material.factor);
1908
+ shininessField.setFloat(material.shininess);
1909
+ shadowbiasField.setFloat(material.shadowbias);
1910
+ diffuseField.setFloat(material.diffuse);
1911
+ specularField.setFloat(material.specular);
1912
+
1913
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1914
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1915
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1916
+
1917
+ materialtouched = true;
1918
+ applySelf();
1919
+ }
1920
+ });
1921
+ presetpanel.add(skin);
1922
+
1923
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1924
+ lambert.setToolTipText("Diffuse");
1925
+ lambert.addMouseListener(new MouseAdapter()
1926
+ {
1927
+ public void mouseClicked(MouseEvent e)
1928
+ {
1929
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1930
+ cMaterial material = object.material;
1931
+
1932
+ diffusenessField.setFloat(material.factor);
1933
+ selfshadowField.setFloat(material.diffuseness);
1934
+
1935
+ materialtouched = true;
1936
+ applySelf();
1937
+ }
1938
+ });
1939
+ presetpanel.add(lambert);
1940
+
1941
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1942
+ diffuse2.setToolTipText("Diffuse2");
1943
+ diffuse2.addMouseListener(new MouseAdapter()
1944
+ {
1945
+ public void mouseClicked(MouseEvent e)
1946
+ {
1947
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1948
+ cMaterial material = object.material;
1949
+
1950
+ diffusenessField.setFloat(material.factor);
1951
+ selfshadowField.setFloat(material.diffuseness);
1952
+
1953
+ materialtouched = true;
1954
+ applySelf();
1955
+ }
1956
+ });
1957
+ presetpanel.add(diffuse2);
1958
+
1959
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1960
+ diffusemoon.setToolTipText("Moon");
1961
+ diffusemoon.addMouseListener(new MouseAdapter()
1962
+ {
1963
+ public void mouseClicked(MouseEvent e)
1964
+ {
1965
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1966
+ cMaterial material = object.material;
1967
+
1968
+ diffusenessField.setFloat(material.factor);
1969
+ selfshadowField.setFloat(material.diffuseness);
1970
+
1971
+ materialtouched = true;
1972
+ applySelf();
1973
+ }
1974
+ });
1975
+ presetpanel.add(diffusemoon);
1976
+
1977
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1978
+ diffusemoon2.setToolTipText("Moon2");
1979
+ diffusemoon2.addMouseListener(new MouseAdapter()
1980
+ {
1981
+ public void mouseClicked(MouseEvent e)
1982
+ {
1983
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1984
+ cMaterial material = object.material;
1985
+
1986
+ diffusenessField.setFloat(material.factor);
1987
+ selfshadowField.setFloat(material.diffuseness);
1988
+
1989
+ materialtouched = true;
1990
+ applySelf();
1991
+ }
1992
+ });
1993
+ presetpanel.add(diffusemoon2);
1994
+
1995
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1996
+ diffusemoon3.setToolTipText("Moon3");
1997
+ diffusemoon3.addMouseListener(new MouseAdapter()
1998
+ {
1999
+ public void mouseClicked(MouseEvent e)
2000
+ {
2001
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2002
+ cMaterial material = object.material;
2003
+
2004
+ diffusenessField.setFloat(material.factor);
2005
+ selfshadowField.setFloat(material.diffuseness);
2006
+
2007
+ materialtouched = true;
2008
+ applySelf();
2009
+ }
2010
+ });
2011
+ presetpanel.add(diffusemoon3);
2012
+
2013
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
2014
+ diffusesheen.setToolTipText("Sheen");
2015
+ diffusesheen.addMouseListener(new MouseAdapter()
2016
+ {
2017
+ public void mouseClicked(MouseEvent e)
2018
+ {
2019
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2020
+ cMaterial material = object.material;
2021
+
2022
+ sheenField.setFloat(material.sheen);
2023
+
2024
+ materialtouched = true;
2025
+ applySelf();
2026
+ }
2027
+ });
2028
+ presetpanel.add(diffusesheen);
2029
+
2030
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2031
+ rough.setToolTipText("Rough metal");
2032
+ rough.addMouseListener(new MouseAdapter()
2033
+ {
2034
+ public void mouseClicked(MouseEvent e)
2035
+ {
2036
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2037
+ cMaterial material = object.material;
2038
+
2039
+ shininessField.setFloat(material.shininess);
2040
+ velvetField.setFloat(material.velvet);
2041
+
2042
+ materialtouched = true;
2043
+ applySelf();
2044
+ }
2045
+ });
2046
+ presetpanel.add(rough);
2047
+
2048
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2049
+ rough2.setToolTipText("Medium metal");
2050
+ rough2.addMouseListener(new MouseAdapter()
2051
+ {
2052
+ public void mouseClicked(MouseEvent e)
2053
+ {
2054
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2055
+ cMaterial material = object.material;
2056
+
2057
+ shininessField.setFloat(material.shininess);
2058
+ lightareaField.setFloat(material.lightarea);
2059
+
2060
+ materialtouched = true;
2061
+ applySelf();
2062
+ }
2063
+ });
2064
+ presetpanel.add(rough2);
2065
+
2066
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2067
+ shini0.setToolTipText("Shiny");
2068
+ shini0.addMouseListener(new MouseAdapter()
2069
+ {
2070
+ public void mouseClicked(MouseEvent e)
2071
+ {
2072
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2073
+ cMaterial material = object.material;
2074
+
2075
+ shininessField.setFloat(material.shininess);
2076
+ lightareaField.setFloat(material.lightarea);
2077
+
2078
+ materialtouched = true;
2079
+ applySelf();
2080
+ }
2081
+ });
2082
+ presetpanel.add(shini0);
2083
+
2084
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2085
+ shini1.setToolTipText("Shiny2");
2086
+ shini1.addMouseListener(new MouseAdapter()
2087
+ {
2088
+ public void mouseClicked(MouseEvent e)
2089
+ {
2090
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2091
+ cMaterial material = object.material;
2092
+
2093
+ shininessField.setFloat(material.shininess);
2094
+ lightareaField.setFloat(material.lightarea);
2095
+
2096
+ materialtouched = true;
2097
+ applySelf();
2098
+ }
2099
+ });
2100
+ presetpanel.add(shini1);
2101
+
2102
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2103
+ shini2.setToolTipText("Shiny3");
2104
+ shini2.addMouseListener(new MouseAdapter()
2105
+ {
2106
+ public void mouseClicked(MouseEvent e)
2107
+ {
2108
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2109
+ cMaterial material = object.material;
2110
+
2111
+ shininessField.setFloat(material.shininess);
2112
+ lightareaField.setFloat(material.lightarea);
2113
+
2114
+ materialtouched = true;
2115
+ applySelf();
2116
+ }
2117
+ });
2118
+ presetpanel.add(shini2);
2119
+
2120
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2121
+ aniso.setToolTipText("AnisoU");
2122
+ aniso.addMouseListener(new MouseAdapter()
2123
+ {
2124
+ public void mouseClicked(MouseEvent e)
2125
+ {
2126
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2127
+ cMaterial material = object.material;
2128
+
2129
+ anisoField.setFloat(material.aniso);
2130
+ anisoVField.setFloat(material.anisoV);
2131
+
2132
+ materialtouched = true;
2133
+ applySelf();
2134
+ }
2135
+ });
2136
+ presetpanel.add(aniso);
2137
+
2138
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2139
+ aniso2.setToolTipText("AnisoV");
2140
+ aniso2.addMouseListener(new MouseAdapter()
2141
+ {
2142
+ public void mouseClicked(MouseEvent e)
2143
+ {
2144
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2145
+ cMaterial material = object.material;
2146
+
2147
+ anisoField.setFloat(material.aniso);
2148
+ anisoVField.setFloat(material.anisoV);
2149
+
2150
+ materialtouched = true;
2151
+ applySelf();
2152
+ }
2153
+ });
2154
+ presetpanel.add(aniso2);
2155
+
2156
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2157
+ aniso3.setToolTipText("AnisoUV");
2158
+ aniso3.addMouseListener(new MouseAdapter()
2159
+ {
2160
+ public void mouseClicked(MouseEvent e)
2161
+ {
2162
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2163
+ cMaterial material = object.material;
2164
+
2165
+ anisoField.setFloat(material.aniso);
2166
+ anisoVField.setFloat(material.anisoV);
2167
+
2168
+ materialtouched = true;
2169
+ applySelf();
2170
+ }
2171
+ });
2172
+ presetpanel.add(aniso3);
2173
+
2174
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2175
+ velvet0.setToolTipText("Velvet");
2176
+ velvet0.addMouseListener(new MouseAdapter()
2177
+ {
2178
+ public void mouseClicked(MouseEvent e)
2179
+ {
2180
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2181
+ cMaterial material = object.material;
2182
+
2183
+ diffusenessField.setFloat(material.factor);
2184
+ selfshadowField.setFloat(material.diffuseness);
2185
+ sheenField.setFloat(material.sheen);
2186
+ shininessField.setFloat(material.shininess);
2187
+ velvetField.setFloat(material.velvet);
2188
+ shiftField.setFloat(material.shift);
2189
+
2190
+ materialtouched = true;
2191
+ applySelf();
2192
+ }
2193
+ });
2194
+ presetpanel.add(velvet0);
2195
+
2196
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2197
+ bump0.setToolTipText("Bump texture");
2198
+ bump0.addMouseListener(new MouseAdapter()
2199
+ {
2200
+ public void mouseClicked(MouseEvent e)
2201
+ {
2202
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2203
+ cMaterial material = object.material;
2204
+
2205
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2206
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2207
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2208
+
2209
+ materialtouched = true;
2210
+ applySelf();
2211
+ }
2212
+ });
2213
+ presetpanel.add(bump0);
2214
+
2215
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2216
+ borderShader.setToolTipText("Border fade");
2217
+ borderShader.addMouseListener(new MouseAdapter()
2218
+ {
2219
+ public void mouseClicked(MouseEvent e)
2220
+ {
2221
+ borderfadeField.setFloat(0.5);
2222
+ opacityField.setFloat(0.75);
2223
+
2224
+ materialtouched = true;
2225
+ applySelf();
2226
+ }
2227
+ });
2228
+ presetpanel.add(borderShader);
2229
+
2230
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2231
+ halo.setToolTipText("Halo");
2232
+ halo.addMouseListener(new MouseAdapter()
2233
+ {
2234
+ public void mouseClicked(MouseEvent e)
2235
+ {
2236
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2237
+ cMaterial material = object.material;
2238
+
2239
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2240
+
2241
+ materialtouched = true;
2242
+ applySelf();
2243
+ }
2244
+ });
2245
+ presetpanel.add(halo);
2246
+
2247
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2248
+ candle.setToolTipText("Candle");
2249
+ candle.addMouseListener(new MouseAdapter()
2250
+ {
2251
+ public void mouseClicked(MouseEvent e)
2252
+ {
2253
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2254
+ cMaterial material = object.material;
2255
+
2256
+ subsurfaceField.setFloat(material.subsurface);
2257
+ shadowbiasField.setFloat(material.shadowbias);
2258
+ ambientField.setFloat(material.ambient);
2259
+ specularField.setFloat(material.specular);
2260
+ lightareaField.setFloat(material.lightarea);
2261
+ shininessField.setFloat(material.shininess);
2262
+
2263
+ materialtouched = true;
2264
+ applySelf();
2265
+ }
2266
+ });
2267
+ presetpanel.add(candle);
2268
+
2269
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2270
+ shadowShader.setToolTipText("Shadow");
2271
+ shadowShader.addMouseListener(new MouseAdapter()
2272
+ {
2273
+ public void mouseClicked(MouseEvent e)
2274
+ {
2275
+ diffuseField.setFloat(0.001);
2276
+ ambientField.setFloat(0.001);
2277
+ cameraField.setFloat(0.001);
2278
+ specularField.setFloat(0.001);
2279
+ fakedepthField.setFloat(0.001);
2280
+ opacityField.setFloat(0.6);
2281
+
2282
+ materialtouched = true;
2283
+ applySelf();
2284
+ }
2285
+ });
2286
+ presetpanel.add(shadowShader);
2287
+
2288
+ cGridBag panel = new cGridBag().setVertical(true);
2289
+
2290
+ presetpanel.preferredWidth = 1;
2291
+
2292
+ materialpanel.add(presetpanel);
2293
+ materialpanel.add(panel);
2294
+
2295
+ panel.preferredWidth = 8;
2296
+
2297
+ /*
13712298 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
13722299 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1373
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1374
- aConstraints.gridx += 1;
1375
- */
2300
+ */
13762301
1377
- aConstraints.gridwidth = 1;
1378
- ctrlPanel.add(createMaterialButton = new cButton("Create"), aConstraints);
1379
- aConstraints.gridx += 1;
1380
- aConstraints.weighty = 0;
1381
- aConstraints.gridwidth = 1;
2302
+ cGridBag editBar = new cGridBag().setVertical(false);
2303
+
2304
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2305
+ createMaterialButton.setToolTipText("Create material");
13822306
13832307 /*
13842308 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
1385
- aConstraints.gridx += 1;
1386
- aConstraints.weighty = 0;
1387
- aConstraints.gridwidth = 1;
13882309 */
13892310
1390
- ctrlPanel.add(clearMaterialButton = new cButton("Clear"), aConstraints);
1391
- aConstraints.gridx += 1;
2311
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2312
+ clearMaterialButton.setToolTipText("Clear material");
2313
+
2314
+ if (Globals.ADVANCED)
2315
+ {
2316
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2317
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
2318
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
2319
+ }
13922320
1393
- ctrlPanel.add(resetSlidersButton = new cButton("Reset"), aConstraints);
1394
-
1395
- aConstraints.gridx += 1;
1396
-
1397
- ctrlPanel.add(propagateToggle = new cCheckBox("Prop", propagate), aConstraints);
1398
-
1399
- aConstraints.gridx += 1;
1400
-
1401
- ctrlPanel.add(multiplyToggle = new cCheckBox("Mult", false), aConstraints);
1402
-
1403
- aConstraints.gridx = 0;
1404
- aConstraints.gridy += 1;
1405
- aConstraints.weighty = 0;
1406
- aConstraints.gridwidth = 1;
2321
+ editBar.preferredHeight = 15;
2322
+
2323
+ panel.add(editBar);
2324
+
14072325 /**/
14082326 //aConstraints.weighty = 0;
14092327 ////aConstraints.weightx = 1;
14102328 //aConstraints.weighty = 1;
14112329 aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
14122330 //aConstraints.gridx += 1;
1413
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1414
- aConstraints.weighty = 0;
1415
- aConstraints.gridx = 0;
1416
- aConstraints.gridy += 1;
1417
- aConstraints.gridwidth = 1;
2331
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14182332
1419
- ctrlPanel.add(colorLabel = new JLabel("Color/hue"), aConstraints);
1420
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1421
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1422
- aConstraints.gridx += 1;
1423
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1424
- //aConstraints.weightx = 0;
1425
- ctrlPanel.add(colorField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1426
- aConstraints.gridx = 0;
1427
- aConstraints.gridy += 1;
1428
- aConstraints.gridwidth = 1;
2333
+ cGridBag colorSection = new cGridBag().setVertical(true);
14292334
1430
- ctrlPanel.add(modulationLabel = new JLabel("Saturation"), aConstraints);
1431
- modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1432
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1433
- aConstraints.gridx += 1;
1434
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1435
- ctrlPanel.add(modulationField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1436
- aConstraints.gridx = 0;
1437
- aConstraints.gridy += 1;
1438
- aConstraints.gridwidth = 1;
2335
+ cGridBag huepanel = new cGridBag();
2336
+ cGridBag huelabel = new cGridBag();
2337
+ cLabel hue = GetLabel("icons/hue.png", false);
2338
+ hue.fit = true;
2339
+
2340
+ hue.addMouseListener(new MouseAdapter()
2341
+ {
2342
+ public void mousePressed(MouseEvent e)
2343
+ {
2344
+ int x = e.getX();
2345
+
2346
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2347
+ }
2348
+ });
2349
+
2350
+ huelabel.add(hue);
2351
+ huelabel.preferredWidth = 20;
2352
+ huepanel.add(new cGridBag()); // Label
2353
+ huepanel.add(huelabel); // Field/slider
2354
+
2355
+ huepanel.preferredHeight = 7;
14392356
1440
- ctrlPanel.add(textureLabel = new JLabel("Texture"), aConstraints);
1441
- textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1442
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1443
- aConstraints.gridx += 1;
1444
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1445
- ctrlPanel.add(textureField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1446
- aConstraints.gridx = 0;
1447
- aConstraints.gridy += 1;
1448
- aConstraints.gridwidth = 1;
2357
+ colorSection.add(huepanel);
2358
+
2359
+ cGridBag color = new cGridBag();
2360
+
2361
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2362
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2363
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14492364
1450
- ctrlPanel.add(anisoLabel = new JLabel("AnisoU"), aConstraints);
1451
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1452
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1453
- aConstraints.gridx += 1;
1454
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1455
- ctrlPanel.add(anisoField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1456
- aConstraints.gridx = 0;
1457
- aConstraints.gridy += 1;
1458
- aConstraints.gridwidth = 1;
2365
+ //colorField.preferredWidth = 200;
2366
+ colorSection.add(color);
14592367
1460
- ctrlPanel.add(anisoVLabel = new JLabel("AnisoV"), aConstraints);
1461
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1462
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1463
- aConstraints.gridx += 1;
1464
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1465
- ctrlPanel.add(anisoVField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1466
- aConstraints.gridx = 0;
1467
- aConstraints.gridy += 1;
1468
- aConstraints.gridwidth = 1;
2368
+ cGridBag modulation = new cGridBag();
2369
+ modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
2370
+ modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2371
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2372
+ colorSection.add(modulation);
14692373
1470
- ctrlPanel.add(shadowbiasLabel = new JLabel("Shadowbias"), aConstraints);
1471
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1472
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1473
- aConstraints.gridx += 1;
1474
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1475
- ctrlPanel.add(shadowbiasField = new NumberSlider(0.001, 50, -1), aConstraints);
1476
- aConstraints.gridx = 0;
1477
- aConstraints.gridy += 1;
1478
- aConstraints.gridwidth = 1;
2374
+ cGridBag opacity = new cGridBag();
2375
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2376
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2377
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2378
+ colorSection.add(opacity);
14792379
1480
- //aConstraints.weighty = 1;
1481
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
1482
- //aConstraints.gridx += 1;
1483
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1484
- aConstraints.weighty = 0;
1485
- aConstraints.gridx = 0;
1486
- aConstraints.gridy += 1;
1487
- aConstraints.gridwidth = 1;
2380
+ colorSection.add(GetSeparator());
2381
+
2382
+ cGridBag texture = new cGridBag();
2383
+ texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
2384
+ textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2385
+ texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2386
+ colorSection.add(texture);
14882387
1489
- ctrlPanel.add(diffuseLabel = new JLabel("Diffuse"), aConstraints);
1490
- diffuseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1491
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1492
- aConstraints.gridx += 1;
1493
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1494
- ctrlPanel.add(diffuseField = new NumberSlider(0.001, 50, -1), aConstraints);
1495
- aConstraints.gridx = 0;
1496
- aConstraints.gridy += 1;
1497
- aConstraints.gridwidth = 1;
2388
+ panel.add(GetSeparator());
2389
+
2390
+ panel.add(colorSection);
2391
+
2392
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
2393
+
2394
+ cGridBag diffuseSection = new cGridBag().setVertical(true);
2395
+
2396
+ cGridBag diffuse = new cGridBag();
2397
+ diffuse.add(diffuseLabel = new JLabel("Diffuse")); // , aConstraints);
2398
+ diffuseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2399
+ diffuse.add(diffuseField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2400
+ diffuseSection.add(diffuse);
14982401
1499
- ctrlPanel.add(diffusenessLabel = new JLabel("Diffusion"), aConstraints);
1500
- diffusenessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1501
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1502
- aConstraints.gridx += 1;
1503
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1504
- ctrlPanel.add(diffusenessField = new NumberSlider(0.001, 50, -1), aConstraints);
1505
- aConstraints.gridx = 0;
1506
- aConstraints.gridy += 1;
1507
- aConstraints.gridwidth = 1;
2402
+ cGridBag diffuseness = new cGridBag();
2403
+ diffuseness.add(diffusenessLabel = new JLabel("Diffusion")); // , aConstraints);
2404
+ diffusenessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2405
+ diffuseness.add(diffusenessField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2406
+ diffuseSection.add(diffuseness);
15082407
1509
- ctrlPanel.add(selfshadowLabel = new JLabel("Selfshadow"), aConstraints);
1510
- selfshadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1511
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1512
- aConstraints.gridx += 1;
1513
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1514
- ctrlPanel.add(selfshadowField = new NumberSlider(0.001, 50, -1), aConstraints);
1515
- aConstraints.gridx = 0;
1516
- aConstraints.gridy += 1;
1517
- aConstraints.gridwidth = 1;
2408
+ cGridBag selfshadow = new cGridBag();
2409
+ selfshadow.add(selfshadowLabel = new JLabel("Selfshadow")); // , aConstraints);
2410
+ selfshadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2411
+ selfshadow.add(selfshadowField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2412
+ diffuseSection.add(selfshadow);
15182413
1519
- ctrlPanel.add(sheenLabel = new JLabel("Sheen"), aConstraints);
1520
- sheenLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1521
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1522
- aConstraints.gridx += 1;
1523
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1524
- ctrlPanel.add(sheenField = new NumberSlider(0.001, 50, -1), aConstraints);
1525
- aConstraints.gridx = 0;
1526
- aConstraints.gridy += 1;
1527
- aConstraints.gridwidth = 1;
2414
+ cGridBag sheen = new cGridBag();
2415
+ sheen.add(sheenLabel = new JLabel("Sheen")); // , aConstraints);
2416
+ sheenLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2417
+ sheen.add(sheenField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2418
+ diffuseSection.add(sheen);
15282419
1529
- ctrlPanel.add(subsurfaceLabel = new JLabel("Subsurface"), aConstraints);
1530
- subsurfaceLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1531
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1532
- aConstraints.gridx += 1;
1533
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1534
- ctrlPanel.add(subsurfaceField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1535
- aConstraints.gridx = 0;
1536
- aConstraints.gridy += 1;
1537
- aConstraints.gridwidth = 1;
2420
+ cGridBag subsurface = new cGridBag();
2421
+ subsurface.add(subsurfaceLabel = new JLabel("Subsurface")); // , aConstraints);
2422
+ subsurfaceLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2423
+ subsurface.add(subsurfaceField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2424
+ diffuseSection.add(subsurface);
15382425
1539
- ctrlPanel.add(shadowLabel = new JLabel("Shadowing"), aConstraints);
1540
- shadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1541
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1542
- aConstraints.gridx += 1;
1543
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1544
- ctrlPanel.add(shadowField = new NumberSlider(0.001, 50, -1), aConstraints);
1545
- aConstraints.gridx = 0;
1546
- aConstraints.gridy += 1;
1547
- aConstraints.gridwidth = 1;
2426
+ cGridBag shadow = new cGridBag();
2427
+ shadow.add(shadowLabel = new JLabel("Shadowing")); // , aConstraints);
2428
+ shadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2429
+ shadow.add(shadowField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2430
+ diffuseSection.add(shadow);
15482431
1549
- ctrlPanel.add(fakedepthLabel = new JLabel("Fakedepth"), aConstraints);
1550
- fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1551
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1552
- aConstraints.gridx += 1;
1553
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1554
- ctrlPanel.add(fakedepthField = new NumberSlider(0.001, 50, -1), aConstraints);
1555
- aConstraints.gridx = 0;
1556
- aConstraints.gridy += 1;
1557
- aConstraints.gridwidth = 1;
2432
+ cGridBag fakedepth = new cGridBag();
2433
+ fakedepth.add(fakedepthLabel = new JLabel("Fakedepth")); // , aConstraints);
2434
+ fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2435
+ fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2436
+ diffuseSection.add(fakedepth);
15582437
1559
- //aConstraints.weighty = 1;
1560
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
1561
- //aConstraints.gridx += 1;
1562
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1563
- aConstraints.weighty = 0;
1564
- aConstraints.gridx = 0;
1565
- aConstraints.gridy += 1;
1566
- aConstraints.gridwidth = 1;
2438
+ cGridBag shadowbias = new cGridBag();
2439
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2440
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2441
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2442
+ diffuseSection.add(shadowbias);
15672443
1568
- ctrlPanel.add(specularLabel = new JLabel("Specular"), aConstraints);
1569
- specularLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1570
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1571
- aConstraints.gridx += 1;
1572
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1573
- ctrlPanel.add(specularField = new NumberSlider(0.001, 50, -1), aConstraints);
1574
- aConstraints.gridx = 0;
1575
- aConstraints.gridy += 1;
1576
- aConstraints.gridwidth = 1;
2444
+ panel.add(GetSeparator());
2445
+
2446
+ panel.add(diffuseSection);
2447
+
2448
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
2449
+
2450
+ cGridBag specularSection = new cGridBag().setVertical(true);
15772451
1578
- ctrlPanel.add(lightareaLabel = new JLabel("Lightarea"), aConstraints);
1579
- lightareaLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1580
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1581
- aConstraints.gridx += 1;
1582
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1583
- ctrlPanel.add(lightareaField = new NumberSlider(0.001, 50, -1), aConstraints);
1584
- aConstraints.gridx = 0;
1585
- aConstraints.gridy += 1;
1586
- aConstraints.gridwidth = 1;
2452
+ cGridBag specular = new cGridBag();
2453
+ specular.add(specularLabel = new JLabel("Specular")); // , aConstraints);
2454
+ specularLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2455
+ specular.add(specularField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2456
+ specularSection.add(specular);
15872457
1588
- ctrlPanel.add(shininessLabel = new JLabel("Roughness"), aConstraints);
1589
- shininessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1590
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1591
- aConstraints.gridx += 1;
1592
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1593
- ctrlPanel.add(shininessField = new NumberSlider(0.001, 50, -1), aConstraints);
1594
- aConstraints.gridx = 0;
1595
- aConstraints.gridy += 1;
1596
- aConstraints.gridwidth = 1;
2458
+ cGridBag lightarea = new cGridBag();
2459
+ lightarea.add(lightareaLabel = new JLabel("Lightarea")); // , aConstraints);
2460
+ lightareaLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2461
+ lightarea.add(lightareaField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2462
+ specularSection.add(lightarea);
15972463
1598
- ctrlPanel.add(metalnessLabel = new JLabel("Metalness"), aConstraints);
1599
- metalnessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1600
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1601
- aConstraints.gridx += 1;
1602
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1603
- ctrlPanel.add(metalnessField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1604
- aConstraints.gridx = 0;
1605
- aConstraints.gridy += 1;
1606
- aConstraints.gridwidth = 1;
2464
+ cGridBag shininess = new cGridBag();
2465
+ shininess.add(shininessLabel = new JLabel("Roughness")); // , aConstraints);
2466
+ shininessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2467
+ shininess.add(shininessField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2468
+ specularSection.add(shininess);
16072469
1608
- ctrlPanel.add(velvetLabel = new JLabel("Velvet"), aConstraints);
1609
- velvetLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1610
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1611
- aConstraints.gridx += 1;
1612
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1613
- ctrlPanel.add(velvetField = new NumberSlider(0.001, 50, -1), aConstraints);
1614
- aConstraints.gridx = 0;
1615
- aConstraints.gridy += 1;
1616
- aConstraints.gridwidth = 1;
2470
+ cGridBag metalness = new cGridBag();
2471
+ metalness.add(metalnessLabel = new JLabel("Metalness")); // , aConstraints);
2472
+ metalnessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2473
+ metalness.add(metalnessField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2474
+ specularSection.add(metalness);
16172475
1618
- shiftField = AddSlider(ctrlPanel, "Shift", 0.001, 50, copy.material.shift, -1);
1619
- Return();
2476
+ cGridBag velvet = new cGridBag();
2477
+ velvet.add(velvetLabel = new JLabel("Velvet")); // , aConstraints);
2478
+ velvetLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2479
+ velvet.add(velvetField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2480
+ specularSection.add(velvet);
2481
+
2482
+ shiftField = (cNumberSlider)AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1).getComponent(1);
2483
+ //Return();
16202484 // ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
16212485 // shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16222486 // aConstraints.fill = GridBagConstraints.HORIZONTAL;
....@@ -1627,130 +2491,99 @@
16272491 // aConstraints.gridy += 1;
16282492 // aConstraints.gridwidth = 1;
16292493
1630
- //aConstraints.weighty = 1;
1631
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
1632
- //aConstraints.gridx += 1;
1633
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1634
- aConstraints.weighty = 0;
1635
- aConstraints.gridx = 0;
1636
- aConstraints.gridy += 1;
1637
- aConstraints.gridwidth = 1;
2494
+ cGridBag anisoU = new cGridBag();
2495
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2496
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2497
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2498
+ specularSection.add(anisoU);
16382499
1639
- ctrlPanel.add(cameraLabel = new JLabel("GlobalLight"), aConstraints);
1640
- cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1641
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1642
- aConstraints.gridx += 1;
1643
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1644
- ctrlPanel.add(cameraField = new NumberSlider(0.001, 50, -1), aConstraints);
1645
- aConstraints.gridx = 0;
1646
- aConstraints.gridy += 1;
1647
- aConstraints.gridwidth = 1;
2500
+ cGridBag anisoV = new cGridBag();
2501
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2502
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2503
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2504
+ specularSection.add(anisoV);
16482505
1649
- ctrlPanel.add(ambientLabel = new JLabel("Ambient"), aConstraints);
1650
- ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1651
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1652
- aConstraints.gridx += 1;
1653
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1654
- ctrlPanel.add(ambientField = new NumberSlider(0.001, 50, -1), aConstraints);
1655
- aConstraints.gridx = 0;
1656
- aConstraints.gridy += 1;
1657
- aConstraints.gridwidth = 1;
16582506
1659
- ctrlPanel.add(backlitLabel = new JLabel("Backlit"), aConstraints);
1660
- backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1661
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1662
- aConstraints.gridx += 1;
1663
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1664
- ctrlPanel.add(backlitField = new NumberSlider(0.001, 50, -1), aConstraints);
1665
- aConstraints.gridx = 0;
1666
- aConstraints.gridy += 1;
1667
- aConstraints.gridwidth = 1;
2507
+ panel.add(GetSeparator());
2508
+
2509
+ panel.add(specularSection);
2510
+
2511
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
2512
+
2513
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16682514
1669
- ctrlPanel.add(opacityLabel = new JLabel("Opacity"), aConstraints);
1670
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1671
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1672
- aConstraints.gridx += 1;
1673
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1674
- ctrlPanel.add(opacityField = new NumberSlider(0.001, 1, -0.1), aConstraints);
1675
- aConstraints.gridx = 0;
1676
- aConstraints.gridy += 1;
1677
- aConstraints.gridwidth = 1;
1678
- aConstraints.weighty = 0;
2515
+ cGridBag camera = new cGridBag();
2516
+ camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
2517
+ cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2518
+ camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2519
+ colorSection.add(camera);
16792520
1680
- ctrlPanel.add(bumpLabel = new JLabel("Bump"), aConstraints);
1681
- bumpLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1682
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1683
- aConstraints.gridx += 1;
1684
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1685
- ctrlPanel.add(bumpField = new NumberSlider(0.0, 2), aConstraints);
1686
- aConstraints.gridx = 0;
1687
- aConstraints.gridy += 1;
1688
- aConstraints.gridwidth = 1;
2521
+ cGridBag ambient = new cGridBag();
2522
+ ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
2523
+ ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2524
+ ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2525
+ colorSection.add(ambient);
16892526
1690
- ctrlPanel.add(noiseLabel = new JLabel("Noise"), aConstraints);
1691
- noiseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1692
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1693
- aConstraints.gridx += 1;
1694
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1695
- ctrlPanel.add(noiseField = new NumberSlider(0.0, 1/*5*/), aConstraints);
1696
- aConstraints.gridx = 0;
1697
- aConstraints.gridy += 1;
1698
- aConstraints.gridwidth = 1;
2527
+ cGridBag backlit = new cGridBag();
2528
+ backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
2529
+ backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2530
+ backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2531
+ colorSection.add(backlit);
16992532
1700
- ctrlPanel.add(powerLabel = new JLabel("Turbulance"), aConstraints);
1701
- powerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1702
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1703
- aConstraints.gridx += 1;
1704
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1705
- ctrlPanel.add(powerField = new NumberSlider(0.0, 5), aConstraints);
1706
- aConstraints.gridx = 0;
1707
- aConstraints.gridy += 1;
1708
- aConstraints.gridwidth = 1;
2533
+ //panel.add(new JSeparator());
2534
+
2535
+ //panel.add(globalSection);
2536
+
2537
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
2538
+
2539
+ cGridBag textureSection = new cGridBag().setVertical(true);
17092540
1710
- ctrlPanel.add(borderfadeLabel = new JLabel("Borderfade"), aConstraints);
1711
- borderfadeLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1712
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1713
- aConstraints.gridx += 1;
1714
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1715
- ctrlPanel.add(borderfadeField = new NumberSlider(0.0, 2), aConstraints);
1716
- aConstraints.gridx = 0;
1717
- aConstraints.gridy += 1;
1718
- aConstraints.gridwidth = 1;
2541
+ cGridBag bump = new cGridBag();
2542
+ bump.add(bumpLabel = new JLabel("Bump")); // , aConstraints);
2543
+ bumpLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2544
+ bump.add(bumpField = new cNumberSlider(this, 0.0, 2)); // , aConstraints);
2545
+ textureSection.add(bump);
17192546
1720
- ctrlPanel.add(fogLabel = new JLabel("Punch"), aConstraints);
1721
- fogLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1722
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1723
- aConstraints.gridx += 1;
1724
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1725
- ctrlPanel.add(fogField = new NumberSlider(0.0, 20), aConstraints);
1726
- aConstraints.gridx = 0;
1727
- aConstraints.gridy += 1;
1728
- aConstraints.gridwidth = 1;
2547
+ cGridBag noise = new cGridBag();
2548
+ noise.add(noiseLabel = new JLabel("Noise")); // , aConstraints);
2549
+ noiseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2550
+ noise.add(noiseField = new cNumberSlider(this, 0.0, 1/*5*/)); // , aConstraints);
2551
+ textureSection.add(noise);
17292552
1730
- ctrlPanel.add(opacityPowerLabel = new JLabel("Halo"), aConstraints);
1731
- opacityPowerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1732
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1733
- aConstraints.gridx += 1;
1734
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1735
- ctrlPanel.add(opacityPowerField = new NumberSlider(0.0, 10 /*10 dec 2013*/), aConstraints);
1736
- aConstraints.gridx = 0;
1737
- aConstraints.gridy += 1;
1738
- aConstraints.gridwidth = 1;
2553
+ cGridBag power = new cGridBag();
2554
+ power.add(powerLabel = new JLabel("Turbulance")); // , aConstraints);
2555
+ powerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2556
+ power.add(powerField = new cNumberSlider(this, 0.0, 5)); // , aConstraints);
2557
+ textureSection.add(power);
17392558
1740
- //aConstraints.weighty = 1;
1741
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
1742
- //aConstraints.gridx += 1;
1743
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1744
- aConstraints.weighty = 0;
2559
+ cGridBag borderfade = new cGridBag();
2560
+ borderfade.add(borderfadeLabel = new JLabel("Borderfade")); // , aConstraints);
2561
+ borderfadeLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2562
+ borderfade.add(borderfadeField = new cNumberSlider(this, 0.0, 2)); // , aConstraints);
2563
+ textureSection.add(borderfade);
17452564
1746
- aConstraints.gridx = 0;
1747
- aConstraints.gridy = 0;
1748
- aConstraints.gridwidth = 1;
2565
+ cGridBag fog = new cGridBag();
2566
+ fog.add(fogLabel = new JLabel("Punch")); // , aConstraints);
2567
+ fogLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2568
+ fog.add(fogField = new cNumberSlider(this, 0.0, 20)); // , aConstraints);
2569
+ textureSection.add(fog);
2570
+
2571
+ cGridBag opacityPower = new cGridBag();
2572
+ opacityPower.add(opacityPowerLabel = new JLabel("Halo")); // , aConstraints);
2573
+ opacityPowerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2574
+ opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
2575
+ textureSection.add(opacityPower);
2576
+
2577
+ panel.add(GetSeparator());
2578
+
2579
+ panel.add(textureSection);
2580
+
2581
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17492582
17502583 SetMaterial(copy); // .GetMaterial());
17512584
1752
- colorField.addChangeListener(this);
1753
- modulationField.addChangeListener(this);
2585
+ //colorField.addChangeListener(this);
2586
+// modulationField.addChangeListener(this);
17542587 metalnessField.addChangeListener(this);
17552588 diffuseField.addChangeListener(this);
17562589 specularField.addChangeListener(this);
....@@ -1780,12 +2613,15 @@
17802613 opacityPowerField.addChangeListener(this);
17812614 /**/
17822615
1783
- resetSlidersButton.addActionListener(this);
17842616 clearMaterialButton.addActionListener(this);
17852617 createMaterialButton.addActionListener(this);
1786
-
1787
- propagateToggle.addItemListener(this);
1788
- multiplyToggle.addItemListener(this);
2618
+
2619
+ if (Globals.ADVANCED)
2620
+ {
2621
+ resetSlidersButton.addActionListener(this);
2622
+ propagateToggle.addItemListener(this);
2623
+ multiplyToggle.addItemListener(this);
2624
+ }
17892625 }
17902626
17912627 void DropFile(java.io.File[] files, boolean textures)
....@@ -1803,8 +2639,9 @@
18032639 // 3D models
18042640 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
18052641 {
1806
- lastConverter = new com.jmex.model.converters.MaxToJme();
1807
- LoadFile(filename, lastConverter);
2642
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2643
+ //LoadFile(filename, lastConverter);
2644
+ LoadObjFile(filename); // New 3ds loader
18082645 continue;
18092646 }
18102647 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1859,19 +2696,21 @@
18592696 }
18602697
18612698 // Images/textures
1862
- if (textures
1863
- && (filename.toLowerCase().endsWith(".jpg")
1864
- || filename.toLowerCase().endsWith(".jpeg")
1865
- || filename.toLowerCase().endsWith(".gif")
1866
- || filename.toLowerCase().endsWith(".png")
1867
- || filename.toLowerCase().endsWith(".tre")
1868
- || filename.toLowerCase().endsWith(".bmp")
1869
- || filename.toLowerCase().endsWith(".tga")
1870
- || filename.toLowerCase().endsWith(".sgi")
1871
- || filename.toLowerCase().endsWith(".tif")
1872
- || filename.toLowerCase().endsWith(".tiff")))
2699
+ if (filename.toLowerCase().endsWith(".jpg")
2700
+ || filename.toLowerCase().endsWith(".jpeg")
2701
+ || filename.toLowerCase().endsWith(".gif")
2702
+ || filename.toLowerCase().endsWith(".png")
2703
+ || filename.toLowerCase().endsWith(".tre")
2704
+ || filename.toLowerCase().endsWith(".bmp")
2705
+ || filename.toLowerCase().endsWith(".tga")
2706
+ || filename.toLowerCase().endsWith(".sgi")
2707
+ || filename.toLowerCase().endsWith(".tif")
2708
+ || filename.toLowerCase().endsWith(".tiff"))
18732709 {
1874
- DropTexture(filename);
2710
+ if (textures)
2711
+ DropTexture(filename);
2712
+ else
2713
+ CreateBillboard(filename);
18752714 continue;
18762715 }
18772716
....@@ -1880,6 +2719,60 @@
18802719 }
18812720
18822721 ResetModel();
2722
+ }
2723
+
2724
+ void CreateBillboard(String filename)
2725
+ {
2726
+ Object3D source = null;
2727
+ Object3D group = copy;
2728
+
2729
+ if (group.selection.size() > 0)
2730
+ {
2731
+ source = group.selection.get(0);
2732
+ }
2733
+
2734
+ Grid grid = new Grid(1,1);
2735
+ grid.material = null;
2736
+
2737
+ grid.toParent = LA.newMatrix();
2738
+ grid.fromParent = LA.newMatrix();
2739
+ LA.matYRotate(grid.toParent, Math.PI/2);
2740
+ LA.matXRotate(grid.toParent, -Math.PI/2);
2741
+ LA.matXRotate(grid.fromParent, Math.PI/2);
2742
+ LA.matYRotate(grid.fromParent, -Math.PI/2);
2743
+
2744
+ BillboardNode bb = new BillboardNode();
2745
+ bb.addChild(grid);
2746
+
2747
+ Object3D newgroup = new Object3D();
2748
+ newgroup.CreateMaterial();
2749
+
2750
+ File file = new File(filename);
2751
+ newgroup.name = file.getName();
2752
+ newgroup.addChild(bb);
2753
+
2754
+ Object3D main = newgroup;
2755
+
2756
+ main.SetPigmentTexture(filename);
2757
+
2758
+ if (source != null)
2759
+ {
2760
+ main.material = new cMaterial(source.material);
2761
+ if (main.projectedVertices.length < source.projectedVertices.length)
2762
+ {
2763
+ main.projectedVertices = new Object3D.cVector2[source.projectedVertices.length];
2764
+ }
2765
+
2766
+ for (int i=0; i<source.projectedVertices.length; i++)
2767
+ {
2768
+ main.projectedVertices[i].x = source.projectedVertices[i].x;
2769
+ main.projectedVertices[i].y = source.projectedVertices[i].y;
2770
+ }
2771
+
2772
+ main.texres = source.texres;
2773
+ }
2774
+
2775
+ makeSomething(newgroup, false);
18832776 }
18842777
18852778 Point location;
....@@ -1900,7 +2793,7 @@
19002793
19012794 //? flashIt = false;
19022795 CameraPane pane = (CameraPane) cameraView;
1903
- pane.clickStart(location.x, location.y, 0);
2796
+ pane.clickStart(location.x, location.y, 0, 0);
19042797 pane.clickEnd(location.x, location.y, 0, true);
19052798
19062799 if (group.selection.size() == 1)
....@@ -1949,6 +2842,7 @@
19492842 e2.printStackTrace();
19502843 }
19512844 }
2845
+
19522846 LoadJMEThread loadThread;
19532847
19542848 class LoadJMEThread extends Thread
....@@ -2006,6 +2900,7 @@
20062900 //LoadFile0(filename, converter);
20072901 }
20082902 }
2903
+
20092904 LoadOBJThread loadObjThread;
20102905
20112906 class LoadOBJThread extends Thread
....@@ -2084,19 +2979,19 @@
20842979
20852980 void LoadObjFile(String fullname)
20862981 {
2087
- /*
2982
+ System.out.println("Loading " + fullname);
2983
+ /**/
20882984 //lastFilename = fullname;
20892985 if(loadObjThread == null)
20902986 {
2091
- loadObjThread = new LoadOBJThread();
2092
- loadObjThread.start();
2987
+ loadObjThread = new LoadOBJThread();
2988
+ loadObjThread.start();
20932989 }
20942990
20952991 loadObjThread.add(fullname);
2096
- */
2992
+ /**/
20972993
2098
- System.out.println("Loading " + fullname);
2099
- makeSomething(new FileObject(fullname, true), true);
2994
+ //makeSomething(new FileObject(fullname, true), true);
21002995 }
21012996
21022997 void LoadGFDFile(String fullname)
....@@ -2138,6 +3033,8 @@
21383033 {
21393034 Mocap sel = (Mocap) copy.selection.get(0);
21403035
3036
+ sel.SetCurrentBones(sel.frame);
3037
+
21413038 sel.fullname = fullname;
21423039
21433040 if (changename)
....@@ -2151,14 +3048,18 @@
21513048 sel.smoothed = false;
21523049
21533050 // if (!changename)
2154
- sel.SetPositionDelta(false, true, true, true/*?*/); // false
3051
+ //sel.SetPositionDelta(false, true, true, true/*?*/); // false
3052
+ sel.SetGlobalTransform();
3053
+ sel.LoadData();
3054
+ sel.Rewind();
3055
+ sel.Fade();
21553056 // sel.setPose(0);
21563057 refreshContents();
21573058 } else
21583059 {
21593060 mocap.Reset();
21603061 // new skeleton
2161
- makeSomething(mocap, false); // true);
3062
+ makeSomething(mocap, true); // true);
21623063 }
21633064 } catch (Exception e)
21643065 {
....@@ -2185,6 +3086,8 @@
21853086 {
21863087 Mocap sel = (Mocap) select;
21873088
3089
+ sel.SetCurrentBones(sel.frame);
3090
+
21883091 File file = new File(fullname);
21893092
21903093 // Mocap mocap = new Mocap("Mocap" + file.getName());
....@@ -2251,7 +3154,11 @@
22513154
22523155 if (!changename)
22533156 {
2254
- sel.SetPositionDelta(false, true, true, true/*?*/);
3157
+ //sel.SetPositionDelta(false, true, true, true/*?*/);
3158
+ sel.SetGlobalTransform();
3159
+ sel.LoadData();
3160
+ sel.Rewind();
3161
+ sel.Fade();
22553162 }
22563163
22573164 // sel.setPose(0);
....@@ -2345,11 +3252,11 @@
23453252
23463253 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23473254 {
2348
- if (GraphreeD.standAlone)
3255
+ if (Grafreed.standAlone)
23493256 {
23503257 /**/
23513258 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2352
- browser.show();
3259
+ browser.setVisible(true);
23533260 String filename = browser.getFile();
23543261 if (filename != null && filename.length() > 0)
23553262 {
....@@ -2460,6 +3367,7 @@
24603367 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24613368 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24623369 }
3370
+
24633371 //cJME.count++;
24643372 //cJME.count %= 12;
24653373 if (gc)
....@@ -2494,6 +3402,7 @@
24943402 }
24953403 if (input == null)
24963404 {
3405
+ new Exception().printStackTrace();
24973406 System.exit(0);
24983407 }
24993408
....@@ -2642,6 +3551,7 @@
26423551 }
26433552 }
26443553 }
3554
+
26453555 cFileSystemPane FSPane;
26463556
26473557 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2651,7 +3561,7 @@
26513561
26523562 freezematerial = true;
26533563 colorField.setFloat(mat.color);
2654
- modulationField.setFloat(mat.modulation);
3564
+ saturationField.setFloat(mat.modulation);
26553565 metalnessField.setFloat(mat.metalness);
26563566 diffuseField.setFloat(mat.diffuse);
26573567 specularField.setFloat(mat.specular);
....@@ -2695,11 +3605,14 @@
26953605 }
26963606 }
26973607 }
3608
+
26983609 freezematerial = false;
26993610 }
27003611
27013612 void SetMaterial(Object3D object)
27023613 {
3614
+ latestObject = object;
3615
+
27033616 cMaterial mat = object.material;
27043617
27053618 if (mat == null)
....@@ -2708,33 +3621,10 @@
27083621 return;
27093622 }
27103623
2711
- multiplyToggle.setSelected(mat.multiply);
2712
-
2713
- assert (object.projectedVertices != null);
2714
-
2715
- if (object.projectedVertices.length <= 2)
2716
- {
2717
- // Side effect...
2718
- Object3D.cVector2[] keep = object.projectedVertices;
2719
- object.projectedVertices = new Object3D.cVector2[3];
2720
- for (int i = 0; i < 3; i++)
2721
- {
2722
- if (i < keep.length)
2723
- {
2724
- object.projectedVertices[i] = keep[i];
2725
- } else
2726
- {
2727
- object.projectedVertices[i] = new Object3D.cVector2();
2728
- }
2729
- /*
2730
- if(keep.length == 0)
2731
- object.projectedVertices[0] = new Object3D.cVector2();
2732
- else
2733
- object.projectedVertices[0] = keep[0];
2734
- object.projectedVertices[1] = new Object3D.cVector2();
2735
- */
2736
- }
2737
- }
3624
+ if (multiplyToggle != null)
3625
+ multiplyToggle.setSelected(mat.multiply);
3626
+
3627
+ AllocProjectedVertices(object);
27383628
27393629 SetMaterial(mat, object.projectedVertices);
27403630 }
....@@ -2810,12 +3700,17 @@
28103700 // }
28113701
28123702 /**/
2813
- if (deselect)
3703
+ if (deselect || child == null)
28143704 {
28153705 //group.deselectAll();
28163706 //freeze = true;
28173707 GetTree().clearSelection();
28183708 //freeze = false;
3709
+
3710
+ if (child == null)
3711
+ {
3712
+ return;
3713
+ }
28193714 }
28203715
28213716 //group.addSelectee(child);
....@@ -2849,6 +3744,17 @@
28493744 public void itemStateChanged(ItemEvent event)
28503745 {
28513746 // System.out.println("Propagate = " + propagate);
3747
+ if (event.getSource() == pinButton)
3748
+ {
3749
+ copy.pinned ^= true;
3750
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3751
+ {
3752
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3753
+ copy.CloseUI();
3754
+ //copy.editWindow.refreshContents();
3755
+ }
3756
+ }
3757
+ else
28523758 if (event.getSource() == propagateToggle)
28533759 {
28543760 propagate ^= true;
....@@ -2884,31 +3790,48 @@
28843790 cameraView.ToggleDL();
28853791 cameraView.repaint();
28863792 return;
2887
- } else if (event.getSource() == toggleTextureItem)
3793
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28883794 {
28893795 cameraView.ToggleTexture();
28903796 // june 2013 copy.HardTouch();
28913797 cameraView.repaint();
28923798 return;
2893
- } else if (event.getSource() == toggleFullItem)
3799
+ } else if (event.getSource() == toggleTimelineItem)
28943800 {
2895
- if (CameraPane.FULLSCREEN)
3801
+ timeline ^= true;
3802
+
3803
+ if (timeline)
28963804 {
2897
- frame.getContentPane().remove(/*"Center",*/bigThree);
2898
- framePanel.add(bigThree);
2899
- frame.getContentPane().add(/*"Center",*/framePanel);
2900
- } else
2901
- {
2902
- frame.getContentPane().remove(/*"Center",*/framePanel);
2903
- frame.getContentPane().add(/*"Center",*/bigThree);
3805
+ centralPanel.remove(cameraView);
3806
+ cameraPanel.add(cameraView);
3807
+ centralPanel.add(cameraPanel);
3808
+ frame.setJMenuBar(timelineMenubar);
3809
+ wasFullScreen = CameraPane.FULLSCREEN;
3810
+ if (!CameraPane.FULLSCREEN)
3811
+ ToggleFullScreen();
3812
+ toggleFullScreenItem.setEnabled(false);
29043813 }
3814
+ else
3815
+ {
3816
+ centralPanel.remove(cameraPanel);
3817
+ centralPanel.add(cameraView);
3818
+ frame.setJMenuBar(null);
3819
+ if (!wasFullScreen)
3820
+ ToggleFullScreen();
3821
+ toggleFullScreenItem.setEnabled(true);
3822
+ }
3823
+
29053824 frame.validate();
2906
- cameraView.ToggleFullScreen();
3825
+ return;
3826
+ } else if (event.getSource() == toggleFullScreenItem)
3827
+ {
3828
+ ToggleFullScreen();
3829
+ frame.validate();
29073830
29083831 return;
2909
- } else if (event.getSource() == toggleRandomItem)
3832
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29103833 {
2911
- cameraView.ToggleRandom();
3834
+ cameraView.ToggleSwitch();
29123835 cameraView.repaint();
29133836 return;
29143837 } else if (event.getSource() == toggleHandleItem)
....@@ -2936,12 +3859,17 @@
29363859 } else if (event.getSource() == liveCB)
29373860 {
29383861 copy.live ^= true;
3862
+ objEditor.refreshContents(true); // To show item colors
3863
+ return;
3864
+ } else if (event.getSource() == selectableCB)
3865
+ {
3866
+ copy.dontselect ^= true;
29393867 return;
29403868 } else if (event.getSource() == hideCB)
29413869 {
29423870 copy.hide ^= true;
29433871 copy.Touch(); // display list issue
2944
- objEditor.refreshContents();
3872
+ objEditor.refreshContents(true); // To show item colors
29453873 return;
29463874 } else if (event.getSource() == link2masterCB)
29473875 {
....@@ -2951,6 +3879,7 @@
29513879 if (event.getSource() == randomCB)
29523880 {
29533881 copy.random ^= true;
3882
+ objEditor.refreshContents();
29543883 return;
29553884 }
29563885 if (event.getSource() == speedupCB)
....@@ -2974,8 +3903,9 @@
29743903
29753904 public void actionPerformed(ActionEvent event)
29763905 {
3906
+ Object source = event.getSource();
29773907 // SCRIPT DIALOG
2978
- if (event.getSource() == okbutton)
3908
+ if (source == okbutton)
29793909 {
29803910 textpanel.setVisible(false);
29813911 textpanel.remove(textarea);
....@@ -2987,7 +3917,7 @@
29873917 textarea = null;
29883918 textpanel = null;
29893919 }
2990
- if (event.getSource() == cancelbutton)
3920
+ if (source == cancelbutton)
29913921 {
29923922 textpanel.setVisible(false);
29933923 textpanel.remove(textarea);
....@@ -2999,49 +3929,50 @@
29993929 //applySelf();
30003930 //client.refreshEditWindow();
30013931 //refreshContents();
3002
- if (event.getSource() == nameField)
3932
+ if (source == nameField)
30033933 {
30043934 //System.out.println("ObjEditor " + event);
30053935 applySelf0(true);
30063936 //parent.applySelf();
3007
- objEditor.refreshContents();
3008
- } else if (event.getSource() == resetButton)
3937
+ // conflicts with requestFocus objEditor.refreshContents();
3938
+ } else if (source == resetButton)
30093939 {
30103940 CameraPane.fullreset = true;
30113941 copy.Reset(); // ResetMeshes();
30123942 copy.Touch();
30133943 objEditor.refreshContents();
3014
- } else if (event.getSource() == stepItem)
3944
+ } else if (source == stepItem)
30153945 {
3016
- cameraView.ONESTEP = true;
3946
+ //cameraView.ONESTEP = true;
3947
+ Globals.ONESTEP = true;
30173948 cameraView.repaint();
30183949 return;
3019
- } else if (event.getSource() == stepButton)
3950
+ } else if (source == stepButton)
30203951 {
30213952 copy.Step();
30223953 copy.Touch();
30233954 objEditor.refreshContents();
3024
- } else if (event.getSource() == slowerButton)
3955
+ } else if (source == slowerButton)
30253956 {
30263957 copy.Slower();
30273958 copy.Touch();
30283959 objEditor.refreshContents();
3029
- } else if (event.getSource() == fasterButton)
3960
+ } else if (source == fasterButton)
30303961 {
30313962 copy.Faster();
30323963 copy.Touch();
30333964 objEditor.refreshContents();
3034
- } else if (event.getSource() == remarkButton)
3965
+ } else if (source == remarkButton)
30353966 {
30363967 copy.Remark();
30373968 copy.Touch();
30383969 objEditor.refreshContents();
3039
- } else if (event.getSource() == stepAllButton)
3970
+ } else if (source == stepAllButton)
30403971 {
30413972 copy.StepAll();
30423973 copy.Touch();
30433974 objEditor.refreshContents();
3044
- } else if (event.getSource() == resetAllButton)
3975
+ } else if (source == resetAllButton)
30453976 {
30463977 //CameraPane.fullreset = true;
30473978 copy.ResetAll(); // ResetMeshes();
....@@ -3074,53 +4005,79 @@
30744005 // Close();
30754006 // }
30764007 // else
3077
- if (event.getSource() == resetSlidersButton)
4008
+ if (source == resetSlidersButton)
30784009 {
30794010 ResetSliders();
3080
- } else if (event.getSource() == clearMaterialButton)
4011
+ } else if (source == clearMaterialButton)
30814012 {
30824013 ClearMaterial();
3083
- } else if (event.getSource() == createMaterialButton)
4014
+ } else if (source == createMaterialButton)
30844015 {
30854016 CreateMaterial();
3086
- } else if (event.getSource() == clearPanelButton)
4017
+ } else if (source == clearPanelButton)
30874018 {
30884019 copy.ClearUI();
30894020 refreshContents(true);
3090
- } /*
3091
- }
3092
-
3093
- public boolean action(Event event, Object arg)
3094
- {
3095
- */ else if (event.getSource() == closeItem)
4021
+ } else if (source == importGFDItem)
4022
+ {
4023
+ ImportGFD();
4024
+ } else
4025
+ if (source == importVRMLX3DItem)
4026
+ {
4027
+ ImportVRMLX3D();
4028
+ } else
4029
+ if (source == import3DSItem)
4030
+ {
4031
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
4032
+ } else
4033
+ if (source == importOBJItem)
4034
+ {
4035
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
4036
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
4037
+ browser.setVisible(true);
4038
+ String filename = browser.getFile();
4039
+ if (filename != null && filename.length() > 0)
4040
+ {
4041
+ String fullname = browser.getDirectory() + filename;
4042
+ makeSomething(ReadOBJ(fullname), true);
4043
+ }
4044
+ } else
4045
+ if (source == closeItem)
30964046 {
30974047 Close();
30984048 //return true;
3099
- } else if (event.getSource() == loadItem)
4049
+ } else if (source == openItem)
31004050 {
3101
- load();
4051
+ Open();
31024052 //return true;
3103
- } else if (event.getSource() == saveItem)
4053
+ } else if (source == newItem)
4054
+ {
4055
+ New();
4056
+ } else if (source == saveItem)
31044057 {
31054058 save();
31064059 //return true;
3107
- } else if (event.getSource() == saveAsItem)
4060
+ } else if (source == saveAsItem)
31084061 {
31094062 saveAs();
31104063 //return true;
3111
- } else if (event.getSource() == reexportItem)
4064
+ } else if (source == reexportItem)
31124065 {
31134066 reexport();
31144067 //return true;
3115
- } else if (event.getSource() == exportAsItem)
4068
+ } else if (source == exportAsItem)
31164069 {
31174070 export();
31184071 //return true;
3119
- } else if (event.getSource() == povItem)
4072
+ } else if (source == povItem)
31204073 {
31214074 generatePOV();
31224075 //return true;
3123
- } else if (event.getSource() == zBufferItem)
4076
+ } else if (event.getSource() == archiveItem)
4077
+ {
4078
+ cTools.Archive(frame);
4079
+ return;
4080
+ } else if (source == zBufferItem)
31244081 {
31254082 try
31264083 {
....@@ -3142,21 +4099,8 @@
31424099 cameraView.repaint();
31434100 //return true;
31444101 }
3145
- */ else if (event.getSource() == editCameraItem)
3146
- {
3147
- cameraView.ProtectCamera();
3148
- cameraView.repaint();
3149
- return;
3150
- } else if (event.getSource() == revertCameraItem)
3151
- {
3152
- cameraView.RevertCamera();
3153
- cameraView.repaint();
3154
- return;
3155
- } else if (event.getSource() == textureButton)
3156
- {
3157
- return; // true;
3158
- } else // combos...
3159
- if (event.getSource() == texresMenu)
4102
+ */ else // combos...
4103
+ if (source == texresMenu)
31604104 {
31614105 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31624106 copy.texres = texresMenu.getSelectedIndex();
....@@ -3168,27 +4112,494 @@
31684112 }
31694113 }
31704114
3171
- void ToggleAnimation()
4115
+ void New()
31724116 {
3173
- if (!CameraPane.ANIMATION)
4117
+ while (copy.Size() > 1)
31744118 {
3175
- FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
4119
+ copy.remove(1);
4120
+ }
4121
+
4122
+ ResetModel();
4123
+ objEditor.refreshContents();
4124
+ }
4125
+
4126
+ static public byte[] Compress(Object3D o)
4127
+ {
4128
+ // Slower to actually compress.
4129
+ try
4130
+ {
4131
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4132
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4133
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
4134
+
4135
+ Object3D parent = o.parent;
4136
+ o.parent = null;
4137
+
4138
+ out.writeObject(o);
4139
+
4140
+ o.parent = parent;
4141
+
4142
+ out.flush();
4143
+
4144
+ baos //zstream
4145
+ .close();
4146
+ out.close();
4147
+
4148
+ byte[] bytes = baos.toByteArray();
4149
+
4150
+ System.out.println("save #bytes = " + bytes.length);
4151
+ return bytes;
4152
+ } catch (Exception e)
4153
+ {
4154
+ System.err.println(e);
4155
+ return null;
4156
+ }
4157
+ }
4158
+
4159
+ static public Object Uncompress(byte[] bytes)
4160
+ {
4161
+ System.out.println("restore #bytes = " + bytes.length);
4162
+ try
4163
+ {
4164
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4165
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4166
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
4167
+ Object obj = in.readObject();
4168
+
4169
+ bais //istream
4170
+ .close();
4171
+ in.close();
4172
+
4173
+ return obj;
4174
+ } catch (Exception e)
4175
+ {
4176
+ System.err.println(e);
4177
+ return null;
4178
+ }
4179
+ }
4180
+
4181
+ static public Object clone(Object o)
4182
+ {
4183
+ try
4184
+ {
4185
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4186
+ ObjectOutputStream out = new ObjectOutputStream(baos);
4187
+
4188
+ out.writeObject(o);
4189
+
4190
+ out.flush();
4191
+ out.close();
4192
+
4193
+ byte[] bytes = baos.toByteArray();
4194
+
4195
+ System.out.println("clone = " + bytes.length);
4196
+
4197
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4198
+ ObjectInputStream in = new ObjectInputStream(bais);
4199
+ Object obj = in.readObject();
4200
+ in.close();
4201
+
4202
+ return obj;
4203
+ } catch (Exception e)
4204
+ {
4205
+ System.err.println(e);
4206
+ return null;
4207
+ }
4208
+ }
4209
+
4210
+ cRadio GetCurrentTab()
4211
+ {
4212
+ cRadio ab;
4213
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4214
+ {
4215
+ ab = (cRadio)e.nextElement();
4216
+ if(ab.GetObject() == copy)
4217
+ {
4218
+ return ab;
4219
+ }
4220
+ }
4221
+
4222
+ return null;
4223
+ }
4224
+
4225
+
4226
+ public void Save()
4227
+ {
4228
+ //Save(true);
4229
+ Replace();
4230
+ SetVersionStates();
4231
+ }
4232
+
4233
+ private boolean Equal(byte[] compress, byte[] name)
4234
+ {
4235
+ if (compress.length != name.length)
4236
+ {
4237
+ return false;
4238
+ }
4239
+
4240
+ for (int i=compress.length; --i>=0;)
4241
+ {
4242
+ if (compress[i] != name[i])
4243
+ return false;
4244
+ }
4245
+
4246
+ return true;
4247
+ }
4248
+
4249
+ void DeleteVersion()
4250
+ {
4251
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4252
+ {
4253
+ copy.versionlist[i] = copy.versionlist[i+1];
4254
+ }
4255
+
4256
+ if (copy.versionlist[copy.versionindex] == null)
4257
+ copy.versionindex -= 1;
4258
+
4259
+ if (copy.versionindex != -1)
4260
+ CopyChanged();
4261
+
4262
+ SetVersionStates();
4263
+ }
4264
+
4265
+ public boolean Save(boolean user)
4266
+ {
4267
+ System.err.println("Save");
4268
+ Replace();
4269
+
4270
+ //cRadio tab = GetCurrentTab();
4271
+
4272
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
4273
+
4274
+ boolean thesame = false;
4275
+
4276
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4277
+// {
4278
+// thesame = true;
4279
+// }
4280
+
4281
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
4282
+ if (!thesame)
4283
+ {
4284
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4285
+ {
4286
+ copy.versionlist[i] = copy.versionlist[i-1];
4287
+ }
4288
+
4289
+ //tab.user[tab.versionindex] = user;
4290
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4291
+
4292
+ copy.versionlist[++copy.versionindex] = compress;
4293
+
4294
+ // if (increment)
4295
+ // tab.versionindex++;
4296
+ }
4297
+
4298
+ //copy.RestoreBigData(versiontable);
4299
+
4300
+ //assert(hashtable.isEmpty());
4301
+
4302
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4303
+// {
4304
+// //tab.user[i] = false;
4305
+// copy.versionlist[i] = null;
4306
+// }
4307
+
4308
+ SetVersionStates();
4309
+
4310
+ // test save
4311
+ if (false)
4312
+ {
4313
+ try
4314
+ {
4315
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
4316
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
4317
+
4318
+ p.writeObject(copy);
4319
+
4320
+ p.flush();
4321
+
4322
+ ostream.close();
4323
+ } catch (Exception e)
4324
+ {
4325
+ e.printStackTrace();
4326
+ }
4327
+ }
4328
+
4329
+ return !thesame;
4330
+ }
4331
+
4332
+ boolean flashIt = true;
4333
+
4334
+ void RefreshSelection()
4335
+ {
4336
+ Object3D selection = new Object3D();
4337
+
4338
+ for (int i = 0; i < copy.selection.size(); i++)
4339
+ {
4340
+ Object3D elem = copy.selection.elementAt(i);
4341
+
4342
+ Object3D obj = copy.GetObject(elem.GetUUID());
4343
+
4344
+ if (obj == null)
4345
+ {
4346
+ copy.selection.remove(i--);
4347
+ }
4348
+ else
4349
+ {
4350
+ selection.add(obj);
4351
+ copy.selection.setElementAt(obj, i);
4352
+ }
4353
+ }
4354
+
4355
+ flashIt = false;
4356
+ GetTree().clearSelection();
4357
+ for (int i = 0; i < selection.size(); i++)
4358
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4359
+ flashIt = true;
4360
+
4361
+ //refreshContents(false);
4362
+ }
4363
+
4364
+ void CopyChanged()
4365
+ {
4366
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4367
+
4368
+ SetVersionStates();
4369
+
4370
+ boolean temp = CameraPane.SWITCH;
4371
+ CameraPane.SWITCH = false;
4372
+
4373
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
4374
+
4375
+ copy.clear();
4376
+
4377
+ copy.skyboxname = obj.skyboxname;
4378
+ copy.skyboxext = obj.skyboxext;
4379
+
4380
+ for (int i=0; i<obj.Size(); i++)
4381
+ {
4382
+ copy.add(obj.get(i));
4383
+ }
4384
+
4385
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
4386
+
4387
+ CameraPane.SWITCH = temp;
4388
+
4389
+ RefreshSelection();
4390
+ //assert(hashtable.isEmpty());
4391
+
4392
+ copy.Touch();
4393
+
4394
+ ResetModel();
4395
+ copy.HardTouch(); // recompile?
4396
+
4397
+ cRadio ab;
4398
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4399
+ {
4400
+ ab = (cRadio)e.nextElement();
4401
+ Object3D test = copy.GetObject(ab.object.GetUUID());
4402
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
4403
+ if (test != null)
4404
+ {
4405
+ test.editWindow = ab.object.editWindow;
4406
+ ab.object = test;
4407
+ }
4408
+ }
4409
+
4410
+ refreshContents(true);
4411
+ }
4412
+
4413
+ cButton previousVersionButton;
4414
+ cButton restoreButton;
4415
+ cButton replaceButton;
4416
+ cButton nextVersionButton;
4417
+ cButton saveVersionButton;
4418
+ cButton deleteVersionButton;
4419
+
4420
+ boolean muteSlider;
4421
+
4422
+ int VersionCount()
4423
+ {
4424
+ int count = 0;
4425
+
4426
+ for (int i = copy.versionlist.length; --i >= 0;)
4427
+ {
4428
+ if (copy.versionlist[i] != null)
4429
+ count++;
4430
+ }
4431
+
4432
+ return count;
4433
+ }
4434
+
4435
+ void SetVersionStates()
4436
+ {
4437
+ //if (true)
4438
+ // return;
4439
+
4440
+ //cRadio tab = GetCurrentTab();
4441
+
4442
+ restoreButton.setEnabled(copy.versionindex != -1);
4443
+ replaceButton.setEnabled(copy.versionindex != -1);
4444
+
4445
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4446
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4447
+
4448
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4449
+ //copy.versionlist[copy.versionindex + 1] != null);
4450
+
4451
+ muteSlider = true;
4452
+ versionSlider.setMinimum(0);
4453
+ versionSlider.setMaximum(VersionCount() - 1);
4454
+ versionSlider.setInteger(copy.versionindex);
4455
+ versionSlider.setEnabled(copy.versionindex != -1);
4456
+ muteSlider = false;
4457
+ }
4458
+
4459
+ public boolean PreviousVersion()
4460
+ {
4461
+ // Option?
4462
+ Replace();
4463
+
4464
+ System.err.println("Undo");
4465
+
4466
+ //cRadio tab = GetCurrentTab();
4467
+
4468
+ if (copy.versionindex == 0)
4469
+ {
4470
+ java.awt.Toolkit.getDefaultToolkit().beep();
4471
+ return false;
4472
+ }
4473
+
4474
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4475
+// {
4476
+// if (Save(false))
4477
+// tab.versionindex -= 1;
4478
+// else
4479
+// {
4480
+// if (tab.versionindex <= 0)
4481
+// return false;
4482
+// else
4483
+// tab.versionindex -= 1;
4484
+// }
4485
+// }
4486
+
4487
+ copy.versionindex -= 1;
4488
+
4489
+ CopyChanged();
4490
+
4491
+ return true;
4492
+ }
4493
+
4494
+ public boolean Restore()
4495
+ {
4496
+ System.err.println("Restore");
4497
+
4498
+ //cRadio tab = GetCurrentTab();
4499
+
4500
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4501
+ {
4502
+ java.awt.Toolkit.getDefaultToolkit().beep();
4503
+ return false;
4504
+ }
4505
+
4506
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4507
+ CopyChanged();
4508
+
4509
+ return true;
4510
+ }
4511
+
4512
+ public boolean Replace()
4513
+ {
4514
+ //System.err.println("Replace");
4515
+
4516
+ //cRadio tab = GetCurrentTab();
4517
+
4518
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4519
+ {
4520
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4521
+ return false;
4522
+ }
4523
+
4524
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4525
+
4526
+ return true;
4527
+ }
4528
+
4529
+ public void NextVersion()
4530
+ {
4531
+ // Option?
4532
+ Replace();
4533
+
4534
+ //cRadio tab = GetCurrentTab();
4535
+
4536
+ if (copy.versionlist[copy.versionindex + 1] == null)
4537
+ {
4538
+ java.awt.Toolkit.getDefaultToolkit().beep();
4539
+ return;
4540
+ }
4541
+
4542
+ copy.versionindex += 1;
4543
+
4544
+ CopyChanged();
4545
+
4546
+ //if (!tab.user[tab.versionindex])
4547
+ // tab.graphs[tab.versionindex] = null;
4548
+ }
4549
+
4550
+ void ImportGFD()
4551
+ {
4552
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
31764553 browser.show();
31774554 String filename = browser.getFile();
31784555 if (filename != null && filename.length() > 0)
31794556 {
3180
- CameraPane.filename = browser.getDirectory() + filename;
4557
+ String fullname = browser.getDirectory() + filename;
4558
+
4559
+ //Object3D readobj =
4560
+ objEditor.ReadGFD(fullname, objEditor);
4561
+ //makeSomething(readobj);
4562
+ }
4563
+ }
4564
+
4565
+ void ImportVRMLX3D()
4566
+ {
4567
+ if (Grafreed.standAlone)
4568
+ {
4569
+ /**/
4570
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
4571
+ browser.show();
4572
+ String filename = browser.getFile();
4573
+ if (filename != null && filename.length() > 0)
4574
+ {
4575
+ String fullname = browser.getDirectory() + filename;
4576
+ LoadVRMLX3D(fullname);
4577
+ }
4578
+ /**/
4579
+ }
4580
+ }
4581
+
4582
+ void ToggleAnimation()
4583
+ {
4584
+ if (!Globals.ANIMATION)
4585
+ {
4586
+ FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
4587
+ browser.setVisible(true);
4588
+ String filename = browser.getFile();
4589
+ if (filename != null && filename.length() > 0)
4590
+ {
4591
+ Globals.filename = browser.getDirectory() + filename;
31814592 //CameraPane.framecount = 0;
3182
- CameraPane.imagecount = 0;
4593
+ Globals.imagecount = 0;
31834594
3184
- CameraPane.ANIMATION ^= true;
4595
+ Globals.ANIMATION ^= true;
31854596
3186
- GraphreeD.wav.cursor = 0;
3187
- GraphreeD.wav.loop = 0;
4597
+ Grafreed.wav.cursor = 0;
4598
+ Grafreed.wav.loop = 0;
31884599 }
31894600 } else
31904601 {
3191
- CameraPane.ANIMATION ^= true;
4602
+ Globals.ANIMATION ^= true;
31924603 }
31934604 }
31944605
....@@ -3234,7 +4645,7 @@
32344645 void CreateMaterial()
32354646 {
32364647 //copy.ClearMaterial(); // PATCH
3237
- copy.CreateMaterialS(multiplyToggle.isSelected());
4648
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32384649 if (copy.selection.size() > 0)
32394650 //SetMaterial(copy);
32404651 {
....@@ -3285,7 +4696,7 @@
32854696 assert false;
32864697 }
32874698
3288
- void EditSelection()
4699
+ void EditSelection(boolean newWindow)
32894700 {
32904701 }
32914702
....@@ -3293,11 +4704,11 @@
32934704 {
32944705 copy.ResetBlockLoop(); // temporary problem
32954706
3296
- boolean random = CameraPane.RANDOM;
3297
- CameraPane.RANDOM = false; // parse everything
4707
+ boolean random = CameraPane.SWITCH;
4708
+ CameraPane.SWITCH = false; // parse everything
32984709 copy.ResetDisplayList();
32994710 copy.HardTouch();
3300
- CameraPane.RANDOM = random;
4711
+ CameraPane.SWITCH = random;
33014712 }
33024713
33034714 // public void applySelf()
....@@ -3327,6 +4738,12 @@
33274738 // else
33284739 // applySelf(true);
33294740 // }
4741
+
4742
+ boolean Equal(double a, double b)
4743
+ {
4744
+ return Math.abs(a - b) < 0.001;
4745
+ }
4746
+
33304747 void applySelf0(boolean name)
33314748 {
33324749 if (name)
....@@ -3344,7 +4761,7 @@
33444761 //copy.material = new cMaterial(copy.GetMaterial());
33454762
33464763 current.color = (float) colorField.getFloat();
3347
- current.modulation = (float) modulationField.getFloat();
4764
+ current.modulation = (float) saturationField.getFloat();
33484765 current.metalness = (float) metalnessField.getFloat();
33494766 current.diffuse = (float) diffuseField.getFloat();
33504767 current.specular = (float) specularField.getFloat();
....@@ -3367,10 +4784,63 @@
33674784 current.fakedepth = (float) fakedepthField.getFloat();
33684785 current.shadowbias = (float) shadowbiasField.getFloat();
33694786
3370
- if (!NumberSlider.frozen)
4787
+ if (!cNumberSlider.frozen)
33714788 {
33724789 //System.out.println("Propagate = " + propagate);
33734790 copy.UpdateMaterial(anchor, current, propagate);
4791
+
4792
+ if (copy.material != null)
4793
+ {
4794
+ cMaterial mat = copy.material;
4795
+
4796
+ if (!Equal(colorField.getFloat(), mat.color))
4797
+ colorField.SetToolTipValue((mat.color));
4798
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4799
+ saturationField.SetToolTipValue((mat.modulation));
4800
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4801
+ metalnessField.SetToolTipValue((mat.metalness));
4802
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4803
+ diffuseField.SetToolTipValue((mat.diffuse));
4804
+ if (!Equal(specularField.getFloat(), mat.specular))
4805
+ specularField.SetToolTipValue((mat.specular));
4806
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4807
+ shininessField.SetToolTipValue((mat.shininess));
4808
+ if (!Equal(shiftField.getFloat(), mat.shift))
4809
+ shiftField.SetToolTipValue((mat.shift));
4810
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4811
+ ambientField.SetToolTipValue((mat.ambient));
4812
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4813
+ lightareaField.SetToolTipValue((mat.lightarea));
4814
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4815
+ diffusenessField.SetToolTipValue((mat.factor));
4816
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4817
+ velvetField.SetToolTipValue((mat.velvet));
4818
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4819
+ sheenField.SetToolTipValue((mat.sheen));
4820
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4821
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4822
+ if (!Equal(backlitField.getFloat(), mat.bump))
4823
+ backlitField.SetToolTipValue((mat.bump));
4824
+ if (!Equal(anisoField.getFloat(), mat.aniso))
4825
+ anisoField.SetToolTipValue((mat.aniso));
4826
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
4827
+ anisoVField.SetToolTipValue((mat.anisoV));
4828
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
4829
+ cameraField.SetToolTipValue((mat.cameralight));
4830
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
4831
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4832
+ if (!Equal(shadowField.getFloat(), mat.shadow))
4833
+ shadowField.SetToolTipValue((mat.shadow));
4834
+ if (!Equal(textureField.getFloat(), mat.texture))
4835
+ textureField.SetToolTipValue((mat.texture));
4836
+ if (!Equal(opacityField.getFloat(), mat.opacity))
4837
+ opacityField.SetToolTipValue((mat.opacity));
4838
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
4839
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4840
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
4841
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
4842
+ }
4843
+
33744844 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33754845 {
33764846 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3399,9 +4869,28 @@
33994869 //copy.Touch();
34004870 }
34014871
4872
+ cNumberSlider versionSlider;
4873
+
34024874 public void stateChanged(ChangeEvent e)
34034875 {
34044876 // assert(false);
4877
+ if (e.getSource() == versionSlider)
4878
+ {
4879
+ if (muteSlider)
4880
+ return;
4881
+
4882
+ Replace();
4883
+
4884
+ int version = versionSlider.getInteger();
4885
+
4886
+ if (version != -1 && copy.versionlist[version] != null)
4887
+ {
4888
+ copy.versionindex = version;
4889
+ CopyChanged();
4890
+ }
4891
+
4892
+ return;
4893
+ }
34054894
34064895 if (freezematerial)
34074896 {
....@@ -3415,6 +4904,7 @@
34154904 || e.getSource() == apertureField
34164905 || e.getSource() == shadowblurField)
34174906 {
4907
+ new Exception().printStackTrace();
34184908 System.exit(0);
34194909 cameraView.options1[0] = (float) focusField.getFloat() * 10;
34204910 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3436,12 +4926,24 @@
34364926 {
34374927 //System.out.println("stateChanged = " + this);
34384928 materialtouched = true;
4929
+
4930
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4931
+ {
4932
+ saturationField.setFloat(1);
4933
+ }
4934
+
34394935 applySelf();
34404936 //System.out.println("this = " + this);
34414937 //System.out.println("PARENT = " + parent);
34424938 //if (parent != null)
34434939 // parent.applySelf();
3444
- refreshContents();
4940
+ if (e.getSource() == normalpushField)
4941
+ {
4942
+ objEditor.refreshContents();
4943
+ //Refresh();
4944
+ }
4945
+ else
4946
+ refreshContents();
34454947 // ??? client.refreshEditWindow();
34464948 }
34474949 //else
....@@ -3453,7 +4955,7 @@
34534955 //group.name = nameField.getText();
34544956 //objEditor.applySelf();
34554957
3456
- assert (objEditor == this);
4958
+ // OCT2018: assert (objEditor == this);
34574959 if (copy.selection == null || copy.selection.size() == 0)
34584960 //super.applySelf()
34594961 ; else
....@@ -3477,12 +4979,18 @@
34774979 objEditor.copy = keep;
34784980 }
34794981 }
4982
+
4983
+ if (normalpushField != null)
4984
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
34804985 }
34814986
34824987 void SnapObject()
34834988 {
3484
- Object3D obj = (Object3D)copy.selection.elementAt(0);
3485
- SnapObject(obj);
4989
+ if (copy.selection.size() > 0)
4990
+ {
4991
+ Object3D obj = (Object3D)copy.selection.elementAt(0);
4992
+ SnapObject(obj);
4993
+ }
34864994 }
34874995
34884996 void SnapObject(Object3D obj)
....@@ -3596,7 +5104,7 @@
35965104
35975105 if (obj.parent != null)
35985106 {
3599
- obj.parent.TransformToWorld(interest);
5107
+// obj.parent.TransformToWorld(interest);
36005108 }
36015109
36025110 if (!CameraPane.TRACK)
....@@ -3723,20 +5231,28 @@
37235231 {
37245232 if (GetTree() != null)
37255233 {
5234
+ GetTree().revalidate();
37265235 GetTree().repaint();
37275236 }
37285237
37295238 radioPanel.revalidate();
37305239 radioPanel.repaint();
3731
- ctrlPanel.revalidate(); // ? new
5240
+ ctrlPanel.validate(); // ? new
37325241 ctrlPanel.repaint();
37335242 }
5243
+
5244
+ if (previousVersionButton != null && copy.versionlist != null)
5245
+ SetVersionStates();
5246
+
5247
+ cameraView.requestFocusInWindow();
37345248 }
37355249
37365250 static TweenManager tweenManager = new TweenManager();
37375251
37385252 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37395253 {
5254
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5255
+ Save();
37405256 //Tween.set(thing, 0).target(1).start(tweenManager);
37415257 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37425258 // if (thing instanceof GenericJointDemo)
....@@ -3760,7 +5276,7 @@
37605276 // group = (Composite) group.get(0);
37615277 // }
37625278
3763
- System.out.println("makeSomething of " + thing);
5279
+ //System.out.println("makeSomething of " + thing);
37645280
37655281 /*
37665282 if (deselect && jList != null)
....@@ -3823,6 +5339,12 @@
38235339 {
38245340 ResetModel();
38255341 Select(thing.GetTreePath(), true, false); // unselect... false);
5342
+
5343
+ if (thing.Size() == 0)
5344
+ {
5345
+ //EditSelection(false);
5346
+ }
5347
+
38265348 refreshContents();
38275349 }
38285350
....@@ -3940,6 +5462,7 @@
39405462 }
39415463 }
39425464 }
5465
+
39435466 LoadGFDThread loadGFDThread;
39445467
39455468 void ReadGFD(String fullname, iCallBack cb)
....@@ -3959,8 +5482,10 @@
39595482
39605483 try
39615484 {
5485
+ // Try compressed version first.
39625486 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3963
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5487
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
5488
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39645489
39655490 readobj = (Object3D) p.readObject();
39665491 istream.close();
....@@ -3968,7 +5493,22 @@
39685493 readobj.ResetDisplayList();
39695494 } catch (Exception e)
39705495 {
3971
- e.printStackTrace();
5496
+ if (!e.toString().contains("GZIP"))
5497
+ e.printStackTrace();
5498
+
5499
+ try
5500
+ {
5501
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
5502
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5503
+
5504
+ readobj = (Object3D) p.readObject();
5505
+ istream.close();
5506
+
5507
+ readobj.ResetDisplayList();
5508
+ } catch (Exception e2)
5509
+ {
5510
+ e2.printStackTrace();
5511
+ }
39725512 }
39735513 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
39745514 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4014,6 +5554,12 @@
40145554
40155555 void LoadIt(Object obj)
40165556 {
5557
+ if (obj == null)
5558
+ {
5559
+ // Invalid file
5560
+ return;
5561
+ }
5562
+
40175563 System.out.println("Loaded " + obj);
40185564 //new Exception().printStackTrace();
40195565 Object3D readobj = (Object3D) obj;
....@@ -4023,10 +5569,14 @@
40235569
40245570 if (readobj != null)
40255571 {
5572
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5573
+ // Save();
40265574 try
40275575 {
40285576 //readobj.deepCopySelf(copy);
40295577 copy.clear(); // june 2014
5578
+ copy.skyboxname = readobj.skyboxname;
5579
+ copy.skyboxext = readobj.skyboxext;
40305580 for (int i = 0; i < readobj.size(); i++)
40315581 {
40325582 Object3D child = readobj.get(i); // reserve(i);
....@@ -4067,6 +5617,7 @@
40675617 }
40685618 } catch (ClassCastException e)
40695619 {
5620
+ e.printStackTrace();
40705621 assert (false);
40715622 Composite c = (Composite) copy;
40725623 c.children.clear();
....@@ -4077,17 +5628,32 @@
40775628 c.addChild(csg);
40785629 }
40795630
5631
+ copy.versionlist = readobj.versionlist;
5632
+ copy.versionindex = readobj.versionindex;
5633
+ copy.versiontable = readobj.versiontable;
5634
+
5635
+ if (copy.versionlist == null)
5636
+ {
5637
+ // Backward compatibility
5638
+ copy.versionlist = new Object3D[100];
5639
+ copy.versionindex = -1;
5640
+
5641
+ //Save(true);
5642
+ }
5643
+
5644
+ //? SetUndoStates();
5645
+
40805646 ResetModel();
40815647 copy.HardTouch(); // recompile?
40825648 refreshContents();
40835649 }
40845650 }
40855651
4086
- void load() // throws ClassNotFoundException
5652
+ void Open() // throws ClassNotFoundException
40875653 {
4088
- if (GraphreeD.standAlone)
5654
+ if (Grafreed.standAlone)
40895655 {
4090
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5656
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
40915657 browser.show();
40925658 String filename = browser.getFile();
40935659 if (filename != null && filename.length() > 0)
....@@ -4164,6 +5730,8 @@
41645730
41655731 void save()
41665732 {
5733
+ Replace();
5734
+
41675735 if (lastname == null)
41685736 {
41695737 return;
....@@ -4172,11 +5740,13 @@
41725740 try
41735741 {
41745742 FileOutputStream ostream = new FileOutputStream(lastname);
4175
- ObjectOutputStream p = new ObjectOutputStream(ostream);
5743
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5744
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
41765745
41775746 p.writeObject(copy);
41785747 p.flush();
41795748
5749
+ zstream.close();
41805750 ostream.close();
41815751
41825752 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4184,19 +5754,23 @@
41845754 //ps.print(buffer.toString());
41855755 } catch (IOException e)
41865756 {
5757
+ e.printStackTrace();
41875758 }
41885759 }
5760
+
41895761 String lastname;
41905762
41915763 void saveAs()
41925764 {
4193
- if (GraphreeD.standAlone)
5765
+ if (Grafreed.standAlone)
41945766 {
41955767 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
41965768 browser.setVisible(true);
41975769 String filename = browser.getFile();
41985770 if (filename != null && filename.length() > 0)
41995771 {
5772
+ if (!filename.endsWith(".gfd"))
5773
+ filename += ".gfd";
42005774 lastname = browser.getDirectory() + filename;
42015775 save();
42025776 }
....@@ -4213,10 +5787,20 @@
42135787
42145788 Object3D object = copy.selection.get(0);
42155789
5790
+ FileObject fileobj = null;
5791
+
5792
+ if (object instanceof FileObject)
5793
+ fileobj = (FileObject)object;
5794
+
42165795 if (object.fileparent != null)
42175796 {
4218
- FileObject fileobj = (FileObject) object.fileparent;
5797
+ assert(fileobj == null);
42195798
5799
+ fileobj = (FileObject) object.fileparent;
5800
+ }
5801
+
5802
+ if (fileobj != null)
5803
+ {
42205804 System.out.println("WriteObject " + object + " : " + fileobj.name);
42215805 WriteObject(object, fileobj.name);
42225806 }
....@@ -4259,7 +5843,7 @@
42595843 }
42605844 }
42615845 else
4262
- //if (GraphreeD.standAlone)
5846
+ //if (GrafreeD.standAlone)
42635847 {
42645848 FileDialog browser = new FileDialog(frame, "Export", FileDialog.SAVE);
42655849 browser.setVisible(true);
....@@ -4285,13 +5869,13 @@
42855869 try
42865870 {
42875871 FileOutputStream ostream = new FileOutputStream(filename);
4288
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4289
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
5872
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5873
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42905874
42915875 Object3D objectparent = obj.parent;
42925876 obj.parent = null;
42935877
4294
- Object3D object = (Object3D) GraphreeD.clone(obj);
5878
+ Object3D object = (Object3D) Grafreed.clone(obj);
42955879
42965880 obj.parent = objectparent;
42975881
....@@ -4303,8 +5887,8 @@
43035887 p.writeObject(object);
43045888 p.flush();
43055889
5890
+ zstream.close();
43065891 ostream.close();
4307
- // zstream.close();
43085892
43095893 // group.selection.get(0).parent = parent;
43105894 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4325,7 +5909,7 @@
43255909 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43265910 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43275911 copy.generatePOV(buffer);
4328
- if (GraphreeD.standAlone)
5912
+ if (Grafreed.standAlone)
43295913 {
43305914 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43315915 browser.show();
....@@ -4351,53 +5935,71 @@
43515935 Object3D client;
43525936 Object3D copy;
43535937 MenuBar menuBar;
4354
- Menu windowMenu;
4355
- MenuItem loadItem;
5938
+ Menu fileMenu;
5939
+ MenuItem newItem;
5940
+ MenuItem openItem;
43565941 MenuItem saveItem;
43575942 MenuItem saveAsItem;
43585943 MenuItem exportAsItem;
43595944 MenuItem reexportItem;
43605945 MenuItem povItem;
43615946 MenuItem closeItem;
4362
- Menu cameraMenu;
5947
+
43635948 CheckboxMenuItem zBufferItem;
43645949 //MenuItem normalLensItem;
4365
- MenuItem editCameraItem;
4366
- MenuItem revertCameraItem;
4367
- CheckboxMenuItem toggleLiveItem;
43685950 MenuItem stepItem;
4369
- CheckboxMenuItem toggleFullItem;
5951
+ CheckboxMenuItem toggleLiveItem;
5952
+ CheckboxMenuItem toggleFullScreenItem;
5953
+ CheckboxMenuItem toggleTimelineItem;
43705954 CheckboxMenuItem toggleRenderItem;
43715955 CheckboxMenuItem toggleDebugItem;
43725956 CheckboxMenuItem toggleFrustumItem;
43735957 CheckboxMenuItem toggleFootContactItem;
43745958 CheckboxMenuItem toggleDLItem;
43755959 CheckboxMenuItem toggleTextureItem;
4376
- CheckboxMenuItem toggleRandomItem;
5960
+ CheckboxMenuItem toggleSwitchItem;
43775961 CheckboxMenuItem toggleRootItem;
43785962 CheckboxMenuItem animationItem;
5963
+ MenuItem archiveItem;
43795964 CheckboxMenuItem toggleHandleItem;
43805965 CheckboxMenuItem togglePaintItem;
43815966 JSplitPane mainPanel;
43825967 JScrollPane scrollpane;
5968
+
43835969 JPanel toolbarPanel;
4384
- JPanel treePanel;
5970
+
5971
+ cGridBag treePanel;
5972
+
43855973 JPanel radioPanel;
43865974 ButtonGroup buttonGroup;
4387
- JPanel ctrlPanel;
4388
- JPanel materialPanel;
5975
+
5976
+ cGridBag toolboxPanel;
5977
+ cGridBag skyboxPanel;
5978
+ cGridBag materialPanel;
5979
+ cGridBag ctrlPanel;
5980
+
43895981 JScrollPane infoPanel;
4390
- JPanel optionsPanel;
5982
+
5983
+ cGridBag optionsPanel;
5984
+
43915985 JTabbedPane objectPanel;
4392
- JPanel XYZPanel;
5986
+ boolean materialFlushed;
5987
+ Object3D latestObject;
5988
+
5989
+ cGridBag XYZPanel;
5990
+
43935991 JSplitPane gridPanel;
43945992 JSplitPane bigPanel;
4395
- JPanel bigThree;
4396
- JTabbedPane jtp;
4397
- JPanel cameraPanel;
5993
+
5994
+ cGridBag bigThree;
5995
+ cGridBag scenePanel;
5996
+ cGridBag centralPanel;
5997
+ JSplitPane cameraPanel;
5998
+ JPanel timelinePanel;
5999
+ JMenuBar timelineMenubar;
43986000 JSplitPane framePanel;
43996001 JTextArea/*Field*/ nameField;
4400
- cButton textureButton;
6002
+ //cButton textureButton;
44016003 cButton okButton;
44026004 cButton applyButton;
44036005 cButton cancelButton;
....@@ -4444,65 +6046,74 @@
44446046 // MATERIAL
44456047 JLabel materialLabel;
44466048 JLabel colorLabel;
4447
- NumberSlider colorField;
6049
+ cNumberSlider colorField;
44486050 JLabel modulationLabel;
4449
- NumberSlider modulationField;
6051
+ cNumberSlider saturationField;
44506052 JLabel metalnessLabel;
4451
- NumberSlider metalnessField;
6053
+ cNumberSlider metalnessField;
44526054 JLabel diffuseLabel;
4453
- NumberSlider diffuseField;
6055
+ cNumberSlider diffuseField;
44546056 JLabel specularLabel;
4455
- NumberSlider specularField;
6057
+ cNumberSlider specularField;
44566058 JLabel shininessLabel;
4457
- NumberSlider shininessField;
6059
+ cNumberSlider shininessField;
44586060 JLabel shiftLabel;
4459
- NumberSlider shiftField;
6061
+ cNumberSlider shiftField;
44606062 JLabel ambientLabel;
4461
- NumberSlider ambientField;
6063
+ cNumberSlider ambientField;
44626064 JLabel lightareaLabel;
4463
- NumberSlider lightareaField;
6065
+ cNumberSlider lightareaField;
44646066 JLabel diffusenessLabel;
4465
- NumberSlider diffusenessField;
6067
+ cNumberSlider diffusenessField;
44666068 JLabel velvetLabel;
4467
- NumberSlider velvetField;
6069
+ cNumberSlider velvetField;
44686070 JLabel sheenLabel;
4469
- NumberSlider sheenField;
6071
+ cNumberSlider sheenField;
44706072 JLabel subsurfaceLabel;
4471
- NumberSlider subsurfaceField;
6073
+ cNumberSlider subsurfaceField;
44726074 //JLabel bumpLabel;
44736075 //NumberSlider bumpField;
44746076 JLabel backlitLabel;
4475
- NumberSlider backlitField;
6077
+ cNumberSlider backlitField;
44766078 JLabel anisoLabel;
4477
- NumberSlider anisoField;
6079
+ cNumberSlider anisoField;
44786080 JLabel anisoVLabel;
4479
- NumberSlider anisoVField;
6081
+ cNumberSlider anisoVField;
6082
+
44806083 JLabel cameraLabel;
4481
- NumberSlider cameraField;
6084
+ cNumberSlider cameraField;
44826085 JLabel selfshadowLabel;
4483
- NumberSlider selfshadowField;
6086
+ cNumberSlider selfshadowField;
44846087 JLabel shadowLabel;
4485
- NumberSlider shadowField;
6088
+ cNumberSlider shadowField;
44866089 JLabel textureLabel;
4487
- NumberSlider textureField;
6090
+ cNumberSlider textureField;
44886091 JLabel opacityLabel;
4489
- NumberSlider opacityField;
6092
+ cNumberSlider opacityField;
44906093 JLabel fakedepthLabel;
4491
- NumberSlider fakedepthField;
6094
+ cNumberSlider fakedepthField;
44926095 JLabel shadowbiasLabel;
4493
- NumberSlider shadowbiasField;
6096
+ cNumberSlider shadowbiasField;
6097
+
44946098 JLabel bumpLabel;
4495
- NumberSlider bumpField;
6099
+ cNumberSlider bumpField;
44966100 JLabel noiseLabel;
4497
- NumberSlider noiseField;
6101
+ cNumberSlider noiseField;
44986102 JLabel powerLabel;
4499
- NumberSlider powerField;
6103
+ cNumberSlider powerField;
45006104 JLabel borderfadeLabel;
4501
- NumberSlider borderfadeField;
6105
+ cNumberSlider borderfadeField;
45026106 JLabel fogLabel;
4503
- NumberSlider fogField;
6107
+ cNumberSlider fogField;
45046108 JLabel opacityPowerLabel;
4505
- NumberSlider opacityPowerField;
4506
- JTree jTree;
6109
+ cNumberSlider opacityPowerField;
6110
+ cTree jTree;
45076111 //ObjectUI parent;
6112
+
6113
+ cNumberSlider normalpushField;
6114
+
6115
+ private MenuItem importGFDItem;
6116
+ private MenuItem importVRMLX3DItem;
6117
+ private MenuItem import3DSItem;
6118
+ private MenuItem importOBJItem;
45086119 }