Normand Briere
2019-08-16 64e20f390e4b8e58bd0006dde8fa10fba1dac1d5
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -30,11 +34,128 @@
3034 iSendInfo
3135 //KeyListener
3236 {
37
+ public cToggleButton pinButton;
3338 boolean timeline;
3439 boolean wasFullScreen;
3540
3641 GroupEditor callee;
3742 JFrame frame;
43
+
44
+ static ObjEditor theFrame;
45
+
46
+ public void AllocProjectedVertices(Object3D object)
47
+ {
48
+ assert (object.projectedVertices != null);
49
+
50
+ if (object.projectedVertices.length <= 2)
51
+ {
52
+ // Side effect...
53
+ Object3D.cVector2[] keep = object.projectedVertices;
54
+ object.projectedVertices = new Object3D.cVector2[3];
55
+ for (int i = 0; i < 3; i++)
56
+ {
57
+ if (i < keep.length)
58
+ {
59
+ object.projectedVertices[i] = keep[i];
60
+ } else
61
+ {
62
+ object.projectedVertices[i] = new Object3D.cVector2();
63
+ }
64
+ /*
65
+ if(keep.length == 0)
66
+ object.projectedVertices[0] = new Object3D.cVector2();
67
+ else
68
+ object.projectedVertices[0] = keep[0];
69
+ object.projectedVertices[1] = new Object3D.cVector2();
70
+ */
71
+ }
72
+ }
73
+ }
74
+
75
+ public cGridBag GetSeparator()
76
+ {
77
+ cGridBag separator = new cGridBag();
78
+ separator.add(new JSeparator());
79
+ separator.preferredHeight = 5;
80
+ return separator;
81
+ }
82
+
83
+ cButton GetButton(String name, boolean border)
84
+ {
85
+ ImageIcon icon = GetIcon(name);
86
+ return new cButton(icon, border);
87
+ }
88
+
89
+ cLabel GetLabel(String name, boolean border)
90
+ {
91
+ //ImageIcon icon = GetIcon(name);
92
+ return new cLabel(GetImage(name), border);
93
+ }
94
+
95
+ cToggleButton GetToggleButton(String name, boolean border)
96
+ {
97
+ ImageIcon icon = GetIcon(name);
98
+ return new cToggleButton(icon, border);
99
+ }
100
+
101
+ cCheckBox GetCheckBox(String name, boolean border)
102
+ {
103
+ ImageIcon icon = GetIcon(name);
104
+ return new cCheckBox(icon, border);
105
+ }
106
+
107
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
108
+
109
+ ImageIcon GetIcon(String name)
110
+ {
111
+ javax.swing.ImageIcon iconCache = icons.get(name);
112
+ if (iconCache != null)
113
+ {
114
+ return iconCache;
115
+ }
116
+
117
+ try
118
+ {
119
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
120
+
121
+// if (image.getWidth() > 48 && image.getHeight() > 48)
122
+// {
123
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
124
+// Graphics2D g = resized.createGraphics();
125
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
126
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
127
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
128
+// g.dispose();
129
+//
130
+// image = resized;
131
+// }
132
+
133
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
134
+
135
+ icons.put(name, icon);
136
+
137
+ return icon;
138
+ }
139
+ catch (Exception e)
140
+ {
141
+ //icons.put(name, null);
142
+ return null;
143
+ }
144
+ }
145
+
146
+ BufferedImage GetImage(String name)
147
+ {
148
+ try
149
+ {
150
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
151
+
152
+ return image;
153
+ }
154
+ catch (Exception e)
155
+ {
156
+ return null;
157
+ }
158
+ }
38159
39160 // SCRIPT
40161
....@@ -138,34 +259,42 @@
138259 public void closeUI()
139260 {
140261 //new Exception().printStackTrace();
141
- System.out.println("this = " + this);
142
- System.out.println("objEditor = " + objEditor);
262
+// System.out.println("this = " + this);
263
+// System.out.println("objEditor = " + objEditor);
143264 //nameField.removeActionListener(this);
144
- objEditor.ctrlPanel.remove(nameField);
265
+// objEditor.ctrlPanel.remove(nameField);
145266
146
- if (!GroupEditor.allparams)
267
+ objEditor.ctrlPanel.remove(namePanel);
268
+
269
+ if (!allparams)
147270 return;
148271
149
- objEditor.ctrlPanel.remove(liveCB);
150
- objEditor.ctrlPanel.remove(hideCB);
151
- objEditor.ctrlPanel.remove(markCB);
152
-
153
- objEditor.ctrlPanel.remove(randomCB);
154
- objEditor.ctrlPanel.remove(speedupCB);
155
- objEditor.ctrlPanel.remove(rewindCB);
156
-
157
- objEditor.ctrlPanel.remove(resetButton);
158
- objEditor.ctrlPanel.remove(stepButton);
159
-// objEditor.ctrlPanel.remove(stepAllButton);
160
-// objEditor.ctrlPanel.remove(resetAllButton);
161
- objEditor.ctrlPanel.remove(link2masterCB);
162
- //objEditor.ctrlPanel.remove(flipVCB);
163
- //objEditor.ctrlPanel.remove(texresMenu);
164
- objEditor.ctrlPanel.remove(slowerButton);
165
- objEditor.ctrlPanel.remove(fasterButton);
166
- 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);
167290
168
- Remove(normalpushField);
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);
169298 }
170299
171300 public ObjEditor GetEditor()
....@@ -209,6 +338,14 @@
209338 client = inClient;
210339 copy = client;
211340
341
+// if (copy.versionlist == null)
342
+// {
343
+// copy.versionlist = new Object3D[100];
344
+// copy.versionindex = -1;
345
+//
346
+// callee.Save(true);
347
+// }
348
+
212349 // "this" is not called: SetupUI2(objEditor);
213350 }
214351
....@@ -222,6 +359,14 @@
222359 client = inClient;
223360 copy = client;
224361
362
+ if (copy.versionlist == null)
363
+ {
364
+ copy.versionlist = new Object3D[100];
365
+ copy.versionindex = -1;
366
+
367
+// Save(true);
368
+ }
369
+
225370 SetupUI2(callee.GetEditor());
226371 }
227372
....@@ -236,13 +381,15 @@
236381 //localCopy.parent = null;
237382
238383 frame = new JFrame();
384
+ frame.setUndecorated(false);
239385 objEditor = this;
240386 this.callee = callee;
241387
242388 //parent = p;
243389
244390 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
245
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
391
+ if (Globals.DEBUG)
392
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
246393 //gd.setFullScreenWindow(this);
247394 //setResizable(false);
248395 //if (!isDisplayable())
....@@ -253,6 +400,14 @@
253400 copy = localCopy;
254401 copy.editWindow = this;
255402
403
+// if (copy.versionlist == null)
404
+// {
405
+// copy.versionlist = new Object3D[100];
406
+// copy.versionindex = -1;
407
+//
408
+// Save(true);
409
+// }
410
+
256411 SetupMenu();
257412
258413 //SetupName(objEditor); // new
....@@ -266,28 +421,49 @@
266421 return frame.action(event, obj);
267422 }
268423
424
+ // Cannot work without static
425
+ static boolean allparams = true;
426
+
427
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
428
+
269429 void SetupMenu()
270430 {
271431 frame.setMenuBar(menuBar = new MenuBar());
272
- menuBar.add(windowMenu = new Menu("File"));
273
- windowMenu.add(loadItem = new MenuItem("Load..."));
274
- windowMenu.add("-");
275
- windowMenu.add(saveItem = new MenuItem("Save"));
276
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
432
+ menuBar.add(fileMenu = new Menu("File"));
433
+ fileMenu.add(newItem = new MenuItem("New"));
434
+ fileMenu.add(openItem = new MenuItem("Open..."));
435
+
436
+ //oe.menuBar.add(menu = new Menu("Include"));
437
+ Menu menu = new Menu("Import");
438
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
439
+ importOBJItem.addActionListener(this);
440
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
441
+ import3DSItem.addActionListener(this);
442
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
443
+ importVRMLX3DItem.addActionListener(this);
444
+ menu.add("-");
445
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
446
+ importGFDItem.addActionListener(this);
447
+ fileMenu.add(menu);
448
+ fileMenu.add("-");
449
+
450
+ fileMenu.add(saveItem = new MenuItem("Save"));
451
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
277452 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
278
- windowMenu.add("-");
279
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
280
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
281
- windowMenu.add("-");
453
+ fileMenu.add("-");
454
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
455
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
456
+ fileMenu.add("-");
282457 if (client.parent != null)
283458 {
284
- windowMenu.add(closeItem = new MenuItem("Close"));
459
+ fileMenu.add(closeItem = new MenuItem("Close"));
285460 } else
286461 {
287
- windowMenu.add(closeItem = new MenuItem("Exit"));
462
+ fileMenu.add(closeItem = new MenuItem("Exit"));
288463 }
289464
290
- loadItem.addActionListener(this);
465
+ newItem.addActionListener(this);
466
+ openItem.addActionListener(this);
291467 saveItem.addActionListener(this);
292468 saveAsItem.addActionListener(this);
293469 exportAsItem.addActionListener(this);
....@@ -295,82 +471,103 @@
295471 //povItem.addActionListener(this);
296472 closeItem.addActionListener(this);
297473
298
- menuBar.add(cameraMenu = new Menu("View"));
299
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
300
- //zBufferItem.addActionListener(this);
301
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
302
- //normalLensItem.addActionListener(this);
303
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
304
- revertCameraItem.addActionListener(this);
305
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
306
- toggleTimelineItem.addItemListener(this);
307
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
308
- toggleFullScreenItem.addItemListener(this);
309
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
310
- cameraMenu.add("-");
311
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
312
- toggleTextureItem.addItemListener(this);
313
- toggleTextureItem.setState(CameraPane.textureon);
314
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
315
- toggleLiveItem.addItemListener(this);
316
- toggleLiveItem.setState(Globals.isLIVE());
317
- cameraMenu.add(stepItem = new MenuItem("Step"));
318
- stepItem.addActionListener(this);
319
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
320
-// toggleDLItem.addItemListener(this);
321
-// toggleDLItem.setState(false);
322
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
323
- toggleRenderItem.addItemListener(this);
324
- toggleRenderItem.setState(!CameraPane.frozen);
325
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
326
- toggleDebugItem.addItemListener(this);
327
- toggleDebugItem.setState(CameraPane.DEBUG);
328
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
329
- toggleFrustumItem.addItemListener(this);
330
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
331
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
332
- toggleFootContactItem.addItemListener(this);
333
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
334
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
335
- toggleRandomItem.addItemListener(this);
336
- toggleRandomItem.setState(CameraPane.RANDOM);
337
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
338
- toggleHandleItem.addItemListener(this);
339
- toggleHandleItem.setState(CameraPane.HANDLES);
340
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
341
- togglePaintItem.addItemListener(this);
342
- togglePaintItem.setState(CameraPane.PAINTMODE);
343
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
344
-// toggleRootItem.addItemListener(this);
345
-// toggleRootItem.setState(false);
346
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
347
-// animationItem.addItemListener(this);
348
-// animationItem.setState(CameraPane.ANIMATION);
349
- cameraMenu.add("-");
350
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
351
- editCameraItem.addActionListener(this);
352
-
353474 objectPanel = new JTabbedPane();
475
+
476
+ ChangeListener changeListener = new ChangeListener()
477
+ {
478
+ //String name;
479
+
480
+ public void stateChanged(ChangeEvent changeEvent)
481
+ {
482
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
483
+// {
484
+// if (latestObject != null)
485
+// {
486
+// refreshContents(true);
487
+// SetMaterial(latestObject);
488
+// }
489
+//
490
+// materialFlushed = true;
491
+// }
492
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
493
+// {
494
+// if (listUI.size() == 0)
495
+// EditSelection(false);
496
+// }
497
+
498
+// if (objectPanel.getSelectedIndex() == 4)
499
+// {
500
+// name = copy.skyboxname;
501
+//
502
+// if (name == null)
503
+// {
504
+// name = "";
505
+// }
506
+//
507
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
508
+// copy.skyboxext = "jpg";
509
+// }
510
+// else
511
+// {
512
+// if (name != null)
513
+// {
514
+// if (name.equals(""))
515
+// {
516
+// copy.skyboxname = null;
517
+// copy.skyboxext = null;
518
+// }
519
+// else
520
+// {
521
+// copy.skyboxname = name;
522
+// }
523
+// }
524
+// }
525
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
526
+
527
+// refreshContents(false); // To refresh Info tab
528
+ cameraView.repaint();
529
+ }
530
+ };
531
+ objectPanel.addChangeListener(changeListener);
532
+
354533 toolbarPanel = new JPanel();
355534 toolbarPanel.setName("Toolbar");
356
- treePanel = new JPanel();
535
+
536
+ treePanel = new cGridBag();
357537 treePanel.setName("Tree");
358
- ctrlPanel = new cGridBag(); // new GridBagLayout());
359
- ctrlPanel.setName("Edit");
360
- materialPanel = new cGridBag().setVertical(true);
361
- materialPanel.setName("Material");
538
+
539
+ editPanel = new cGridBag().setVertical(true);
540
+ //editPanel.setName("Edit");
541
+
542
+ ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
543
+
544
+ editCommandsPanel = new cGridBag();
545
+ editPanel.add(editCommandsPanel);
546
+ editPanel.add(ctrlPanel);
547
+
548
+ toolboxPanel = new cGridBag().setVertical(true);
549
+ //toolboxPanel.setName("Toolbox");
550
+
551
+ skyboxPanel = new cGridBag().setVertical(true);
552
+
553
+ materialPanel = new cGridBag().setVertical(false);
554
+ //materialPanel.setName("Material");
555
+
362556 /*JTextPane*/
363557 infoarea = createTextPane();
558
+ doc = infoarea.getStyledDocument();
559
+
364560 infoarea.setEditable(true);
365561 SetText();
562
+
366563 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
367564 // infoarea.setOpaque(false);
368565 // //infoarea.setForeground(textcolor);
369
- infoarea.setLineWrap(true);
370
- infoarea.setWrapStyleWord(true);
566
+// TEXTAREA infoarea.setLineWrap(true);
567
+// TEXTAREA infoarea.setWrapStyleWord(true);
371568 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
372
- infoPanel.setPreferredSize(new Dimension(50, 200));
373
- infoPanel.setName("Info");
569
+ infoPanel.setPreferredSize(new Dimension(1, 1));
570
+ //infoPanel.setName("Info");
374571 //infoPanel.setLayout(new BorderLayout());
375572 //infoPanel.add(createTextPane());
376573
....@@ -378,15 +575,22 @@
378575 mainPanel.setName("Main");
379576 mainPanel.setContinuousLayout(true);
380577 mainPanel.setOneTouchExpandable(true);
381
- mainPanel.setDividerLocation(1.0);
382578 mainPanel.setDividerSize(9);
383
- mainPanel.setResizeWeight(0);
384
-
579
+ mainPanel.setDividerLocation(0.5); //1.0);
580
+ mainPanel.setResizeWeight(0.5);
581
+
582
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
583
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
584
+ divider.setDividerSize(15);
585
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
586
+
587
+ mainPanel.setUI(new BasicSplitPaneUI());
588
+
385589 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
386590 //mainPanel.setLayout(new GridBagLayout());
387591 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
388
- treePanel.setLayout(new GridBagLayout());
389
- ctrlPanel.setLayout(new GridBagLayout());
592
+// treePanel.setLayout(new GridBagLayout());
593
+ //ctrlPanel.setLayout(new GridBagLayout());
390594 //materialPanel.setLayout(new GridBagLayout());
391595
392596 aConstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
....@@ -426,7 +630,7 @@
426630 static String newline = "\n";
427631 protected static final String buttonString = "JButton";
428632 StyledDocument doc;
429
- JTextArea infoarea;
633
+ JTextPane infoarea;
430634
431635 void ClearInfo()
432636 {
....@@ -449,10 +653,10 @@
449653 e.printStackTrace();
450654 }
451655
452
- String selection = infoarea.getText();
453
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
454
- java.awt.datatransfer.Clipboard clipboard =
455
- Toolkit.getDefaultToolkit().getSystemClipboard();
656
+// String selection = infoarea.getText();
657
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
658
+// java.awt.datatransfer.Clipboard clipboard =
659
+// Toolkit.getDefaultToolkit().getSystemClipboard();
456660 //clipboard.setContents(data, data);
457661 }
458662
....@@ -475,13 +679,13 @@
475679 //SendInfo("Name:", "bold");
476680 if (sel.GetTextures() != null || debug)
477681 {
478
- si.SendInfo(sel.toString(), "bold");
682
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
479683 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
480684 if (sel.Size() > 0)
481685 {
482686 si.SendInfo("#children = " + sel.Size(), "regular");
483687 }
484
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
688
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
485689 if (debug)
486690 {
487691 try
....@@ -493,7 +697,10 @@
493697 }
494698
495699 if (full)
496
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
700
+ {
701
+ si.SendInfo(" BBox min: " + minima, "regular");
702
+ si.SendInfo(" BBox max: " + maxima, "regular");
703
+ }
497704
498705 if (sel.bRep != null)
499706 {
....@@ -520,7 +727,7 @@
520727 }
521728 if (sel.support != null)
522729 {
523
- si.SendInfo(" support: " + sel.support, "regular");
730
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
524731 }
525732 if (sel.scriptnode != null)
526733 {
....@@ -591,6 +798,9 @@
591798 {
592799 CameraPane.pointflow = (PointFlow) sel;
593800 }
801
+
802
+ si.SendInfo("_____________________", "regular");
803
+ si.SendInfo("", "regular");
594804 }
595805 }
596806
....@@ -606,68 +816,205 @@
606816 }
607817 }
608818
819
+//static GraphicsDevice device = GraphicsEnvironment
820
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
821
+
822
+ Rectangle keeprect;
823
+ cRadio radio;
824
+
825
+cButton keepButton;
826
+ cButton twoButton; // Full 3D
827
+ cButton sixButton;
828
+ cButton threeButton;
829
+ cButton sevenButton;
830
+ cButton fourButton; // full panel
831
+ cButton oneButton; // full XYZ
832
+ //cButton currentLayout;
833
+
834
+ boolean maximized;
835
+
836
+ cButton fullscreenLayout;
837
+ cButton expandedLayout;
838
+
839
+ void Minimize()
840
+ {
841
+ frame.setState(Frame.ICONIFIED);
842
+ frame.validate();
843
+ }
844
+
845
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
846
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
847
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
848
+ void Maximize()
849
+ {
850
+ if (CameraPane.FULLSCREEN)
851
+ {
852
+ ToggleFullScreen();
853
+ }
854
+
855
+ if (maximized)
856
+ {
857
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
858
+ }
859
+ else
860
+ {
861
+ keeprect = frame.getBounds();
862
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
863
+// Dimension rect2 = frame.getToolkit().getScreenSize();
864
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
865
+// frame.setState(Frame.MAXIMIZED_BOTH);
866
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
867
+ }
868
+
869
+ maximized ^= true;
870
+
871
+ frame.validate();
872
+ }
873
+
874
+ cButton minButton;
875
+ cButton maxButton;
876
+ cButton fullButton;
877
+ cButton collapseButton;
878
+ cButton maximize3DButton;
879
+
609880 void ToggleFullScreen()
610881 {
611
- if (CameraPane.FULLSCREEN)
882
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
883
+
884
+ cameraView.ToggleFullScreen();
885
+
886
+ if (!CameraPane.FULLSCREEN)
612887 {
613
- frame.getContentPane().remove(/*"Center",*/bigThree);
614
- framePanel.add(bigThree);
615
- frame.getContentPane().add(/*"Center",*/framePanel);
888
+ device.setFullScreenWindow(null);
889
+ frame.dispose();
890
+ frame.setUndecorated(false);
891
+ frame.validate();
892
+ frame.setVisible(true);
893
+
894
+ //frame.setVisible(false);
895
+// frame.removeNotify();
896
+// frame.setUndecorated(false);
897
+// frame.addNotify();
898
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
899
+
900
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
901
+// X framePanel.add(bigThree);
902
+// X frame.getContentPane().add(/*"Center",*/framePanel);
903
+// framePanel.setDividerLocation(46); // icons are 24x24
904
+
905
+ //frame.setVisible(true);
906
+// radio.layout = keepButton;
907
+ //theFrame = null;
908
+ keepButton = null;
909
+// radio.layout.doClick();
910
+
616911 } else
617912 {
618
- frame.getContentPane().remove(/*"Center",*/framePanel);
619
- framePanel.remove(bigThree);
620
- frame.getContentPane().add(/*"Center",*/bigThree);
913
+ keepButton = radio.layout;
914
+ //keeprect = frame.getBounds();
915
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
916
+// frame.getToolkit().getScreenSize().height);
917
+ //frame.setVisible(false);
918
+
919
+ frame.dispose();
920
+ frame.setUndecorated(true);
921
+ device.setFullScreenWindow(frame);
922
+ frame.validate();
923
+ frame.setVisible(true);
924
+// frame.removeNotify();
925
+// frame.setUndecorated(true);
926
+// frame.addNotify();
927
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
928
+// X framePanel.remove(bigThree);
929
+// X frame.getContentPane().add(/*"Center",*/bigThree);
930
+// framePanel.setDividerLocation(0);
931
+
932
+// radio.layout = fullscreenLayout;
933
+// radio.layout.doClick();
934
+ //frame.setVisible(true);
621935 }
622
- cameraView.ToggleFullScreen();
936
+ frame.validate();
937
+
938
+ cameraView.requestFocusInWindow();
623939 }
624940
625
- private JTextArea createTextPane()
941
+ void CollapseToolbar()
942
+ {
943
+ framePanel.setDividerLocation(0);
944
+ //frame.validate();
945
+
946
+ cameraView.requestFocusInWindow();
947
+ }
948
+
949
+ private Object3D Duplicate(Object3D object)
626950 {
627
- String[] initString =
628
- {
629
- "This is an editable JTextPane, ", //regular
630
- "another ", //italic
631
- "styled ", //bold
632
- "text ", //small
633
- "component, ", //large
634
- "which supports embedded components..." + newline,//regular
635
- " " + newline, //button
636
- "...and embedded icons..." + newline, //regular
637
- " ", //icon
638
- newline + "JTextPane is a subclass of JEditorPane that "
639
- + "uses a StyledEditorKit and StyledDocument, and provides "
640
- + "cover methods for interacting with those objects."
641
- };
951
+ boolean temp = CameraPane.SWITCH;
952
+ CameraPane.SWITCH = false;
953
+
954
+ object.ExtractBigData(versiontable);
955
+ // if (copy == client)
956
+
957
+ Object3D versions[] = object.versionlist;
958
+ object.versionlist = null;
959
+
960
+ //byte[] compress = Compress(copy);
961
+ Object3D compress = (Object3D)Grafreed.clone(object);
962
+
963
+ object.versionlist = versions;
964
+
965
+ object.RestoreBigData(versiontable);
966
+
967
+ CameraPane.SWITCH = temp;
968
+
969
+ return compress;
970
+ }
642971
643
- String[] initStyles =
644
- {
645
- "regular", "italic", "bold", "small", "large",
646
- "regular", "button", "regular", "icon",
647
- "regular"
648
- };
972
+ private JTextPane createTextPane()
973
+ {
974
+// TEXTAREA String[] initString =
975
+// {
976
+// "This is an editable JTextPane, ", //regular
977
+// "another ", //italic
978
+// "styled ", //bold
979
+// "text ", //small
980
+// "component, ", //large
981
+// "which supports embedded components..." + newline,//regular
982
+// " " + newline, //button
983
+// "...and embedded icons..." + newline, //regular
984
+// " ", //icon
985
+// newline + "JTextPane is a subclass of JEditorPane that "
986
+// + "uses a StyledEditorKit and StyledDocument, and provides "
987
+// + "cover methods for interacting with those objects."
988
+// };
989
+//
990
+// String[] initStyles =
991
+// {
992
+// "regular", "italic", "bold", "small", "large",
993
+// "regular", "button", "regular", "icon",
994
+// "regular"
995
+// };
996
+//
997
+// JTextPane textPane = new JTextPane();
998
+// textPane.setEditable(true);
999
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
1000
+// addStylesToDocument(doc);
1001
+//
1002
+// try
1003
+// {
1004
+// for (int j = 0; j < 2; j++)
1005
+// {
1006
+// for (int i = 0; i < initString.length; i++)
1007
+// {
1008
+// doc.insertString(doc.getLength(), initString[i],
1009
+// doc.getStyle(initStyles[i]));
1010
+// }
1011
+// }
1012
+// } catch (BadLocationException ble)
1013
+// {
1014
+// System.err.println("Couldn't insert initial text into text pane.");
1015
+// }
6491016
650
- JTextPane textPane = new JTextPane();
651
- textPane.setEditable(true);
652
- /*StyledDocument*/ doc = textPane.getStyledDocument();
653
- addStylesToDocument(doc);
654
-
655
- try
656
- {
657
- for (int j = 0; j < 2; j++)
658
- {
659
- for (int i = 0; i < initString.length; i++)
660
- {
661
- doc.insertString(doc.getLength(), initString[i],
662
- doc.getStyle(initStyles[i]));
663
- }
664
- }
665
- } catch (BadLocationException ble)
666
- {
667
- System.err.println("Couldn't insert initial text into text pane.");
668
- }
669
-
670
- return new JTextArea(); // textPane;
1017
+ return new JTextPane(); // textPane;
6711018 }
6721019
6731020 protected void addStylesToDocument(StyledDocument doc)
....@@ -720,7 +1067,7 @@
7201067 protected static ImageIcon createImageIcon(String path,
7211068 String description)
7221069 {
723
- java.net.URL imgURL = GrafreeD.class.getResource(path);
1070
+ java.net.URL imgURL = Grafreed.class.getResource(path);
7241071 if (imgURL != null)
7251072 {
7261073 return new ImageIcon(imgURL, description);
....@@ -743,6 +1090,7 @@
7431090 {
7441091 SetupMaterial(materialPanel);
7451092 }
1093
+
7461094 //SetupName();
7471095 //SetupViews();
7481096 }
....@@ -752,6 +1100,7 @@
7521100 // NumberSlider vDivsField;
7531101 // JCheckBox endcaps;
7541102 JCheckBox liveCB;
1103
+ JCheckBox selectableCB;
7551104 JCheckBox hideCB;
7561105 JCheckBox link2masterCB;
7571106 JCheckBox markCB;
....@@ -759,7 +1108,12 @@
7591108 JCheckBox speedupCB;
7601109 JCheckBox rewindCB;
7611110 JCheckBox flipVCB;
1111
+
1112
+ cCheckBox toggleTextureCB;
1113
+ cCheckBox toggleSwitchCB;
1114
+
7621115 JComboBox texresMenu;
1116
+
7631117 JButton resetButton;
7641118 JButton stepButton;
7651119 JButton stepAllButton;
....@@ -767,54 +1121,48 @@
7671121 JButton slowerButton;
7681122 JButton fasterButton;
7691123 JButton remarkButton;
1124
+
1125
+ cGridBag editPanel;
1126
+ cGridBag editCommandsPanel;
1127
+
1128
+ cGridBag namePanel;
1129
+ cGridBag setupPanel;
1130
+ cGridBag setupPanel2;
1131
+ cGridBag objectCommandsPanel;
1132
+ cGridBag pushPanel;
1133
+ cGridBag fillPanel;
7701134
771
- JCheckBox AddCheckBox(ObjEditor oe, String label, boolean on)
1135
+ JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
7721136 {
7731137 JCheckBox cb;
7741138
775
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
776
- oe.aConstraints.gridwidth = 1; // 3;
777
-// oe.aConstraints.weightx = 1;
778
-// oe.aConstraints.anchor = GridBagConstraints.WEST;
779
- oe.ctrlPanel.add(cb = new JCheckBox(label, on), oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
1139
+ panel.add(cb = new JCheckBox(label, on)); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
7801140 cb.addItemListener(this);
781
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
782
- oe.aConstraints.gridwidth = 1;
783
- oe.aConstraints.gridx += 1;
7841141
7851142 return cb;
7861143 }
7871144
788
- cButton AddButton(ObjEditor oe, String label)
1145
+ cButton AddButton(cGridBag panel, String label)
7891146 {
7901147 cButton cb;
7911148
792
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
793
- oe.aConstraints.gridwidth = 1;
794
-// oe.aConstraints.weightx = 1;
795
-// oe.aConstraints.anchor = GridBagConstraints.WEST;
796
- oe.ctrlPanel.add(cb = new cButton(label), oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
1149
+ panel.add(cb = new cButton(label)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
7971150 cb.addActionListener(this);
798
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
799
- oe.aConstraints.gridwidth = 1;
800
- oe.aConstraints.gridx += 1;
8011151
8021152 return cb;
8031153 }
8041154
805
- JComboBox AddCombo(ObjEditor oe, java.util.Vector list, int item)
1155
+ JComboBox AddCombo(cGridBag panel, java.util.Vector list, int item)
8061156 {
8071157 JComboBox combo;
8081158
809
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
810
- oe.ctrlPanel.add(combo = new JComboBox(new cListModel(list, item)), oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
811
- oe.aConstraints.gridx += 1;
1159
+ panel.add(combo = new JComboBox(new cListModel(list, item))); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8121160 combo.addActionListener(this);
8131161
8141162 return combo;
8151163 }
8161164
817
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, double min, double max, double current, double pow)
1165
+ cGridBag AddSlider(cGridBag panel, String label, double min, double max, double current, double pow)
8181166 {
8191167 cGridBag control = new cGridBag();
8201168
....@@ -826,12 +1174,12 @@
8261174 control.add(combo = new cNumberSlider(this, min, max, pow)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8271175 combo.setFloat(current);
8281176
829
- ctrlPanel.add(control);
1177
+ panel.add(control);
8301178
831
- return combo;
1179
+ return control;
8321180 }
8331181
834
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, int min, int max, int current)
1182
+ cGridBag AddSlider(cGridBag panel, String label, int min, int max, int current)
8351183 {
8361184 cGridBag control = new cGridBag();
8371185
....@@ -839,25 +1187,21 @@
8391187
8401188 JLabel jlabel = new JLabel(label);
8411189 jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
842
- ctrlPanel.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
843
- ctrlPanel.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
1190
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
1191
+ control.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8441192 combo.setInteger(current);
8451193
846
- ctrlPanel.add(control);
1194
+ panel.add(control);
8471195
848
- return combo;
1196
+ return control;
8491197 }
8501198
8511199 JTextArea AddText(cGridBag ctrlPanel, String name)
8521200 {
8531201 JTextArea text;
8541202
855
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
856
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
8571203 ctrlPanel.add(text = new JTextArea(name)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8581204 text.addCaretListener(this);
859
- aConstraints.gridx += 1;
860
- aConstraints.gridwidth = 1;
8611205
8621206 return text;
8631207 }
....@@ -896,7 +1240,7 @@
8961240
8971241 /*
8981242 */
899
- void Return() // ObjEditor oe)
1243
+ void Return0() // ObjEditor oe)
9001244 {
9011245 aConstraints.gridy += 1;
9021246 aConstraints.gridx = 0;
....@@ -951,37 +1295,92 @@
9511295
9521296 void SetupUI2(ObjEditor oe)
9531297 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
958
- SetupName(oe);
1298
+ //SetupName(oe);
9591299
960
- if (!GroupEditor.allparams)
1300
+ namePanel = new cGridBag();
1301
+
1302
+ //if (copy.pinned)
1303
+ {
1304
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1305
+ pinButton.setSelected(copy.pinned);
1306
+ cGridBag t = new cGridBag();
1307
+ t.preferredWidth = 2;
1308
+ t.add(pinButton);
1309
+ namePanel.add(t);
1310
+
1311
+ pinButton.addItemListener(this);
1312
+ }
1313
+
1314
+ nameField = AddText(namePanel, copy.GetName());
1315
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
1316
+ oe.ctrlPanel.add(namePanel);
1317
+
1318
+ oe.ctrlPanel.Return();
1319
+
1320
+ if (!allparams)
9611321 return;
9621322
963
- liveCB = AddCheckBox(oe, "Live", copy.live);
964
- link2masterCB = AddCheckBox(oe, "Supp", copy.link2master);
965
- hideCB = AddCheckBox(oe, "Hide", copy.hide);
1323
+ setupPanel = new cGridBag().setVertical(false);
1324
+
1325
+ liveCB = AddCheckBox(setupPanel, "Live", copy.live);
1326
+ liveCB.setToolTipText("Animate object");
1327
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1328
+ markCB.setToolTipText("Set target transform");
1329
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1330
+ selectableCB.setToolTipText("Make object selectable");
9661331 // Return();
967
- markCB = AddCheckBox(oe, "Mark", copy.marked);
968
- rewindCB = AddCheckBox(oe, "Rew", copy.rewind);
969
- randomCB = AddCheckBox(oe, "Rand", copy.random);
970
- Return();
971
- resetButton = AddButton(oe, "Reset");
972
- stepButton = AddButton(oe, "Step");
1332
+
1333
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1334
+ hideCB.setToolTipText("Hide object");
1335
+
1336
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1337
+
1338
+ setupPanel2 = new cGridBag().setVertical(false);
1339
+
1340
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1341
+ rewindCB.setToolTipText("Rewind animation");
1342
+
1343
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1344
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
1345
+
1346
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1347
+ link2masterCB.setToolTipText("Attach to support");
1348
+
1349
+ if (Globals.ADVANCED)
1350
+ {
1351
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1352
+ speedupCB.setToolTipText("Option motion capture");
1353
+ }
1354
+
1355
+ oe.ctrlPanel.add(setupPanel);
1356
+ oe.ctrlPanel.Return();
1357
+ oe.ctrlPanel.add(setupPanel2);
1358
+ oe.ctrlPanel.Return();
1359
+
1360
+ objectCommandsPanel = new cGridBag().setVertical(false);
1361
+
1362
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1363
+ resetButton.setToolTipText("Jump to frame zero");
1364
+ stepButton = AddButton(objectCommandsPanel, "Step");
1365
+ stepButton.setToolTipText("Step one frame");
9731366 // resetAllButton = AddButton(oe, "Reset All");
9741367 // stepAllButton = AddButton(oe, "Step All");
975
- speedupCB = AddCheckBox(oe, "Speed", copy.speedup);
9761368 // Return();
977
- slowerButton = AddButton(oe, "Slow");
978
- fasterButton = AddButton(oe, "Fast");
979
- remarkButton = AddButton(oe, "Rem");
1369
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1370
+ slowerButton.setToolTipText("Decrease animation speed");
1371
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1372
+ fasterButton.setToolTipText("Increase animation speed");
1373
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1374
+ remarkButton.setToolTipText("Set the current transform as the target");
9801375
981
- //Return();
1376
+ oe.ctrlPanel.add(objectCommandsPanel);
1377
+ oe.ctrlPanel.Return();
9821378
983
- //normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1);
1379
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
1380
+ normalpushField = (cNumberSlider)pushPanel.getComponent(1);
9841381 //Return();
1382
+
1383
+ oe.ctrlPanel.Return();
9851384
9861385 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
9871386 // ObjEditor.aConstraints.gridx += 1;
....@@ -1076,7 +1475,7 @@
10761475 oe.aConstraints.gridwidth = 1;
10771476 /**/
10781477 nameField = AddText(oe.ctrlPanel, copy.GetName());
1079
- Return();
1478
+ oe.ctrlPanel.Return();
10801479
10811480 //ctrlPanel.add(textureButton = new Button("Texture..."));
10821481 //textureButton.setEnabled(false);
....@@ -1134,6 +1533,7 @@
11341533
11351534 if (cam == null || !(copy.get(0) instanceof cGroup))
11361535 {
1536
+ if (Globals.DEBUG)
11371537 System.out.println("CREATE CAMERAS");
11381538 cams = new cTemplate();
11391539 cams.name = "Cameras";
....@@ -1180,8 +1580,11 @@
11801580 //worldPanel.setName("World");
11811581 centralPanel = new cGridBag();
11821582 centralPanel.preferredWidth = 20;
1183
- timelinePanel = new JPanel(new BorderLayout());
1184
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1583
+
1584
+ if (Globals.ADVANCED)
1585
+ {
1586
+ timelinePanel = new JPanel(new BorderLayout());
1587
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11851588
11861589 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11871590 cameraPanel.setContinuousLayout(true);
....@@ -1190,7 +1593,10 @@
11901593 // cameraPanel.setDividerSize(9);
11911594 cameraPanel.setResizeWeight(1.0);
11921595
1596
+ }
1597
+
11931598 centralPanel.add(cameraView);
1599
+ centralPanel.setFocusable(true);
11941600 //frame.setJMenuBar(timelineMenubar);
11951601 //centralPanel.add(timelinePanel);
11961602
....@@ -1216,6 +1622,7 @@
12161622 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12171623 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12181624 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1625
+ //XYZPanel.setName("XYZ");
12191626
12201627 /*
12211628 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1253,12 +1660,29 @@
12531660 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12541661 //tmp.setName("Edit");
12551662 objectPanel.add(materialPanel);
1256
- JPanel north = new JPanel(new BorderLayout());
1257
- north.setName("Edit");
1258
- north.add(ctrlPanel, BorderLayout.NORTH);
1259
- objectPanel.add(north);
1260
- objectPanel.add(infoPanel);
1663
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1664
+ objectPanel.setToolTipTextAt(0, "Material");
1665
+
1666
+ objectPanel.add(toolboxPanel);
1667
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1668
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
12611669
1670
+ objectPanel.add(skyboxPanel);
1671
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1672
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1673
+
1674
+// JPanel north = new JPanel(new BorderLayout());
1675
+// north.setName("Edit");
1676
+// north.add(ctrlPanel, BorderLayout.NORTH);
1677
+// objectPanel.add(north);
1678
+ objectPanel.add(editPanel);
1679
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1680
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1681
+
1682
+ objectPanel.add(XYZPanel);
1683
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1684
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1685
+
12621686 /*
12631687 aConstraints.gridx = 0;
12641688 aConstraints.gridwidth = 1;
....@@ -1266,7 +1690,7 @@
12661690 aConstraints.gridy += 1;
12671691 aConstraints.gridwidth = 1;
12681692 mainPanel.add(objectPanel, aConstraints);
1269
- */
1693
+ */
12701694
12711695 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12721696 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1278,14 +1702,12 @@
12781702 scrollpane.addMouseWheelListener(this); // Default not fast enough
12791703
12801704 /*JTabbedPane*/ scenePanel = new cGridBag();
1281
- scenePanel.preferredWidth = 7;
1705
+ scenePanel.preferredWidth = 5;
12821706
12831707 JTabbedPane tabbedPane = new JTabbedPane();
12841708 tabbedPane.add(scrollpane);
12851709
1286
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1287
-
1288
- optionsPanel = new cGridBag().setVertical(true);
1710
+ optionsPanel = new cGridBag().setVertical(false);
12891711
12901712 optionsPanel.setName("Options");
12911713
....@@ -1293,8 +1715,15 @@
12931715
12941716 tabbedPane.add(optionsPanel);
12951717
1718
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1719
+
12961720 scenePanel.add(tabbedPane);
12971721
1722
+ //if (Globals.ADVANCED)
1723
+// tabbedPane.add(infoPanel);
1724
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1725
+// tabbedPane.setToolTipTextAt(3, "Information");
1726
+
12981727 /*
12991728 cTree jTree = new cTree(null);
13001729 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1356,7 +1785,7 @@
13561785 bigThree = new cGridBag();
13571786 bigThree.addComponent(scenePanel);
13581787 bigThree.addComponent(centralPanel);
1359
- bigThree.addComponent(XYZPanel);
1788
+ //bigThree.addComponent(XYZPanel);
13601789
13611790 // // SIDE EFFECT!!!
13621791 // aConstraints.gridx = 0;
....@@ -1365,16 +1794,33 @@
13651794 // aConstraints.gridheight = 1;
13661795
13671796 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1368
- framePanel.setContinuousLayout(true);
1369
- framePanel.setOneTouchExpandable(true);
1370
- framePanel.setDividerLocation(0.8);
1797
+
1798
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1799
+ new java.beans.PropertyChangeListener()
1800
+ {
1801
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1802
+ {
1803
+ if ((Integer)pce.getOldValue() == 1)
1804
+ {
1805
+ if (radio.layout != expandedLayout)
1806
+ {
1807
+ radio.layout = expandedLayout;
1808
+ radio.layout.doClick();
1809
+ }
1810
+ }
1811
+ }
1812
+ });
1813
+
1814
+ framePanel.setContinuousLayout(false);
1815
+ framePanel.setOneTouchExpandable(false);
1816
+ //.setDividerLocation(0.8);
13711817 //framePanel.setDividerSize(15);
13721818 //framePanel.setResizeWeight(0.15);
13731819 framePanel.setName("Frame");
13741820
13751821 frame.getContentPane().setLayout(new BorderLayout());
13761822 /**/
1377
- JTabbedPane worldPane = new JTabbedPane();
1823
+ //JTabbedPane worldPane = new JTabbedPane();
13781824 //worldPane.add(bigPanel);
13791825 //worldPane.add(worldPanel);
13801826 /**/
....@@ -1384,15 +1830,19 @@
13841830
13851831 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13861832
1387
- frame.setSize(1024, 768);
1388
- frame.show();
1389
-
1833
+ frame.setSize(1280, 860);
1834
+
1835
+ cameraView.requestFocusInWindow();
1836
+
13901837 gridPanel.setDividerLocation(1.0);
1838
+
1839
+ frame.validate();
1840
+
1841
+ frame.setVisible(true);
13911842
13921843 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13931844 frame.addWindowListener(new WindowAdapter()
13941845 {
1395
-
13961846 public void windowClosing(WindowEvent e)
13971847 {
13981848 Close();
....@@ -1415,27 +1865,441 @@
14151865 ctrlPanel.removeAll();
14161866 }
14171867
1418
- void SetupMaterial(cGridBag ctrlPanel)
1868
+ void SetupMaterial(cGridBag materialpanel)
14191869 {
1420
- /*
1870
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1871
+
1872
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1873
+ skin.setToolTipText("Skin");
1874
+ skin.addMouseListener(new MouseAdapter()
1875
+ {
1876
+ public void mouseClicked(MouseEvent e)
1877
+ {
1878
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1879
+ cMaterial material = object.material;
1880
+
1881
+ // Skin
1882
+ colorField.setFloat(material.color);
1883
+ saturationField.setFloat(material.modulation);
1884
+ subsurfaceField.setFloat(material.subsurface);
1885
+ selfshadowField.setFloat(material.diffuseness);
1886
+ diffusenessField.setFloat(material.factor);
1887
+ shininessField.setFloat(material.shininess);
1888
+ shadowbiasField.setFloat(material.shadowbias);
1889
+ diffuseField.setFloat(material.diffuse);
1890
+ specularField.setFloat(material.specular);
1891
+
1892
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1893
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1894
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1895
+
1896
+ materialtouched = true;
1897
+ applySelf();
1898
+ }
1899
+ });
1900
+ presetpanel.add(skin);
1901
+
1902
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1903
+ lambert.setToolTipText("Diffuse");
1904
+ lambert.addMouseListener(new MouseAdapter()
1905
+ {
1906
+ public void mouseClicked(MouseEvent e)
1907
+ {
1908
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1909
+ cMaterial material = object.material;
1910
+
1911
+ diffusenessField.setFloat(material.factor);
1912
+ selfshadowField.setFloat(material.diffuseness);
1913
+
1914
+ materialtouched = true;
1915
+ applySelf();
1916
+ }
1917
+ });
1918
+ presetpanel.add(lambert);
1919
+
1920
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1921
+ diffuse2.setToolTipText("Diffuse2");
1922
+ diffuse2.addMouseListener(new MouseAdapter()
1923
+ {
1924
+ public void mouseClicked(MouseEvent e)
1925
+ {
1926
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1927
+ cMaterial material = object.material;
1928
+
1929
+ diffusenessField.setFloat(material.factor);
1930
+ selfshadowField.setFloat(material.diffuseness);
1931
+
1932
+ materialtouched = true;
1933
+ applySelf();
1934
+ }
1935
+ });
1936
+ presetpanel.add(diffuse2);
1937
+
1938
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1939
+ diffusemoon.setToolTipText("Moon");
1940
+ diffusemoon.addMouseListener(new MouseAdapter()
1941
+ {
1942
+ public void mouseClicked(MouseEvent e)
1943
+ {
1944
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1945
+ cMaterial material = object.material;
1946
+
1947
+ diffusenessField.setFloat(material.factor);
1948
+ selfshadowField.setFloat(material.diffuseness);
1949
+
1950
+ materialtouched = true;
1951
+ applySelf();
1952
+ }
1953
+ });
1954
+ presetpanel.add(diffusemoon);
1955
+
1956
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1957
+ diffusemoon2.setToolTipText("Moon2");
1958
+ diffusemoon2.addMouseListener(new MouseAdapter()
1959
+ {
1960
+ public void mouseClicked(MouseEvent e)
1961
+ {
1962
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1963
+ cMaterial material = object.material;
1964
+
1965
+ diffusenessField.setFloat(material.factor);
1966
+ selfshadowField.setFloat(material.diffuseness);
1967
+
1968
+ materialtouched = true;
1969
+ applySelf();
1970
+ }
1971
+ });
1972
+ presetpanel.add(diffusemoon2);
1973
+
1974
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1975
+ diffusemoon3.setToolTipText("Moon3");
1976
+ diffusemoon3.addMouseListener(new MouseAdapter()
1977
+ {
1978
+ public void mouseClicked(MouseEvent e)
1979
+ {
1980
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1981
+ cMaterial material = object.material;
1982
+
1983
+ diffusenessField.setFloat(material.factor);
1984
+ selfshadowField.setFloat(material.diffuseness);
1985
+
1986
+ materialtouched = true;
1987
+ applySelf();
1988
+ }
1989
+ });
1990
+ presetpanel.add(diffusemoon3);
1991
+
1992
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1993
+ diffusesheen.setToolTipText("Sheen");
1994
+ diffusesheen.addMouseListener(new MouseAdapter()
1995
+ {
1996
+ public void mouseClicked(MouseEvent e)
1997
+ {
1998
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1999
+ cMaterial material = object.material;
2000
+
2001
+ sheenField.setFloat(material.sheen);
2002
+
2003
+ materialtouched = true;
2004
+ applySelf();
2005
+ }
2006
+ });
2007
+ presetpanel.add(diffusesheen);
2008
+
2009
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2010
+ rough.setToolTipText("Rough metal");
2011
+ rough.addMouseListener(new MouseAdapter()
2012
+ {
2013
+ public void mouseClicked(MouseEvent e)
2014
+ {
2015
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2016
+ cMaterial material = object.material;
2017
+
2018
+ shininessField.setFloat(material.shininess);
2019
+ velvetField.setFloat(material.velvet);
2020
+
2021
+ materialtouched = true;
2022
+ applySelf();
2023
+ }
2024
+ });
2025
+ presetpanel.add(rough);
2026
+
2027
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2028
+ rough2.setToolTipText("Medium metal");
2029
+ rough2.addMouseListener(new MouseAdapter()
2030
+ {
2031
+ public void mouseClicked(MouseEvent e)
2032
+ {
2033
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2034
+ cMaterial material = object.material;
2035
+
2036
+ shininessField.setFloat(material.shininess);
2037
+ lightareaField.setFloat(material.lightarea);
2038
+
2039
+ materialtouched = true;
2040
+ applySelf();
2041
+ }
2042
+ });
2043
+ presetpanel.add(rough2);
2044
+
2045
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2046
+ shini0.setToolTipText("Shiny");
2047
+ shini0.addMouseListener(new MouseAdapter()
2048
+ {
2049
+ public void mouseClicked(MouseEvent e)
2050
+ {
2051
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2052
+ cMaterial material = object.material;
2053
+
2054
+ shininessField.setFloat(material.shininess);
2055
+ lightareaField.setFloat(material.lightarea);
2056
+
2057
+ materialtouched = true;
2058
+ applySelf();
2059
+ }
2060
+ });
2061
+ presetpanel.add(shini0);
2062
+
2063
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2064
+ shini1.setToolTipText("Shiny2");
2065
+ shini1.addMouseListener(new MouseAdapter()
2066
+ {
2067
+ public void mouseClicked(MouseEvent e)
2068
+ {
2069
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2070
+ cMaterial material = object.material;
2071
+
2072
+ shininessField.setFloat(material.shininess);
2073
+ lightareaField.setFloat(material.lightarea);
2074
+
2075
+ materialtouched = true;
2076
+ applySelf();
2077
+ }
2078
+ });
2079
+ presetpanel.add(shini1);
2080
+
2081
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2082
+ shini2.setToolTipText("Shiny3");
2083
+ shini2.addMouseListener(new MouseAdapter()
2084
+ {
2085
+ public void mouseClicked(MouseEvent e)
2086
+ {
2087
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2088
+ cMaterial material = object.material;
2089
+
2090
+ shininessField.setFloat(material.shininess);
2091
+ lightareaField.setFloat(material.lightarea);
2092
+
2093
+ materialtouched = true;
2094
+ applySelf();
2095
+ }
2096
+ });
2097
+ presetpanel.add(shini2);
2098
+
2099
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2100
+ aniso.setToolTipText("AnisoU");
2101
+ aniso.addMouseListener(new MouseAdapter()
2102
+ {
2103
+ public void mouseClicked(MouseEvent e)
2104
+ {
2105
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2106
+ cMaterial material = object.material;
2107
+
2108
+ anisoField.setFloat(material.aniso);
2109
+ anisoVField.setFloat(material.anisoV);
2110
+
2111
+ materialtouched = true;
2112
+ applySelf();
2113
+ }
2114
+ });
2115
+ presetpanel.add(aniso);
2116
+
2117
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2118
+ aniso2.setToolTipText("AnisoV");
2119
+ aniso2.addMouseListener(new MouseAdapter()
2120
+ {
2121
+ public void mouseClicked(MouseEvent e)
2122
+ {
2123
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2124
+ cMaterial material = object.material;
2125
+
2126
+ anisoField.setFloat(material.aniso);
2127
+ anisoVField.setFloat(material.anisoV);
2128
+
2129
+ materialtouched = true;
2130
+ applySelf();
2131
+ }
2132
+ });
2133
+ presetpanel.add(aniso2);
2134
+
2135
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2136
+ aniso3.setToolTipText("AnisoUV");
2137
+ aniso3.addMouseListener(new MouseAdapter()
2138
+ {
2139
+ public void mouseClicked(MouseEvent e)
2140
+ {
2141
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2142
+ cMaterial material = object.material;
2143
+
2144
+ anisoField.setFloat(material.aniso);
2145
+ anisoVField.setFloat(material.anisoV);
2146
+
2147
+ materialtouched = true;
2148
+ applySelf();
2149
+ }
2150
+ });
2151
+ presetpanel.add(aniso3);
2152
+
2153
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2154
+ velvet0.setToolTipText("Velvet");
2155
+ velvet0.addMouseListener(new MouseAdapter()
2156
+ {
2157
+ public void mouseClicked(MouseEvent e)
2158
+ {
2159
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2160
+ cMaterial material = object.material;
2161
+
2162
+ diffusenessField.setFloat(material.factor);
2163
+ selfshadowField.setFloat(material.diffuseness);
2164
+ sheenField.setFloat(material.sheen);
2165
+ shininessField.setFloat(material.shininess);
2166
+ velvetField.setFloat(material.velvet);
2167
+ shiftField.setFloat(material.shift);
2168
+
2169
+ materialtouched = true;
2170
+ applySelf();
2171
+ }
2172
+ });
2173
+ presetpanel.add(velvet0);
2174
+
2175
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2176
+ bump0.setToolTipText("Bump texture");
2177
+ bump0.addMouseListener(new MouseAdapter()
2178
+ {
2179
+ public void mouseClicked(MouseEvent e)
2180
+ {
2181
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2182
+ cMaterial material = object.material;
2183
+
2184
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2185
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2186
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2187
+
2188
+ materialtouched = true;
2189
+ applySelf();
2190
+ }
2191
+ });
2192
+ presetpanel.add(bump0);
2193
+
2194
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2195
+ borderShader.setToolTipText("Border fade");
2196
+ borderShader.addMouseListener(new MouseAdapter()
2197
+ {
2198
+ public void mouseClicked(MouseEvent e)
2199
+ {
2200
+ borderfadeField.setFloat(0.5);
2201
+ opacityField.setFloat(0.75);
2202
+
2203
+ materialtouched = true;
2204
+ applySelf();
2205
+ }
2206
+ });
2207
+ presetpanel.add(borderShader);
2208
+
2209
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2210
+ halo.setToolTipText("Halo");
2211
+ halo.addMouseListener(new MouseAdapter()
2212
+ {
2213
+ public void mouseClicked(MouseEvent e)
2214
+ {
2215
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2216
+ cMaterial material = object.material;
2217
+
2218
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2219
+
2220
+ materialtouched = true;
2221
+ applySelf();
2222
+ }
2223
+ });
2224
+ presetpanel.add(halo);
2225
+
2226
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2227
+ candle.setToolTipText("Candle");
2228
+ candle.addMouseListener(new MouseAdapter()
2229
+ {
2230
+ public void mouseClicked(MouseEvent e)
2231
+ {
2232
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2233
+ cMaterial material = object.material;
2234
+
2235
+ subsurfaceField.setFloat(material.subsurface);
2236
+ shadowbiasField.setFloat(material.shadowbias);
2237
+ ambientField.setFloat(material.ambient);
2238
+ specularField.setFloat(material.specular);
2239
+ lightareaField.setFloat(material.lightarea);
2240
+ shininessField.setFloat(material.shininess);
2241
+
2242
+ materialtouched = true;
2243
+ applySelf();
2244
+ }
2245
+ });
2246
+ presetpanel.add(candle);
2247
+
2248
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2249
+ shadowShader.setToolTipText("Shadow");
2250
+ shadowShader.addMouseListener(new MouseAdapter()
2251
+ {
2252
+ public void mouseClicked(MouseEvent e)
2253
+ {
2254
+ diffuseField.setFloat(0.001);
2255
+ ambientField.setFloat(0.001);
2256
+ cameraField.setFloat(0.001);
2257
+ specularField.setFloat(0.001);
2258
+ fakedepthField.setFloat(0.001);
2259
+ opacityField.setFloat(0.6);
2260
+
2261
+ materialtouched = true;
2262
+ applySelf();
2263
+ }
2264
+ });
2265
+ presetpanel.add(shadowShader);
2266
+
2267
+ cGridBag panel = new cGridBag().setVertical(true);
2268
+
2269
+ presetpanel.preferredWidth = 1;
2270
+
2271
+ materialpanel.add(presetpanel);
2272
+ materialpanel.add(panel);
2273
+
2274
+ panel.preferredWidth = 8;
2275
+
2276
+ /*
14212277 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14222278 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1423
- */
2279
+ */
14242280
14252281 cGridBag editBar = new cGridBag().setVertical(false);
14262282
1427
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
2283
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
2284
+ createMaterialButton.setToolTipText("Create material");
14282285
14292286 /*
14302287 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14312288 */
14322289
1433
- editBar.add(clearMaterialButton = new cButton("Clear")); // , aConstraints);
1434
- editBar.add(resetSlidersButton = new cButton("Reset")); // , aConstraints);
1435
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1436
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
2290
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
2291
+ clearMaterialButton.setToolTipText("Clear material");
2292
+
2293
+ if (Globals.ADVANCED)
2294
+ {
2295
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
2296
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
2297
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
2298
+ }
14372299
1438
- ctrlPanel.add(editBar);
2300
+ editBar.preferredHeight = 15;
2301
+
2302
+ panel.add(editBar);
14392303
14402304 /**/
14412305 //aConstraints.weighty = 0;
....@@ -1446,47 +2310,63 @@
14462310 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14472311
14482312 cGridBag colorSection = new cGridBag().setVertical(true);
2313
+
2314
+ cGridBag huepanel = new cGridBag();
2315
+ cGridBag huelabel = new cGridBag();
2316
+ cLabel hue = GetLabel("icons/hue.png", false);
2317
+ hue.fit = true;
2318
+
2319
+ hue.addMouseListener(new MouseAdapter()
2320
+ {
2321
+ public void mousePressed(MouseEvent e)
2322
+ {
2323
+ int x = e.getX();
2324
+
2325
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2326
+ }
2327
+ });
2328
+
2329
+ huelabel.add(hue);
2330
+ huelabel.preferredWidth = 20;
2331
+ huepanel.add(new cGridBag()); // Label
2332
+ huepanel.add(huelabel); // Field/slider
2333
+
2334
+ huepanel.preferredHeight = 7;
2335
+
2336
+ colorSection.add(huepanel);
14492337
14502338 cGridBag color = new cGridBag();
1451
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1452
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1453
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2339
+
2340
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2341
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2342
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2343
+
14542344 //colorField.preferredWidth = 200;
14552345 colorSection.add(color);
14562346
14572347 cGridBag modulation = new cGridBag();
14582348 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14592349 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1460
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2350
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14612351 colorSection.add(modulation);
14622352
2353
+ cGridBag opacity = new cGridBag();
2354
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2355
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2356
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2357
+ colorSection.add(opacity);
2358
+
2359
+ colorSection.add(GetSeparator());
2360
+
14632361 cGridBag texture = new cGridBag();
14642362 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14652363 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14662364 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14672365 colorSection.add(texture);
14682366
1469
- cGridBag anisoU = new cGridBag();
1470
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1471
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1472
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1473
- colorSection.add(anisoU);
1474
-
1475
- cGridBag anisoV = new cGridBag();
1476
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1477
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1478
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1479
- colorSection.add(anisoV);
1480
-
1481
- cGridBag shadowbias = new cGridBag();
1482
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1483
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1484
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1485
- colorSection.add(shadowbias);
1486
-
1487
- ctrlPanel.add(new JSeparator());
2367
+ panel.add(GetSeparator());
14882368
1489
- ctrlPanel.add(colorSection);
2369
+ panel.add(colorSection);
14902370
14912371 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14922372
....@@ -1534,9 +2414,15 @@
15342414 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15352415 diffuseSection.add(fakedepth);
15362416
1537
- ctrlPanel.add(new JSeparator());
2417
+ cGridBag shadowbias = new cGridBag();
2418
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
2419
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2420
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
2421
+ diffuseSection.add(shadowbias);
2422
+
2423
+ panel.add(GetSeparator());
15382424
1539
- ctrlPanel.add(diffuseSection);
2425
+ panel.add(diffuseSection);
15402426
15412427 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15422428
....@@ -1572,7 +2458,7 @@
15722458 velvet.add(velvetField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15732459 specularSection.add(velvet);
15742460
1575
- shiftField = AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1);
2461
+ shiftField = (cNumberSlider)AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1).getComponent(1);
15762462 //Return();
15772463 // ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
15782464 // shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
....@@ -1584,42 +2470,48 @@
15842470 // aConstraints.gridy += 1;
15852471 // aConstraints.gridwidth = 1;
15862472
2473
+ cGridBag anisoU = new cGridBag();
2474
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2475
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2476
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2477
+ specularSection.add(anisoU);
15872478
1588
- ctrlPanel.add(new JSeparator());
2479
+ cGridBag anisoV = new cGridBag();
2480
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2481
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2482
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2483
+ specularSection.add(anisoV);
2484
+
2485
+
2486
+ panel.add(GetSeparator());
15892487
1590
- ctrlPanel.add(specularSection);
2488
+ panel.add(specularSection);
15912489
15922490 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15932491
1594
- cGridBag globalSection = new cGridBag().setVertical(true);
2492
+ //cGridBag globalSection = new cGridBag().setVertical(true);
15952493
15962494 cGridBag camera = new cGridBag();
15972495 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
15982496 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15992497 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1600
- globalSection.add(camera);
2498
+ colorSection.add(camera);
16012499
16022500 cGridBag ambient = new cGridBag();
16032501 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16042502 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16052503 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1606
- globalSection.add(ambient);
2504
+ colorSection.add(ambient);
16072505
16082506 cGridBag backlit = new cGridBag();
16092507 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16102508 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16112509 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1612
- globalSection.add(backlit);
2510
+ colorSection.add(backlit);
16132511
1614
- cGridBag opacity = new cGridBag();
1615
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1616
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1617
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1618
- globalSection.add(opacity);
1619
-
1620
- ctrlPanel.add(new JSeparator());
2512
+ //panel.add(new JSeparator());
16212513
1622
- ctrlPanel.add(globalSection);
2514
+ //panel.add(globalSection);
16232515
16242516 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16252517
....@@ -1661,9 +2553,9 @@
16612553 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16622554 textureSection.add(opacityPower);
16632555
1664
- ctrlPanel.add(new JSeparator());
2556
+ panel.add(GetSeparator());
16652557
1666
- ctrlPanel.add(textureSection);
2558
+ panel.add(textureSection);
16672559
16682560 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16692561
....@@ -1700,12 +2592,15 @@
17002592 opacityPowerField.addChangeListener(this);
17012593 /**/
17022594
1703
- resetSlidersButton.addActionListener(this);
17042595 clearMaterialButton.addActionListener(this);
17052596 createMaterialButton.addActionListener(this);
1706
-
1707
- propagateToggle.addItemListener(this);
1708
- multiplyToggle.addItemListener(this);
2597
+
2598
+ if (Globals.ADVANCED)
2599
+ {
2600
+ resetSlidersButton.addActionListener(this);
2601
+ propagateToggle.addItemListener(this);
2602
+ multiplyToggle.addItemListener(this);
2603
+ }
17092604 }
17102605
17112606 void DropFile(java.io.File[] files, boolean textures)
....@@ -1723,8 +2618,9 @@
17232618 // 3D models
17242619 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17252620 {
1726
- lastConverter = new com.jmex.model.converters.MaxToJme();
1727
- LoadFile(filename, lastConverter);
2621
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2622
+ //LoadFile(filename, lastConverter);
2623
+ LoadObjFile(filename); // New 3ds loader
17282624 continue;
17292625 }
17302626 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1876,7 +2772,7 @@
18762772
18772773 //? flashIt = false;
18782774 CameraPane pane = (CameraPane) cameraView;
1879
- pane.clickStart(location.x, location.y, 0);
2775
+ pane.clickStart(location.x, location.y, 0, 0);
18802776 pane.clickEnd(location.x, location.y, 0, true);
18812777
18822778 if (group.selection.size() == 1)
....@@ -1925,6 +2821,7 @@
19252821 e2.printStackTrace();
19262822 }
19272823 }
2824
+
19282825 LoadJMEThread loadThread;
19292826
19302827 class LoadJMEThread extends Thread
....@@ -1982,6 +2879,7 @@
19822879 //LoadFile0(filename, converter);
19832880 }
19842881 }
2882
+
19852883 LoadOBJThread loadObjThread;
19862884
19872885 class LoadOBJThread extends Thread
....@@ -2060,19 +2958,19 @@
20602958
20612959 void LoadObjFile(String fullname)
20622960 {
2063
- /*
2961
+ System.out.println("Loading " + fullname);
2962
+ /**/
20642963 //lastFilename = fullname;
20652964 if(loadObjThread == null)
20662965 {
2067
- loadObjThread = new LoadOBJThread();
2068
- loadObjThread.start();
2966
+ loadObjThread = new LoadOBJThread();
2967
+ loadObjThread.start();
20692968 }
20702969
20712970 loadObjThread.add(fullname);
2072
- */
2971
+ /**/
20732972
2074
- System.out.println("Loading " + fullname);
2075
- makeSomething(new FileObject(fullname, true), true);
2973
+ //makeSomething(new FileObject(fullname, true), true);
20762974 }
20772975
20782976 void LoadGFDFile(String fullname)
....@@ -2333,11 +3231,11 @@
23333231
23343232 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23353233 {
2336
- if (GrafreeD.standAlone)
3234
+ if (Grafreed.standAlone)
23373235 {
23383236 /**/
23393237 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2340
- browser.show();
3238
+ browser.setVisible(true);
23413239 String filename = browser.getFile();
23423240 if (filename != null && filename.length() > 0)
23433241 {
....@@ -2448,6 +3346,7 @@
24483346 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24493347 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24503348 }
3349
+
24513350 //cJME.count++;
24523351 //cJME.count %= 12;
24533352 if (gc)
....@@ -2482,6 +3381,7 @@
24823381 }
24833382 if (input == null)
24843383 {
3384
+ new Exception().printStackTrace();
24853385 System.exit(0);
24863386 }
24873387
....@@ -2630,6 +3530,7 @@
26303530 }
26313531 }
26323532 }
3533
+
26333534 cFileSystemPane FSPane;
26343535
26353536 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2639,7 +3540,7 @@
26393540
26403541 freezematerial = true;
26413542 colorField.setFloat(mat.color);
2642
- modulationField.setFloat(mat.modulation);
3543
+ saturationField.setFloat(mat.modulation);
26433544 metalnessField.setFloat(mat.metalness);
26443545 diffuseField.setFloat(mat.diffuse);
26453546 specularField.setFloat(mat.specular);
....@@ -2683,11 +3584,14 @@
26833584 }
26843585 }
26853586 }
3587
+
26863588 freezematerial = false;
26873589 }
26883590
26893591 void SetMaterial(Object3D object)
26903592 {
3593
+ latestObject = object;
3594
+
26913595 cMaterial mat = object.material;
26923596
26933597 if (mat == null)
....@@ -2696,33 +3600,10 @@
26963600 return;
26973601 }
26983602
2699
- multiplyToggle.setSelected(mat.multiply);
2700
-
2701
- assert (object.projectedVertices != null);
2702
-
2703
- if (object.projectedVertices.length <= 2)
2704
- {
2705
- // Side effect...
2706
- Object3D.cVector2[] keep = object.projectedVertices;
2707
- object.projectedVertices = new Object3D.cVector2[3];
2708
- for (int i = 0; i < 3; i++)
2709
- {
2710
- if (i < keep.length)
2711
- {
2712
- object.projectedVertices[i] = keep[i];
2713
- } else
2714
- {
2715
- object.projectedVertices[i] = new Object3D.cVector2();
2716
- }
2717
- /*
2718
- if(keep.length == 0)
2719
- object.projectedVertices[0] = new Object3D.cVector2();
2720
- else
2721
- object.projectedVertices[0] = keep[0];
2722
- object.projectedVertices[1] = new Object3D.cVector2();
2723
- */
2724
- }
2725
- }
3603
+ if (multiplyToggle != null)
3604
+ multiplyToggle.setSelected(mat.multiply);
3605
+
3606
+ AllocProjectedVertices(object);
27263607
27273608 SetMaterial(mat, object.projectedVertices);
27283609 }
....@@ -2798,12 +3679,17 @@
27983679 // }
27993680
28003681 /**/
2801
- if (deselect)
3682
+ if (deselect || child == null)
28023683 {
28033684 //group.deselectAll();
28043685 //freeze = true;
28053686 GetTree().clearSelection();
28063687 //freeze = false;
3688
+
3689
+ if (child == null)
3690
+ {
3691
+ return;
3692
+ }
28073693 }
28083694
28093695 //group.addSelectee(child);
....@@ -2837,6 +3723,17 @@
28373723 public void itemStateChanged(ItemEvent event)
28383724 {
28393725 // System.out.println("Propagate = " + propagate);
3726
+ if (event.getSource() == pinButton)
3727
+ {
3728
+ copy.pinned ^= true;
3729
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3730
+ {
3731
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3732
+ copy.CloseUI();
3733
+ //copy.editWindow.refreshContents();
3734
+ }
3735
+ }
3736
+ else
28403737 if (event.getSource() == propagateToggle)
28413738 {
28423739 propagate ^= true;
....@@ -2872,7 +3769,7 @@
28723769 cameraView.ToggleDL();
28733770 cameraView.repaint();
28743771 return;
2875
- } else if (event.getSource() == toggleTextureItem)
3772
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28763773 {
28773774 cameraView.ToggleTexture();
28783775 // june 2013 copy.HardTouch();
....@@ -2911,9 +3808,9 @@
29113808 frame.validate();
29123809
29133810 return;
2914
- } else if (event.getSource() == toggleRandomItem)
3811
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29153812 {
2916
- cameraView.ToggleRandom();
3813
+ cameraView.ToggleSwitch();
29173814 cameraView.repaint();
29183815 return;
29193816 } else if (event.getSource() == toggleHandleItem)
....@@ -2941,12 +3838,17 @@
29413838 } else if (event.getSource() == liveCB)
29423839 {
29433840 copy.live ^= true;
3841
+ objEditor.refreshContents(true); // To show item colors
3842
+ return;
3843
+ } else if (event.getSource() == selectableCB)
3844
+ {
3845
+ copy.dontselect ^= true;
29443846 return;
29453847 } else if (event.getSource() == hideCB)
29463848 {
29473849 copy.hide ^= true;
29483850 copy.Touch(); // display list issue
2949
- objEditor.refreshContents();
3851
+ objEditor.refreshContents(true); // To show item colors
29503852 return;
29513853 } else if (event.getSource() == link2masterCB)
29523854 {
....@@ -2956,6 +3858,7 @@
29563858 if (event.getSource() == randomCB)
29573859 {
29583860 copy.random ^= true;
3861
+ objEditor.refreshContents();
29593862 return;
29603863 }
29613864 if (event.getSource() == speedupCB)
....@@ -2979,8 +3882,9 @@
29793882
29803883 public void actionPerformed(ActionEvent event)
29813884 {
3885
+ Object source = event.getSource();
29823886 // SCRIPT DIALOG
2983
- if (event.getSource() == okbutton)
3887
+ if (source == okbutton)
29843888 {
29853889 textpanel.setVisible(false);
29863890 textpanel.remove(textarea);
....@@ -2992,7 +3896,7 @@
29923896 textarea = null;
29933897 textpanel = null;
29943898 }
2995
- if (event.getSource() == cancelbutton)
3899
+ if (source == cancelbutton)
29963900 {
29973901 textpanel.setVisible(false);
29983902 textpanel.remove(textarea);
....@@ -3004,50 +3908,50 @@
30043908 //applySelf();
30053909 //client.refreshEditWindow();
30063910 //refreshContents();
3007
- if (event.getSource() == nameField)
3911
+ if (source == nameField)
30083912 {
30093913 //System.out.println("ObjEditor " + event);
30103914 applySelf0(true);
30113915 //parent.applySelf();
30123916 objEditor.refreshContents();
3013
- } else if (event.getSource() == resetButton)
3917
+ } else if (source == resetButton)
30143918 {
30153919 CameraPane.fullreset = true;
30163920 copy.Reset(); // ResetMeshes();
30173921 copy.Touch();
30183922 objEditor.refreshContents();
3019
- } else if (event.getSource() == stepItem)
3923
+ } else if (source == stepItem)
30203924 {
30213925 //cameraView.ONESTEP = true;
30223926 Globals.ONESTEP = true;
30233927 cameraView.repaint();
30243928 return;
3025
- } else if (event.getSource() == stepButton)
3929
+ } else if (source == stepButton)
30263930 {
30273931 copy.Step();
30283932 copy.Touch();
30293933 objEditor.refreshContents();
3030
- } else if (event.getSource() == slowerButton)
3934
+ } else if (source == slowerButton)
30313935 {
30323936 copy.Slower();
30333937 copy.Touch();
30343938 objEditor.refreshContents();
3035
- } else if (event.getSource() == fasterButton)
3939
+ } else if (source == fasterButton)
30363940 {
30373941 copy.Faster();
30383942 copy.Touch();
30393943 objEditor.refreshContents();
3040
- } else if (event.getSource() == remarkButton)
3944
+ } else if (source == remarkButton)
30413945 {
30423946 copy.Remark();
30433947 copy.Touch();
30443948 objEditor.refreshContents();
3045
- } else if (event.getSource() == stepAllButton)
3949
+ } else if (source == stepAllButton)
30463950 {
30473951 copy.StepAll();
30483952 copy.Touch();
30493953 objEditor.refreshContents();
3050
- } else if (event.getSource() == resetAllButton)
3954
+ } else if (source == resetAllButton)
30513955 {
30523956 //CameraPane.fullreset = true;
30533957 copy.ResetAll(); // ResetMeshes();
....@@ -3080,53 +3984,79 @@
30803984 // Close();
30813985 // }
30823986 // else
3083
- if (event.getSource() == resetSlidersButton)
3987
+ if (source == resetSlidersButton)
30843988 {
30853989 ResetSliders();
3086
- } else if (event.getSource() == clearMaterialButton)
3990
+ } else if (source == clearMaterialButton)
30873991 {
30883992 ClearMaterial();
3089
- } else if (event.getSource() == createMaterialButton)
3993
+ } else if (source == createMaterialButton)
30903994 {
30913995 CreateMaterial();
3092
- } else if (event.getSource() == clearPanelButton)
3996
+ } else if (source == clearPanelButton)
30933997 {
30943998 copy.ClearUI();
30953999 refreshContents(true);
3096
- } /*
3097
- }
3098
-
3099
- public boolean action(Event event, Object arg)
3100
- {
3101
- */ else if (event.getSource() == closeItem)
4000
+ } else if (source == importGFDItem)
4001
+ {
4002
+ ImportGFD();
4003
+ } else
4004
+ if (source == importVRMLX3DItem)
4005
+ {
4006
+ ImportVRMLX3D();
4007
+ } else
4008
+ if (source == import3DSItem)
4009
+ {
4010
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
4011
+ } else
4012
+ if (source == importOBJItem)
4013
+ {
4014
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
4015
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
4016
+ browser.setVisible(true);
4017
+ String filename = browser.getFile();
4018
+ if (filename != null && filename.length() > 0)
4019
+ {
4020
+ String fullname = browser.getDirectory() + filename;
4021
+ makeSomething(ReadOBJ(fullname), true);
4022
+ }
4023
+ } else
4024
+ if (source == closeItem)
31024025 {
31034026 Close();
31044027 //return true;
3105
- } else if (event.getSource() == loadItem)
4028
+ } else if (source == openItem)
31064029 {
3107
- load();
4030
+ Open();
31084031 //return true;
3109
- } else if (event.getSource() == saveItem)
4032
+ } else if (source == newItem)
4033
+ {
4034
+ New();
4035
+ } else if (source == saveItem)
31104036 {
31114037 save();
31124038 //return true;
3113
- } else if (event.getSource() == saveAsItem)
4039
+ } else if (source == saveAsItem)
31144040 {
31154041 saveAs();
31164042 //return true;
3117
- } else if (event.getSource() == reexportItem)
4043
+ } else if (source == reexportItem)
31184044 {
31194045 reexport();
31204046 //return true;
3121
- } else if (event.getSource() == exportAsItem)
4047
+ } else if (source == exportAsItem)
31224048 {
31234049 export();
31244050 //return true;
3125
- } else if (event.getSource() == povItem)
4051
+ } else if (source == povItem)
31264052 {
31274053 generatePOV();
31284054 //return true;
3129
- } else if (event.getSource() == zBufferItem)
4055
+ } else if (event.getSource() == archiveItem)
4056
+ {
4057
+ cTools.Archive(frame);
4058
+ return;
4059
+ } else if (source == zBufferItem)
31304060 {
31314061 try
31324062 {
....@@ -3148,21 +4078,8 @@
31484078 cameraView.repaint();
31494079 //return true;
31504080 }
3151
- */ else if (event.getSource() == editCameraItem)
3152
- {
3153
- cameraView.ProtectCamera();
3154
- cameraView.repaint();
3155
- return;
3156
- } else if (event.getSource() == revertCameraItem)
3157
- {
3158
- cameraView.RevertCamera();
3159
- cameraView.repaint();
3160
- return;
3161
-// } else if (event.getSource() == textureButton)
3162
-// {
3163
-// return; // true;
3164
- } else // combos...
3165
- if (event.getSource() == texresMenu)
4081
+ */ else // combos...
4082
+ if (source == texresMenu)
31664083 {
31674084 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31684085 copy.texres = texresMenu.getSelectedIndex();
....@@ -3174,12 +4091,477 @@
31744091 }
31754092 }
31764093
4094
+ void New()
4095
+ {
4096
+ while (copy.Size() > 1)
4097
+ {
4098
+ copy.remove(1);
4099
+ }
4100
+
4101
+ ResetModel();
4102
+ objEditor.refreshContents();
4103
+ }
4104
+
4105
+ static public byte[] Compress(Object3D o)
4106
+ {
4107
+ // Slower to actually compress.
4108
+ try
4109
+ {
4110
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4111
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4112
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
4113
+
4114
+ Object3D parent = o.parent;
4115
+ o.parent = null;
4116
+
4117
+ out.writeObject(o);
4118
+
4119
+ o.parent = parent;
4120
+
4121
+ out.flush();
4122
+
4123
+ baos //zstream
4124
+ .close();
4125
+ out.close();
4126
+
4127
+ byte[] bytes = baos.toByteArray();
4128
+
4129
+ System.out.println("save #bytes = " + bytes.length);
4130
+ return bytes;
4131
+ } catch (Exception e)
4132
+ {
4133
+ System.err.println(e);
4134
+ return null;
4135
+ }
4136
+ }
4137
+
4138
+ static public Object Uncompress(byte[] bytes)
4139
+ {
4140
+ System.out.println("restore #bytes = " + bytes.length);
4141
+ try
4142
+ {
4143
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4144
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4145
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
4146
+ Object obj = in.readObject();
4147
+
4148
+ bais //istream
4149
+ .close();
4150
+ in.close();
4151
+
4152
+ return obj;
4153
+ } catch (Exception e)
4154
+ {
4155
+ System.err.println(e);
4156
+ return null;
4157
+ }
4158
+ }
4159
+
4160
+ static public Object clone(Object o)
4161
+ {
4162
+ try
4163
+ {
4164
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
4165
+ ObjectOutputStream out = new ObjectOutputStream(baos);
4166
+
4167
+ out.writeObject(o);
4168
+
4169
+ out.flush();
4170
+ out.close();
4171
+
4172
+ byte[] bytes = baos.toByteArray();
4173
+
4174
+ System.out.println("clone = " + bytes.length);
4175
+
4176
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
4177
+ ObjectInputStream in = new ObjectInputStream(bais);
4178
+ Object obj = in.readObject();
4179
+ in.close();
4180
+
4181
+ return obj;
4182
+ } catch (Exception e)
4183
+ {
4184
+ System.err.println(e);
4185
+ return null;
4186
+ }
4187
+ }
4188
+
4189
+ cRadio GetCurrentTab()
4190
+ {
4191
+ cRadio ab;
4192
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4193
+ {
4194
+ ab = (cRadio)e.nextElement();
4195
+ if(ab.GetObject() == copy)
4196
+ {
4197
+ return ab;
4198
+ }
4199
+ }
4200
+
4201
+ return null;
4202
+ }
4203
+
4204
+
4205
+ public void Save()
4206
+ {
4207
+ //Save(true);
4208
+ Replace();
4209
+ SetVersionStates();
4210
+ }
4211
+
4212
+ private boolean Equal(byte[] compress, byte[] name)
4213
+ {
4214
+ if (compress.length != name.length)
4215
+ {
4216
+ return false;
4217
+ }
4218
+
4219
+ for (int i=compress.length; --i>=0;)
4220
+ {
4221
+ if (compress[i] != name[i])
4222
+ return false;
4223
+ }
4224
+
4225
+ return true;
4226
+ }
4227
+
4228
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4229
+
4230
+ void DeleteVersion()
4231
+ {
4232
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4233
+ {
4234
+ copy.versionlist[i] = copy.versionlist[i+1];
4235
+ }
4236
+
4237
+ CopyChanged();
4238
+
4239
+ SetVersionStates();
4240
+ }
4241
+
4242
+ public boolean Save(boolean user)
4243
+ {
4244
+ System.err.println("Save");
4245
+ Replace();
4246
+
4247
+ //cRadio tab = GetCurrentTab();
4248
+
4249
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
4250
+
4251
+ boolean thesame = false;
4252
+
4253
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4254
+// {
4255
+// thesame = true;
4256
+// }
4257
+
4258
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
4259
+ if (!thesame)
4260
+ {
4261
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4262
+ {
4263
+ copy.versionlist[i] = copy.versionlist[i-1];
4264
+ }
4265
+
4266
+ //tab.user[tab.versionindex] = user;
4267
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4268
+
4269
+ copy.versionlist[++copy.versionindex] = compress;
4270
+
4271
+ // if (increment)
4272
+ // tab.versionindex++;
4273
+ }
4274
+
4275
+ //copy.RestoreBigData(versiontable);
4276
+
4277
+ //assert(hashtable.isEmpty());
4278
+
4279
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4280
+// {
4281
+// //tab.user[i] = false;
4282
+// copy.versionlist[i] = null;
4283
+// }
4284
+
4285
+ SetVersionStates();
4286
+
4287
+ // test save
4288
+ if (false)
4289
+ {
4290
+ try
4291
+ {
4292
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
4293
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
4294
+
4295
+ p.writeObject(copy);
4296
+
4297
+ p.flush();
4298
+
4299
+ ostream.close();
4300
+ } catch (Exception e)
4301
+ {
4302
+ e.printStackTrace();
4303
+ }
4304
+ }
4305
+
4306
+ return !thesame;
4307
+ }
4308
+
4309
+ boolean flashIt = true;
4310
+
4311
+ void RefreshSelection()
4312
+ {
4313
+ Object3D selection = new Object3D();
4314
+
4315
+ for (int i = 0; i < copy.selection.size(); i++)
4316
+ {
4317
+ Object3D elem = copy.selection.elementAt(i);
4318
+
4319
+ Object3D obj = copy.GetObject(elem.GetUUID());
4320
+
4321
+ if (obj == null)
4322
+ {
4323
+ copy.selection.remove(i--);
4324
+ }
4325
+ else
4326
+ {
4327
+ selection.add(obj);
4328
+ copy.selection.setElementAt(obj, i);
4329
+ }
4330
+ }
4331
+
4332
+ flashIt = false;
4333
+ GetTree().clearSelection();
4334
+ for (int i = 0; i < selection.size(); i++)
4335
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4336
+ flashIt = true;
4337
+
4338
+ //refreshContents(false);
4339
+ }
4340
+
4341
+ void CopyChanged()
4342
+ {
4343
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4344
+
4345
+ SetVersionStates();
4346
+
4347
+ boolean temp = CameraPane.SWITCH;
4348
+ CameraPane.SWITCH = false;
4349
+
4350
+ copy.ExtractBigData(versiontable);
4351
+
4352
+ copy.clear();
4353
+
4354
+ copy.skyboxname = obj.skyboxname;
4355
+ copy.skyboxext = obj.skyboxext;
4356
+
4357
+ for (int i=0; i<obj.Size(); i++)
4358
+ {
4359
+ copy.add(obj.get(i));
4360
+ }
4361
+
4362
+ copy.RestoreBigData(versiontable);
4363
+
4364
+ CameraPane.SWITCH = temp;
4365
+
4366
+ RefreshSelection();
4367
+ //assert(hashtable.isEmpty());
4368
+
4369
+ copy.Touch();
4370
+
4371
+ ResetModel();
4372
+ copy.HardTouch(); // recompile?
4373
+
4374
+ cRadio ab;
4375
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4376
+ {
4377
+ ab = (cRadio)e.nextElement();
4378
+ Object3D test = copy.GetObject(ab.object.GetUUID());
4379
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
4380
+ if (test != null)
4381
+ {
4382
+ test.editWindow = ab.object.editWindow;
4383
+ ab.object = test;
4384
+ }
4385
+ }
4386
+
4387
+ refreshContents(true);
4388
+ }
4389
+
4390
+ cButton previousVersionButton;
4391
+ cButton restoreButton;
4392
+ cButton replaceButton;
4393
+ cButton nextVersionButton;
4394
+ cButton saveVersionButton;
4395
+ cButton deleteVersionButton;
4396
+
4397
+ boolean muteSlider;
4398
+
4399
+ int VersionCount()
4400
+ {
4401
+ int count = 0;
4402
+
4403
+ for (int i = copy.versionlist.length; --i >= 0;)
4404
+ {
4405
+ if (copy.versionlist[i] != null)
4406
+ count++;
4407
+ }
4408
+
4409
+ return count;
4410
+ }
4411
+
4412
+ void SetVersionStates()
4413
+ {
4414
+ //if (true)
4415
+ // return;
4416
+
4417
+ //cRadio tab = GetCurrentTab();
4418
+
4419
+ restoreButton.setEnabled(copy.versionindex != -1);
4420
+ replaceButton.setEnabled(copy.versionindex != -1);
4421
+
4422
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4423
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4424
+
4425
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4426
+ copy.versionlist[copy.versionindex + 1] != null);
4427
+
4428
+ muteSlider = true;
4429
+ versionSlider.setMinimum(0);
4430
+ versionSlider.setMaximum(VersionCount() - 1);
4431
+ versionSlider.setInteger(copy.versionindex);
4432
+ versionSlider.setEnabled(copy.versionindex != -1);
4433
+ muteSlider = false;
4434
+ }
4435
+
4436
+ public boolean PreviousVersion()
4437
+ {
4438
+ // Option?
4439
+ Replace();
4440
+
4441
+ System.err.println("Undo");
4442
+
4443
+ //cRadio tab = GetCurrentTab();
4444
+
4445
+ if (copy.versionindex == 0)
4446
+ {
4447
+ java.awt.Toolkit.getDefaultToolkit().beep();
4448
+ return false;
4449
+ }
4450
+
4451
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4452
+// {
4453
+// if (Save(false))
4454
+// tab.versionindex -= 1;
4455
+// else
4456
+// {
4457
+// if (tab.versionindex <= 0)
4458
+// return false;
4459
+// else
4460
+// tab.versionindex -= 1;
4461
+// }
4462
+// }
4463
+
4464
+ copy.versionindex -= 1;
4465
+
4466
+ CopyChanged();
4467
+
4468
+ return true;
4469
+ }
4470
+
4471
+ public boolean Restore()
4472
+ {
4473
+ System.err.println("Restore");
4474
+
4475
+ //cRadio tab = GetCurrentTab();
4476
+
4477
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4478
+ {
4479
+ java.awt.Toolkit.getDefaultToolkit().beep();
4480
+ return false;
4481
+ }
4482
+
4483
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4484
+ CopyChanged();
4485
+
4486
+ return true;
4487
+ }
4488
+
4489
+ public boolean Replace()
4490
+ {
4491
+ System.err.println("Replace");
4492
+
4493
+ //cRadio tab = GetCurrentTab();
4494
+
4495
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4496
+ {
4497
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4498
+ return false;
4499
+ }
4500
+
4501
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4502
+
4503
+ return true;
4504
+ }
4505
+
4506
+ public void NextVersion()
4507
+ {
4508
+ // Option?
4509
+ Replace();
4510
+
4511
+ //cRadio tab = GetCurrentTab();
4512
+
4513
+ if (copy.versionlist[copy.versionindex + 1] == null)
4514
+ {
4515
+ java.awt.Toolkit.getDefaultToolkit().beep();
4516
+ return;
4517
+ }
4518
+
4519
+ copy.versionindex += 1;
4520
+
4521
+ CopyChanged();
4522
+
4523
+ //if (!tab.user[tab.versionindex])
4524
+ // tab.graphs[tab.versionindex] = null;
4525
+ }
4526
+
4527
+ void ImportGFD()
4528
+ {
4529
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
4530
+ browser.show();
4531
+ String filename = browser.getFile();
4532
+ if (filename != null && filename.length() > 0)
4533
+ {
4534
+ String fullname = browser.getDirectory() + filename;
4535
+
4536
+ //Object3D readobj =
4537
+ objEditor.ReadGFD(fullname, objEditor);
4538
+ //makeSomething(readobj);
4539
+ }
4540
+ }
4541
+
4542
+ void ImportVRMLX3D()
4543
+ {
4544
+ if (Grafreed.standAlone)
4545
+ {
4546
+ /**/
4547
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
4548
+ browser.show();
4549
+ String filename = browser.getFile();
4550
+ if (filename != null && filename.length() > 0)
4551
+ {
4552
+ String fullname = browser.getDirectory() + filename;
4553
+ LoadVRMLX3D(fullname);
4554
+ }
4555
+ /**/
4556
+ }
4557
+ }
4558
+
31774559 void ToggleAnimation()
31784560 {
31794561 if (!Globals.ANIMATION)
31804562 {
31814563 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3182
- browser.show();
4564
+ browser.setVisible(true);
31834565 String filename = browser.getFile();
31844566 if (filename != null && filename.length() > 0)
31854567 {
....@@ -3189,8 +4571,8 @@
31894571
31904572 Globals.ANIMATION ^= true;
31914573
3192
- GrafreeD.wav.cursor = 0;
3193
- GrafreeD.wav.loop = 0;
4574
+ Grafreed.wav.cursor = 0;
4575
+ Grafreed.wav.loop = 0;
31944576 }
31954577 } else
31964578 {
....@@ -3240,7 +4622,7 @@
32404622 void CreateMaterial()
32414623 {
32424624 //copy.ClearMaterial(); // PATCH
3243
- copy.CreateMaterialS(multiplyToggle.isSelected());
4625
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32444626 if (copy.selection.size() > 0)
32454627 //SetMaterial(copy);
32464628 {
....@@ -3291,7 +4673,7 @@
32914673 assert false;
32924674 }
32934675
3294
- void EditSelection()
4676
+ void EditSelection(boolean newWindow)
32954677 {
32964678 }
32974679
....@@ -3299,11 +4681,11 @@
32994681 {
33004682 copy.ResetBlockLoop(); // temporary problem
33014683
3302
- boolean random = CameraPane.RANDOM;
3303
- CameraPane.RANDOM = false; // parse everything
4684
+ boolean random = CameraPane.SWITCH;
4685
+ CameraPane.SWITCH = false; // parse everything
33044686 copy.ResetDisplayList();
33054687 copy.HardTouch();
3306
- CameraPane.RANDOM = random;
4688
+ CameraPane.SWITCH = random;
33074689 }
33084690
33094691 // public void applySelf()
....@@ -3350,7 +4732,7 @@
33504732 //copy.material = new cMaterial(copy.GetMaterial());
33514733
33524734 current.color = (float) colorField.getFloat();
3353
- current.modulation = (float) modulationField.getFloat();
4735
+ current.modulation = (float) saturationField.getFloat();
33544736 current.metalness = (float) metalnessField.getFloat();
33554737 current.diffuse = (float) diffuseField.getFloat();
33564738 current.specular = (float) specularField.getFloat();
....@@ -3377,6 +4759,36 @@
33774759 {
33784760 //System.out.println("Propagate = " + propagate);
33794761 copy.UpdateMaterial(anchor, current, propagate);
4762
+
4763
+ if (copy.material != null)
4764
+ {
4765
+ cMaterial mat = copy.material;
4766
+
4767
+ colorField.SetToolTipValue((mat.color));
4768
+ saturationField.SetToolTipValue((mat.modulation));
4769
+ metalnessField.SetToolTipValue((mat.metalness));
4770
+ diffuseField.SetToolTipValue((mat.diffuse));
4771
+ specularField.SetToolTipValue((mat.specular));
4772
+ shininessField.SetToolTipValue((mat.shininess));
4773
+ shiftField.SetToolTipValue((mat.shift));
4774
+ ambientField.SetToolTipValue((mat.ambient));
4775
+ lightareaField.SetToolTipValue((mat.lightarea));
4776
+ diffusenessField.SetToolTipValue((mat.factor));
4777
+ velvetField.SetToolTipValue((mat.velvet));
4778
+ sheenField.SetToolTipValue((mat.sheen));
4779
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4780
+ backlitField.SetToolTipValue((mat.bump));
4781
+ anisoField.SetToolTipValue((mat.aniso));
4782
+ anisoVField.SetToolTipValue((mat.anisoV));
4783
+ cameraField.SetToolTipValue((mat.cameralight));
4784
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4785
+ shadowField.SetToolTipValue((mat.shadow));
4786
+ textureField.SetToolTipValue((mat.texture));
4787
+ opacityField.SetToolTipValue((mat.opacity));
4788
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4789
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
4790
+ }
4791
+
33804792 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33814793 {
33824794 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3405,9 +4817,28 @@
34054817 //copy.Touch();
34064818 }
34074819
4820
+ cNumberSlider versionSlider;
4821
+
34084822 public void stateChanged(ChangeEvent e)
34094823 {
34104824 // assert(false);
4825
+ if (e.getSource() == versionSlider)
4826
+ {
4827
+ if (muteSlider)
4828
+ return;
4829
+
4830
+ Replace();
4831
+
4832
+ int version = versionSlider.getInteger();
4833
+
4834
+ if (version != -1 && copy.versionlist[version] != null)
4835
+ {
4836
+ copy.versionindex = version;
4837
+ CopyChanged();
4838
+ }
4839
+
4840
+ return;
4841
+ }
34114842
34124843 if (freezematerial)
34134844 {
....@@ -3421,6 +4852,7 @@
34214852 || e.getSource() == apertureField
34224853 || e.getSource() == shadowblurField)
34234854 {
4855
+ new Exception().printStackTrace();
34244856 System.exit(0);
34254857 cameraView.options1[0] = (float) focusField.getFloat() * 10;
34264858 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3442,6 +4874,12 @@
34424874 {
34434875 //System.out.println("stateChanged = " + this);
34444876 materialtouched = true;
4877
+
4878
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4879
+ {
4880
+ saturationField.setFloat(1);
4881
+ }
4882
+
34454883 applySelf();
34464884 //System.out.println("this = " + this);
34474885 //System.out.println("PARENT = " + parent);
....@@ -3491,7 +4929,7 @@
34914929 }
34924930
34934931 if (normalpushField != null)
3494
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4932
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
34954933 }
34964934
34974935 void SnapObject()
....@@ -3741,6 +5179,7 @@
37415179 {
37425180 if (GetTree() != null)
37435181 {
5182
+ GetTree().revalidate();
37445183 GetTree().repaint();
37455184 }
37465185
....@@ -3749,12 +5188,19 @@
37495188 ctrlPanel.validate(); // ? new
37505189 ctrlPanel.repaint();
37515190 }
5191
+
5192
+ if (previousVersionButton != null && copy.versionlist != null)
5193
+ SetVersionStates();
5194
+
5195
+ cameraView.requestFocusInWindow();
37525196 }
37535197
37545198 static TweenManager tweenManager = new TweenManager();
37555199
37565200 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37575201 {
5202
+ if (Globals.REPLACEONMAKE) // && resetmodel)
5203
+ Save();
37585204 //Tween.set(thing, 0).target(1).start(tweenManager);
37595205 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37605206 // if (thing instanceof GenericJointDemo)
....@@ -3778,7 +5224,7 @@
37785224 // group = (Composite) group.get(0);
37795225 // }
37805226
3781
- System.out.println("makeSomething of " + thing);
5227
+ //System.out.println("makeSomething of " + thing);
37825228
37835229 /*
37845230 if (deselect && jList != null)
....@@ -3841,6 +5287,12 @@
38415287 {
38425288 ResetModel();
38435289 Select(thing.GetTreePath(), true, false); // unselect... false);
5290
+
5291
+ if (thing.Size() == 0)
5292
+ {
5293
+ //EditSelection(false);
5294
+ }
5295
+
38445296 refreshContents();
38455297 }
38465298
....@@ -3958,6 +5410,7 @@
39585410 }
39595411 }
39605412 }
5413
+
39615414 LoadGFDThread loadGFDThread;
39625415
39635416 void ReadGFD(String fullname, iCallBack cb)
....@@ -3977,8 +5430,10 @@
39775430
39785431 try
39795432 {
5433
+ // Try compressed version first.
39805434 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3981
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5435
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
5436
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39825437
39835438 readobj = (Object3D) p.readObject();
39845439 istream.close();
....@@ -3986,7 +5441,22 @@
39865441 readobj.ResetDisplayList();
39875442 } catch (Exception e)
39885443 {
3989
- e.printStackTrace();
5444
+ if (!e.toString().contains("GZIP"))
5445
+ e.printStackTrace();
5446
+
5447
+ try
5448
+ {
5449
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
5450
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
5451
+
5452
+ readobj = (Object3D) p.readObject();
5453
+ istream.close();
5454
+
5455
+ readobj.ResetDisplayList();
5456
+ } catch (Exception e2)
5457
+ {
5458
+ e2.printStackTrace();
5459
+ }
39905460 }
39915461 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
39925462 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4032,6 +5502,12 @@
40325502
40335503 void LoadIt(Object obj)
40345504 {
5505
+ if (obj == null)
5506
+ {
5507
+ // Invalid file
5508
+ return;
5509
+ }
5510
+
40355511 System.out.println("Loaded " + obj);
40365512 //new Exception().printStackTrace();
40375513 Object3D readobj = (Object3D) obj;
....@@ -4041,10 +5517,14 @@
40415517
40425518 if (readobj != null)
40435519 {
5520
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5521
+ // Save();
40445522 try
40455523 {
40465524 //readobj.deepCopySelf(copy);
40475525 copy.clear(); // june 2014
5526
+ copy.skyboxname = readobj.skyboxname;
5527
+ copy.skyboxext = readobj.skyboxext;
40485528 for (int i = 0; i < readobj.size(); i++)
40495529 {
40505530 Object3D child = readobj.get(i); // reserve(i);
....@@ -4085,6 +5565,7 @@
40855565 }
40865566 } catch (ClassCastException e)
40875567 {
5568
+ e.printStackTrace();
40885569 assert (false);
40895570 Composite c = (Composite) copy;
40905571 c.children.clear();
....@@ -4095,17 +5576,31 @@
40955576 c.addChild(csg);
40965577 }
40975578
5579
+ copy.versionlist = readobj.versionlist;
5580
+ copy.versionindex = readobj.versionindex;
5581
+
5582
+ if (copy.versionlist == null)
5583
+ {
5584
+ // Backward compatibility
5585
+ copy.versionlist = new Object3D[100];
5586
+ copy.versionindex = -1;
5587
+
5588
+ //Save(true);
5589
+ }
5590
+
5591
+ //? SetUndoStates();
5592
+
40985593 ResetModel();
40995594 copy.HardTouch(); // recompile?
41005595 refreshContents();
41015596 }
41025597 }
41035598
4104
- void load() // throws ClassNotFoundException
5599
+ void Open() // throws ClassNotFoundException
41055600 {
4106
- if (GrafreeD.standAlone)
5601
+ if (Grafreed.standAlone)
41075602 {
4108
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5603
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
41095604 browser.show();
41105605 String filename = browser.getFile();
41115606 if (filename != null && filename.length() > 0)
....@@ -4182,6 +5677,8 @@
41825677
41835678 void save()
41845679 {
5680
+ Replace();
5681
+
41855682 if (lastname == null)
41865683 {
41875684 return;
....@@ -4190,11 +5687,13 @@
41905687 try
41915688 {
41925689 FileOutputStream ostream = new FileOutputStream(lastname);
4193
- ObjectOutputStream p = new ObjectOutputStream(ostream);
5690
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5691
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
41945692
41955693 p.writeObject(copy);
41965694 p.flush();
41975695
5696
+ zstream.close();
41985697 ostream.close();
41995698
42005699 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4202,19 +5701,23 @@
42025701 //ps.print(buffer.toString());
42035702 } catch (IOException e)
42045703 {
5704
+ e.printStackTrace();
42055705 }
42065706 }
5707
+
42075708 String lastname;
42085709
42095710 void saveAs()
42105711 {
4211
- if (GrafreeD.standAlone)
5712
+ if (Grafreed.standAlone)
42125713 {
42135714 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42145715 browser.setVisible(true);
42155716 String filename = browser.getFile();
42165717 if (filename != null && filename.length() > 0)
42175718 {
5719
+ if (!filename.endsWith(".gfd"))
5720
+ filename += ".gfd";
42185721 lastname = browser.getDirectory() + filename;
42195722 save();
42205723 }
....@@ -4313,13 +5816,13 @@
43135816 try
43145817 {
43155818 FileOutputStream ostream = new FileOutputStream(filename);
4316
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4317
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
5819
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
5820
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43185821
43195822 Object3D objectparent = obj.parent;
43205823 obj.parent = null;
43215824
4322
- Object3D object = (Object3D) GrafreeD.clone(obj);
5825
+ Object3D object = (Object3D) Grafreed.clone(obj);
43235826
43245827 obj.parent = objectparent;
43255828
....@@ -4331,8 +5834,8 @@
43315834 p.writeObject(object);
43325835 p.flush();
43335836
5837
+ zstream.close();
43345838 ostream.close();
4335
- // zstream.close();
43365839
43375840 // group.selection.get(0).parent = parent;
43385841 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4353,7 +5856,7 @@
43535856 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43545857 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43555858 copy.generatePOV(buffer);
4356
- if (GrafreeD.standAlone)
5859
+ if (Grafreed.standAlone)
43575860 {
43585861 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43595862 browser.show();
....@@ -4379,21 +5882,20 @@
43795882 Object3D client;
43805883 Object3D copy;
43815884 MenuBar menuBar;
4382
- Menu windowMenu;
4383
- MenuItem loadItem;
5885
+ Menu fileMenu;
5886
+ MenuItem newItem;
5887
+ MenuItem openItem;
43845888 MenuItem saveItem;
43855889 MenuItem saveAsItem;
43865890 MenuItem exportAsItem;
43875891 MenuItem reexportItem;
43885892 MenuItem povItem;
43895893 MenuItem closeItem;
4390
- Menu cameraMenu;
5894
+
43915895 CheckboxMenuItem zBufferItem;
43925896 //MenuItem normalLensItem;
4393
- MenuItem editCameraItem;
4394
- MenuItem revertCameraItem;
4395
- CheckboxMenuItem toggleLiveItem;
43965897 MenuItem stepItem;
5898
+ CheckboxMenuItem toggleLiveItem;
43975899 CheckboxMenuItem toggleFullScreenItem;
43985900 CheckboxMenuItem toggleTimelineItem;
43995901 CheckboxMenuItem toggleRenderItem;
....@@ -4402,25 +5904,40 @@
44025904 CheckboxMenuItem toggleFootContactItem;
44035905 CheckboxMenuItem toggleDLItem;
44045906 CheckboxMenuItem toggleTextureItem;
4405
- CheckboxMenuItem toggleRandomItem;
5907
+ CheckboxMenuItem toggleSwitchItem;
44065908 CheckboxMenuItem toggleRootItem;
44075909 CheckboxMenuItem animationItem;
5910
+ MenuItem archiveItem;
44085911 CheckboxMenuItem toggleHandleItem;
44095912 CheckboxMenuItem togglePaintItem;
44105913 JSplitPane mainPanel;
44115914 JScrollPane scrollpane;
5915
+
44125916 JPanel toolbarPanel;
4413
- JPanel treePanel;
5917
+
5918
+ cGridBag treePanel;
5919
+
44145920 JPanel radioPanel;
44155921 ButtonGroup buttonGroup;
4416
- cGridBag ctrlPanel;
5922
+
5923
+ cGridBag toolboxPanel;
5924
+ cGridBag skyboxPanel;
44175925 cGridBag materialPanel;
5926
+ cGridBag ctrlPanel;
5927
+
44185928 JScrollPane infoPanel;
5929
+
44195930 cGridBag optionsPanel;
5931
+
44205932 JTabbedPane objectPanel;
5933
+ boolean materialFlushed;
5934
+ Object3D latestObject;
5935
+
44215936 cGridBag XYZPanel;
5937
+
44225938 JSplitPane gridPanel;
44235939 JSplitPane bigPanel;
5940
+
44245941 cGridBag bigThree;
44255942 cGridBag scenePanel;
44265943 cGridBag centralPanel;
....@@ -4478,7 +5995,7 @@
44785995 JLabel colorLabel;
44795996 cNumberSlider colorField;
44805997 JLabel modulationLabel;
4481
- cNumberSlider modulationField;
5998
+ cNumberSlider saturationField;
44825999 JLabel metalnessLabel;
44836000 cNumberSlider metalnessField;
44846001 JLabel diffuseLabel;
....@@ -4509,6 +6026,7 @@
45096026 cNumberSlider anisoField;
45106027 JLabel anisoVLabel;
45116028 cNumberSlider anisoVField;
6029
+
45126030 JLabel cameraLabel;
45136031 cNumberSlider cameraField;
45146032 JLabel selfshadowLabel;
....@@ -4523,6 +6041,7 @@
45236041 cNumberSlider fakedepthField;
45246042 JLabel shadowbiasLabel;
45256043 cNumberSlider shadowbiasField;
6044
+
45266045 JLabel bumpLabel;
45276046 cNumberSlider bumpField;
45286047 JLabel noiseLabel;
....@@ -4535,8 +6054,13 @@
45356054 cNumberSlider fogField;
45366055 JLabel opacityPowerLabel;
45376056 cNumberSlider opacityPowerField;
4538
- JTree jTree;
6057
+ cTree jTree;
45396058 //ObjectUI parent;
45406059
45416060 cNumberSlider normalpushField;
6061
+
6062
+ private MenuItem importGFDItem;
6063
+ private MenuItem importVRMLX3DItem;
6064
+ private MenuItem import3DSItem;
6065
+ private MenuItem importOBJItem;
45426066 }