Normand Briere
2019-08-26 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a
ObjEditor.java
....@@ -316,6 +316,8 @@
316316 objEditor.ctrlPanel.remove(setupPanel2);
317317 objEditor.ctrlPanel.remove(objectCommandsPanel);
318318 objEditor.ctrlPanel.remove(pushPanel);
319
+ if (versionPanel != null)
320
+ objEditor.ctrlPanel.remove(versionPanel);
319321 //objEditor.ctrlPanel.remove(fillPanel);
320322
321323 //Remove(normalpushField);
....@@ -383,14 +385,6 @@
383385 client = inClient;
384386 copy = client;
385387
386
- if (copy.versionlist == null)
387
- {
388
- copy.versionlist = new Object3D[100];
389
- copy.versionindex = -1;
390
-
391
-// Save(true);
392
- }
393
-
394388 SetupUI2(callee.GetEditor());
395389 }
396390
....@@ -1171,6 +1165,7 @@
11711165 cGridBag setupPanel2;
11721166 cGridBag objectCommandsPanel;
11731167 cGridBag pushPanel;
1168
+ cGridBag versionPanel;
11741169 cGridBag fillPanel;
11751170
11761171 JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
....@@ -1417,9 +1412,14 @@
14171412 oe.ctrlPanel.add(objectCommandsPanel);
14181413 oe.ctrlPanel.Return();
14191414
1420
- 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
14211416 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1422
- //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
+ }
14231423
14241424 oe.ctrlPanel.Return();
14251425
....@@ -1775,7 +1775,7 @@
17751775 scrollpane.addMouseWheelListener(this); // Default not fast enough
17761776
17771777 /*JTabbedPane*/ scenePanel = new cGridBag();
1778
- scenePanel.preferredWidth = 6;
1778
+ scenePanel.preferredWidth = 5;
17791779
17801780 JTabbedPane tabbedPane = new JTabbedPane();
17811781 tabbedPane.add(scrollpane);
....@@ -1884,9 +1884,9 @@
18841884
18851885 if (Globals.ADVANCED)
18861886 {
1887
- tabbedPane.add(infoPanel);
1888
- tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
1889
- tabbedPane.setToolTipTextAt(4, "Information");
1887
+ objectPanel.add(infoPanel);
1888
+ objectPanel.setIconAt(5, GetIcon("icons/info.png"));
1889
+ objectPanel.setToolTipTextAt(4, "Information");
18901890 }
18911891
18921892 /*
....@@ -2370,7 +2370,7 @@
23702370 {
23712371 public void mouseClicked(MouseEvent e)
23722372 {
2373
- borderfadeField.setFloat(0.5);
2373
+ borderfadeField.setFloat(0.4);
23742374 opacityField.setFloat(0.75);
23752375
23762376 materialtouched = true;
....@@ -2429,13 +2429,55 @@
24292429 cameraField.setFloat(0.001);
24302430 specularField.setFloat(0.001);
24312431 fakedepthField.setFloat(0.001);
2432
- opacityField.setFloat(0.6);
2432
+ opacityField.setFloat(0.4);
24332433
24342434 materialtouched = true;
24352435 applySelf();
24362436 }
24372437 });
24382438 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);
24392481
24402482 cGridBag panel = new cGridBag().setVertical(true);
24412483
....@@ -2682,6 +2724,12 @@
26822724 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
26832725 colorSection.add(backlit);
26842726
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
+
26852733 //panel.add(new JSeparator());
26862734
26872735 //panel.add(globalSection);
....@@ -3733,6 +3781,7 @@
37333781 shadowField.setFloat(mat.shadow);
37343782 textureField.setFloat(mat.texture);
37353783 opacityField.setFloat(mat.opacity);
3784
+ parallaxField.setFloat(mat.parallax + 0.125f);
37363785 fakedepthField.setFloat(mat.fakedepth);
37373786 shadowbiasField.setFloat(mat.shadowbias);
37383787 bumpField.setInteger(1); // dec 2013
....@@ -4026,6 +4075,7 @@
40264075 } else if (event.getSource() == link2masterCB)
40274076 {
40284077 copy.link2master ^= true;
4078
+ objEditor.refreshContents();
40294079 return;
40304080 }
40314081 if (event.getSource() == randomCB)
....@@ -4416,7 +4466,7 @@
44164466 copy.versionindex -= 1;
44174467
44184468 if (copy.versionindex != -1)
4419
- CopyChanged();
4469
+ CopyChanged(copy);
44204470
44214471 SetVersionStates();
44224472 }
....@@ -4426,7 +4476,11 @@
44264476 System.err.println("Save");
44274477 Replace();
44284478
4429
- //cRadio tab = GetCurrentTab();
4479
+ if (copy.versionlist == null)
4480
+ {
4481
+ copy.versionlist = new Object3D[100];
4482
+ copy.versionindex = -1;
4483
+ }
44304484
44314485 Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
44324486
....@@ -4494,20 +4548,20 @@
44944548 {
44954549 Object3D selection = new Object3D();
44964550
4497
- for (int i = 0; i < copy.selection.size(); i++)
4551
+ for (int i = 0; i < objEditor.copy.selection.size(); i++)
44984552 {
4499
- Object3D elem = copy.selection.elementAt(i);
4553
+ Object3D elem = objEditor.copy.selection.elementAt(i);
45004554
4501
- Object3D obj = copy.GetObject(elem.GetUUID());
4555
+ Object3D obj = objEditor.copy.GetObject(elem.GetUUID());
45024556
45034557 if (obj == null)
45044558 {
4505
- copy.selection.remove(i--);
4559
+ objEditor.copy.selection.remove(i--);
45064560 }
45074561 else
45084562 {
45094563 selection.add(obj);
4510
- copy.selection.setElementAt(obj, i);
4564
+ objEditor.copy.selection.setElementAt(obj, i);
45114565 }
45124566 }
45134567
....@@ -4520,44 +4574,43 @@
45204574 //refreshContents(false);
45214575 }
45224576
4523
- void CopyChanged()
4577
+ void CopyChanged(Object3D changed)
45244578 {
4525
- Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4526
-
4527
- SetVersionStates();
4579
+ Object3D obj = (Object3D)Grafreed.clone(changed.versionlist[copy.versionindex]);
45284580
45294581 boolean temp = CameraPane.SWITCH;
45304582 CameraPane.SWITCH = false;
45314583
4532
- copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
4584
+ changed.ExtractBigData(Grafreed.grafreed.universe.versiontable);
45334585
4534
- copy.clear();
4586
+ changed.clear();
45354587
4536
- copy.skyboxname = obj.skyboxname;
4537
- copy.skyboxext = obj.skyboxext;
4588
+ changed.skyboxname = obj.skyboxname;
4589
+ changed.skyboxext = obj.skyboxext;
45384590
45394591 for (int i=0; i<obj.Size(); i++)
45404592 {
4541
- copy.add(obj.get(i));
4593
+ changed.add(obj.get(i));
45424594 }
45434595
4544
- copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
4596
+ changed.RestoreBigData(Grafreed.grafreed.universe.versiontable);
45454597
45464598 CameraPane.SWITCH = temp;
45474599
4548
- RefreshSelection();
4600
+ if (objEditor == this)
4601
+ RefreshSelection();
45494602 //assert(hashtable.isEmpty());
45504603
4551
- copy.Touch();
4604
+ objEditor.copy.Touch();
45524605
45534606 ResetModel();
4554
- copy.HardTouch(); // recompile?
4607
+ objEditor.copy.HardTouch(); // recompile?
45554608
45564609 cRadio ab;
4557
- for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
4610
+ for (java.util.Enumeration e = objEditor.buttonGroup.getElements(); e.hasMoreElements();)
45584611 {
45594612 ab = (cRadio)e.nextElement();
4560
- Object3D test = copy.GetObject(ab.object.GetUUID());
4613
+ Object3D test = objEditor.copy.GetObject(ab.object.GetUUID());
45614614 //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
45624615 if (test != null)
45634616 {
....@@ -4566,7 +4619,7 @@
45664619 }
45674620 }
45684621
4569
- refreshContents(true);
4622
+ objEditor.refreshContents(true);
45704623 }
45714624
45724625 cButton previousVersionButton;
....@@ -4580,15 +4633,7 @@
45804633
45814634 int VersionCount()
45824635 {
4583
- int count = 0;
4584
-
4585
- for (int i = copy.versionlist.length; --i >= 0;)
4586
- {
4587
- if (copy.versionlist[i] != null)
4588
- count++;
4589
- }
4590
-
4591
- return count;
4636
+ return copy.VersionCount();
45924637 }
45934638
45944639 public cGridBag versionSliderPane;
....@@ -4600,7 +4645,7 @@
46004645
46014646 //cRadio tab = GetCurrentTab();
46024647
4603
- if (copy.versionlist == null)
4648
+ if (copy.versionindex == -2)
46044649 {
46054650 saveVersionButton.setEnabled(false);
46064651 restoreButton.setEnabled(false);
....@@ -4662,7 +4707,9 @@
46624707
46634708 copy.versionindex -= 1;
46644709
4665
- CopyChanged();
4710
+ CopyChanged(copy);
4711
+
4712
+ SetVersionStates();
46664713
46674714 return true;
46684715 }
....@@ -4680,7 +4727,9 @@
46804727 }
46814728
46824729 //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4683
- CopyChanged();
4730
+ CopyChanged(copy);
4731
+
4732
+ SetVersionStates();
46844733
46854734 return true;
46864735 }
....@@ -4717,10 +4766,12 @@
47174766
47184767 copy.versionindex += 1;
47194768
4720
- CopyChanged();
4769
+ CopyChanged(copy);
47214770
47224771 //if (!tab.user[tab.versionindex])
47234772 // tab.graphs[tab.versionindex] = null;
4773
+
4774
+ SetVersionStates();
47244775 }
47254776
47264777 void ImportGFD()
....@@ -4957,6 +5008,7 @@
49575008 current.shadow = (float) shadowField.getFloat();
49585009 current.texture = (float) textureField.getFloat();
49595010 current.opacity = (float) opacityField.getFloat();
5011
+ current.parallax = (float) parallaxField.getFloat() - 0.125f;
49605012 current.fakedepth = (float) fakedepthField.getFloat();
49615013 current.shadowbias = (float) shadowbiasField.getFloat();
49625014
....@@ -5011,6 +5063,8 @@
50115063 textureField.SetToolTipValue((mat.texture));
50125064 if (!Equal(opacityField.getFloat(), mat.opacity))
50135065 opacityField.SetToolTipValue((mat.opacity));
5066
+ //if (!Equal(parallaxField.getFloat(), mat.parallax))
5067
+ parallaxField.SetToolTipValue((mat.parallax));
50145068 if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
50155069 fakedepthField.SetToolTipValue((mat.fakedepth));
50165070 if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
....@@ -5046,6 +5100,7 @@
50465100 }
50475101
50485102 cNumberSlider versionSlider;
5103
+ cNumberSlider versionField;
50495104
50505105 public void stateChanged(ChangeEvent e)
50515106 {
....@@ -5062,12 +5117,26 @@
50625117 if (version != -1 && copy.versionlist[version] != null)
50635118 {
50645119 copy.versionindex = version;
5065
- CopyChanged();
5120
+ CopyChanged(copy);
5121
+ SetVersionStates();
50665122 }
50675123
50685124 return;
50695125 }
50705126
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
+
50715140 if (freezematerial)
50725141 {
50735142 return;
....@@ -5157,7 +5226,7 @@
51575226 }
51585227
51595228 if (normalpushField != null)
5160
- copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
5229
+ copy.NORMALPUSH = (float)normalpushField.getFloat() / 100;
51615230 }
51625231
51635232 void SnapObject()
....@@ -5531,7 +5600,7 @@
55315600 void ResetModel()
55325601 {
55335602 //assert(copy instanceof Composite);
5534
- Object3D /*Composite*/ group = (Object3D /*Composite*/) copy;
5603
+ Object3D /*Composite*/ group = (Object3D /*Composite*/) objEditor.copy;
55355604
55365605 // necessary? group.selection = new Object3D(); // java.util.Vector();
55375606
....@@ -5542,14 +5611,14 @@
55425611 //group.refreshEditWindow();
55435612 //refreshContents();
55445613
5545
- if (copy.selection == null)
5614
+ if (objEditor.copy.selection == null)
55465615 {
5547
- copy.selection = new Object3D();
5616
+ objEditor.copy.selection = new Object3D();
55485617 }
55495618
5550
- for (int j = 0; j < copy.selection.size(); j++)
5619
+ for (int j = 0; j < objEditor.copy.selection.size(); j++)
55515620 {
5552
- Object3D item = copy.selection.get(j);
5621
+ Object3D item = objEditor.copy.selection.get(j);
55535622
55545623 if (item instanceof cGroup && ((cGroup) item).transientlink)
55555624 {
....@@ -5558,15 +5627,15 @@
55585627
55595628 if (item.count <= 1) // ??? == 0)
55605629 {
5561
- copy.selection.remove(item);
5630
+ objEditor.copy.selection.remove(item);
55625631 }
55635632 }
55645633
55655634 boolean first = true;
55665635
5567
- for (int i = copy.selection.size(); --i >= 0;)
5636
+ for (int i = objEditor.copy.selection.size(); --i >= 0;)
55685637 {
5569
- Object3D item = copy.selection.get(i);
5638
+ Object3D item = objEditor.copy.selection.get(i);
55705639
55715640 if (item instanceof cGroup && ((cGroup) item).transientlink)
55725641 {
....@@ -6267,6 +6336,8 @@
62676336 cNumberSlider textureField;
62686337 JLabel opacityLabel;
62696338 cNumberSlider opacityField;
6339
+ JLabel parallaxLabel;
6340
+ cNumberSlider parallaxField;
62706341 JLabel fakedepthLabel;
62716342 cNumberSlider fakedepthField;
62726343 JLabel shadowbiasLabel;