| .. | .. | 
|---|
| 542 | 542 |                  LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); | 
|---|
| 543 | 543 |                  LA.vecCross(obj.v0, obj.v1, obj.v2); | 
|---|
| 544 | 544 |                  LA.vecNormalize(obj.v2); | 
|---|
| 545 |  | -                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);  | 
|---|
| 546 | 547 |              } | 
|---|
| 547 | 548 |   | 
|---|
| 548 | 549 |              // P | 
|---|
| .. | .. | 
|---|
| 564 | 565 |                  y += ny * obj.NORMALPUSH; | 
|---|
| 565 | 566 |                  z += nz * obj.NORMALPUSH; | 
|---|
| 566 | 567 |                   | 
|---|
| 567 |  | -                gl.glNormal3f(nx, ny, nz);  | 
|---|
 | 568 | +                SetGLNormal(gl, nx, ny, nz);  | 
|---|
| 568 | 569 |              } | 
|---|
| 569 | 570 |              gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); | 
|---|
| 570 | 571 |              SetColor(obj, pv); | 
|---|
| .. | .. | 
|---|
| 596 | 597 |                  y += ny * obj.NORMALPUSH; | 
|---|
| 597 | 598 |                  z += nz * obj.NORMALPUSH; | 
|---|
| 598 | 599 |                   | 
|---|
| 599 |  | -                gl.glNormal3f(nx, ny, nz);  | 
|---|
 | 600 | +                SetGLNormal(gl, nx, ny, nz);  | 
|---|
| 600 | 601 |              } | 
|---|
| 601 | 602 |              //System.out.println("vertexq = " + qv.s + ", " + qv.t); | 
|---|
| 602 | 603 |          //    boolean locked = false; | 
|---|
| .. | .. | 
|---|
| 644 | 645 |                  y += ny * obj.NORMALPUSH; | 
|---|
| 645 | 646 |                  z += nz * obj.NORMALPUSH; | 
|---|
| 646 | 647 |                   | 
|---|
| 647 |  | -                gl.glNormal3f(nx, ny, nz);  | 
|---|
 | 648 | +                SetGLNormal(gl, nx, ny, nz);  | 
|---|
| 648 | 649 |              } | 
|---|
| 649 | 650 |               | 
|---|
| 650 | 651 |          //    if ((dot&4) == 0) | 
|---|
| .. | .. | 
|---|
| 1250 | 1251 |                              { | 
|---|
| 1251 | 1252 |                                  if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) | 
|---|
| 1252 | 1253 |                                  { | 
|---|
| 1253 |  | -                                    gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);  | 
|---|
 | 1254 | +                                    SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);  | 
|---|
| 1254 | 1255 |                                  } else | 
|---|
| 1255 | 1256 |                                  { | 
|---|
| 1256 |  | -                                    gl.glNormal3f(0, 0, 1);  | 
|---|
 | 1257 | +                                    SetGLNormal(gl, 0, 0, 1);  | 
|---|
| 1257 | 1258 |                                  } | 
|---|
| 1258 | 1259 |   | 
|---|
| 1259 | 1260 |                                  if (c != null) | 
|---|
| .. | .. | 
|---|
| 1277 | 1278 |                              { | 
|---|
| 1278 | 1279 |                                  if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) | 
|---|
| 1279 | 1280 |                                  { | 
|---|
| 1280 |  | -                                    gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);  | 
|---|
 | 1281 | +                                    SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);  | 
|---|
| 1281 | 1282 |                                  } else | 
|---|
| 1282 | 1283 |                                  { | 
|---|
| 1283 |  | -                                    gl.glNormal3f(0, 0, 1);  | 
|---|
 | 1284 | +                                    SetGLNormal(gl, 0, 0, 1);  | 
|---|
| 1284 | 1285 |                                  } | 
|---|
| 1285 | 1286 |                                  if (c != null) | 
|---|
| 1286 | 1287 |                                  { | 
|---|
| .. | .. | 
|---|
| 1305 | 1306 |                                  { | 
|---|
| 1306 | 1307 |                                      if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) | 
|---|
| 1307 | 1308 |                                      { | 
|---|
| 1308 |  | -                                        gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);  | 
|---|
 | 1309 | +                                        SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);  | 
|---|
| 1309 | 1310 |                                      } else | 
|---|
| 1310 | 1311 |                                      { | 
|---|
| 1311 |  | -                                        gl.glNormal3f(0, 0, 1);  | 
|---|
 | 1312 | +                                        SetGLNormal(gl, 0, 0, 1);  | 
|---|
| 1312 | 1313 |                                      } | 
|---|
| 1313 | 1314 |                                      if (c != null) | 
|---|
| 1314 | 1315 |                                      { | 
|---|
| .. | .. | 
|---|
| 1490 | 1491 |      { | 
|---|
| 1491 | 1492 |          if (!selectmode) | 
|---|
| 1492 | 1493 |          { | 
|---|
| 1493 |  | -            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);  | 
|---|
| 1494 | 1495 |              gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); | 
|---|
| 1495 | 1496 |               | 
|---|
| 1496 | 1497 |              if (flipV) | 
|---|
| .. | .. | 
|---|
| 2473 | 2474 |          byte[] bytes = bytebuf.array(); | 
|---|
| 2474 | 2475 |           | 
|---|
| 2475 | 2476 |          return CreateBim(bytes, width, height); | 
|---|
 | 2477 | +    }  | 
|---|
 | 2478 | +  | 
|---|
 | 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);  | 
|---|
| 2476 | 2489 |      } | 
|---|
| 2477 | 2490 |   | 
|---|
| 2478 | 2491 |      /**/ | 
|---|
| .. | .. | 
|---|
| 12940 | 12953 |                  "MOV normald, normal;" + | 
|---|
| 12941 | 12954 |                  "MOV normals, normal;" + | 
|---|
| 12942 | 12955 |                   | 
|---|
 | 12956 | +                "MOV temp, fragment.texcoord[4];" +  | 
|---|
 | 12957 | +                  | 
|---|
| 12943 | 12958 |                  // UV base		 | 
|---|
| 12944 | 12959 |                  //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + | 
|---|
| 12945 | 12960 |                  //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + | 
|---|
| 12946 | 12961 |                  //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + | 
|---|
| 12947 |  | -                "DP3 UP.x,state.matrix.texture[7].row[0],Y;" +  | 
|---|
| 12948 |  | -                "DP3 UP.y,state.matrix.texture[7].row[1],Y;" +  | 
|---|
| 12949 |  | -                "DP3 UP.z,state.matrix.texture[7].row[2],Y;" +  | 
|---|
 | 12962 | +                "DP3 UP.x,state.matrix.texture[7].row[0],temp;" +  | 
|---|
 | 12963 | +                "DP3 UP.y,state.matrix.texture[7].row[1],temp;" +  | 
|---|
 | 12964 | +                "DP3 UP.z,state.matrix.texture[7].row[2],temp;" +  | 
|---|
 | 12965 | +                Normalize("UP") +  | 
|---|
 | 12966 | +                  | 
|---|
| 12950 | 12967 |                  "XPD V, normal, UP;" + | 
|---|
| 12951 | 12968 |                  Normalize("V") + | 
|---|
| 12952 | 12969 |                  "XPD U, V, normal;" + | 
|---|
| .. | .. | 
|---|
| 12978 | 12995 |                   | 
|---|
| 12979 | 12996 |                  "SUB temp, temp, temp2;" + | 
|---|
| 12980 | 12997 |                   | 
|---|
| 12981 |  | -                "TEX texSamp, temp, texture[0], 2D;" +  | 
|---|
| 12982 |  | -                "POW texSamp.a, texSamp.a, params6.w;" + // punch through  | 
|---|
 | 12998 | +                "TEX temp, temp, texture[0], 2D;" +  | 
|---|
 | 12999 | +                "POW temp.a, temp.a, params6.w;" + // punch through  | 
|---|
 | 13000 | +                  | 
|---|
 | 13001 | +                "ADD texSamp, temp, texSamp;" +  | 
|---|
 | 13002 | +                "MUL temp.xyz, half, texSamp;" +  | 
|---|
 | 13003 | +                  | 
|---|
| 12983 | 13004 |                  "MOV alpha, texSamp.aaaa;" + | 
|---|
| 12984 | 13005 |                   | 
|---|
| 12985 | 13006 |  // parallax mapping | 
|---|
| .. | .. | 
|---|
| 13936 | 13957 |                  "PARAM p[4]    = { state.matrix.projection };     # modelview projection matrix\n" + | 
|---|
| 13937 | 13958 |                  "PARAM zero    = { 0.0, 0.0, 0.0, 1.0 };" + | 
|---|
| 13938 | 13959 |                  "PARAM half    = { 0.5, 0.5, 0.5, 1.0 };" + | 
|---|
| 13939 |  | -                "PARAM one     = { 1.0, 1.0, 1.0, 0.0 };" +  | 
|---|
 | 13960 | +                "PARAM one     = { 1.0, 1.0, 1.0, 1.0 };" +  | 
|---|
| 13940 | 13961 |                  "PARAM two     = { 2.0, 2.0, 2.0, 1.0 };" + | 
|---|
| 13941 | 13962 |                  "PARAM third   = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + | 
|---|
| 13942 | 13963 |                  //"PARAM v256    = { 256.0, 256.0, 256.0, 1.0 };" + | 
|---|
| .. | .. | 
|---|
| 13997 | 14018 |                  "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + | 
|---|
| 13998 | 14019 |                  "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + | 
|---|
| 13999 | 14020 |                  "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + | 
|---|
| 14000 |  | -                //"MOV result.texcoord, vertex.texcoord;" +  | 
|---|
 | 14021 | +                //"MOV result.texcoord, vertex.fogcoord;" +  | 
|---|
| 14001 | 14022 |                  "MOV result.texcoord, temp;" + | 
|---|
| 14002 | 14023 |                  // border fade | 
|---|
| 14003 | 14024 |                  "MOV result.texcoord[3], vertex.texcoord;" + | 
|---|
| .. | .. | 
|---|
| 14044 | 14065 |   | 
|---|
| 14045 | 14066 |                  //"ADD temp.z, temp.z, one;" + | 
|---|
| 14046 | 14067 |   | 
|---|
| 14047 |  | -                "MOV result.color, temp;"  | 
|---|
 | 14068 | +                "MOV result.texcoord[4], vertex.attrib[4];" + // U dir  | 
|---|
 | 14069 | +                  | 
|---|
 | 14070 | +                "MOV result.color, temp;" // Normal  | 
|---|
| 14048 | 14071 |                  : "MOV result.color, vertex.color;") + | 
|---|
| 14049 | 14072 |                  ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" | 
|---|
| 14050 | 14073 |                  : "") + | 
|---|
| .. | .. | 
|---|
| 16925 | 16948 |              gl.glScalef(1.0f, -1.0f, 1.0f); | 
|---|
| 16926 | 16949 |          } | 
|---|
| 16927 | 16950 |   | 
|---|
| 16928 |  | -        gl.glNormal3f(0.0f, 0.0f, 1.0f);  | 
|---|
 | 16951 | +        SetGLNormal(gl, 0.0f, 0.0f, 1.0f);  | 
|---|
| 16929 | 16952 |               | 
|---|
| 16930 | 16953 |          float step = 2; // 0.1666f; //0.25f; | 
|---|
| 16931 | 16954 |          float stepv = 2; // step * 1652 / 998; | 
|---|