Normand Briere
2019-08-26 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a
ObjEditor.java
....@@ -134,8 +134,14 @@
134134
135135 try
136136 {
137
- BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
138
-
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
+
139145 // if (image.getWidth() > 48 && image.getHeight() > 48)
140146 // {
141147 // BufferedImage resized = new BufferedImage(48, 48, image.getType());
....@@ -310,6 +316,8 @@
310316 objEditor.ctrlPanel.remove(setupPanel2);
311317 objEditor.ctrlPanel.remove(objectCommandsPanel);
312318 objEditor.ctrlPanel.remove(pushPanel);
319
+ if (versionPanel != null)
320
+ objEditor.ctrlPanel.remove(versionPanel);
313321 //objEditor.ctrlPanel.remove(fillPanel);
314322
315323 //Remove(normalpushField);
....@@ -377,14 +385,6 @@
377385 client = inClient;
378386 copy = client;
379387
380
- if (copy.versionlist == null)
381
- {
382
- copy.versionlist = new Object3D[100];
383
- copy.versionindex = -1;
384
-
385
-// Save(true);
386
- }
387
-
388388 SetupUI2(callee.GetEditor());
389389 }
390390
....@@ -460,8 +460,11 @@
460460 importOBJItem.addActionListener(this);
461461 import3DSItem = menu.add(new MenuItem("3DS file..."));
462462 import3DSItem.addActionListener(this);
463
+ if (Globals.ADVANCED)
464
+ {
463465 importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
464466 importVRMLX3DItem.addActionListener(this);
467
+ }
465468 menu.add("-");
466469 importGFDItem = menu.add(new MenuItem("Grafreed file..."));
467470 importGFDItem.addActionListener(this);
....@@ -1162,6 +1165,7 @@
11621165 cGridBag setupPanel2;
11631166 cGridBag objectCommandsPanel;
11641167 cGridBag pushPanel;
1168
+ cGridBag versionPanel;
11651169 cGridBag fillPanel;
11661170
11671171 JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
....@@ -1408,9 +1412,14 @@
14081412 oe.ctrlPanel.add(objectCommandsPanel);
14091413 oe.ctrlPanel.Return();
14101414
1411
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
1415
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH * 100, 1.1); // To have the buttons
14121416 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1413
- //Return();
1417
+ if (false && copy.versionlist != null && copy.versionindex != -1)
1418
+ {
1419
+ oe.ctrlPanel.Return();
1420
+ versionPanel = AddSlider(oe.ctrlPanel, "Version", 0, copy.VersionCount() - 1, copy.versionindex);
1421
+ versionField = (cNumberSlider)versionPanel.getComponent(1);
1422
+ }
14141423
14151424 oe.ctrlPanel.Return();
14161425
....@@ -1766,7 +1775,7 @@
17661775 scrollpane.addMouseWheelListener(this); // Default not fast enough
17671776
17681777 /*JTabbedPane*/ scenePanel = new cGridBag();
1769
- scenePanel.preferredWidth = 6;
1778
+ scenePanel.preferredWidth = 5;
17701779
17711780 JTabbedPane tabbedPane = new JTabbedPane();
17721781 tabbedPane.add(scrollpane);
....@@ -1786,14 +1795,14 @@
17861795 cGridBag creditsPanel = new cGridBag().setVertical(true);
17871796 creditsPanel.setName("Credits");
17881797
1789
- cLabel ogaLabel = new cLabel(" Most Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
1798
+ cLabel ogaLabel = new cLabel(" Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
17901799 creditsPanel.add(ogaLabel);
17911800
1792
- cButton opengameartButton;
1793
- creditsPanel.add(opengameartButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
1794
- 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");
17951804
1796
- opengameartButton.addMouseListener(new MouseAdapter()
1805
+ creditButton.addMouseListener(new MouseAdapter()
17971806 {
17981807 public void mouseClicked(MouseEvent e)
17991808 {
....@@ -1808,7 +1817,64 @@
18081817 }
18091818 });
18101819
1811
- 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;)
18121878 {
18131879 creditsPanel.add(new cGridBag());
18141880 }
....@@ -1818,9 +1884,9 @@
18181884
18191885 if (Globals.ADVANCED)
18201886 {
1821
- tabbedPane.add(infoPanel);
1822
- tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1823
- tabbedPane.setToolTipTextAt(4, "Information");
1887
+ objectPanel.add(infoPanel);
1888
+ objectPanel.setIconAt(5, GetIcon("icons/info.png"));
1889
+ objectPanel.setToolTipTextAt(4, "Information");
18241890 }
18251891
18261892 /*
....@@ -2304,7 +2370,7 @@
23042370 {
23052371 public void mouseClicked(MouseEvent e)
23062372 {
2307
- borderfadeField.setFloat(0.5);
2373
+ borderfadeField.setFloat(0.4);
23082374 opacityField.setFloat(0.75);
23092375
23102376 materialtouched = true;
....@@ -2363,13 +2429,55 @@
23632429 cameraField.setFloat(0.001);
23642430 specularField.setFloat(0.001);
23652431 fakedepthField.setFloat(0.001);
2366
- opacityField.setFloat(0.6);
2432
+ opacityField.setFloat(0.4);
23672433
23682434 materialtouched = true;
23692435 applySelf();
23702436 }
23712437 });
23722438 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);
23732481
23742482 cGridBag panel = new cGridBag().setVertical(true);
23752483
....@@ -2616,6 +2724,12 @@
26162724 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
26172725 colorSection.add(backlit);
26182726
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
+
26192733 //panel.add(new JSeparator());
26202734
26212735 //panel.add(globalSection);
....@@ -3667,6 +3781,7 @@
36673781 shadowField.setFloat(mat.shadow);
36683782 textureField.setFloat(mat.texture);
36693783 opacityField.setFloat(mat.opacity);
3784
+ parallaxField.setFloat(mat.parallax + 0.125f);
36703785 fakedepthField.setFloat(mat.fakedepth);
36713786 shadowbiasField.setFloat(mat.shadowbias);
36723787 bumpField.setInteger(1); // dec 2013
....@@ -3960,6 +4075,7 @@
39604075 } else if (event.getSource() == link2masterCB)
39614076 {
39624077 copy.link2master ^= true;
4078
+ objEditor.refreshContents();
39634079 return;
39644080 }
39654081 if (event.getSource() == randomCB)
....@@ -4350,7 +4466,7 @@
43504466 copy.versionindex -= 1;
43514467
43524468 if (copy.versionindex != -1)
4353
- CopyChanged();
4469
+ CopyChanged(copy);
43544470
43554471 SetVersionStates();
43564472 }
....@@ -4360,7 +4476,11 @@
43604476 System.err.println("Save");
43614477 Replace();
43624478
4363
- //cRadio tab = GetCurrentTab();
4479
+ if (copy.versionlist == null)
4480
+ {
4481
+ copy.versionlist = new Object3D[100];
4482
+ copy.versionindex = -1;
4483
+ }
43644484
43654485 Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
43664486
....@@ -4428,20 +4548,20 @@
44284548 {
44294549 Object3D selection = new Object3D();
44304550
4431
- for (int i = 0; i < copy.selection.size(); i++)
4551
+ for (int i = 0; i < objEditor.copy.selection.size(); i++)
44324552 {
4433
- Object3D elem = copy.selection.elementAt(i);
4553
+ Object3D elem = objEditor.copy.selection.elementAt(i);
44344554
4435
- Object3D obj = copy.GetObject(elem.GetUUID());
4555
+ Object3D obj = objEditor.copy.GetObject(elem.GetUUID());
44364556
44374557 if (obj == null)
44384558 {
4439
- copy.selection.remove(i--);
4559
+ objEditor.copy.selection.remove(i--);
44404560 }
44414561 else
44424562 {
44434563 selection.add(obj);
4444
- copy.selection.setElementAt(obj, i);
4564
+ objEditor.copy.selection.setElementAt(obj, i);
44454565 }
44464566 }
44474567
....@@ -4454,44 +4574,43 @@
44544574 //refreshContents(false);
44554575 }
44564576
4457
- void CopyChanged()
4577
+ void CopyChanged(Object3D changed)
44584578 {
4459
- Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4460
-
4461
- SetVersionStates();
4579
+ Object3D obj = (Object3D)Grafreed.clone(changed.versionlist[copy.versionindex]);
44624580
44634581 boolean temp = CameraPane.SWITCH;
44644582 CameraPane.SWITCH = false;
44654583
4466
- copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
4584
+ changed.ExtractBigData(Grafreed.grafreed.universe.versiontable);
44674585
4468
- copy.clear();
4586
+ changed.clear();
44694587
4470
- copy.skyboxname = obj.skyboxname;
4471
- copy.skyboxext = obj.skyboxext;
4588
+ changed.skyboxname = obj.skyboxname;
4589
+ changed.skyboxext = obj.skyboxext;
44724590
44734591 for (int i=0; i<obj.Size(); i++)
44744592 {
4475
- copy.add(obj.get(i));
4593
+ changed.add(obj.get(i));
44764594 }
44774595
4478
- copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
4596
+ changed.RestoreBigData(Grafreed.grafreed.universe.versiontable);
44794597
44804598 CameraPane.SWITCH = temp;
44814599
4482
- RefreshSelection();
4600
+ if (objEditor == this)
4601
+ RefreshSelection();
44834602 //assert(hashtable.isEmpty());
44844603
4485
- copy.Touch();
4604
+ objEditor.copy.Touch();
44864605
44874606 ResetModel();
4488
- copy.HardTouch(); // recompile?
4607
+ objEditor.copy.HardTouch(); // recompile?
44894608
44904609 cRadio ab;
4491
- for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4610
+ for (java.util.Enumeration e = objEditor.buttonGroup.getElements(); e.hasMoreElements();)
44924611 {
44934612 ab = (cRadio)e.nextElement();
4494
- Object3D test = copy.GetObject(ab.object.GetUUID());
4613
+ Object3D test = objEditor.copy.GetObject(ab.object.GetUUID());
44954614 //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
44964615 if (test != null)
44974616 {
....@@ -4500,7 +4619,7 @@
45004619 }
45014620 }
45024621
4503
- refreshContents(true);
4622
+ objEditor.refreshContents(true);
45044623 }
45054624
45064625 cButton previousVersionButton;
....@@ -4514,15 +4633,7 @@
45144633
45154634 int VersionCount()
45164635 {
4517
- int count = 0;
4518
-
4519
- for (int i = copy.versionlist.length; --i >= 0;)
4520
- {
4521
- if (copy.versionlist[i] != null)
4522
- count++;
4523
- }
4524
-
4525
- return count;
4636
+ return copy.VersionCount();
45264637 }
45274638
45284639 public cGridBag versionSliderPane;
....@@ -4534,7 +4645,7 @@
45344645
45354646 //cRadio tab = GetCurrentTab();
45364647
4537
- if (copy.versionlist == null)
4648
+ if (copy.versionindex == -2)
45384649 {
45394650 saveVersionButton.setEnabled(false);
45404651 restoreButton.setEnabled(false);
....@@ -4596,7 +4707,9 @@
45964707
45974708 copy.versionindex -= 1;
45984709
4599
- CopyChanged();
4710
+ CopyChanged(copy);
4711
+
4712
+ SetVersionStates();
46004713
46014714 return true;
46024715 }
....@@ -4614,7 +4727,9 @@
46144727 }
46154728
46164729 //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4617
- CopyChanged();
4730
+ CopyChanged(copy);
4731
+
4732
+ SetVersionStates();
46184733
46194734 return true;
46204735 }
....@@ -4651,10 +4766,12 @@
46514766
46524767 copy.versionindex += 1;
46534768
4654
- CopyChanged();
4769
+ CopyChanged(copy);
46554770
46564771 //if (!tab.user[tab.versionindex])
46574772 // tab.graphs[tab.versionindex] = null;
4773
+
4774
+ SetVersionStates();
46584775 }
46594776
46604777 void ImportGFD()
....@@ -4891,6 +5008,7 @@
48915008 current.shadow = (float) shadowField.getFloat();
48925009 current.texture = (float) textureField.getFloat();
48935010 current.opacity = (float) opacityField.getFloat();
5011
+ current.parallax = (float) parallaxField.getFloat() - 0.125f;
48945012 current.fakedepth = (float) fakedepthField.getFloat();
48955013 current.shadowbias = (float) shadowbiasField.getFloat();
48965014
....@@ -4945,6 +5063,8 @@
49455063 textureField.SetToolTipValue((mat.texture));
49465064 if (!Equal(opacityField.getFloat(), mat.opacity))
49475065 opacityField.SetToolTipValue((mat.opacity));
5066
+ //if (!Equal(parallaxField.getFloat(), mat.parallax))
5067
+ parallaxField.SetToolTipValue((mat.parallax));
49485068 if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
49495069 fakedepthField.SetToolTipValue((mat.fakedepth));
49505070 if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
....@@ -4980,6 +5100,7 @@
49805100 }
49815101
49825102 cNumberSlider versionSlider;
5103
+ cNumberSlider versionField;
49835104
49845105 public void stateChanged(ChangeEvent e)
49855106 {
....@@ -4996,12 +5117,26 @@
49965117 if (version != -1 && copy.versionlist[version] != null)
49975118 {
49985119 copy.versionindex = version;
4999
- CopyChanged();
5120
+ CopyChanged(copy);
5121
+ SetVersionStates();
50005122 }
50015123
50025124 return;
50035125 }
50045126
5127
+ if (e.getSource() == versionField)
5128
+ {
5129
+ int version = versionField.getInteger();
5130
+
5131
+ if (version != -1 && copy.versionindex != version && copy.versionlist[version] != null)
5132
+ {
5133
+ copy.versionindex = version;
5134
+ CopyChanged(copy);
5135
+ }
5136
+
5137
+ return;
5138
+ }
5139
+
50055140 if (freezematerial)
50065141 {
50075142 return;
....@@ -5091,7 +5226,7 @@
50915226 }
50925227
50935228 if (normalpushField != null)
5094
- copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
5229
+ copy.NORMALPUSH = (float)normalpushField.getFloat() / 100;
50955230 }
50965231
50975232 void SnapObject()
....@@ -5465,7 +5600,7 @@
54655600 void ResetModel()
54665601 {
54675602 //assert(copy instanceof Composite);
5468
- Object3D /*Composite*/ group = (Object3D /*Composite*/) copy;
5603
+ Object3D /*Composite*/ group = (Object3D /*Composite*/) objEditor.copy;
54695604
54705605 // necessary? group.selection = new Object3D(); // java.util.Vector();
54715606
....@@ -5476,14 +5611,14 @@
54765611 //group.refreshEditWindow();
54775612 //refreshContents();
54785613
5479
- if (copy.selection == null)
5614
+ if (objEditor.copy.selection == null)
54805615 {
5481
- copy.selection = new Object3D();
5616
+ objEditor.copy.selection = new Object3D();
54825617 }
54835618
5484
- for (int j = 0; j < copy.selection.size(); j++)
5619
+ for (int j = 0; j < objEditor.copy.selection.size(); j++)
54855620 {
5486
- Object3D item = copy.selection.get(j);
5621
+ Object3D item = objEditor.copy.selection.get(j);
54875622
54885623 if (item instanceof cGroup && ((cGroup) item).transientlink)
54895624 {
....@@ -5492,15 +5627,15 @@
54925627
54935628 if (item.count <= 1) // ??? == 0)
54945629 {
5495
- copy.selection.remove(item);
5630
+ objEditor.copy.selection.remove(item);
54965631 }
54975632 }
54985633
54995634 boolean first = true;
55005635
5501
- for (int i = copy.selection.size(); --i >= 0;)
5636
+ for (int i = objEditor.copy.selection.size(); --i >= 0;)
55025637 {
5503
- Object3D item = copy.selection.get(i);
5638
+ Object3D item = objEditor.copy.selection.get(i);
55045639
55055640 if (item instanceof cGroup && ((cGroup) item).transientlink)
55065641 {
....@@ -6201,6 +6336,8 @@
62016336 cNumberSlider textureField;
62026337 JLabel opacityLabel;
62036338 cNumberSlider opacityField;
6339
+ JLabel parallaxLabel;
6340
+ cNumberSlider parallaxField;
62046341 JLabel fakedepthLabel;
62056342 cNumberSlider fakedepthField;
62066343 JLabel shadowbiasLabel;