Normand Briere
2019-08-17 5892f05411c3d4dce2d8a59e0966dc2e1843a971
ObjEditor.java
....@@ -106,7 +106,7 @@
106106
107107 static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
108108
109
- ImageIcon GetIcon(String name)
109
+ static ImageIcon GetIcon(String name)
110110 {
111111 javax.swing.ImageIcon iconCache = icons.get(name);
112112 if (iconCache != null)
....@@ -116,7 +116,7 @@
116116
117117 try
118118 {
119
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
119
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
120120
121121 // if (image.getWidth() > 48 && image.getHeight() > 48)
122122 // {
....@@ -388,7 +388,8 @@
388388 //parent = p;
389389
390390 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
391
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
391
+ if (Globals.DEBUG)
392
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
392393 //gd.setFullScreenWindow(this);
393394 //setResizable(false);
394395 //if (!isDisplayable())
....@@ -425,6 +426,9 @@
425426
426427 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
427428
429
+ // This is to refresh the UI of the material panel.
430
+ boolean patchMaterial;
431
+
428432 void SetupMenu()
429433 {
430434 frame.setMenuBar(menuBar = new MenuBar());
....@@ -950,18 +954,24 @@
950954 boolean temp = CameraPane.SWITCH;
951955 CameraPane.SWITCH = false;
952956
953
- object.ExtractBigData(versiontable);
957
+ if (Grafreed.grafreed.universe.versiontable == null)
958
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
959
+
960
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
954961 // if (copy == client)
955962
956963 Object3D versions[] = object.versionlist;
964
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
957965 object.versionlist = null;
966
+ object.versiontable = null;
958967
959968 //byte[] compress = Compress(copy);
960969 Object3D compress = (Object3D)Grafreed.clone(object);
961970
962971 object.versionlist = versions;
972
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
963973
964
- object.RestoreBigData(versiontable);
974
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
965975
966976 CameraPane.SWITCH = temp;
967977
....@@ -1323,14 +1333,14 @@
13231333
13241334 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
13251335 liveCB.setToolTipText("Animate object");
1336
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1337
+ markCB.setToolTipText("Set target transform");
13261338 selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
13271339 selectableCB.setToolTipText("Make object selectable");
13281340 // Return();
13291341
13301342 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
13311343 hideCB.setToolTipText("Hide object");
1332
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1333
- markCB.setToolTipText("As animation target transform");
13341344
13351345 ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
13361346
....@@ -1532,6 +1542,7 @@
15321542
15331543 if (cam == null || !(copy.get(0) instanceof cGroup))
15341544 {
1545
+ if (Globals.DEBUG)
15351546 System.out.println("CREATE CAMERAS");
15361547 cams = new cTemplate();
15371548 cams.name = "Cameras";
....@@ -1657,14 +1668,14 @@
16571668
16581669 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
16591670 //tmp.setName("Edit");
1660
- objectPanel.add(materialPanel);
1661
- objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1662
- objectPanel.setToolTipTextAt(0, "Material");
1663
-
16641671 objectPanel.add(toolboxPanel);
1665
- objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1666
- objectPanel.setToolTipTextAt(1, "Objects & textures");
1672
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1673
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
16671674
1675
+ objectPanel.add(materialPanel);
1676
+ objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1677
+ objectPanel.setToolTipTextAt(1, "Material");
1678
+
16681679 objectPanel.add(skyboxPanel);
16691680 objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
16701681 objectPanel.setToolTipTextAt(2, "Backgrounds");
....@@ -1681,6 +1692,10 @@
16811692 objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
16821693 objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
16831694
1695
+ patchMaterial = true;
1696
+ cameraView.patchMaterial = this;
1697
+ objectPanel.setSelectedIndex(1);
1698
+
16841699 /*
16851700 aConstraints.gridx = 0;
16861701 aConstraints.gridwidth = 1;
....@@ -1700,7 +1715,7 @@
17001715 scrollpane.addMouseWheelListener(this); // Default not fast enough
17011716
17021717 /*JTabbedPane*/ scenePanel = new cGridBag();
1703
- scenePanel.preferredWidth = 5;
1718
+ scenePanel.preferredWidth = 6;
17041719
17051720 JTabbedPane tabbedPane = new JTabbedPane();
17061721 tabbedPane.add(scrollpane);
....@@ -1878,7 +1893,15 @@
18781893
18791894 // Skin
18801895 colorField.setFloat(material.color);
1881
- saturationField.setFloat(material.modulation);
1896
+ float saturation = material.modulation;
1897
+
1898
+ if (!cameraView.Skinshader)
1899
+ {
1900
+ saturation /= 1.5;
1901
+ }
1902
+
1903
+ saturationField.setFloat(saturation);
1904
+
18821905 subsurfaceField.setFloat(material.subsurface);
18831906 selfshadowField.setFloat(material.diffuseness);
18841907 diffusenessField.setFloat(material.factor);
....@@ -2196,7 +2219,7 @@
21962219 public void mouseClicked(MouseEvent e)
21972220 {
21982221 borderfadeField.setFloat(0.5);
2199
- opacityField.setFloat(0.6);
2222
+ opacityField.setFloat(0.75);
22002223
22012224 materialtouched = true;
22022225 applySelf();
....@@ -2311,9 +2334,20 @@
23112334
23122335 cGridBag huepanel = new cGridBag();
23132336 cGridBag huelabel = new cGridBag();
2314
- skin = GetLabel("icons/hue.png", false);
2315
- skin.fit = true;
2316
- huelabel.add(skin);
2337
+ cLabel hue = GetLabel("icons/hue.png", false);
2338
+ hue.fit = true;
2339
+
2340
+ hue.addMouseListener(new MouseAdapter()
2341
+ {
2342
+ public void mousePressed(MouseEvent e)
2343
+ {
2344
+ int x = e.getX();
2345
+
2346
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2347
+ }
2348
+ });
2349
+
2350
+ huelabel.add(hue);
23172351 huelabel.preferredWidth = 20;
23182352 huepanel.add(new cGridBag()); // Label
23192353 huepanel.add(huelabel); // Field/slider
....@@ -3900,7 +3934,7 @@
39003934 //System.out.println("ObjEditor " + event);
39013935 applySelf0(true);
39023936 //parent.applySelf();
3903
- objEditor.refreshContents();
3937
+ // conflicts with requestFocus objEditor.refreshContents();
39043938 } else if (source == resetButton)
39053939 {
39063940 CameraPane.fullreset = true;
....@@ -4212,8 +4246,6 @@
42124246 return true;
42134247 }
42144248
4215
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4216
-
42174249 void DeleteVersion()
42184250 {
42194251 for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
....@@ -4221,7 +4253,11 @@
42214253 copy.versionlist[i] = copy.versionlist[i+1];
42224254 }
42234255
4224
- CopyChanged();
4256
+ if (copy.versionlist[copy.versionindex] == null)
4257
+ copy.versionindex -= 1;
4258
+
4259
+ if (copy.versionindex != -1)
4260
+ CopyChanged();
42254261
42264262 SetVersionStates();
42274263 }
....@@ -4334,7 +4370,7 @@
43344370 boolean temp = CameraPane.SWITCH;
43354371 CameraPane.SWITCH = false;
43364372
4337
- copy.ExtractBigData(versiontable);
4373
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
43384374
43394375 copy.clear();
43404376
....@@ -4346,7 +4382,7 @@
43464382 copy.add(obj.get(i));
43474383 }
43484384
4349
- copy.RestoreBigData(versiontable);
4385
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
43504386
43514387 CameraPane.SWITCH = temp;
43524388
....@@ -4409,8 +4445,8 @@
44094445 previousVersionButton.setEnabled(copy.versionindex > 0);
44104446 nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
44114447
4412
- deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4413
- copy.versionlist[copy.versionindex + 1] != null);
4448
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4449
+ //copy.versionlist[copy.versionindex + 1] != null);
44144450
44154451 muteSlider = true;
44164452 versionSlider.setMinimum(0);
....@@ -4475,7 +4511,7 @@
44754511
44764512 public boolean Replace()
44774513 {
4478
- System.err.println("Replace");
4514
+ //System.err.println("Replace");
44794515
44804516 //cRadio tab = GetCurrentTab();
44814517
....@@ -4702,6 +4738,12 @@
47024738 // else
47034739 // applySelf(true);
47044740 // }
4741
+
4742
+ boolean Equal(double a, double b)
4743
+ {
4744
+ return Math.abs(a - b) < 0.001;
4745
+ }
4746
+
47054747 void applySelf0(boolean name)
47064748 {
47074749 if (name)
....@@ -4751,29 +4793,52 @@
47514793 {
47524794 cMaterial mat = copy.material;
47534795
4754
- colorField.SetToolTipValue((mat.color));
4755
- saturationField.SetToolTipValue((mat.modulation));
4756
- metalnessField.SetToolTipValue((mat.metalness));
4757
- diffuseField.SetToolTipValue((mat.diffuse));
4758
- specularField.SetToolTipValue((mat.specular));
4759
- shininessField.SetToolTipValue((mat.shininess));
4760
- shiftField.SetToolTipValue((mat.shift));
4761
- ambientField.SetToolTipValue((mat.ambient));
4762
- lightareaField.SetToolTipValue((mat.lightarea));
4763
- diffusenessField.SetToolTipValue((mat.factor));
4764
- velvetField.SetToolTipValue((mat.velvet));
4765
- sheenField.SetToolTipValue((mat.sheen));
4766
- subsurfaceField.SetToolTipValue((mat.subsurface));
4767
- backlitField.SetToolTipValue((mat.bump));
4768
- anisoField.SetToolTipValue((mat.aniso));
4769
- anisoVField.SetToolTipValue((mat.anisoV));
4770
- cameraField.SetToolTipValue((mat.cameralight));
4771
- selfshadowField.SetToolTipValue((mat.diffuseness));
4772
- shadowField.SetToolTipValue((mat.shadow));
4773
- textureField.SetToolTipValue((mat.texture));
4774
- opacityField.SetToolTipValue((mat.opacity));
4775
- fakedepthField.SetToolTipValue((mat.fakedepth));
4776
- shadowbiasField.SetToolTipValue((mat.shadowbias));
4796
+ if (!Equal(colorField.getFloat(), mat.color))
4797
+ colorField.SetToolTipValue((mat.color));
4798
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4799
+ saturationField.SetToolTipValue((mat.modulation));
4800
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4801
+ metalnessField.SetToolTipValue((mat.metalness));
4802
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4803
+ diffuseField.SetToolTipValue((mat.diffuse));
4804
+ if (!Equal(specularField.getFloat(), mat.specular))
4805
+ specularField.SetToolTipValue((mat.specular));
4806
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4807
+ shininessField.SetToolTipValue((mat.shininess));
4808
+ if (!Equal(shiftField.getFloat(), mat.shift))
4809
+ shiftField.SetToolTipValue((mat.shift));
4810
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4811
+ ambientField.SetToolTipValue((mat.ambient));
4812
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4813
+ lightareaField.SetToolTipValue((mat.lightarea));
4814
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4815
+ diffusenessField.SetToolTipValue((mat.factor));
4816
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4817
+ velvetField.SetToolTipValue((mat.velvet));
4818
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4819
+ sheenField.SetToolTipValue((mat.sheen));
4820
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4821
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4822
+ if (!Equal(backlitField.getFloat(), mat.bump))
4823
+ backlitField.SetToolTipValue((mat.bump));
4824
+ if (!Equal(anisoField.getFloat(), mat.aniso))
4825
+ anisoField.SetToolTipValue((mat.aniso));
4826
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
4827
+ anisoVField.SetToolTipValue((mat.anisoV));
4828
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
4829
+ cameraField.SetToolTipValue((mat.cameralight));
4830
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
4831
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4832
+ if (!Equal(shadowField.getFloat(), mat.shadow))
4833
+ shadowField.SetToolTipValue((mat.shadow));
4834
+ if (!Equal(textureField.getFloat(), mat.texture))
4835
+ textureField.SetToolTipValue((mat.texture));
4836
+ if (!Equal(opacityField.getFloat(), mat.opacity))
4837
+ opacityField.SetToolTipValue((mat.opacity));
4838
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
4839
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4840
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
4841
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
47774842 }
47784843
47794844 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -5178,6 +5243,8 @@
51785243
51795244 if (previousVersionButton != null && copy.versionlist != null)
51805245 SetVersionStates();
5246
+
5247
+ cameraView.requestFocusInWindow();
51815248 }
51825249
51835250 static TweenManager tweenManager = new TweenManager();
....@@ -5209,7 +5276,7 @@
52095276 // group = (Composite) group.get(0);
52105277 // }
52115278
5212
- System.out.println("makeSomething of " + thing);
5279
+ //System.out.println("makeSomething of " + thing);
52135280
52145281 /*
52155282 if (deselect && jList != null)
....@@ -5563,6 +5630,7 @@
55635630
55645631 copy.versionlist = readobj.versionlist;
55655632 copy.versionindex = readobj.versionindex;
5633
+ copy.versiontable = readobj.versiontable;
55665634
55675635 if (copy.versionlist == null)
55685636 {