Normand Briere
2019-08-26 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a
CameraPane.java
....@@ -110,7 +110,11 @@
110110 //private Mat4f spotlightTransform = new Mat4f();
111111 //private Mat4f spotlightInverseTransform = new Mat4f();
112112 static GLContext glcontext = null;
113
- /*static*/ com.sun.opengl.util.texture.Texture cubemap;
113
+ /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb
114
+ /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom;
115
+ /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb;
116
+ boolean transformMode;
117
+
114118 boolean reverseUP = false;
115119 static boolean frozen = false;
116120 boolean enablebackspace = false; // patch for back buffer refresh
....@@ -164,7 +168,7 @@
164168
165169
166170 // OPTIONS
167
- boolean Skinshader = true;
171
+ boolean Skinshader = false; // true;
168172 boolean cameraLight = false;
169173 boolean UVdebug = false;
170174 boolean Udebug = false;
....@@ -173,7 +177,7 @@
173177 static boolean doublesided = false; // true; // reversed normals are awful for conformance
174178 boolean anisotropy = true;
175179 boolean softshadow = true; // slower but better false;
176
- boolean opacityhalo = false;
180
+ boolean opacityhalo = false; // reverse the halo effect (e.g. glass)
177181
178182 boolean macromode = false;
179183
....@@ -188,15 +192,16 @@
188192
189193 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
190194
191
- public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException
195
+ public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
192196 {
193197 try
194198 {
195
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
199
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
196200 } catch (IOException e)
197201 {
198202 System.out.println("NAME = " + name);
199203 e.printStackTrace(); // throw new RuntimeException(e);
204
+ return null;
200205 }
201206 }
202207
....@@ -537,7 +542,8 @@
537542 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
538543 LA.vecCross(obj.v0, obj.v1, obj.v2);
539544 LA.vecNormalize(obj.v2);
540
- gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
545
+
546
+ SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
541547 }
542548
543549 // P
....@@ -559,7 +565,7 @@
559565 y += ny * obj.NORMALPUSH;
560566 z += nz * obj.NORMALPUSH;
561567
562
- gl.glNormal3f(nx, ny, nz);
568
+ SetGLNormal(gl, nx, ny, nz);
563569 }
564570 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
565571 SetColor(obj, pv);
....@@ -591,7 +597,7 @@
591597 y += ny * obj.NORMALPUSH;
592598 z += nz * obj.NORMALPUSH;
593599
594
- gl.glNormal3f(nx, ny, nz);
600
+ SetGLNormal(gl, nx, ny, nz);
595601 }
596602 //System.out.println("vertexq = " + qv.s + ", " + qv.t);
597603 // boolean locked = false;
....@@ -639,7 +645,7 @@
639645 y += ny * obj.NORMALPUSH;
640646 z += nz * obj.NORMALPUSH;
641647
642
- gl.glNormal3f(nx, ny, nz);
648
+ SetGLNormal(gl, nx, ny, nz);
643649 }
644650
645651 // if ((dot&4) == 0)
....@@ -875,7 +881,7 @@
875881 //// tris.postdraw(this);
876882 }
877883
878
- static Camera localcamera = new Camera();
884
+ static Camera localAOcamera = new Camera();
879885 static cVector from = new cVector();
880886 static cVector to = new cVector();
881887
....@@ -884,7 +890,7 @@
884890 CameraPane cp = this;
885891
886892 Camera keep = cp.RenderCamera();
887
- cp.renderCamera = localcamera;
893
+ cp.renderCamera = localAOcamera;
888894
889895 if (br.trimmed)
890896 {
....@@ -902,7 +908,7 @@
902908 br.positions[i3 + 2] + br.normals[i3 + 2]);
903909 LA.xformPos(from, transform, from);
904910 LA.xformPos(to, transform, to); // RIGID ONLY
905
- localcamera.setAim(from, to);
911
+ localAOcamera.setAim(from, to);
906912
907913 CameraPane.occlusionbuffer.display();
908914
....@@ -936,7 +942,7 @@
936942 to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
937943 LA.xformPos(from, transform, from);
938944 LA.xformPos(to, transform, to); // RIGID ONLY
939
- localcamera.setAim(from, to);
945
+ localAOcamera.setAim(from, to);
940946
941947 CameraPane.occlusionbuffer.display();
942948
....@@ -1245,10 +1251,10 @@
12451251 {
12461252 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12471253 {
1248
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1254
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12491255 } else
12501256 {
1251
- gl.glNormal3f(0, 0, 1);
1257
+ SetGLNormal(gl, 0, 0, 1);
12521258 }
12531259
12541260 if (c != null)
....@@ -1272,10 +1278,10 @@
12721278 {
12731279 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12741280 {
1275
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1281
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12761282 } else
12771283 {
1278
- gl.glNormal3f(0, 0, 1);
1284
+ SetGLNormal(gl, 0, 0, 1);
12791285 }
12801286 if (c != null)
12811287 {
....@@ -1300,10 +1306,10 @@
13001306 {
13011307 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
13021308 {
1303
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1309
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
13041310 } else
13051311 {
1306
- gl.glNormal3f(0, 0, 1);
1312
+ SetGLNormal(gl, 0, 0, 1);
13071313 }
13081314 if (c != null)
13091315 {
....@@ -1485,7 +1491,7 @@
14851491 {
14861492 if (!selectmode)
14871493 {
1488
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1494
+ SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
14891495 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
14901496
14911497 if (flipV)
....@@ -1814,7 +1820,7 @@
18141820
18151821 display.modelParams7[0] = 0;
18161822 display.modelParams7[1] = 1000;
1817
- display.modelParams7[2] = 0;
1823
+ display.modelParams7[2] = material.parallax;
18181824 display.modelParams7[3] = 0;
18191825
18201826 //display.modelParams6[0] = 100; // criss de bug de bump
....@@ -2047,9 +2053,9 @@
20472053 switch(viewcode)
20482054 {
20492055 case 0: return "main";
2050
- case 1: return "one";
2051
- case 2: return "two";
2052
- case 3: return "three";
2056
+ case 1: return "Red";
2057
+ case 2: return "Green";
2058
+ case 3: return "Blue";
20532059 case 4: return "light";
20542060 }
20552061
....@@ -2470,6 +2476,18 @@
24702476 return CreateBim(bytes, width, height);
24712477 }
24722478
2479
+ private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz)
2480
+ {
2481
+ gl.glNormal3f(nx, ny, nz);
2482
+
2483
+ if (ny > 0.9 || ny < -0.9)
2484
+ // Ground or ceiling
2485
+ gl.glVertexAttrib3f(4, 1, 0, 0);
2486
+ else
2487
+ // Walls
2488
+ gl.glVertexAttrib3f(4, 0, 1, 0);
2489
+ }
2490
+
24732491 /**/
24742492 class CacheTexture
24752493 {
....@@ -2512,7 +2530,7 @@
25122530 com.sun.opengl.util.texture.TextureIO.newTextureData(
25132531 getClass().getClassLoader().getResourceAsStream(name),
25142532 true,
2515
- com.sun.opengl.util.texture.TextureIO.PNG);
2533
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
25162534 } catch (java.io.IOException e)
25172535 {
25182536 throw new javax.media.opengl.GLException(e);
....@@ -8358,7 +8376,7 @@
83588376 // else
83598377 // if (!texname.startsWith("/"))
83608378 // texname = "/Users/nbriere/Textures/" + texname;
8361
- if (!FileExists(texname))
8379
+ if (!FileExists(texname) && !texname.startsWith("@"))
83628380 {
83638381 texname = fallbackTextureName;
83648382 }
....@@ -8441,6 +8459,15 @@
84418459 new Exception().printStackTrace();
84428460 } else
84438461 {
8462
+ if (texname.startsWith("@"))
8463
+ {
8464
+ // texturecache = textures.get(texname); // suspicious
8465
+ if (texturecache == null)
8466
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8467
+ else
8468
+ new Exception().printStackTrace();
8469
+ } else
8470
+ {
84448471 if (textureon)
84458472 {
84468473 String cachename = texname;
....@@ -8500,6 +8527,7 @@
85008527 texturecache = new CacheTexture(texturedata,resolution);
85018528 //texture = GetTexture(tex, bump);
85028529 }
8530
+ }
85038531 }
85048532 //}
85058533 }
....@@ -8768,10 +8796,12 @@
87688796
87698797 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
87708798 MAXSTACK = temp[0];
8771
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8799
+ if (Globals.DEBUG)
8800
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
87728801 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
87738802 MAXSTACK = temp[0];
8774
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8803
+ if (Globals.DEBUG)
8804
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
87758805
87768806 // Use debug pipeline
87778807 //drawable.setGL(new DebugGL(gl)); //
....@@ -8779,7 +8809,8 @@
87798809 gl = drawable.getGL(); //
87808810
87818811 GL gl3 = getGL();
8782
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8812
+ if (Globals.DEBUG)
8813
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
87838814
87848815
87858816 //float pos[] = { 100, 100, 100, 0 };
....@@ -9220,6 +9251,8 @@
92209251
92219252 void LoadEnvy(int which)
92229253 {
9254
+ assert(false);
9255
+
92239256 String name;
92249257 String ext;
92259258
....@@ -10670,9 +10703,18 @@
1067010703 static boolean init = false;
1067110704
1067210705 double[][] matrix = LA.newMatrix();
10706
+
10707
+ // This is to refresh the UI of the material panel.
10708
+ ObjEditor patchMaterial;
1067310709
1067410710 public void display(GLAutoDrawable drawable)
1067510711 {
10712
+ if (patchMaterial.patchMaterial)
10713
+ {
10714
+ patchMaterial.patchMaterial = false;
10715
+ patchMaterial.objectPanel.setSelectedIndex(1);
10716
+ }
10717
+
1067610718 if (Grafreed.savesound && Grafreed.hassound)
1067710719 {
1067810720 Grafreed.wav.save();
....@@ -10841,7 +10883,7 @@
1084110883
1084210884 if (wait)
1084310885 {
10844
- Sleep(500);
10886
+ Sleep(200); // blocks everything
1084510887
1084610888 wait = false;
1084710889 }
....@@ -11064,18 +11106,34 @@
1106411106 //
1106511107 // newenvy = -1;
1106611108
11067
- if (object.skyboxname != null)
11109
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1106811110 {
11069
- if (!object.skyboxname.equals(this.loadedskyboxname))
11111
+ if (cubemaprgb == null)
1107011112 {
11071
- LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11072
- loadedskyboxname = object.skyboxname;
11113
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
1107311114 }
11115
+
11116
+ cubemap = cubemaprgb;
1107411117 }
1107511118 else
1107611119 {
11077
- cubemap = null;
11078
- loadedskyboxname = null;
11120
+ if (object.skyboxname != null)
11121
+ {
11122
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11123
+ {
11124
+ if (cubemap != null && cubemap != cubemaprgb)
11125
+ cubemap.dispose();
11126
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11127
+ loadedskyboxname = object.skyboxname;
11128
+ }
11129
+ }
11130
+ else
11131
+ {
11132
+ cubemapcustom = null;
11133
+ loadedskyboxname = null;
11134
+ }
11135
+
11136
+ cubemap = cubemapcustom;
1107911137 }
1108011138
1108111139 ratio = ((double) getWidth()) / getHeight();
....@@ -12456,8 +12514,9 @@
1245612514 String programmin =
1245712515 // Min shader
1245812516 "!!ARBfp1.0\n" +
12459
- "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12460
- "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12517
+ "PARAM zero12t = { 0.0, 1.0, 2, 1.25 };" +
12518
+ "PARAM pow_2 = { 0.5, 0.25, 0.125, 0.0 };" +
12519
+ "PARAM pow2 = { 2, 4, 8, 0.0 };" +
1246112520 "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1246212521 "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
1246312522 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
....@@ -12472,10 +12531,11 @@
1247212531 "TEMP eye;" +
1247312532 "TEMP pos;" +
1247412533
12475
- "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12534
+ "MAD normal, fragment.color, zero12t.z, -zero12t.y;" +
1247612535 Normalize("normal") +
1247712536 "MOV light, state.light[0].position;" +
1247812537 "DP3 ndotl.x, light, normal;" +
12538
+ "MAX ndotl.x, ndotl.x, zero12t.x;" +
1247912539
1248012540 // shadow
1248112541 "MOV pos, fragment.texcoord[1];" +
....@@ -12491,7 +12551,7 @@
1249112551 "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
1249212552
1249312553 // Backlit
12494
- "MOV pos.w, zero123.y;" +
12554
+ "MOV pos.w, zero12t.y;" + // one
1249512555 "DP4 eye.x, pos, light2cam0;" +
1249612556 "DP4 eye.y, pos, light2cam1;" +
1249712557 "DP4 eye.z, pos, light2cam2;" +
....@@ -12499,24 +12559,28 @@
1249912559
1250012560 "DP3 ndotl.y, -eye, normal;" +
1250112561 //"MUL ndotl.y, ndotl.y, pow2.x;" +
12502
- "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12503
- "SUB ndotl.y, zero123.y, ndotl.y;" +
12562
+ "POW ndotl.y, ndotl.y, pow2.x;" + // backlit
12563
+ "SUB ndotl.y, zero12t.y, ndotl.y;" + // 1 - y
12564
+ //"POW ndotl.y, ndotl.y, pow2.z;" + // backlit
1250412565 //"SUB ndotl.y, zero123.y, ndotl.y;" +
1250512566 //"MUL ndotl.y, ndotl.y, pow2.z;" +
12567
+ "ADD ndotl.y, ndotl.y, one.x;" +
12568
+ "MUL ndotl.y, ndotl.y, pow_2.x;" +
1250612569
1250712570 //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
1250812571 //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
1250912572
1251012573 // Pigment
1251112574 "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12512
- "LRP temp, zero123.w, temp, one;" + // texture proportion
12513
- "MUL temp, temp, ndotl.x;" +
12514
-
12515
- "MUL temp, temp, zero123.z;" +
12575
+ "LRP temp, zero12t.w, temp, one;" + // texture proportion
12576
+ "MUL temp, temp, zero12t.w;" + // Times x
1251612577
1251712578 //"MUL temp, temp, ndotl.y;" +
12579
+ "MAD ndotl.x, pow_2.xxxx, ndotl.yyyy, ndotl.x;" +
1251812580
12519
- "MOV temp.w, zero123.y;" + // reset alpha
12581
+ "MUL temp, temp, ndotl.x;" + // lambert
12582
+
12583
+ "MOV temp.w, zero12t.y;" + // reset alpha
1252012584 "MOV result.color, temp;" +
1252112585 "END";
1252212586
....@@ -12548,7 +12612,7 @@
1254812612 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1254912613 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1255012614 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
12551
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12615
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1255212616 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1255312617 "PARAM options1 = program.env[62];" + // fog rgb color
1255412618 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -12793,7 +12857,7 @@
1279312857 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1279412858 // mar 2013 ??? "KIL alpha.a;" +
1279512859 "MOV alpha, texSamp.aaaa;" + // y;" +
12796
- "KIL alpha.a;" +
12860
+ "KIL alpha.a;" + // not sure with parallax mapping
1279712861 /*
1279812862 "MUL temp.xy, temp, two;" +
1279912863 "TXB bump, temp, texture[0], 2D;" +
....@@ -12879,11 +12943,6 @@
1287912943 "SUB bump0, bump0, half;" +
1288012944 "ADD bump, bump, bump0;" +
1288112945
12882
- "MOV temp.x, texSamp.a;" +
12883
- "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12884
- //"LRP texSamp0, params5.x, texSamp0, one;" +
12885
- "MOV texSamp.a, temp.x;" +
12886
-
1288712946 // double-sided
1288812947 /**/
1288912948 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -12893,26 +12952,73 @@
1289312952 "ADD temp.x, temp.x, one.x;" +
1289412953 "MUL normal, normal, temp.xxxx;":""
1289512954 ) +
12896
- /**/
12897
-//// Normalize("normal") +
12898
-//// "MAX normal.z, eps.x, normal.z;" +
12899
-// Normalize("normal") +
12900
- "MOV normald, normal;" +
12901
- "MOV normals, normal;" +
12955
+ /**/
12956
+
12957
+ "MOV temp, fragment.texcoord[4];" +
1290212958
1290312959 // UV base
1290412960 //"DP3 UP.x,state.matrix.modelview.row[0],Y;" +
1290512961 //"DP3 UP.y,state.matrix.modelview.row[1],Y;" +
1290612962 //"DP3 UP.z,state.matrix.modelview.row[2],Y;" +
12907
- "DP3 UP.x,state.matrix.texture[7].row[0],Y;" +
12908
- "DP3 UP.y,state.matrix.texture[7].row[1],Y;" +
12909
- "DP3 UP.z,state.matrix.texture[7].row[2],Y;" +
12963
+ "DP3 UP.x,state.matrix.texture[7].row[0],temp;" +
12964
+ "DP3 UP.y,state.matrix.texture[7].row[1],temp;" +
12965
+ "DP3 UP.z,state.matrix.texture[7].row[2],temp;" +
12966
+ Normalize("UP") +
12967
+
1291012968 "XPD V, normal, UP;" +
1291112969 Normalize("V") +
1291212970 "XPD U, V, normal;" +
1291312971 Normalize("U") +
1291412972
12973
+ "MOV temp, fragment.texcoord[0];" +
12974
+
12975
+// "MAD normal, -temp.x, U, normal;" +
12976
+// "MAD normal, -temp.y, V, normal;" +
12977
+// Normalize("normal") +
12978
+
12979
+//// "MAX normal.z, eps.x, normal.z;" +
12980
+// Normalize("normal") +
12981
+ "MOV normald, normal;" +
12982
+ "MOV normals, normal;" +
12983
+
1291512984 // parallax mapping
12985
+
12986
+ "DP3 temp2.x, V, eye;" +
12987
+ "DP3 temp2.y, U, eye;" +
12988
+ "DP3 temp2.z, normal, eye;" +
12989
+ "RCP temp2.z, temp2.z;" +
12990
+
12991
+ "DP3 temp2.w, texSamp, texSamp;" + // Height
12992
+ "RSQ temp2.w, temp2.w;" +
12993
+ "RCP temp2.w, temp2.w;" +
12994
+
12995
+ "SUB temp2.w, temp2.w, half;" +
12996
+ // "SGE temp.x, temp2.w, eps.x;" +
12997
+ // "MUL temp2.w, temp2.w, temp.x;" +
12998
+
12999
+ // "MOV texSamp, U;" +
13000
+
13001
+ "MUL temp2.z, temp2.z, temp2.w;" +
13002
+ "MUL temp2.z, temp2.z, params7.z;" + // parallax
13003
+
13004
+ "MUL temp2, temp2, temp2.z;" +
13005
+
13006
+ "SUB temp, temp, temp2;" +
13007
+
13008
+ "TEX temp, temp, texture[0], 2D;" +
13009
+ "POW temp.a, temp.a, params6.w;" + // punch through
13010
+
13011
+ "ADD texSamp, temp, texSamp;" +
13012
+ "MUL texSamp.xyz, half, texSamp;" +
13013
+
13014
+ "MOV alpha, texSamp.aaaa;" +
13015
+
13016
+// parallax mapping
13017
+
13018
+ "MOV temp.x, texSamp.a;" +
13019
+ "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
13020
+ //"LRP texSamp0, params5.x, texSamp0, one;" +
13021
+ "MOV texSamp.a, temp.x;" +
1291613022
1291713023 //"MOV temp, fragment.texcoord[0];" +
1291813024 //
....@@ -13383,8 +13489,12 @@
1338313489 program = programmin;
1338413490 }
1338513491
13386
- System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13387
- System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13492
+ if (Globals.DEBUG)
13493
+ {
13494
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13495
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13496
+ }
13497
+
1338813498 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1338913499
1339013500 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13431,7 +13541,8 @@
1343113541 "\n" +
1343213542 "END\n";
1343313543
13434
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13544
+ if (Globals.DEBUG)
13545
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1343513546 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1343613547
1343713548 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13689,7 +13800,7 @@
1368913800 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1369013801 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1369113802 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
13692
- /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13803
+ /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax
1369313804
1369413805 //Object3D.cVector2[] vector2buffer;
1369513806
....@@ -13856,7 +13967,7 @@
1385613967 "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" +
1385713968 "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" +
1385813969 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
13859
- "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" +
13970
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1386013971 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1386113972 "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" +
1386213973 //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" +
....@@ -13917,7 +14028,7 @@
1391714028 "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" +
1391814029 "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" +
1391914030 "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" +
13920
- //"MOV result.texcoord, vertex.texcoord;" +
14031
+ //"MOV result.texcoord, vertex.fogcoord;" +
1392114032 "MOV result.texcoord, temp;" +
1392214033 // border fade
1392314034 "MOV result.texcoord[3], vertex.texcoord;" +
....@@ -13964,7 +14075,9 @@
1396414075
1396514076 //"ADD temp.z, temp.z, one;" +
1396614077
13967
- "MOV result.color, temp;"
14078
+ "MOV result.texcoord[4], vertex.attrib[4];" + // U dir
14079
+
14080
+ "MOV result.color, temp;" // Normal
1396814081 : "MOV result.color, vertex.color;") +
1396914082 ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;"
1397014083 : "") +
....@@ -14623,18 +14736,24 @@
1462314736 }
1462414737 }
1462514738 PingThread pingthread = new PingThread();
14626
- int delta = 5;
14627
- int speed = 5;
14739
+ int delta = 2;
14740
+ int speed = 10;
1462814741 boolean autorepeat = false;
1462914742
1463014743 void GoDown(int mod)
1463114744 {
1463214745 MODIFIERS |= COMMAND;
14746
+ boolean isVR = (mouseMode&VR)!=0;
1463314747 /**/
1463414748 if((mod&SHIFT) == SHIFT)
14635
- manipCamera.RotatePosition(0, -speed);
14749
+ {
14750
+ if (isVR)
14751
+ manipCamera.RotateInterest(0, -speed);
14752
+ else
14753
+ manipCamera.RotatePosition(0, -speed);
14754
+ }
1463614755 else
14637
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14756
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1463814757 /**/
1463914758 if ((mod & SHIFT) == SHIFT)
1464014759 {
....@@ -14644,6 +14763,8 @@
1464414763 mouseMode |= BACKFORTH;
1464514764 }
1464614765
14766
+ targetLookAt.set(manipCamera.lookAt);
14767
+
1464714768 //prevX = X = anchorX;
1464814769 prevY = Y = anchorY - (int) (renderCamera.Distance());
1464914770 }
....@@ -14652,10 +14773,17 @@
1465214773 {
1465314774 MODIFIERS |= COMMAND;
1465414775 /**/
14776
+ boolean isVR = (mouseMode&VR)!=0;
14777
+
1465514778 if((mod&SHIFT) == SHIFT)
14656
- manipCamera.RotatePosition(0, speed);
14779
+ {
14780
+ if (isVR)
14781
+ manipCamera.RotateInterest(0, speed);
14782
+ else
14783
+ manipCamera.RotatePosition(0, speed);
14784
+ }
1465714785 else
14658
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14786
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1465914787 /**/
1466014788 if ((mod & SHIFT) == SHIFT)
1466114789 {
....@@ -14665,6 +14793,8 @@
1466514793 mouseMode |= BACKFORTH;
1466614794 }
1466714795
14796
+ targetLookAt.set(manipCamera.lookAt);
14797
+
1466814798 //prevX = X = anchorX;
1466914799 prevY = Y = anchorY + (int) (renderCamera.Distance());
1467014800 }
....@@ -14674,9 +14804,14 @@
1467414804 MODIFIERS |= COMMAND;
1467514805 /**/
1467614806 if((mod&SHIFT) == SHIFT)
14677
- manipCamera.Translate(speed*delta, 0, getWidth());
14807
+ manipCamera.Translate(speed*delta, 0, getWidth());
1467814808 else
14679
- manipCamera.RotatePosition(speed, 0);
14809
+ {
14810
+ if ((mouseMode&VR)!=0)
14811
+ manipCamera.RotateInterest(-speed, 0);
14812
+ else
14813
+ manipCamera.RotatePosition(speed, 0);
14814
+ }
1468014815 /**/
1468114816 if ((mod & SHIFT) == SHIFT)
1468214817 {
....@@ -14686,6 +14821,8 @@
1468614821 mouseMode |= ROTATE;
1468714822 } // TRANSLATE;
1468814823
14824
+ targetLookAt.set(manipCamera.lookAt);
14825
+
1468914826 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1469014827 prevY = Y = anchorY;
1469114828 }
....@@ -14695,9 +14832,15 @@
1469514832 MODIFIERS |= COMMAND;
1469614833 /**/
1469714834 if((mod&SHIFT) == SHIFT)
14698
- manipCamera.Translate(-speed*delta, 0, getWidth());
14835
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1469914836 else
14700
- manipCamera.RotatePosition(-speed, 0);
14837
+ {
14838
+ if ((mouseMode&VR)!=0)
14839
+ manipCamera.RotateInterest(speed, 0);
14840
+ else
14841
+ manipCamera.RotatePosition(-speed, 0);
14842
+ }
14843
+
1470114844 /**/
1470214845 if ((mod & SHIFT) == SHIFT)
1470314846 {
....@@ -14707,6 +14850,8 @@
1470714850 mouseMode |= ROTATE;
1470814851 } // TRANSLATE;
1470914852
14853
+ targetLookAt.set(manipCamera.lookAt);
14854
+
1471014855 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1471114856 prevY = Y = anchorY;
1471214857 }
....@@ -15209,8 +15354,8 @@
1520915354 case 'K':
1521015355 KOMPACTTEXTURE ^= true;
1521115356 //textures.clear();
15212
- break;
15213
- case 'P': // Texture Projection macros
15357
+ // break;
15358
+ //case 'P': // Texture Projection macros
1521415359 // SAVETEXTURE ^= true;
1521515360 macromode = true;
1521615361 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -15331,7 +15476,7 @@
1533115476 targetLookAt.set(manipCamera.lookAt);
1533215477 repaint();
1533315478 break;
15334
- case 'p':
15479
+ case 'P': // p':
1533515480 // c'est quoi ca au juste? spherical ^= true;
1533615481 Skinshader ^= true; programInitialized = false;
1533715482 repaint();
....@@ -15369,7 +15514,7 @@
1536915514 repaint();
1537015515 break;
1537115516 case 'O':
15372
- Globals.drawMode = OCCLUSION; // WARNING
15517
+ // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING
1537315518 repaint();
1537415519 break;
1537515520 case 'o':
....@@ -16091,7 +16236,7 @@
1609116236 {
1609216237 switch (hitSomething)
1609316238 {
16094
- case Object3D.hitCenter: gr.setColor(Color.pink);
16239
+ case Object3D.hitCenter: gr.setColor(Color.white);
1609516240 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1609616241 break;
1609716242 case Object3D.hitRotate: gr.setColor(Color.yellow);
....@@ -16117,7 +16262,7 @@
1611716262 if (hasMarquee)
1611816263 {
1611916264 gr.setXORMode(Color.white);
16120
- gr.setColor(Color.red);
16265
+ gr.setColor(Color.white);
1612116266 if (!firstime)
1612216267 {
1612316268 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16657,6 +16802,7 @@
1665716802 private void DrawSkyBox(GL gl, float ratio)
1665816803 {
1665916804 if (//envyoff ||
16805
+ WIREFRAME ||
1666016806 cubemap == null)
1666116807 {
1666216808 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
....@@ -16755,7 +16901,8 @@
1675516901 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1675616902
1675716903 cubemap.disable();
16758
- ////cubemap.unbind();
16904
+ //cubemap.dispose();
16905
+
1675916906 if (CULLFACE)
1676016907 {
1676116908 gl.glEnable(gl.GL_CULL_FACE);
....@@ -16811,7 +16958,7 @@
1681116958 gl.glScalef(1.0f, -1.0f, 1.0f);
1681216959 }
1681316960
16814
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
16961
+ SetGLNormal(gl, 0.0f, 0.0f, 1.0f);
1681516962
1681616963 float step = 2; // 0.1666f; //0.25f;
1681716964 float stepv = 2; // step * 1652 / 998;
....@@ -17291,6 +17438,7 @@
1729117438
1729217439 public void init(GLAutoDrawable drawable)
1729317440 {
17441
+ if (Globals.DEBUG)
1729417442 System.out.println("shadow buffer init");
1729517443
1729617444 GL gl = drawable.getGL();
....@@ -17519,10 +17667,14 @@
1751917667 gl.glFlush();
1752017668
1752117669 /**/
17522
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17670
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1752317671
17524
- float[] pixels = occlusionsizebuffer.array();
17672
+ float[] depths = occlusiondepthbuffer.array();
1752517673
17674
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17675
+
17676
+ int[] pixels = selectsizebuffer.array();
17677
+
1752617678 double r = 0, g = 0, b = 0;
1752717679
1752817680 double count = 0;
....@@ -17533,7 +17685,7 @@
1753317685
1753417686 double FACTOR = 1;
1753517687
17536
- for (int i = 0; i < pixels.length; i++)
17688
+ for (int i = 0; i < depths.length; i++)
1753717689 {
1753817690 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1753917691 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17616,7 +17768,7 @@
1761617768
1761717769 double scale = ray.z; // 1; // cos
1761817770
17619
- float depth = pixels[newindex];
17771
+ float depth = depths[newindex];
1762017772
1762117773 /*
1762217774 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17813,11 +17965,14 @@
1781317965 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1781417966 static IntBuffer bigAAbuffer;
1781517967 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17816
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17968
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1781717969 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1781817970 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1781917971 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17820
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17972
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17973
+
17974
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17975
+
1782117976 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1782217977 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1782317978 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();