.. | .. |
---|
83 | 83 | cButton GetButton(String name, boolean border) |
---|
84 | 84 | { |
---|
85 | 85 | ImageIcon icon = GetIcon(name); |
---|
86 | | - return new cButton(icon, border); |
---|
| 86 | + if (icon != null) |
---|
| 87 | + return new cButton(icon, border); |
---|
| 88 | + else |
---|
| 89 | + return new cButton(name, border); |
---|
87 | 90 | } |
---|
88 | 91 | |
---|
89 | 92 | cLabel GetLabel(String name, boolean border) |
---|
.. | .. |
---|
106 | 109 | |
---|
107 | 110 | static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>(); |
---|
108 | 111 | |
---|
109 | | - ImageIcon GetIcon(String name) |
---|
| 112 | + static ImageIcon GetIcon(String name) |
---|
110 | 113 | { |
---|
111 | 114 | javax.swing.ImageIcon iconCache = icons.get(name); |
---|
112 | 115 | if (iconCache != null) |
---|
.. | .. |
---|
116 | 119 | |
---|
117 | 120 | try |
---|
118 | 121 | { |
---|
119 | | - BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 122 | + BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name)); |
---|
120 | 123 | |
---|
121 | 124 | // if (image.getWidth() > 48 && image.getHeight() > 48) |
---|
122 | 125 | // { |
---|
.. | .. |
---|
426 | 429 | |
---|
427 | 430 | static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>(); |
---|
428 | 431 | |
---|
| 432 | + // This is to refresh the UI of the material panel. |
---|
| 433 | + boolean patchMaterial; |
---|
| 434 | + |
---|
429 | 435 | void SetupMenu() |
---|
430 | 436 | { |
---|
431 | 437 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
.. | .. |
---|
962 | 968 | object.versionlist = null; |
---|
963 | 969 | object.versiontable = null; |
---|
964 | 970 | |
---|
| 971 | + Object3D parent = object.parent; |
---|
| 972 | + object.parent = null; |
---|
| 973 | + |
---|
965 | 974 | //byte[] compress = Compress(copy); |
---|
966 | 975 | Object3D compress = (Object3D)Grafreed.clone(object); |
---|
| 976 | + |
---|
| 977 | + object.parent = parent; |
---|
967 | 978 | |
---|
968 | 979 | object.versionlist = versions; |
---|
969 | 980 | object.versiontable = versiontable; // if Grafreed.grafreed.universe |
---|
.. | .. |
---|
1621 | 1632 | //frontView.object = copy; |
---|
1622 | 1633 | //sideView.object = copy; |
---|
1623 | 1634 | |
---|
| 1635 | + transformPanel = new cGridBag().setVertical(true); |
---|
| 1636 | + |
---|
| 1637 | + cGridBag resetTransformPanel = new cGridBag(); |
---|
| 1638 | + |
---|
| 1639 | + resetTransformPanel.preferredHeight = 2; |
---|
| 1640 | + |
---|
| 1641 | + cButton resetTransform = GetButton("Reset all", !Grafreed.NIMBUSLAF); |
---|
| 1642 | + resetTransform.addMouseListener(new MouseAdapter() |
---|
| 1643 | + { |
---|
| 1644 | + public void mouseClicked(MouseEvent e) |
---|
| 1645 | + { |
---|
| 1646 | + ResetTransform(); |
---|
| 1647 | + } |
---|
| 1648 | + }); |
---|
| 1649 | + resetTransformPanel.add(resetTransform); |
---|
| 1650 | + |
---|
| 1651 | + resetTransform = GetButton("T only", !Grafreed.NIMBUSLAF); |
---|
| 1652 | + resetTransform.addMouseListener(new MouseAdapter() |
---|
| 1653 | + { |
---|
| 1654 | + public void mouseClicked(MouseEvent e) |
---|
| 1655 | + { |
---|
| 1656 | + ResetTransform(1); |
---|
| 1657 | + } |
---|
| 1658 | + }); |
---|
| 1659 | + resetTransformPanel.add(resetTransform); |
---|
| 1660 | + |
---|
| 1661 | + resetTransform = GetButton("RS only", !Grafreed.NIMBUSLAF); |
---|
| 1662 | + resetTransform.addMouseListener(new MouseAdapter() |
---|
| 1663 | + { |
---|
| 1664 | + public void mouseClicked(MouseEvent e) |
---|
| 1665 | + { |
---|
| 1666 | + ResetTransform(2); |
---|
| 1667 | + } |
---|
| 1668 | + }); |
---|
| 1669 | + resetTransformPanel.add(resetTransform); |
---|
| 1670 | + |
---|
1624 | 1671 | XYZPanel = new cGridBag().setVertical(true); |
---|
1625 | 1672 | //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5)); |
---|
1626 | 1673 | |
---|
.. | .. |
---|
1630 | 1677 | XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll); |
---|
1631 | 1678 | //XYZPanel.setName("XYZ"); |
---|
1632 | 1679 | |
---|
| 1680 | + transformPanel.add(resetTransformPanel); |
---|
| 1681 | + transformPanel.add(XYZPanel); |
---|
| 1682 | + |
---|
1633 | 1683 | /* |
---|
1634 | 1684 | gridPanel = new JPanel(); //new BorderLayout()); |
---|
1635 | 1685 | gridPanel.setLayout(new GridLayout(1, 2)); |
---|
.. | .. |
---|
1637 | 1687 | gridPanel.add(cameraView); |
---|
1638 | 1688 | gridPanel.add(XYZPanel); |
---|
1639 | 1689 | */ |
---|
1640 | | - gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout()); |
---|
1641 | | - gridPanel.setContinuousLayout(true); |
---|
1642 | | - gridPanel.setOneTouchExpandable(true); |
---|
1643 | | - gridPanel.setDividerLocation(1.0); |
---|
1644 | | - gridPanel.setDividerSize(9); |
---|
1645 | | - gridPanel.setResizeWeight(0.85); |
---|
| 1690 | +// gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, centralPanel, XYZPanel); //new BorderLayout()); |
---|
| 1691 | +// gridPanel.setContinuousLayout(true); |
---|
| 1692 | +// gridPanel.setOneTouchExpandable(true); |
---|
| 1693 | +// gridPanel.setDividerLocation(1.0); |
---|
| 1694 | +// gridPanel.setDividerSize(9); |
---|
| 1695 | +// gridPanel.setResizeWeight(0.85); |
---|
1646 | 1696 | |
---|
1647 | 1697 | // aConstraints.weighty = 0; |
---|
1648 | 1698 | //System.out.println("THIS = " + this); |
---|
.. | .. |
---|
1685 | 1735 | objectPanel.setIconAt(3, GetIcon("icons/write.png")); |
---|
1686 | 1736 | objectPanel.setToolTipTextAt(3, "Edit controls"); |
---|
1687 | 1737 | |
---|
1688 | | - objectPanel.add(XYZPanel); |
---|
| 1738 | + objectPanel.add(transformPanel); |
---|
1689 | 1739 | objectPanel.setIconAt(4, GetIcon("icons/XYZ.png")); |
---|
1690 | | - objectPanel.setToolTipTextAt(4, "XYZ/RGB transform"); |
---|
| 1740 | + objectPanel.setToolTipTextAt(4, "TRS transform"); |
---|
1691 | 1741 | |
---|
| 1742 | + patchMaterial = true; |
---|
| 1743 | + cameraView.patchMaterial = this; |
---|
| 1744 | + objectPanel.setSelectedIndex(1); |
---|
| 1745 | + |
---|
1692 | 1746 | /* |
---|
1693 | 1747 | aConstraints.gridx = 0; |
---|
1694 | 1748 | aConstraints.gridwidth = 1; |
---|
.. | .. |
---|
1708 | 1762 | scrollpane.addMouseWheelListener(this); // Default not fast enough |
---|
1709 | 1763 | |
---|
1710 | 1764 | /*JTabbedPane*/ scenePanel = new cGridBag(); |
---|
1711 | | - scenePanel.preferredWidth = 5; |
---|
| 1765 | + scenePanel.preferredWidth = 6; |
---|
1712 | 1766 | |
---|
1713 | 1767 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1714 | 1768 | tabbedPane.add(scrollpane); |
---|
.. | .. |
---|
1750 | 1804 | jtp.add(tree); |
---|
1751 | 1805 | */ |
---|
1752 | 1806 | |
---|
1753 | | - bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel); |
---|
1754 | | - bigPanel.setContinuousLayout(true); |
---|
1755 | | - bigPanel.setOneTouchExpandable(true); |
---|
1756 | | - bigPanel.setDividerLocation(0.8); |
---|
1757 | | - bigPanel.setDividerSize(15); |
---|
1758 | | - bigPanel.setResizeWeight(0.15); |
---|
1759 | | - bigPanel.setName("Scene"); |
---|
| 1807 | +// bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scenePanel, gridPanel); |
---|
| 1808 | +// bigPanel.setContinuousLayout(true); |
---|
| 1809 | +// bigPanel.setOneTouchExpandable(true); |
---|
| 1810 | +// bigPanel.setDividerLocation(0.8); |
---|
| 1811 | +// bigPanel.setDividerSize(15); |
---|
| 1812 | +// bigPanel.setResizeWeight(0.15); |
---|
| 1813 | +// bigPanel.setName("Scene"); |
---|
1760 | 1814 | |
---|
1761 | 1815 | //bigPanel.setLayout(new BorderLayout()); |
---|
1762 | 1816 | //bigPanel.setSize(new Dimension(10,10)); |
---|
.. | .. |
---|
1840 | 1894 | |
---|
1841 | 1895 | cameraView.requestFocusInWindow(); |
---|
1842 | 1896 | |
---|
1843 | | - gridPanel.setDividerLocation(1.0); |
---|
| 1897 | +// gridPanel.setDividerLocation(1.0); |
---|
1844 | 1898 | |
---|
1845 | 1899 | frame.validate(); |
---|
1846 | 1900 | |
---|
.. | .. |
---|
1886 | 1940 | |
---|
1887 | 1941 | // Skin |
---|
1888 | 1942 | colorField.setFloat(material.color); |
---|
1889 | | - saturationField.setFloat(material.modulation); |
---|
| 1943 | + float saturation = material.modulation; |
---|
| 1944 | + |
---|
| 1945 | + if (!cameraView.Skinshader) |
---|
| 1946 | + { |
---|
| 1947 | + saturation /= 1.5; |
---|
| 1948 | + } |
---|
| 1949 | + |
---|
| 1950 | + saturationField.setFloat(saturation); |
---|
| 1951 | + |
---|
1890 | 1952 | subsurfaceField.setFloat(material.subsurface); |
---|
1891 | 1953 | selfshadowField.setFloat(material.diffuseness); |
---|
1892 | 1954 | diffusenessField.setFloat(material.factor); |
---|
.. | .. |
---|
4417 | 4479 | return count; |
---|
4418 | 4480 | } |
---|
4419 | 4481 | |
---|
| 4482 | + public cGridBag versionSliderPane; |
---|
| 4483 | + |
---|
4420 | 4484 | void SetVersionStates() |
---|
4421 | 4485 | { |
---|
4422 | 4486 | //if (true) |
---|
.. | .. |
---|
4424 | 4488 | |
---|
4425 | 4489 | //cRadio tab = GetCurrentTab(); |
---|
4426 | 4490 | |
---|
4427 | | - restoreButton.setEnabled(copy.versionindex != -1); |
---|
4428 | | - replaceButton.setEnabled(copy.versionindex != -1); |
---|
4429 | | - |
---|
4430 | | - previousVersionButton.setEnabled(copy.versionindex > 0); |
---|
4431 | | - nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null); |
---|
4432 | | - |
---|
4433 | | - deleteVersionButton.setEnabled(copy.versionindex != -1); |
---|
4434 | | - //copy.versionlist[copy.versionindex + 1] != null); |
---|
4435 | | - |
---|
4436 | | - muteSlider = true; |
---|
4437 | | - versionSlider.setMinimum(0); |
---|
4438 | | - versionSlider.setMaximum(VersionCount() - 1); |
---|
4439 | | - versionSlider.setInteger(copy.versionindex); |
---|
4440 | | - versionSlider.setEnabled(copy.versionindex != -1); |
---|
4441 | | - muteSlider = false; |
---|
| 4491 | + if (copy.versionlist == null) |
---|
| 4492 | + { |
---|
| 4493 | + saveVersionButton.setEnabled(false); |
---|
| 4494 | + restoreButton.setEnabled(false); |
---|
| 4495 | + replaceButton.setEnabled(false); |
---|
| 4496 | + previousVersionButton.setEnabled(false); |
---|
| 4497 | + nextVersionButton.setEnabled(false); |
---|
| 4498 | + deleteVersionButton.setEnabled(false); |
---|
| 4499 | + versionSliderPane.setVisible(false); |
---|
| 4500 | + } |
---|
| 4501 | + else |
---|
| 4502 | + { |
---|
| 4503 | + restoreButton.setEnabled(copy.versionindex != -1); |
---|
| 4504 | + replaceButton.setEnabled(copy.versionindex != -1); |
---|
| 4505 | + |
---|
| 4506 | + previousVersionButton.setEnabled(copy.versionindex > 0); |
---|
| 4507 | + nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null); |
---|
| 4508 | + |
---|
| 4509 | + deleteVersionButton.setEnabled(copy.versionindex != -1); |
---|
| 4510 | + //copy.versionlist[copy.versionindex + 1] != null); |
---|
| 4511 | + |
---|
| 4512 | + muteSlider = true; |
---|
| 4513 | + versionSlider.setMinimum(0); |
---|
| 4514 | + versionSlider.setMaximum(VersionCount() - 1); |
---|
| 4515 | + versionSlider.setInteger(copy.versionindex); |
---|
| 4516 | + versionSlider.setEnabled(copy.versionindex != -1); |
---|
| 4517 | + muteSlider = false; |
---|
| 4518 | + |
---|
| 4519 | + versionSliderPane.setVisible(true); |
---|
| 4520 | + } |
---|
4442 | 4521 | } |
---|
4443 | 4522 | |
---|
4444 | 4523 | public boolean PreviousVersion() |
---|
.. | .. |
---|
4723 | 4802 | // else |
---|
4724 | 4803 | // applySelf(true); |
---|
4725 | 4804 | // } |
---|
| 4805 | + |
---|
| 4806 | + boolean Equal(double a, double b) |
---|
| 4807 | + { |
---|
| 4808 | + return Math.abs(a - b) < 0.001; |
---|
| 4809 | + } |
---|
| 4810 | + |
---|
4726 | 4811 | void applySelf0(boolean name) |
---|
4727 | 4812 | { |
---|
4728 | 4813 | if (name) |
---|
.. | .. |
---|
4772 | 4857 | { |
---|
4773 | 4858 | cMaterial mat = copy.material; |
---|
4774 | 4859 | |
---|
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)); |
---|
| 4860 | + if (!Equal(colorField.getFloat(), mat.color)) |
---|
| 4861 | + colorField.SetToolTipValue((mat.color)); |
---|
| 4862 | + if (!Equal(saturationField.getFloat(), mat.modulation)) |
---|
| 4863 | + saturationField.SetToolTipValue((mat.modulation)); |
---|
| 4864 | + if (!Equal(metalnessField.getFloat(), mat.metalness)) |
---|
| 4865 | + metalnessField.SetToolTipValue((mat.metalness)); |
---|
| 4866 | + if (!Equal(diffuseField.getFloat(), mat.diffuse)) |
---|
| 4867 | + diffuseField.SetToolTipValue((mat.diffuse)); |
---|
| 4868 | + if (!Equal(specularField.getFloat(), mat.specular)) |
---|
| 4869 | + specularField.SetToolTipValue((mat.specular)); |
---|
| 4870 | + if (!Equal(shininessField.getFloat(), mat.shininess)) |
---|
| 4871 | + shininessField.SetToolTipValue((mat.shininess)); |
---|
| 4872 | + if (!Equal(shiftField.getFloat(), mat.shift)) |
---|
| 4873 | + shiftField.SetToolTipValue((mat.shift)); |
---|
| 4874 | + if (!Equal(ambientField.getFloat(), mat.ambient)) |
---|
| 4875 | + ambientField.SetToolTipValue((mat.ambient)); |
---|
| 4876 | + if (!Equal(lightareaField.getFloat(), mat.lightarea)) |
---|
| 4877 | + lightareaField.SetToolTipValue((mat.lightarea)); |
---|
| 4878 | + if (!Equal(diffusenessField.getFloat(), mat.factor)) |
---|
| 4879 | + diffusenessField.SetToolTipValue((mat.factor)); |
---|
| 4880 | + if (!Equal(velvetField.getFloat(), mat.velvet)) |
---|
| 4881 | + velvetField.SetToolTipValue((mat.velvet)); |
---|
| 4882 | + if (!Equal(sheenField.getFloat(), mat.sheen)) |
---|
| 4883 | + sheenField.SetToolTipValue((mat.sheen)); |
---|
| 4884 | + if (!Equal(subsurfaceField.getFloat(), mat.subsurface)) |
---|
| 4885 | + subsurfaceField.SetToolTipValue((mat.subsurface)); |
---|
| 4886 | + if (!Equal(backlitField.getFloat(), mat.bump)) |
---|
| 4887 | + backlitField.SetToolTipValue((mat.bump)); |
---|
| 4888 | + if (!Equal(anisoField.getFloat(), mat.aniso)) |
---|
| 4889 | + anisoField.SetToolTipValue((mat.aniso)); |
---|
| 4890 | + if (!Equal(anisoVField.getFloat(), mat.anisoV)) |
---|
| 4891 | + anisoVField.SetToolTipValue((mat.anisoV)); |
---|
| 4892 | + if (!Equal(cameraField.getFloat(), mat.cameralight)) |
---|
| 4893 | + cameraField.SetToolTipValue((mat.cameralight)); |
---|
| 4894 | + if (!Equal(selfshadowField.getFloat(), mat.diffuseness)) |
---|
| 4895 | + selfshadowField.SetToolTipValue((mat.diffuseness)); |
---|
| 4896 | + if (!Equal(shadowField.getFloat(), mat.shadow)) |
---|
| 4897 | + shadowField.SetToolTipValue((mat.shadow)); |
---|
| 4898 | + if (!Equal(textureField.getFloat(), mat.texture)) |
---|
| 4899 | + textureField.SetToolTipValue((mat.texture)); |
---|
| 4900 | + if (!Equal(opacityField.getFloat(), mat.opacity)) |
---|
| 4901 | + opacityField.SetToolTipValue((mat.opacity)); |
---|
| 4902 | + if (!Equal(fakedepthField.getFloat(), mat.fakedepth)) |
---|
| 4903 | + fakedepthField.SetToolTipValue((mat.fakedepth)); |
---|
| 4904 | + if (!Equal(shadowbiasField.getFloat(), mat.shadowbias)) |
---|
| 4905 | + shadowbiasField.SetToolTipValue((mat.shadowbias)); |
---|
4798 | 4906 | } |
---|
4799 | 4907 | |
---|
4800 | 4908 | if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null) |
---|
.. | .. |
---|
4829 | 4937 | |
---|
4830 | 4938 | public void stateChanged(ChangeEvent e) |
---|
4831 | 4939 | { |
---|
4832 | | - // assert(false); |
---|
| 4940 | + // assert(false); |
---|
4833 | 4941 | if (e.getSource() == versionSlider) |
---|
4834 | 4942 | { |
---|
4835 | 4943 | if (muteSlider) |
---|
.. | .. |
---|
5942 | 6050 | boolean materialFlushed; |
---|
5943 | 6051 | Object3D latestObject; |
---|
5944 | 6052 | |
---|
| 6053 | + cGridBag transformPanel; |
---|
5945 | 6054 | cGridBag XYZPanel; |
---|
5946 | 6055 | |
---|
5947 | 6056 | JSplitPane gridPanel; |
---|