Normand Briere
2019-08-22 6a145f6c81dfcbe0653eda27d042efb48daa7512
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());
....@@ -445,8 +466,11 @@
445466 importOBJItem.addActionListener(this);
446467 import3DSItem = menu.add(new MenuItem("3DS file..."));
447468 import3DSItem.addActionListener(this);
469
+ if (Globals.ADVANCED)
470
+ {
448471 importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
449472 importVRMLX3DItem.addActionListener(this);
473
+ }
450474 menu.add("-");
451475 importGFDItem = menu.add(new MenuItem("Grafreed file..."));
452476 importGFDItem.addActionListener(this);
....@@ -1550,23 +1574,9 @@
15501574
15511575 if (cam == null || !(copy.get(0) instanceof cGroup))
15521576 {
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);
1577
+ if (Globals.DEBUG)
1578
+ System.out.println("CREATE CAMERAS");
1579
+ cams = CreateCameras();
15701580 } else
15711581 {
15721582 cams = (cGroup) copy.get(0);
....@@ -1718,24 +1728,24 @@
17181728
17191729 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
17201730 //tmp.setName("Edit");
1731
+ objectPanel.add(skyboxPanel);
1732
+ objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
1733
+ objectPanel.setToolTipTextAt(0, "Backgrounds");
1734
+
17211735 objectPanel.add(toolboxPanel);
1722
- objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1723
- objectPanel.setToolTipTextAt(0, "Objects & textures");
1736
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1737
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
17241738
17251739 objectPanel.add(materialPanel);
1726
- objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1727
- objectPanel.setToolTipTextAt(1, "Material");
1740
+ objectPanel.setIconAt(2, GetIcon("icons/material.png"));
1741
+ objectPanel.setToolTipTextAt(2, "Material");
17281742
1729
- objectPanel.add(skyboxPanel);
1730
- objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1731
- objectPanel.setToolTipTextAt(2, "Backgrounds");
1732
-
17331743 // JPanel north = new JPanel(new BorderLayout());
17341744 // north.setName("Edit");
17351745 // north.add(ctrlPanel, BorderLayout.NORTH);
17361746 // objectPanel.add(north);
17371747 objectPanel.add(editPanel);
1738
- objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1748
+ objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
17391749 objectPanel.setToolTipTextAt(3, "Edit controls");
17401750
17411751 objectPanel.add(transformPanel);
....@@ -1744,7 +1754,7 @@
17441754
17451755 patchMaterial = true;
17461756 cameraView.patchMaterial = this;
1747
- objectPanel.setSelectedIndex(1);
1757
+ objectPanel.setSelectedIndex(2);
17481758
17491759 /*
17501760 aConstraints.gridx = 0;
....@@ -1785,14 +1795,14 @@
17851795 cGridBag creditsPanel = new cGridBag().setVertical(true);
17861796 creditsPanel.setName("Credits");
17871797
1788
- cLabel ogaLabel = new cLabel(" Most Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1798
+ cLabel ogaLabel = new cLabel(" Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
17891799 creditsPanel.add(ogaLabel);
17901800
1791
- cButton opengameartButton;
1792
- creditsPanel.add(opengameartButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1793
- opengameartButton.setToolTipText("https://opengameart.org");
1801
+ cButton creditButton;
1802
+ creditsPanel.add(creditButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1803
+ creditButton.setToolTipText("https://opengameart.org");
17941804
1795
- opengameartButton.addMouseListener(new MouseAdapter()
1805
+ creditButton.addMouseListener(new MouseAdapter()
17961806 {
17971807 public void mouseClicked(MouseEvent e)
17981808 {
....@@ -1807,7 +1817,64 @@
18071817 }
18081818 });
18091819
1810
- for (int i=10; --i>=0;)
1820
+ ogaLabel = new cLabel(" Download 3D models! (.3ds and .obj only)", !Globals.NIMBUSLAF);
1821
+ creditsPanel.add(ogaLabel);
1822
+
1823
+ creditsPanel.add(creditButton = GetButton("icons/3delicious.png", !Globals.NIMBUSLAF));
1824
+ creditButton.setToolTipText("https://3delicious.net");
1825
+
1826
+ creditButton.addMouseListener(new MouseAdapter()
1827
+ {
1828
+ public void mouseClicked(MouseEvent e)
1829
+ {
1830
+ try
1831
+ {
1832
+ Desktop.getDesktop().browse(new java.net.URI("https://3delicious.net"));
1833
+ } catch (Exception e1)
1834
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1835
+ {
1836
+ e1.printStackTrace();
1837
+ }
1838
+ }
1839
+ });
1840
+
1841
+ creditsPanel.add(creditButton = GetButton("icons/archive3d.png", !Globals.NIMBUSLAF));
1842
+ creditButton.setToolTipText("https://archive3d.net");
1843
+
1844
+ creditButton.addMouseListener(new MouseAdapter()
1845
+ {
1846
+ public void mouseClicked(MouseEvent e)
1847
+ {
1848
+ try
1849
+ {
1850
+ Desktop.getDesktop().browse(new java.net.URI("https://archive3d.net"));
1851
+ } catch (Exception e1)
1852
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1853
+ {
1854
+ e1.printStackTrace();
1855
+ }
1856
+ }
1857
+ });
1858
+
1859
+ creditsPanel.add(creditButton = GetButton("icons/turbosquid.png", !Globals.NIMBUSLAF));
1860
+ creditButton.setToolTipText("https://turbosquid.com");
1861
+
1862
+ creditButton.addMouseListener(new MouseAdapter()
1863
+ {
1864
+ public void mouseClicked(MouseEvent e)
1865
+ {
1866
+ try
1867
+ {
1868
+ Desktop.getDesktop().browse(new java.net.URI("https://www.turbosquid.com/Search/3D-Models/free"));
1869
+ } catch (Exception e1)
1870
+// } catch (java.io.IOException | java.net.URISyntaxException e1)
1871
+ {
1872
+ e1.printStackTrace();
1873
+ }
1874
+ }
1875
+ });
1876
+
1877
+ for (int i=6; --i>=0;)
18111878 {
18121879 creditsPanel.add(new cGridBag());
18131880 }
....@@ -2303,7 +2370,7 @@
23032370 {
23042371 public void mouseClicked(MouseEvent e)
23052372 {
2306
- borderfadeField.setFloat(0.5);
2373
+ borderfadeField.setFloat(0.4);
23072374 opacityField.setFloat(0.75);
23082375
23092376 materialtouched = true;
....@@ -2369,6 +2436,48 @@
23692436 }
23702437 });
23712438 presetpanel.add(shadowShader);
2439
+
2440
+ cLabel para0 = GetLabel("icons/shadericons/parallax0.png", !Globals.NIMBUSLAF);
2441
+ para0.setToolTipText("No parallax");
2442
+ para0.addMouseListener(new MouseAdapter()
2443
+ {
2444
+ public void mouseClicked(MouseEvent e)
2445
+ {
2446
+ parallaxField.setFloat(0.125);
2447
+
2448
+ materialtouched = true;
2449
+ applySelf();
2450
+ }
2451
+ });
2452
+ presetpanel.add(para0);
2453
+
2454
+ cLabel para1 = GetLabel("icons/shadericons/parallax1.png", !Globals.NIMBUSLAF);
2455
+ para1.setToolTipText("With parallax");
2456
+ para1.addMouseListener(new MouseAdapter()
2457
+ {
2458
+ public void mouseClicked(MouseEvent e)
2459
+ {
2460
+ parallaxField.setFloat(0.13);
2461
+
2462
+ materialtouched = true;
2463
+ applySelf();
2464
+ }
2465
+ });
2466
+ presetpanel.add(para1);
2467
+
2468
+ cLabel para2 = GetLabel("icons/shadericons/parallax2.png", !Globals.NIMBUSLAF);
2469
+ para2.setToolTipText("Reset parallax");
2470
+ para2.addMouseListener(new MouseAdapter()
2471
+ {
2472
+ public void mouseClicked(MouseEvent e)
2473
+ {
2474
+ parallaxField.setFloat(0.14);
2475
+
2476
+ materialtouched = true;
2477
+ applySelf();
2478
+ }
2479
+ });
2480
+ presetpanel.add(para2);
23722481
23732482 cGridBag panel = new cGridBag().setVertical(true);
23742483
....@@ -2615,6 +2724,12 @@
26152724 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
26162725 colorSection.add(backlit);
26172726
2727
+ cGridBag parallax = new cGridBag();
2728
+ parallax.add(parallaxLabel = new JLabel("Parallax")); // , aConstraints);
2729
+ parallaxLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2730
+ parallax.add(parallaxField = new cNumberSlider(this, 0.001, 0.25, -0.125)); // , aConstraints);
2731
+ colorSection.add(parallax);
2732
+
26182733 //panel.add(new JSeparator());
26192734
26202735 //panel.add(globalSection);
....@@ -3666,6 +3781,7 @@
36663781 shadowField.setFloat(mat.shadow);
36673782 textureField.setFloat(mat.texture);
36683783 opacityField.setFloat(mat.opacity);
3784
+ parallaxField.setFloat(mat.parallax + 0.125f);
36693785 fakedepthField.setFloat(mat.fakedepth);
36703786 shadowbiasField.setFloat(mat.shadowbias);
36713787 bumpField.setInteger(1); // dec 2013
....@@ -4206,8 +4322,12 @@
42064322
42074323 copy.selection.clear();
42084324
4325
+ if (copy == Grafreed.grafreed.universe)
4326
+ {
4327
+ CreateCameras();
4328
+ cameraView.SetCamera(GetCamera(copy, 0));
4329
+ }
42094330 ResetModel();
4210
- SetupViews();
42114331 objEditor.refreshContents();
42124332 }
42134333
....@@ -4886,6 +5006,7 @@
48865006 current.shadow = (float) shadowField.getFloat();
48875007 current.texture = (float) textureField.getFloat();
48885008 current.opacity = (float) opacityField.getFloat();
5009
+ current.parallax = (float) parallaxField.getFloat() - 0.125f;
48895010 current.fakedepth = (float) fakedepthField.getFloat();
48905011 current.shadowbias = (float) shadowbiasField.getFloat();
48915012
....@@ -4940,6 +5061,8 @@
49405061 textureField.SetToolTipValue((mat.texture));
49415062 if (!Equal(opacityField.getFloat(), mat.opacity))
49425063 opacityField.SetToolTipValue((mat.opacity));
5064
+ //if (!Equal(parallaxField.getFloat(), mat.parallax))
5065
+ parallaxField.SetToolTipValue((mat.parallax));
49435066 if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
49445067 fakedepthField.SetToolTipValue((mat.fakedepth));
49455068 if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
....@@ -6196,6 +6319,8 @@
61966319 cNumberSlider textureField;
61976320 JLabel opacityLabel;
61986321 cNumberSlider opacityField;
6322
+ JLabel parallaxLabel;
6323
+ cNumberSlider parallaxField;
61996324 JLabel fakedepthLabel;
62006325 cNumberSlider fakedepthField;
62016326 JLabel shadowbiasLabel;