Normand Briere
2019-08-23 60cec91731a350fe67e9b5ffe7a00d70e9026314
ObjEditor.java
....@@ -72,6 +72,21 @@
7272 }
7373 }
7474
75
+ public Composite CreateCameras()
76
+ {
77
+ Composite cams = new cTemplate();
78
+ cams.name = "Cameras";
79
+ copy.insertElementAt(cams, 0);
80
+
81
+ cams.addChild(new Camera());
82
+ cams.addChild(new Camera(1));
83
+ cams.addChild(new Camera(2));
84
+ cams.addChild(new Camera(3));
85
+ cams.addChild(new Camera(4));
86
+
87
+ return cams;
88
+ }
89
+
7590 public cGridBag GetSeparator()
7691 {
7792 cGridBag separator = new cGridBag();
....@@ -119,8 +134,14 @@
119134
120135 try
121136 {
122
- BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
123
-
137
+ BufferedImage image;
138
+
139
+ if (name.endsWith("jpg"))
140
+ // Much faster!
141
+ image = new sun.awt.image.codec.JPEGImageDecoderImpl(ObjEditor.class.getClassLoader().getResourceAsStream(name)).decodeAsBufferedImage();
142
+ else
143
+ image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
144
+
124145 // if (image.getWidth() > 48 && image.getHeight() > 48)
125146 // {
126147 // BufferedImage resized = new BufferedImage(48, 48, image.getType());
....@@ -362,14 +383,6 @@
362383 client = inClient;
363384 copy = client;
364385
365
- if (copy.versionlist == null)
366
- {
367
- copy.versionlist = new Object3D[100];
368
- copy.versionindex = -1;
369
-
370
-// Save(true);
371
- }
372
-
373386 SetupUI2(callee.GetEditor());
374387 }
375388
....@@ -445,8 +458,11 @@
445458 importOBJItem.addActionListener(this);
446459 import3DSItem = menu.add(new MenuItem("3DS file..."));
447460 import3DSItem.addActionListener(this);
461
+ if (Globals.ADVANCED)
462
+ {
448463 importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
449464 importVRMLX3DItem.addActionListener(this);
465
+ }
450466 menu.add("-");
451467 importGFDItem = menu.add(new MenuItem("Grafreed file..."));
452468 importGFDItem.addActionListener(this);
....@@ -1550,23 +1566,9 @@
15501566
15511567 if (cam == null || !(copy.get(0) instanceof cGroup))
15521568 {
1553
- if (Globals.DEBUG)
1554
- System.out.println("CREATE CAMERAS");
1555
- cams = new cTemplate();
1556
- cams.name = "Cameras";
1557
- copy.insertElementAt(cams, 0);
1558
- //cams.parent = copy;
1559
-
1560
- cam = new Camera(); // LA.newVector(3, 2, 1));
1561
- cams.addChild(cam);
1562
- cam = new Camera(1);
1563
- cams.addChild(cam);
1564
- cam = new Camera(2);
1565
- cams.addChild(cam);
1566
- cam = new Camera(3);
1567
- cams.addChild(cam);
1568
- cam = new Camera(4); // Light
1569
- cams.addChild(cam);
1569
+ if (Globals.DEBUG)
1570
+ System.out.println("CREATE CAMERAS");
1571
+ cams = CreateCameras();
15701572 } else
15711573 {
15721574 cams = (cGroup) copy.get(0);
....@@ -1718,24 +1720,24 @@
17181720
17191721 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
17201722 //tmp.setName("Edit");
1723
+ objectPanel.add(skyboxPanel);
1724
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1725
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1726
+
17211727 objectPanel.add(toolboxPanel);
1722
- objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1723
- objectPanel.setToolTipTextAt(0, "Objects & textures");
1728
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1729
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
17241730
17251731 objectPanel.add(materialPanel);
1726
- objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1727
- objectPanel.setToolTipTextAt(1, "Material");
1732
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1733
+ objectPanel.setToolTipTextAt(2, "Material");
17281734
1729
- objectPanel.add(skyboxPanel);
1730
- objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1731
- objectPanel.setToolTipTextAt(2, "Backgrounds");
1732
-
17331735 // JPanel north = new JPanel(new BorderLayout());
17341736 // north.setName("Edit");
17351737 // north.add(ctrlPanel, BorderLayout.NORTH);
17361738 // objectPanel.add(north);
17371739 objectPanel.add(editPanel);
1738
- objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1740
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
17391741 objectPanel.setToolTipTextAt(3, "Edit controls");
17401742
17411743 objectPanel.add(transformPanel);
....@@ -1744,7 +1746,7 @@
17441746
17451747 patchMaterial = true;
17461748 cameraView.patchMaterial = this;
1747
- objectPanel.setSelectedIndex(1);
1749
+ objectPanel.setSelectedIndex(2);
17481750
17491751 /*
17501752 aConstraints.gridx = 0;
....@@ -1765,7 +1767,7 @@
17651767 scrollpane.addMouseWheelListener(this); // Default not fast enough
17661768
17671769 /*JTabbedPane*/ scenePanel = new cGridBag();
1768
- scenePanel.preferredWidth = 6;
1770
+ scenePanel.preferredWidth = 5;
17691771
17701772 JTabbedPane tabbedPane = new JTabbedPane();
17711773 tabbedPane.add(scrollpane);
....@@ -1785,14 +1787,14 @@
17851787 cGridBag creditsPanel = new cGridBag().setVertical(true);
17861788 creditsPanel.setName("Credits");
17871789
1788
- cLabel ogaLabel = new cLabel(" Most Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1790
+ cLabel ogaLabel = new cLabel(" Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
17891791 creditsPanel.add(ogaLabel);
17901792
1791
- cButton opengameartButton;
1792
- creditsPanel.add(opengameartButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1793
- opengameartButton.setToolTipText("https://opengameart.org");
1793
+ cButton creditButton;
1794
+ creditsPanel.add(creditButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1795
+ creditButton.setToolTipText("https://opengameart.org");
17941796
1795
- opengameartButton.addMouseListener(new MouseAdapter()
1797
+ creditButton.addMouseListener(new MouseAdapter()
17961798 {
17971799 public void mouseClicked(MouseEvent e)
17981800 {
....@@ -1807,7 +1809,64 @@
18071809 }
18081810 });
18091811
1810
- for (int i=10; --i>=0;)
1812
+ ogaLabel = new cLabel(" Download 3D models! (.3ds and .obj only)", !Globals.NIMBUSLAF);
1813
+ creditsPanel.add(ogaLabel);
1814
+
1815
+ creditsPanel.add(creditButton = GetButton("icons/3delicious.png", !Globals.NIMBUSLAF));
1816
+ creditButton.setToolTipText("https://3delicious.net");
1817
+
1818
+ creditButton.addMouseListener(new MouseAdapter()
1819
+ {
1820
+ public void mouseClicked(MouseEvent e)
1821
+ {
1822
+ try
1823
+ {
1824
+ Desktop.getDesktop().browse(new java.net.URI("https://3delicious.net"));
1825
+ } catch (Exception e1)
1826
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1827
+ {
1828
+ e1.printStackTrace();
1829
+ }
1830
+ }
1831
+ });
1832
+
1833
+ creditsPanel.add(creditButton = GetButton("icons/archive3d.png", !Globals.NIMBUSLAF));
1834
+ creditButton.setToolTipText("https://archive3d.net");
1835
+
1836
+ creditButton.addMouseListener(new MouseAdapter()
1837
+ {
1838
+ public void mouseClicked(MouseEvent e)
1839
+ {
1840
+ try
1841
+ {
1842
+ Desktop.getDesktop().browse(new java.net.URI("https://archive3d.net"));
1843
+ } catch (Exception e1)
1844
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1845
+ {
1846
+ e1.printStackTrace();
1847
+ }
1848
+ }
1849
+ });
1850
+
1851
+ creditsPanel.add(creditButton = GetButton("icons/turbosquid.png", !Globals.NIMBUSLAF));
1852
+ creditButton.setToolTipText("https://turbosquid.com");
1853
+
1854
+ creditButton.addMouseListener(new MouseAdapter()
1855
+ {
1856
+ public void mouseClicked(MouseEvent e)
1857
+ {
1858
+ try
1859
+ {
1860
+ Desktop.getDesktop().browse(new java.net.URI("https://www.turbosquid.com/Search/3D-Models/free"));
1861
+ } catch (Exception e1)
1862
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1863
+ {
1864
+ e1.printStackTrace();
1865
+ }
1866
+ }
1867
+ });
1868
+
1869
+ for (int i=6; --i>=0;)
18111870 {
18121871 creditsPanel.add(new cGridBag());
18131872 }
....@@ -1817,9 +1876,9 @@
18171876
18181877 if (Globals.ADVANCED)
18191878 {
1820
- tabbedPane.add(infoPanel);
1821
- tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1822
- tabbedPane.setToolTipTextAt(4, "Information");
1879
+ objectPanel.add(infoPanel);
1880
+ objectPanel.setIconAt(5, GetIcon("icons/info.png"));
1881
+ objectPanel.setToolTipTextAt(4, "Information");
18231882 }
18241883
18251884 /*
....@@ -2303,7 +2362,7 @@
23032362 {
23042363 public void mouseClicked(MouseEvent e)
23052364 {
2306
- borderfadeField.setFloat(0.5);
2365
+ borderfadeField.setFloat(0.4);
23072366 opacityField.setFloat(0.75);
23082367
23092368 materialtouched = true;
....@@ -2369,6 +2428,48 @@
23692428 }
23702429 });
23712430 presetpanel.add(shadowShader);
2431
+
2432
+ cLabel para0 = GetLabel("icons/shadericons/parallax0.png", !Globals.NIMBUSLAF);
2433
+ para0.setToolTipText("No parallax");
2434
+ para0.addMouseListener(new MouseAdapter()
2435
+ {
2436
+ public void mouseClicked(MouseEvent e)
2437
+ {
2438
+ parallaxField.setFloat(0.125);
2439
+
2440
+ materialtouched = true;
2441
+ applySelf();
2442
+ }
2443
+ });
2444
+ presetpanel.add(para0);
2445
+
2446
+ cLabel para1 = GetLabel("icons/shadericons/parallax1.png", !Globals.NIMBUSLAF);
2447
+ para1.setToolTipText("With parallax");
2448
+ para1.addMouseListener(new MouseAdapter()
2449
+ {
2450
+ public void mouseClicked(MouseEvent e)
2451
+ {
2452
+ parallaxField.setFloat(0.13);
2453
+
2454
+ materialtouched = true;
2455
+ applySelf();
2456
+ }
2457
+ });
2458
+ presetpanel.add(para1);
2459
+
2460
+ cLabel para2 = GetLabel("icons/shadericons/parallax2.png", !Globals.NIMBUSLAF);
2461
+ para2.setToolTipText("Reset parallax");
2462
+ para2.addMouseListener(new MouseAdapter()
2463
+ {
2464
+ public void mouseClicked(MouseEvent e)
2465
+ {
2466
+ parallaxField.setFloat(0.14);
2467
+
2468
+ materialtouched = true;
2469
+ applySelf();
2470
+ }
2471
+ });
2472
+ presetpanel.add(para2);
23722473
23732474 cGridBag panel = new cGridBag().setVertical(true);
23742475
....@@ -2615,6 +2716,12 @@
26152716 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
26162717 colorSection.add(backlit);
26172718
2719
+ cGridBag parallax = new cGridBag();
2720
+ parallax.add(parallaxLabel = new JLabel("Parallax")); // , aConstraints);
2721
+ parallaxLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2722
+ parallax.add(parallaxField = new cNumberSlider(this, 0.001, 0.25, -0.125)); // , aConstraints);
2723
+ colorSection.add(parallax);
2724
+
26182725 //panel.add(new JSeparator());
26192726
26202727 //panel.add(globalSection);
....@@ -3666,6 +3773,7 @@
36663773 shadowField.setFloat(mat.shadow);
36673774 textureField.setFloat(mat.texture);
36683775 opacityField.setFloat(mat.opacity);
3776
+ parallaxField.setFloat(mat.parallax + 0.125f);
36693777 fakedepthField.setFloat(mat.fakedepth);
36703778 shadowbiasField.setFloat(mat.shadowbias);
36713779 bumpField.setInteger(1); // dec 2013
....@@ -4206,8 +4314,12 @@
42064314
42074315 copy.selection.clear();
42084316
4317
+ if (copy == Grafreed.grafreed.universe)
4318
+ {
4319
+ CreateCameras();
4320
+ cameraView.SetCamera(GetCamera(copy, 0));
4321
+ }
42094322 ResetModel();
4210
- SetupViews();
42114323 objEditor.refreshContents();
42124324 }
42134325
....@@ -4355,7 +4467,11 @@
43554467 System.err.println("Save");
43564468 Replace();
43574469
4358
- //cRadio tab = GetCurrentTab();
4470
+ if (copy.versionlist == null)
4471
+ {
4472
+ copy.versionlist = new Object3D[100];
4473
+ copy.versionindex = -1;
4474
+ }
43594475
43604476 Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
43614477
....@@ -4529,7 +4645,7 @@
45294645
45304646 //cRadio tab = GetCurrentTab();
45314647
4532
- if (copy.versionlist == null)
4648
+ if (copy.versionindex == -2)
45334649 {
45344650 saveVersionButton.setEnabled(false);
45354651 restoreButton.setEnabled(false);
....@@ -4886,6 +5002,7 @@
48865002 current.shadow = (float) shadowField.getFloat();
48875003 current.texture = (float) textureField.getFloat();
48885004 current.opacity = (float) opacityField.getFloat();
5005
+ current.parallax = (float) parallaxField.getFloat() - 0.125f;
48895006 current.fakedepth = (float) fakedepthField.getFloat();
48905007 current.shadowbias = (float) shadowbiasField.getFloat();
48915008
....@@ -4940,6 +5057,8 @@
49405057 textureField.SetToolTipValue((mat.texture));
49415058 if (!Equal(opacityField.getFloat(), mat.opacity))
49425059 opacityField.SetToolTipValue((mat.opacity));
5060
+ //if (!Equal(parallaxField.getFloat(), mat.parallax))
5061
+ parallaxField.SetToolTipValue((mat.parallax));
49435062 if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
49445063 fakedepthField.SetToolTipValue((mat.fakedepth));
49455064 if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
....@@ -6196,6 +6315,8 @@
61966315 cNumberSlider textureField;
61976316 JLabel opacityLabel;
61986317 cNumberSlider opacityField;
6318
+ JLabel parallaxLabel;
6319
+ cNumberSlider parallaxField;
61996320 JLabel fakedepthLabel;
62006321 cNumberSlider fakedepthField;
62016322 JLabel shadowbiasLabel;