Normand Briere
2019-06-17 e36047725ce3217618d4e5807ac7c8769b9e3598
Split pigment bump.
4 files modified
230 ■■■■■ changed files
CameraPane.java 125 ●●●●● patch | view | raw | blame | history
Composite.java 24 ●●●● patch | view | raw | blame | history
Object3D.java 73 ●●●●● patch | view | raw | blame | history
iCameraPane.java 8 ●●●● patch | view | raw | blame | history
CameraPane.java
....@@ -7921,6 +7921,64 @@
79217921 ReleaseTexture(pigment, false);
79227922 }
79237923
7924
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7925
+ {
7926
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7927
+ {
7928
+ return;
7929
+ }
7930
+
7931
+ if (tex == null)
7932
+ {
7933
+ ReleaseTexture(null, false);
7934
+ return;
7935
+ }
7936
+
7937
+ String pigment = Object3D.GetPigment(tex);
7938
+
7939
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7940
+ {
7941
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7942
+ // System.out.println("; bump = " + bump);
7943
+ }
7944
+
7945
+ if (pigment.equals(""))
7946
+ {
7947
+ pigment = null;
7948
+ }
7949
+
7950
+ ReleaseTexture(pigment, false);
7951
+ }
7952
+
7953
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7954
+ {
7955
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7956
+ {
7957
+ return;
7958
+ }
7959
+
7960
+ if (tex == null)
7961
+ {
7962
+ ReleaseTexture(null, true);
7963
+ return;
7964
+ }
7965
+
7966
+ String bump = Object3D.GetBump(tex);
7967
+
7968
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7969
+ {
7970
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7971
+ // System.out.println("; bump = " + bump);
7972
+ }
7973
+
7974
+ if (bump.equals(""))
7975
+ {
7976
+ bump = null;
7977
+ }
7978
+
7979
+ ReleaseTexture(bump, true);
7980
+ }
7981
+
79247982 void ReleaseTexture(String tex, boolean bump)
79257983 {
79267984 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8069,6 +8127,73 @@
80698127 return; // true;
80708128 }
80718129
8130
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8131
+ {
8132
+ if (// DrawMode() != 0 || /*tex == null ||*/
8133
+ ambientOcclusion ) // || !textureon)
8134
+ {
8135
+ return; // false;
8136
+ }
8137
+
8138
+ if (tex == null)
8139
+ {
8140
+ BindTexture(null,false,resolution);
8141
+ return;
8142
+ }
8143
+
8144
+ String pigment = Object3D.GetPigment(tex);
8145
+
8146
+ usedtextures.put(pigment, pigment);
8147
+
8148
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8149
+ {
8150
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8151
+ // System.out.println("; bump = " + bump);
8152
+ }
8153
+
8154
+ if (pigment.equals(""))
8155
+ {
8156
+ pigment = null;
8157
+ }
8158
+
8159
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8160
+ BindTexture(pigment, false, resolution);
8161
+ }
8162
+
8163
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8164
+ {
8165
+ if (// DrawMode() != 0 || /*tex == null ||*/
8166
+ ambientOcclusion ) // || !textureon)
8167
+ {
8168
+ return; // false;
8169
+ }
8170
+
8171
+ if (tex == null)
8172
+ {
8173
+ BindTexture(null,true,resolution);
8174
+ return;
8175
+ }
8176
+
8177
+ String bump = Object3D.GetBump(tex);
8178
+
8179
+ usedtextures.put(bump, bump);
8180
+
8181
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8182
+ {
8183
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8184
+ // System.out.println("; bump = " + bump);
8185
+ }
8186
+
8187
+ if (bump.equals(""))
8188
+ {
8189
+ bump = null;
8190
+ }
8191
+
8192
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8193
+ BindTexture(bump, true, resolution);
8194
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8195
+ }
8196
+
80728197 java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
80738198
80748199 private boolean FileExists(String tex)
Composite.java
....@@ -867,15 +867,29 @@
867867 tex = GetTextures();
868868 }
869869
870
+ boolean failedPigment = false;
871
+ boolean failedBump = false;
872
+
870873 try
871874 {
872
- display.BindTextures(tex, texres);
875
+ display.BindPigmentTexture(tex, texres);
873876 }
874877 catch (Exception e)
875878 {
876879 System.err.println("FAILED: " + this);
880
+ failedPigment = true;
877881 }
878
-
882
+
883
+ try
884
+ {
885
+ display.BindBumpTexture(tex, texres);
886
+ }
887
+ catch (Exception e)
888
+ {
889
+ //System.err.println("FAILED: " + this);
890
+ failedBump = true;
891
+ }
892
+
879893 if (//true) // new NORMAND
880894 touched || softtouched)
881895 {
....@@ -937,7 +951,11 @@
937951 }
938952 }
939953
940
- display.ReleaseTextures(tex);
954
+ if (!failedBump)
955
+ display.ReleaseBumpTexture(tex);
956
+
957
+ if (!failedPigment)
958
+ display.ReleasePigmentTexture(tex);
941959 }
942960
943961 void Reset0()
Object3D.java
....@@ -4351,6 +4351,55 @@
43514351 }
43524352 }
43534353
4354
+ void RepairSOV()
4355
+ {
4356
+ if (blockloop)
4357
+ return;
4358
+
4359
+ String texname = this.GetPigmentTexture();
4360
+
4361
+ if (texname.startsWith("sov"))
4362
+ {
4363
+ String[] s = texname.split("/");
4364
+
4365
+ String[] sname = s[1].split("Color.pn");
4366
+
4367
+ texname = sname[0];
4368
+
4369
+ if (sname.length > 1)
4370
+ {
4371
+ texname += "Color.jpg";
4372
+ }
4373
+
4374
+ this.SetPigmentTexture("sov/" + texname);
4375
+ }
4376
+
4377
+ texname = this.GetBumpTexture();
4378
+
4379
+ if (texname.startsWith("sov"))
4380
+ {
4381
+ String[] s = texname.split("/");
4382
+
4383
+ String[] sname = s[1].split("Bump.pn");
4384
+
4385
+ texname = sname[0];
4386
+
4387
+ if (sname.length > 1)
4388
+ {
4389
+ texname += "Bump.jpg";
4390
+ }
4391
+
4392
+ this.SetBumpTexture("sov/" + texname);
4393
+ }
4394
+
4395
+ for (int i=0; i<Size(); i++)
4396
+ {
4397
+ blockloop = true;
4398
+ get(i).RepairSOV();
4399
+ blockloop = false;
4400
+ }
4401
+ }
4402
+
43544403 void RepairTexture()
43554404 {
43564405 if (this instanceof FileObject || blockloop)
....@@ -5846,16 +5895,27 @@
58465895 tex = GetTextures();
58475896 }
58485897
5849
- boolean failed = false;
5898
+ boolean failedPigment = false;
5899
+ boolean failedBump = false;
58505900
58515901 try
58525902 {
5853
- display.BindTextures(tex, texres);
5903
+ display.BindPigmentTexture(tex, texres);
58545904 }
58555905 catch (Exception e)
58565906 {
58575907 System.err.println("FAILED: " + this);
5858
- failed = true;
5908
+ failedPigment = true;
5909
+ }
5910
+
5911
+ try
5912
+ {
5913
+ display.BindBumpTexture(tex, texres);
5914
+ }
5915
+ catch (Exception e)
5916
+ {
5917
+ //System.err.println("FAILED: " + this);
5918
+ failedBump = true;
58595919 }
58605920
58615921 if (!compiled)
....@@ -5878,8 +5938,11 @@
58785938 }
58795939 }
58805940
5881
- if (!failed)
5882
- display.ReleaseTextures(tex);
5941
+ if (!failedBump)
5942
+ display.ReleaseBumpTexture(tex);
5943
+
5944
+ if (!failedPigment)
5945
+ display.ReleasePigmentTexture(tex);
58835946
58845947 display.PopMaterial(this, selected);
58855948 }
iCameraPane.java
....@@ -55,8 +55,12 @@
5555
5656 void DrawString(Object3D obj);
5757
58
- void BindTextures(cTexture tex, int resolution) throws Exception;
59
- void ReleaseTextures(cTexture tex);
58
+ //void BindTextures(cTexture tex, int resolution) throws Exception;
59
+ //void ReleaseTextures(cTexture tex);
60
+ void BindPigmentTexture(cTexture tex, int resolution) throws Exception;
61
+ void BindBumpTexture(cTexture tex, int resolution) throws Exception;
62
+ void ReleasePigmentTexture(cTexture tex);
63
+ void ReleaseBumpTexture(cTexture tex);
6064
6165 void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face);
6266