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
....@@ -1165,6 +1165,7 @@
11651165 cGridBag setupPanel2;
11661166 cGridBag objectCommandsPanel;
11671167 cGridBag pushPanel;
1168
+ cGridBag versionPanel;
11681169 cGridBag fillPanel;
11691170
11701171 JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
....@@ -1411,9 +1412,14 @@
14111412 oe.ctrlPanel.add(objectCommandsPanel);
14121413 oe.ctrlPanel.Return();
14131414
1414
- 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
14151416 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1416
- //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
+ }
14171423
14181424 oe.ctrlPanel.Return();
14191425
....@@ -1769,7 +1775,7 @@
17691775 scrollpane.addMouseWheelListener(this); // Default not fast enough
17701776
17711777 /*JTabbedPane*/ scenePanel = new cGridBag();
1772
- scenePanel.preferredWidth = 6;
1778
+ scenePanel.preferredWidth = 5;
17731779
17741780 JTabbedPane tabbedPane = new JTabbedPane();
17751781 tabbedPane.add(scrollpane);
....@@ -1878,9 +1884,9 @@
18781884
18791885 if (Globals.ADVANCED)
18801886 {
1881
- tabbedPane.add(infoPanel);
1882
- tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1883
- tabbedPane.setToolTipTextAt(4, "Information");
1887
+ objectPanel.add(infoPanel);
1888
+ objectPanel.setIconAt(5, GetIcon("icons/info.png"));
1889
+ objectPanel.setToolTipTextAt(4, "Information");
18841890 }
18851891
18861892 /*
....@@ -2364,7 +2370,7 @@
23642370 {
23652371 public void mouseClicked(MouseEvent e)
23662372 {
2367
- borderfadeField.setFloat(0.5);
2373
+ borderfadeField.setFloat(0.4);
23682374 opacityField.setFloat(0.75);
23692375
23702376 materialtouched = true;
....@@ -2423,13 +2429,55 @@
24232429 cameraField.setFloat(0.001);
24242430 specularField.setFloat(0.001);
24252431 fakedepthField.setFloat(0.001);
2426
- opacityField.setFloat(0.6);
2432
+ opacityField.setFloat(0.4);
24272433
24282434 materialtouched = true;
24292435 applySelf();
24302436 }
24312437 });
24322438 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);
24332481
24342482 cGridBag panel = new cGridBag().setVertical(true);
24352483
....@@ -2676,6 +2724,12 @@
26762724 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
26772725 colorSection.add(backlit);
26782726
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
+
26792733 //panel.add(new JSeparator());
26802734
26812735 //panel.add(globalSection);
....@@ -3727,6 +3781,7 @@
37273781 shadowField.setFloat(mat.shadow);
37283782 textureField.setFloat(mat.texture);
37293783 opacityField.setFloat(mat.opacity);
3784
+ parallaxField.setFloat(mat.parallax + 0.125f);
37303785 fakedepthField.setFloat(mat.fakedepth);
37313786 shadowbiasField.setFloat(mat.shadowbias);
37323787 bumpField.setInteger(1); // dec 2013
....@@ -4020,6 +4075,7 @@
40204075 } else if (event.getSource() == link2masterCB)
40214076 {
40224077 copy.link2master ^= true;
4078
+ objEditor.refreshContents();
40234079 return;
40244080 }
40254081 if (event.getSource() == randomCB)
....@@ -4410,7 +4466,7 @@
44104466 copy.versionindex -= 1;
44114467
44124468 if (copy.versionindex != -1)
4413
- CopyChanged();
4469
+ CopyChanged(copy);
44144470
44154471 SetVersionStates();
44164472 }
....@@ -4420,7 +4476,11 @@
44204476 System.err.println("Save");
44214477 Replace();
44224478
4423
- //cRadio tab = GetCurrentTab();
4479
+ if (copy.versionlist == null)
4480
+ {
4481
+ copy.versionlist = new Object3D[100];
4482
+ copy.versionindex = -1;
4483
+ }
44244484
44254485 Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
44264486
....@@ -4488,20 +4548,20 @@
44884548 {
44894549 Object3D selection = new Object3D();
44904550
4491
- for (int i = 0; i < copy.selection.size(); i++)
4551
+ for (int i = 0; i < objEditor.copy.selection.size(); i++)
44924552 {
4493
- Object3D elem = copy.selection.elementAt(i);
4553
+ Object3D elem = objEditor.copy.selection.elementAt(i);
44944554
4495
- Object3D obj = copy.GetObject(elem.GetUUID());
4555
+ Object3D obj = objEditor.copy.GetObject(elem.GetUUID());
44964556
44974557 if (obj == null)
44984558 {
4499
- copy.selection.remove(i--);
4559
+ objEditor.copy.selection.remove(i--);
45004560 }
45014561 else
45024562 {
45034563 selection.add(obj);
4504
- copy.selection.setElementAt(obj, i);
4564
+ objEditor.copy.selection.setElementAt(obj, i);
45054565 }
45064566 }
45074567
....@@ -4514,44 +4574,43 @@
45144574 //refreshContents(false);
45154575 }
45164576
4517
- void CopyChanged()
4577
+ void CopyChanged(Object3D changed)
45184578 {
4519
- Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4520
-
4521
- SetVersionStates();
4579
+ Object3D obj = (Object3D)Grafreed.clone(changed.versionlist[copy.versionindex]);
45224580
45234581 boolean temp = CameraPane.SWITCH;
45244582 CameraPane.SWITCH = false;
45254583
4526
- copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
4584
+ changed.ExtractBigData(Grafreed.grafreed.universe.versiontable);
45274585
4528
- copy.clear();
4586
+ changed.clear();
45294587
4530
- copy.skyboxname = obj.skyboxname;
4531
- copy.skyboxext = obj.skyboxext;
4588
+ changed.skyboxname = obj.skyboxname;
4589
+ changed.skyboxext = obj.skyboxext;
45324590
45334591 for (int i=0; i<obj.Size(); i++)
45344592 {
4535
- copy.add(obj.get(i));
4593
+ changed.add(obj.get(i));
45364594 }
45374595
4538
- copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
4596
+ changed.RestoreBigData(Grafreed.grafreed.universe.versiontable);
45394597
45404598 CameraPane.SWITCH = temp;
45414599
4542
- RefreshSelection();
4600
+ if (objEditor == this)
4601
+ RefreshSelection();
45434602 //assert(hashtable.isEmpty());
45444603
4545
- copy.Touch();
4604
+ objEditor.copy.Touch();
45464605
45474606 ResetModel();
4548
- copy.HardTouch(); // recompile?
4607
+ objEditor.copy.HardTouch(); // recompile?
45494608
45504609 cRadio ab;
4551
- for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4610
+ for (java.util.Enumeration e = objEditor.buttonGroup.getElements(); e.hasMoreElements();)
45524611 {
45534612 ab = (cRadio)e.nextElement();
4554
- Object3D test = copy.GetObject(ab.object.GetUUID());
4613
+ Object3D test = objEditor.copy.GetObject(ab.object.GetUUID());
45554614 //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
45564615 if (test != null)
45574616 {
....@@ -4560,7 +4619,7 @@
45604619 }
45614620 }
45624621
4563
- refreshContents(true);
4622
+ objEditor.refreshContents(true);
45644623 }
45654624
45664625 cButton previousVersionButton;
....@@ -4574,15 +4633,7 @@
45744633
45754634 int VersionCount()
45764635 {
4577
- int count = 0;
4578
-
4579
- for (int i = copy.versionlist.length; --i >= 0;)
4580
- {
4581
- if (copy.versionlist[i] != null)
4582
- count++;
4583
- }
4584
-
4585
- return count;
4636
+ return copy.VersionCount();
45864637 }
45874638
45884639 public cGridBag versionSliderPane;
....@@ -4594,7 +4645,7 @@
45944645
45954646 //cRadio tab = GetCurrentTab();
45964647
4597
- if (copy.versionlist == null)
4648
+ if (copy.versionindex == -2)
45984649 {
45994650 saveVersionButton.setEnabled(false);
46004651 restoreButton.setEnabled(false);
....@@ -4656,7 +4707,9 @@
46564707
46574708 copy.versionindex -= 1;
46584709
4659
- CopyChanged();
4710
+ CopyChanged(copy);
4711
+
4712
+ SetVersionStates();
46604713
46614714 return true;
46624715 }
....@@ -4674,7 +4727,9 @@
46744727 }
46754728
46764729 //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4677
- CopyChanged();
4730
+ CopyChanged(copy);
4731
+
4732
+ SetVersionStates();
46784733
46794734 return true;
46804735 }
....@@ -4711,10 +4766,12 @@
47114766
47124767 copy.versionindex += 1;
47134768
4714
- CopyChanged();
4769
+ CopyChanged(copy);
47154770
47164771 //if (!tab.user[tab.versionindex])
47174772 // tab.graphs[tab.versionindex] = null;
4773
+
4774
+ SetVersionStates();
47184775 }
47194776
47204777 void ImportGFD()
....@@ -4951,6 +5008,7 @@
49515008 current.shadow = (float) shadowField.getFloat();
49525009 current.texture = (float) textureField.getFloat();
49535010 current.opacity = (float) opacityField.getFloat();
5011
+ current.parallax = (float) parallaxField.getFloat() - 0.125f;
49545012 current.fakedepth = (float) fakedepthField.getFloat();
49555013 current.shadowbias = (float) shadowbiasField.getFloat();
49565014
....@@ -5005,6 +5063,8 @@
50055063 textureField.SetToolTipValue((mat.texture));
50065064 if (!Equal(opacityField.getFloat(), mat.opacity))
50075065 opacityField.SetToolTipValue((mat.opacity));
5066
+ //if (!Equal(parallaxField.getFloat(), mat.parallax))
5067
+ parallaxField.SetToolTipValue((mat.parallax));
50085068 if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
50095069 fakedepthField.SetToolTipValue((mat.fakedepth));
50105070 if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
....@@ -5040,6 +5100,7 @@
50405100 }
50415101
50425102 cNumberSlider versionSlider;
5103
+ cNumberSlider versionField;
50435104
50445105 public void stateChanged(ChangeEvent e)
50455106 {
....@@ -5056,12 +5117,26 @@
50565117 if (version != -1 && copy.versionlist[version] != null)
50575118 {
50585119 copy.versionindex = version;
5059
- CopyChanged();
5120
+ CopyChanged(copy);
5121
+ SetVersionStates();
50605122 }
50615123
50625124 return;
50635125 }
50645126
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
+
50655140 if (freezematerial)
50665141 {
50675142 return;
....@@ -5151,7 +5226,7 @@
51515226 }
51525227
51535228 if (normalpushField != null)
5154
- copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
5229
+ copy.NORMALPUSH = (float)normalpushField.getFloat() / 100;
51555230 }
51565231
51575232 void SnapObject()
....@@ -5525,7 +5600,7 @@
55255600 void ResetModel()
55265601 {
55275602 //assert(copy instanceof Composite);
5528
- Object3D /*Composite*/ group = (Object3D /*Composite*/) copy;
5603
+ Object3D /*Composite*/ group = (Object3D /*Composite*/) objEditor.copy;
55295604
55305605 // necessary? group.selection = new Object3D(); // java.util.Vector();
55315606
....@@ -5536,14 +5611,14 @@
55365611 //group.refreshEditWindow();
55375612 //refreshContents();
55385613
5539
- if (copy.selection == null)
5614
+ if (objEditor.copy.selection == null)
55405615 {
5541
- copy.selection = new Object3D();
5616
+ objEditor.copy.selection = new Object3D();
55425617 }
55435618
5544
- for (int j = 0; j < copy.selection.size(); j++)
5619
+ for (int j = 0; j < objEditor.copy.selection.size(); j++)
55455620 {
5546
- Object3D item = copy.selection.get(j);
5621
+ Object3D item = objEditor.copy.selection.get(j);
55475622
55485623 if (item instanceof cGroup && ((cGroup) item).transientlink)
55495624 {
....@@ -5552,15 +5627,15 @@
55525627
55535628 if (item.count <= 1) // ??? == 0)
55545629 {
5555
- copy.selection.remove(item);
5630
+ objEditor.copy.selection.remove(item);
55565631 }
55575632 }
55585633
55595634 boolean first = true;
55605635
5561
- for (int i = copy.selection.size(); --i >= 0;)
5636
+ for (int i = objEditor.copy.selection.size(); --i >= 0;)
55625637 {
5563
- Object3D item = copy.selection.get(i);
5638
+ Object3D item = objEditor.copy.selection.get(i);
55645639
55655640 if (item instanceof cGroup && ((cGroup) item).transientlink)
55665641 {
....@@ -6261,6 +6336,8 @@
62616336 cNumberSlider textureField;
62626337 JLabel opacityLabel;
62636338 cNumberSlider opacityField;
6339
+ JLabel parallaxLabel;
6340
+ cNumberSlider parallaxField;
62646341 JLabel fakedepthLabel;
62656342 cNumberSlider fakedepthField;
62666343 JLabel shadowbiasLabel;