.. | .. |
---|
106 | 106 | |
---|
107 | 107 | static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>(); |
---|
108 | 108 | |
---|
109 | | - ImageIcon GetIcon(String name) |
---|
| 109 | + static ImageIcon GetIcon(String name) |
---|
110 | 110 | { |
---|
111 | 111 | javax.swing.ImageIcon iconCache = icons.get(name); |
---|
112 | 112 | if (iconCache != null) |
---|
.. | .. |
---|
116 | 116 | |
---|
117 | 117 | try |
---|
118 | 118 | { |
---|
119 | | - BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 119 | + BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name)); |
---|
120 | 120 | |
---|
121 | 121 | // if (image.getWidth() > 48 && image.getHeight() > 48) |
---|
122 | 122 | // { |
---|
.. | .. |
---|
426 | 426 | |
---|
427 | 427 | static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>(); |
---|
428 | 428 | |
---|
| 429 | + // This is to refresh the UI of the material panel. |
---|
| 430 | + boolean patchMaterial; |
---|
| 431 | + |
---|
429 | 432 | void SetupMenu() |
---|
430 | 433 | { |
---|
431 | 434 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
.. | .. |
---|
1689 | 1692 | objectPanel.setIconAt(4, GetIcon("icons/XYZ.png")); |
---|
1690 | 1693 | objectPanel.setToolTipTextAt(4, "XYZ/RGB transform"); |
---|
1691 | 1694 | |
---|
| 1695 | + patchMaterial = true; |
---|
| 1696 | + cameraView.patchMaterial = this; |
---|
| 1697 | + objectPanel.setSelectedIndex(1); |
---|
| 1698 | + |
---|
1692 | 1699 | /* |
---|
1693 | 1700 | aConstraints.gridx = 0; |
---|
1694 | 1701 | aConstraints.gridwidth = 1; |
---|
.. | .. |
---|
1708 | 1715 | scrollpane.addMouseWheelListener(this); // Default not fast enough |
---|
1709 | 1716 | |
---|
1710 | 1717 | /*JTabbedPane*/ scenePanel = new cGridBag(); |
---|
1711 | | - scenePanel.preferredWidth = 5; |
---|
| 1718 | + scenePanel.preferredWidth = 6; |
---|
1712 | 1719 | |
---|
1713 | 1720 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1714 | 1721 | tabbedPane.add(scrollpane); |
---|
.. | .. |
---|
1886 | 1893 | |
---|
1887 | 1894 | // Skin |
---|
1888 | 1895 | colorField.setFloat(material.color); |
---|
1889 | | - 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 | + |
---|
1890 | 1905 | subsurfaceField.setFloat(material.subsurface); |
---|
1891 | 1906 | selfshadowField.setFloat(material.diffuseness); |
---|
1892 | 1907 | diffusenessField.setFloat(material.factor); |
---|
.. | .. |
---|
4723 | 4738 | // else |
---|
4724 | 4739 | // applySelf(true); |
---|
4725 | 4740 | // } |
---|
| 4741 | + |
---|
| 4742 | + boolean Equal(double a, double b) |
---|
| 4743 | + { |
---|
| 4744 | + return Math.abs(a - b) < 0.001; |
---|
| 4745 | + } |
---|
| 4746 | + |
---|
4726 | 4747 | void applySelf0(boolean name) |
---|
4727 | 4748 | { |
---|
4728 | 4749 | if (name) |
---|
.. | .. |
---|
4772 | 4793 | { |
---|
4773 | 4794 | cMaterial mat = copy.material; |
---|
4774 | 4795 | |
---|
4775 | | - colorField.SetToolTipValue((mat.color)); |
---|
4776 | | - saturationField.SetToolTipValue((mat.modulation)); |
---|
4777 | | - metalnessField.SetToolTipValue((mat.metalness)); |
---|
4778 | | - diffuseField.SetToolTipValue((mat.diffuse)); |
---|
4779 | | - specularField.SetToolTipValue((mat.specular)); |
---|
4780 | | - shininessField.SetToolTipValue((mat.shininess)); |
---|
4781 | | - shiftField.SetToolTipValue((mat.shift)); |
---|
4782 | | - ambientField.SetToolTipValue((mat.ambient)); |
---|
4783 | | - lightareaField.SetToolTipValue((mat.lightarea)); |
---|
4784 | | - diffusenessField.SetToolTipValue((mat.factor)); |
---|
4785 | | - velvetField.SetToolTipValue((mat.velvet)); |
---|
4786 | | - sheenField.SetToolTipValue((mat.sheen)); |
---|
4787 | | - subsurfaceField.SetToolTipValue((mat.subsurface)); |
---|
4788 | | - backlitField.SetToolTipValue((mat.bump)); |
---|
4789 | | - anisoField.SetToolTipValue((mat.aniso)); |
---|
4790 | | - anisoVField.SetToolTipValue((mat.anisoV)); |
---|
4791 | | - cameraField.SetToolTipValue((mat.cameralight)); |
---|
4792 | | - selfshadowField.SetToolTipValue((mat.diffuseness)); |
---|
4793 | | - shadowField.SetToolTipValue((mat.shadow)); |
---|
4794 | | - textureField.SetToolTipValue((mat.texture)); |
---|
4795 | | - opacityField.SetToolTipValue((mat.opacity)); |
---|
4796 | | - fakedepthField.SetToolTipValue((mat.fakedepth)); |
---|
4797 | | - 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)); |
---|
4798 | 4842 | } |
---|
4799 | 4843 | |
---|
4800 | 4844 | if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null) |
---|