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
....@@ -187,6 +191,19 @@
187191 }
188192
189193 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
194
+
195
+ public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
196
+ {
197
+ try
198
+ {
199
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
200
+ } catch (IOException e)
201
+ {
202
+ System.out.println("NAME = " + name);
203
+ e.printStackTrace(); // throw new RuntimeException(e);
204
+ return null;
205
+ }
206
+ }
190207
191208 void SetAsGLRenderer(boolean b)
192209 {
....@@ -525,7 +542,8 @@
525542 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
526543 LA.vecCross(obj.v0, obj.v1, obj.v2);
527544 LA.vecNormalize(obj.v2);
528
- 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);
529547 }
530548
531549 // P
....@@ -547,7 +565,7 @@
547565 y += ny * obj.NORMALPUSH;
548566 z += nz * obj.NORMALPUSH;
549567
550
- gl.glNormal3f(nx, ny, nz);
568
+ SetGLNormal(gl, nx, ny, nz);
551569 }
552570 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
553571 SetColor(obj, pv);
....@@ -579,7 +597,7 @@
579597 y += ny * obj.NORMALPUSH;
580598 z += nz * obj.NORMALPUSH;
581599
582
- gl.glNormal3f(nx, ny, nz);
600
+ SetGLNormal(gl, nx, ny, nz);
583601 }
584602 //System.out.println("vertexq = " + qv.s + ", " + qv.t);
585603 // boolean locked = false;
....@@ -627,7 +645,7 @@
627645 y += ny * obj.NORMALPUSH;
628646 z += nz * obj.NORMALPUSH;
629647
630
- gl.glNormal3f(nx, ny, nz);
648
+ SetGLNormal(gl, nx, ny, nz);
631649 }
632650
633651 // if ((dot&4) == 0)
....@@ -863,7 +881,7 @@
863881 //// tris.postdraw(this);
864882 }
865883
866
- static Camera localcamera = new Camera();
884
+ static Camera localAOcamera = new Camera();
867885 static cVector from = new cVector();
868886 static cVector to = new cVector();
869887
....@@ -872,7 +890,7 @@
872890 CameraPane cp = this;
873891
874892 Camera keep = cp.RenderCamera();
875
- cp.renderCamera = localcamera;
893
+ cp.renderCamera = localAOcamera;
876894
877895 if (br.trimmed)
878896 {
....@@ -890,7 +908,7 @@
890908 br.positions[i3 + 2] + br.normals[i3 + 2]);
891909 LA.xformPos(from, transform, from);
892910 LA.xformPos(to, transform, to); // RIGID ONLY
893
- localcamera.setAim(from, to);
911
+ localAOcamera.setAim(from, to);
894912
895913 CameraPane.occlusionbuffer.display();
896914
....@@ -924,7 +942,7 @@
924942 to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
925943 LA.xformPos(from, transform, from);
926944 LA.xformPos(to, transform, to); // RIGID ONLY
927
- localcamera.setAim(from, to);
945
+ localAOcamera.setAim(from, to);
928946
929947 CameraPane.occlusionbuffer.display();
930948
....@@ -1233,10 +1251,10 @@
12331251 {
12341252 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12351253 {
1236
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1254
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12371255 } else
12381256 {
1239
- gl.glNormal3f(0, 0, 1);
1257
+ SetGLNormal(gl, 0, 0, 1);
12401258 }
12411259
12421260 if (c != null)
....@@ -1260,10 +1278,10 @@
12601278 {
12611279 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12621280 {
1263
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1281
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12641282 } else
12651283 {
1266
- gl.glNormal3f(0, 0, 1);
1284
+ SetGLNormal(gl, 0, 0, 1);
12671285 }
12681286 if (c != null)
12691287 {
....@@ -1288,10 +1306,10 @@
12881306 {
12891307 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12901308 {
1291
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1309
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12921310 } else
12931311 {
1294
- gl.glNormal3f(0, 0, 1);
1312
+ SetGLNormal(gl, 0, 0, 1);
12951313 }
12961314 if (c != null)
12971315 {
....@@ -1473,7 +1491,7 @@
14731491 {
14741492 if (!selectmode)
14751493 {
1476
- 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);
14771495 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
14781496
14791497 if (flipV)
....@@ -1485,6 +1503,8 @@
14851503 gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
14861504 }
14871505
1506
+ float[] colorV = new float[4];
1507
+
14881508 void SetColor(Object3D obj, Vertex p0)
14891509 {
14901510 CameraPane display = this;
....@@ -1552,8 +1572,6 @@
15521572 {
15531573 return;
15541574 }
1555
-
1556
- float[] colorV = new float[3];
15571575
15581576 if (false) // marked)
15591577 {
....@@ -1802,7 +1820,7 @@
18021820
18031821 display.modelParams7[0] = 0;
18041822 display.modelParams7[1] = 1000;
1805
- display.modelParams7[2] = 0;
1823
+ display.modelParams7[2] = material.parallax;
18061824 display.modelParams7[3] = 0;
18071825
18081826 //display.modelParams6[0] = 100; // criss de bug de bump
....@@ -2035,9 +2053,9 @@
20352053 switch(viewcode)
20362054 {
20372055 case 0: return "main";
2038
- case 1: return "one";
2039
- case 2: return "two";
2040
- case 3: return "three";
2056
+ case 1: return "Red";
2057
+ case 2: return "Green";
2058
+ case 3: return "Blue";
20412059 case 4: return "light";
20422060 }
20432061
....@@ -2458,6 +2476,18 @@
24582476 return CreateBim(bytes, width, height);
24592477 }
24602478
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
+
24612491 /**/
24622492 class CacheTexture
24632493 {
....@@ -2500,7 +2530,7 @@
25002530 com.sun.opengl.util.texture.TextureIO.newTextureData(
25012531 getClass().getClassLoader().getResourceAsStream(name),
25022532 true,
2503
- com.sun.opengl.util.texture.TextureIO.PNG);
2533
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
25042534 } catch (java.io.IOException e)
25052535 {
25062536 throw new javax.media.opengl.GLException(e);
....@@ -8346,7 +8376,7 @@
83468376 // else
83478377 // if (!texname.startsWith("/"))
83488378 // texname = "/Users/nbriere/Textures/" + texname;
8349
- if (!FileExists(texname))
8379
+ if (!FileExists(texname) && !texname.startsWith("@"))
83508380 {
83518381 texname = fallbackTextureName;
83528382 }
....@@ -8429,6 +8459,15 @@
84298459 new Exception().printStackTrace();
84308460 } else
84318461 {
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
+ {
84328471 if (textureon)
84338472 {
84348473 String cachename = texname;
....@@ -8488,6 +8527,7 @@
84888527 texturecache = new CacheTexture(texturedata,resolution);
84898528 //texture = GetTexture(tex, bump);
84908529 }
8530
+ }
84918531 }
84928532 //}
84938533 }
....@@ -8756,10 +8796,12 @@
87568796
87578797 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
87588798 MAXSTACK = temp[0];
8759
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8799
+ if (Globals.DEBUG)
8800
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
87608801 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
87618802 MAXSTACK = temp[0];
8762
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8803
+ if (Globals.DEBUG)
8804
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
87638805
87648806 // Use debug pipeline
87658807 //drawable.setGL(new DebugGL(gl)); //
....@@ -8767,7 +8809,8 @@
87678809 gl = drawable.getGL(); //
87688810
87698811 GL gl3 = getGL();
8770
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8812
+ if (Globals.DEBUG)
8813
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
87718814
87728815
87738816 //float pos[] = { 100, 100, 100, 0 };
....@@ -8932,7 +8975,7 @@
89328975
89338976 if (cubemap == null)
89348977 {
8935
- LoadEnvy(5);
8978
+ //LoadEnvy(1);
89368979 }
89378980
89388981 //cubemap.enable();
....@@ -9208,6 +9251,8 @@
92089251
92099252 void LoadEnvy(int which)
92109253 {
9254
+ assert(false);
9255
+
92119256 String name;
92129257 String ext;
92139258
....@@ -9219,37 +9264,58 @@
92199264 cubemap = null;
92209265 return;
92219266 case 1:
9222
- name = "cubemaps/box_";
9223
- ext = "png";
9267
+ name = "cubemaps/rgb/";
9268
+ ext = "jpg";
92249269 reverseUP = false;
92259270 break;
92269271 case 2:
9227
- name = "cubemaps/uffizi_";
9228
- ext = "png";
9229
- break; // reverseUP = true; break;
9272
+ name = "cubemaps/uffizi/";
9273
+ ext = "jpg";
9274
+ reverseUP = false;
9275
+ break;
92309276 case 3:
9231
- name = "cubemaps/CloudyHills_";
9232
- ext = "tga";
9277
+ name = "cubemaps/CloudyHills/";
9278
+ ext = "jpg";
92339279 reverseUP = false;
92349280 break;
92359281 case 4:
9236
- name = "cubemaps/cornell_";
9282
+ name = "cubemaps/cornell/";
92379283 ext = "png";
92389284 reverseUP = false;
92399285 break;
9286
+ case 5:
9287
+ name = "cubemaps/skycube/";
9288
+ ext = "jpg";
9289
+ reverseUP = false;
9290
+ break;
9291
+ case 6:
9292
+ name = "cubemaps/SaintLazarusChurch3/";
9293
+ ext = "jpg";
9294
+ reverseUP = false;
9295
+ break;
9296
+ case 7:
9297
+ name = "cubemaps/Sodermalmsallen/";
9298
+ ext = "jpg";
9299
+ reverseUP = false;
9300
+ break;
9301
+ case 8:
9302
+ name = "cubemaps/Sodermalmsallen2/";
9303
+ ext = "jpg";
9304
+ reverseUP = false;
9305
+ break;
9306
+ case 9:
9307
+ name = "cubemaps/UnionSquare/";
9308
+ ext = "jpg";
9309
+ reverseUP = false;
9310
+ break;
92409311 default:
9241
- name = "cubemaps/rgb_";
9242
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9312
+ name = "cubemaps/box/";
9313
+ ext = "png"; /*mipmap = true;*/
9314
+ reverseUP = false;
92439315 break;
92449316 }
9245
-
9246
- try
9247
- {
9248
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
9249
- } catch (IOException e)
9250
- {
9251
- throw new RuntimeException(e);
9252
- }
9317
+
9318
+ LoadSkybox(name, ext, mipmap);
92539319 }
92549320
92559321 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -9281,8 +9347,12 @@
92819347 static double[] model = new double[16];
92829348 double[] camera2light = new double[16];
92839349 double[] light2camera = new double[16];
9284
- int newenvy = -1;
9285
- boolean envyoff = true; // false;
9350
+
9351
+ //int newenvy = -1;
9352
+ //boolean envyoff = false;
9353
+
9354
+ String loadedskyboxname;
9355
+
92869356 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
92879357 //float[] light0 = { 0,0,0 };
92889358 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9762,10 +9832,12 @@
97629832 rati = 1 / rati;
97639833 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
97649834 }
9765
- assert (newenvy == -1);
9835
+
9836
+ //assert (newenvy == -1);
9837
+
97669838 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
97679839 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9768
- DrawSkyBox(gl);
9840
+ DrawSkyBox(gl, (float)rati);
97699841 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
97709842 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
97719843 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -10631,9 +10703,18 @@
1063110703 static boolean init = false;
1063210704
1063310705 double[][] matrix = LA.newMatrix();
10706
+
10707
+ // This is to refresh the UI of the material panel.
10708
+ ObjEditor patchMaterial;
1063410709
1063510710 public void display(GLAutoDrawable drawable)
1063610711 {
10712
+ if (patchMaterial.patchMaterial)
10713
+ {
10714
+ patchMaterial.patchMaterial = false;
10715
+ patchMaterial.objectPanel.setSelectedIndex(1);
10716
+ }
10717
+
1063710718 if (Grafreed.savesound && Grafreed.hassound)
1063810719 {
1063910720 Grafreed.wav.save();
....@@ -10802,7 +10883,7 @@
1080210883
1080310884 if (wait)
1080410885 {
10805
- Sleep(500);
10886
+ Sleep(200); // blocks everything
1080610887
1080710888 wait = false;
1080810889 }
....@@ -11018,13 +11099,43 @@
1101811099 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1101911100 }
1102011101
11021
- if (newenvy > -1)
11102
+// if (newenvy > -1)
11103
+// {
11104
+// LoadEnvy(newenvy);
11105
+// }
11106
+//
11107
+// newenvy = -1;
11108
+
11109
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1102211110 {
11023
- LoadEnvy(newenvy);
11111
+ if (cubemaprgb == null)
11112
+ {
11113
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
11114
+ }
11115
+
11116
+ cubemap = cubemaprgb;
1102411117 }
11025
-
11026
- newenvy = -1;
11027
-
11118
+ else
11119
+ {
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;
11137
+ }
11138
+
1102811139 ratio = ((double) getWidth()) / getHeight();
1102911140 //System.out.println("ratio = " + ratio);
1103011141
....@@ -11040,7 +11151,7 @@
1104011151
1104111152 if (!IsFrozen() && !ambientOcclusion)
1104211153 {
11043
- DrawSkyBox(gl);
11154
+ DrawSkyBox(gl, (float)ratio);
1104411155 }
1104511156
1104611157 //if (selection_view == -1)
....@@ -11326,7 +11437,7 @@
1132611437
1132711438 // if (cam != lightCamera)
1132811439 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11329
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11440
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1133011441 }
1133111442
1133211443 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12400,11 +12511,12 @@
1240012511
1240112512 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240212513
12403
- String program =
12514
+ String programmin =
1240412515 // Min shader
1240512516 "!!ARBfp1.0\n" +
12406
- "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12407
- "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 };" +
1240812520 "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1240912521 "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
1241012522 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
....@@ -12419,10 +12531,11 @@
1241912531 "TEMP eye;" +
1242012532 "TEMP pos;" +
1242112533
12422
- "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12534
+ "MAD normal, fragment.color, zero12t.z, -zero12t.y;" +
1242312535 Normalize("normal") +
1242412536 "MOV light, state.light[0].position;" +
1242512537 "DP3 ndotl.x, light, normal;" +
12538
+ "MAX ndotl.x, ndotl.x, zero12t.x;" +
1242612539
1242712540 // shadow
1242812541 "MOV pos, fragment.texcoord[1];" +
....@@ -12438,7 +12551,7 @@
1243812551 "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
1243912552
1244012553 // Backlit
12441
- "MOV pos.w, zero123.y;" +
12554
+ "MOV pos.w, zero12t.y;" + // one
1244212555 "DP4 eye.x, pos, light2cam0;" +
1244312556 "DP4 eye.y, pos, light2cam1;" +
1244412557 "DP4 eye.z, pos, light2cam2;" +
....@@ -12446,27 +12559,32 @@
1244612559
1244712560 "DP3 ndotl.y, -eye, normal;" +
1244812561 //"MUL ndotl.y, ndotl.y, pow2.x;" +
12449
- "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12450
- "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
1245112565 //"SUB ndotl.y, zero123.y, ndotl.y;" +
1245212566 //"MUL ndotl.y, ndotl.y, pow2.z;" +
12567
+ "ADD ndotl.y, ndotl.y, one.x;" +
12568
+ "MUL ndotl.y, ndotl.y, pow_2.x;" +
1245312569
12454
- "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12570
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12571
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
1245512572
1245612573 // Pigment
1245712574 "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12458
- "LRP temp, zero123.w, temp, one;" + // texture proportion
12459
- "MUL temp, temp, ndotl.x;" +
12460
-
12461
- "MUL temp, temp, zero123.z;" +
12575
+ "LRP temp, zero12t.w, temp, one;" + // texture proportion
12576
+ "MUL temp, temp, zero12t.w;" + // Times x
1246212577
1246312578 //"MUL temp, temp, ndotl.y;" +
12579
+ "MAD ndotl.x, pow_2.xxxx, ndotl.yyyy, ndotl.x;" +
1246412580
12465
- "MOV temp.w, zero123.y;" + // reset alpha
12581
+ "MUL temp, temp, ndotl.x;" + // lambert
12582
+
12583
+ "MOV temp.w, zero12t.y;" + // reset alpha
1246612584 "MOV result.color, temp;" +
1246712585 "END";
1246812586
12469
- String program2 =
12587
+ String programmax =
1247012588 "!!ARBfp1.0\n" +
1247112589
1247212590 //"OPTION ARB_fragment_program_shadow;" +
....@@ -12494,7 +12612,7 @@
1249412612 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1249512613 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1249612614 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
12497
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12615
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1249812616 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1249912617 "PARAM options1 = program.env[62];" + // fog rgb color
1250012618 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -12739,7 +12857,7 @@
1273912857 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1274012858 // mar 2013 ??? "KIL alpha.a;" +
1274112859 "MOV alpha, texSamp.aaaa;" + // y;" +
12742
- "KIL alpha.a;" +
12860
+ "KIL alpha.a;" + // not sure with parallax mapping
1274312861 /*
1274412862 "MUL temp.xy, temp, two;" +
1274512863 "TXB bump, temp, texture[0], 2D;" +
....@@ -12825,11 +12943,6 @@
1282512943 "SUB bump0, bump0, half;" +
1282612944 "ADD bump, bump, bump0;" +
1282712945
12828
- "MOV temp.x, texSamp.a;" +
12829
- "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12830
- //"LRP texSamp0, params5.x, texSamp0, one;" +
12831
- "MOV texSamp.a, temp.x;" +
12832
-
1283312946 // double-sided
1283412947 /**/
1283512948 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -12839,26 +12952,73 @@
1283912952 "ADD temp.x, temp.x, one.x;" +
1284012953 "MUL normal, normal, temp.xxxx;":""
1284112954 ) +
12842
- /**/
12843
-//// Normalize("normal") +
12844
-//// "MAX normal.z, eps.x, normal.z;" +
12845
-// Normalize("normal") +
12846
- "MOV normald, normal;" +
12847
- "MOV normals, normal;" +
12955
+ /**/
12956
+
12957
+ "MOV temp, fragment.texcoord[4];" +
1284812958
1284912959 // UV base
1285012960 //"DP3 UP.x,state.matrix.modelview.row[0],Y;" +
1285112961 //"DP3 UP.y,state.matrix.modelview.row[1],Y;" +
1285212962 //"DP3 UP.z,state.matrix.modelview.row[2],Y;" +
12853
- "DP3 UP.x,state.matrix.texture[7].row[0],Y;" +
12854
- "DP3 UP.y,state.matrix.texture[7].row[1],Y;" +
12855
- "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
+
1285612968 "XPD V, normal, UP;" +
1285712969 Normalize("V") +
1285812970 "XPD U, V, normal;" +
1285912971 Normalize("U") +
1286012972
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
+
1286112984 // 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;" +
1286213022
1286313023 //"MOV temp, fragment.texcoord[0];" +
1286413024 //
....@@ -12991,7 +13151,7 @@
1299113151 // display shadow only (fakedepth == 0)
1299213152 "SUB temp.x, half.x, shadow.x;" +
1299313153 "MOV temp.y, -params5.z;" + // params6.x;" +
12994
- "SLT temp.z, temp.y, -one2048th.x;" +
13154
+ "SLT temp.z, temp.y, -c256i.x;" +
1299513155 "SUB temp.y, one.x, temp.z;" +
1299613156 "MUL temp.x, temp.x, temp.y;" +
1299713157 "KIL temp.x;" +
....@@ -13322,8 +13482,19 @@
1332213482 //once = true;
1332313483 }
1332413484
13325
- System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13326
- System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13485
+ String program = programmax;
13486
+
13487
+ if (Globals.MINSHADER)
13488
+ {
13489
+ program = programmin;
13490
+ }
13491
+
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
+
1332713498 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1332813499
1332913500 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13370,7 +13541,8 @@
1337013541 "\n" +
1337113542 "END\n";
1337213543
13373
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13544
+ if (Globals.DEBUG)
13545
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1337413546 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1337513547
1337613548 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13628,7 +13800,7 @@
1362813800 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1362913801 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1363013802 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
13631
- /*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
1363213804
1363313805 //Object3D.cVector2[] vector2buffer;
1363413806
....@@ -13795,7 +13967,7 @@
1379513967 "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" +
1379613968 "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" +
1379713969 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
13798
- "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" +
13970
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1379913971 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1380013972 "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" +
1380113973 //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" +
....@@ -13856,7 +14028,7 @@
1385614028 "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" +
1385714029 "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" +
1385814030 "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" +
13859
- //"MOV result.texcoord, vertex.texcoord;" +
14031
+ //"MOV result.texcoord, vertex.fogcoord;" +
1386014032 "MOV result.texcoord, temp;" +
1386114033 // border fade
1386214034 "MOV result.texcoord[3], vertex.texcoord;" +
....@@ -13903,7 +14075,9 @@
1390314075
1390414076 //"ADD temp.z, temp.z, one;" +
1390514077
13906
- "MOV result.color, temp;"
14078
+ "MOV result.texcoord[4], vertex.attrib[4];" + // U dir
14079
+
14080
+ "MOV result.color, temp;" // Normal
1390714081 : "MOV result.color, vertex.color;") +
1390814082 ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;"
1390914083 : "") +
....@@ -14562,18 +14736,24 @@
1456214736 }
1456314737 }
1456414738 PingThread pingthread = new PingThread();
14565
- int delta = 5;
14566
- int speed = 5;
14739
+ int delta = 2;
14740
+ int speed = 10;
1456714741 boolean autorepeat = false;
1456814742
1456914743 void GoDown(int mod)
1457014744 {
1457114745 MODIFIERS |= COMMAND;
14746
+ boolean isVR = (mouseMode&VR)!=0;
1457214747 /**/
1457314748 if((mod&SHIFT) == SHIFT)
14574
- manipCamera.RotatePosition(0, -speed);
14749
+ {
14750
+ if (isVR)
14751
+ manipCamera.RotateInterest(0, -speed);
14752
+ else
14753
+ manipCamera.RotatePosition(0, -speed);
14754
+ }
1457514755 else
14576
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14756
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1457714757 /**/
1457814758 if ((mod & SHIFT) == SHIFT)
1457914759 {
....@@ -14583,6 +14763,8 @@
1458314763 mouseMode |= BACKFORTH;
1458414764 }
1458514765
14766
+ targetLookAt.set(manipCamera.lookAt);
14767
+
1458614768 //prevX = X = anchorX;
1458714769 prevY = Y = anchorY - (int) (renderCamera.Distance());
1458814770 }
....@@ -14591,10 +14773,17 @@
1459114773 {
1459214774 MODIFIERS |= COMMAND;
1459314775 /**/
14776
+ boolean isVR = (mouseMode&VR)!=0;
14777
+
1459414778 if((mod&SHIFT) == SHIFT)
14595
- manipCamera.RotatePosition(0, speed);
14779
+ {
14780
+ if (isVR)
14781
+ manipCamera.RotateInterest(0, speed);
14782
+ else
14783
+ manipCamera.RotatePosition(0, speed);
14784
+ }
1459614785 else
14597
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14786
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1459814787 /**/
1459914788 if ((mod & SHIFT) == SHIFT)
1460014789 {
....@@ -14604,6 +14793,8 @@
1460414793 mouseMode |= BACKFORTH;
1460514794 }
1460614795
14796
+ targetLookAt.set(manipCamera.lookAt);
14797
+
1460714798 //prevX = X = anchorX;
1460814799 prevY = Y = anchorY + (int) (renderCamera.Distance());
1460914800 }
....@@ -14613,9 +14804,14 @@
1461314804 MODIFIERS |= COMMAND;
1461414805 /**/
1461514806 if((mod&SHIFT) == SHIFT)
14616
- manipCamera.Translate(speed*delta, 0, getWidth());
14807
+ manipCamera.Translate(speed*delta, 0, getWidth());
1461714808 else
14618
- manipCamera.RotatePosition(speed, 0);
14809
+ {
14810
+ if ((mouseMode&VR)!=0)
14811
+ manipCamera.RotateInterest(-speed, 0);
14812
+ else
14813
+ manipCamera.RotatePosition(speed, 0);
14814
+ }
1461914815 /**/
1462014816 if ((mod & SHIFT) == SHIFT)
1462114817 {
....@@ -14625,6 +14821,8 @@
1462514821 mouseMode |= ROTATE;
1462614822 } // TRANSLATE;
1462714823
14824
+ targetLookAt.set(manipCamera.lookAt);
14825
+
1462814826 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1462914827 prevY = Y = anchorY;
1463014828 }
....@@ -14634,9 +14832,15 @@
1463414832 MODIFIERS |= COMMAND;
1463514833 /**/
1463614834 if((mod&SHIFT) == SHIFT)
14637
- manipCamera.Translate(-speed*delta, 0, getWidth());
14835
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1463814836 else
14639
- manipCamera.RotatePosition(-speed, 0);
14837
+ {
14838
+ if ((mouseMode&VR)!=0)
14839
+ manipCamera.RotateInterest(speed, 0);
14840
+ else
14841
+ manipCamera.RotatePosition(-speed, 0);
14842
+ }
14843
+
1464014844 /**/
1464114845 if ((mod & SHIFT) == SHIFT)
1464214846 {
....@@ -14646,6 +14850,8 @@
1464614850 mouseMode |= ROTATE;
1464714851 } // TRANSLATE;
1464814852
14853
+ targetLookAt.set(manipCamera.lookAt);
14854
+
1464914855 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1465014856 prevY = Y = anchorY;
1465114857 }
....@@ -15148,8 +15354,8 @@
1514815354 case 'K':
1514915355 KOMPACTTEXTURE ^= true;
1515015356 //textures.clear();
15151
- break;
15152
- case 'P': // Texture Projection macros
15357
+ // break;
15358
+ //case 'P': // Texture Projection macros
1515315359 // SAVETEXTURE ^= true;
1515415360 macromode = true;
1515515361 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -15270,7 +15476,7 @@
1527015476 targetLookAt.set(manipCamera.lookAt);
1527115477 repaint();
1527215478 break;
15273
- case 'p':
15479
+ case 'P': // p':
1527415480 // c'est quoi ca au juste? spherical ^= true;
1527515481 Skinshader ^= true; programInitialized = false;
1527615482 repaint();
....@@ -15308,27 +15514,31 @@
1530815514 repaint();
1530915515 break;
1531015516 case 'O':
15311
- Globals.drawMode = OCCLUSION; // WARNING
15517
+ // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING
1531215518 repaint();
1531315519 break;
1531415520 case 'o':
1531515521 OCCLUSION_CULLING ^= true;
1531615522 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1531715523 break;
15318
- case '0': envyoff ^= true; repaint(); break;
15524
+ //case '0': envyoff ^= true; repaint(); break;
1531915525 case '1':
1532015526 case '2':
1532115527 case '3':
1532215528 case '4':
1532315529 case '5':
15324
- newenvy = Character.getNumericValue(key);
15325
- repaint();
15326
- break;
1532715530 case '6':
1532815531 case '7':
1532915532 case '8':
1533015533 case '9':
15331
- BGcolor = (key - '6')/3.f;
15534
+ if (true) // envyoff)
15535
+ {
15536
+ BGcolor = (key - '1')/8.f;
15537
+ }
15538
+ else
15539
+ {
15540
+ //newenvy = Character.getNumericValue(key);
15541
+ }
1533215542 repaint();
1533315543 break;
1533415544 case '!':
....@@ -16026,14 +16236,14 @@
1602616236 {
1602716237 switch (hitSomething)
1602816238 {
16029
- case Object3D.hitCenter: gr.setColor(Color.pink);
16239
+ case Object3D.hitCenter: gr.setColor(Color.white);
1603016240 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1603116241 break;
1603216242 case Object3D.hitRotate: gr.setColor(Color.yellow);
1603316243 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1603416244 break;
1603516245 case Object3D.hitScale: gr.setColor(Color.cyan);
16036
- gr.drawLine(X, Y, 0, 0);
16246
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1603716247 break;
1603816248 }
1603916249
....@@ -16052,7 +16262,7 @@
1605216262 if (hasMarquee)
1605316263 {
1605416264 gr.setXORMode(Color.white);
16055
- gr.setColor(Color.red);
16265
+ gr.setColor(Color.white);
1605616266 if (!firstime)
1605716267 {
1605816268 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16519,6 +16729,8 @@
1651916729 private /*static*/ boolean firstime;
1652016730 private /*static*/ cVector newView = new cVector();
1652116731 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16732
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16733
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1652216734 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1652316735 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1652416736 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16531,29 +16743,67 @@
1653116743 {
1653216744 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1653316745
16746
+ int usedsuf = 0;
16747
+
1653416748 for (int i = 0; i < suffixes.length; i++)
1653516749 {
16536
- String resourceName = basename + suffixes[i] + "." + suffix;
16537
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16538
- mipmapped,
16539
- FileUtil.getFileSuffix(resourceName));
16540
- if (data == null)
16750
+ String[] suffixe = suffixes;
16751
+ String[] fallback = suffixes2;
16752
+ String[] fallfallback = suffixes3;
16753
+
16754
+ for (int c=usedsuf; --c>=0;)
1654116755 {
16542
- throw new IOException("Unable to load texture " + resourceName);
16756
+// String[] temp = suffixe;
16757
+// suffixe = fallback;
16758
+// fallback = fallfallback;
16759
+// fallfallback = temp;
1654316760 }
16761
+
16762
+ String resourceName = basename + suffixe[i] + "." + suffix;
16763
+ TextureData data;
16764
+
16765
+ try
16766
+ {
16767
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16768
+ mipmapped,
16769
+ FileUtil.getFileSuffix(resourceName));
16770
+ }
16771
+ catch (Exception e)
16772
+ {
16773
+ try
16774
+ {
16775
+ resourceName = basename + fallback[i] + "." + suffix;
16776
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16777
+ mipmapped,
16778
+ FileUtil.getFileSuffix(resourceName));
16779
+ }
16780
+ catch (Exception e2)
16781
+ {
16782
+ resourceName = basename + fallfallback[i] + "." + suffix;
16783
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16784
+ mipmapped,
16785
+ FileUtil.getFileSuffix(resourceName));
16786
+ }
16787
+ }
16788
+
1654416789 //System.out.println("Target = " + targets[i]);
1654516790 cubemap.updateImage(data, targets[i]);
1654616791 }
1654716792
1654816793 return cubemap;
1654916794 }
16795
+
1655016796 int bigsphere = -1;
1655116797
1655216798 float BGcolor = 0.5f;
1655316799
16554
- private void DrawSkyBox(GL gl)
16800
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16801
+
16802
+ private void DrawSkyBox(GL gl, float ratio)
1655516803 {
16556
- if (envyoff || cubemap == null)
16804
+ if (//envyoff ||
16805
+ WIREFRAME ||
16806
+ cubemap == null)
1655716807 {
1655816808 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1655916809 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16568,7 +16818,17 @@
1656816818 // Compensates for ExaminerViewer's modification of modelview matrix
1656916819 gl.glMatrixMode(GL.GL_MODELVIEW);
1657016820 gl.glLoadIdentity();
16821
+ gl.glScalef(1,ratio,1);
1657116822
16823
+// colorV[0] = 2;
16824
+// colorV[1] = 2;
16825
+// colorV[2] = 2;
16826
+// colorV[3] = 1;
16827
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16828
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16829
+//
16830
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16831
+
1657216832 //gl.glActiveTexture(GL.GL_TEXTURE1);
1657316833 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1657416834
....@@ -16600,6 +16860,7 @@
1660016860 {
1660116861 gl.glScalef(1.0f, -1.0f, 1.0f);
1660216862 }
16863
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1660316864 gl.glMultMatrixd(viewrot_1, 0);
1660416865 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1660516866 //viewer.updateInverseRotation(gl);
....@@ -16640,7 +16901,8 @@
1664016901 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1664116902
1664216903 cubemap.disable();
16643
- ////cubemap.unbind();
16904
+ //cubemap.dispose();
16905
+
1664416906 if (CULLFACE)
1664516907 {
1664616908 gl.glEnable(gl.GL_CULL_FACE);
....@@ -16696,7 +16958,7 @@
1669616958 gl.glScalef(1.0f, -1.0f, 1.0f);
1669716959 }
1669816960
16699
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
16961
+ SetGLNormal(gl, 0.0f, 0.0f, 1.0f);
1670016962
1670116963 float step = 2; // 0.1666f; //0.25f;
1670216964 float stepv = 2; // step * 1652 / 998;
....@@ -16858,7 +17120,7 @@
1685817120 //new Exception().printStackTrace();
1685917121 System.out.println("select buffer init");
1686017122 // Use debug pipeline
16861
- drawable.setGL(new DebugGL(drawable.getGL()));
17123
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1686217124
1686317125 GL gl = drawable.getGL();
1686417126
....@@ -17176,6 +17438,7 @@
1717617438
1717717439 public void init(GLAutoDrawable drawable)
1717817440 {
17441
+ if (Globals.DEBUG)
1717917442 System.out.println("shadow buffer init");
1718017443
1718117444 GL gl = drawable.getGL();
....@@ -17404,10 +17667,14 @@
1740417667 gl.glFlush();
1740517668
1740617669 /**/
17407
- 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);
1740817671
17409
- float[] pixels = occlusionsizebuffer.array();
17672
+ float[] depths = occlusiondepthbuffer.array();
1741017673
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
+
1741117678 double r = 0, g = 0, b = 0;
1741217679
1741317680 double count = 0;
....@@ -17418,7 +17685,7 @@
1741817685
1741917686 double FACTOR = 1;
1742017687
17421
- for (int i = 0; i < pixels.length; i++)
17688
+ for (int i = 0; i < depths.length; i++)
1742217689 {
1742317690 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1742417691 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17501,7 +17768,7 @@
1750117768
1750217769 double scale = ray.z; // 1; // cos
1750317770
17504
- float depth = pixels[newindex];
17771
+ float depth = depths[newindex];
1750517772
1750617773 /*
1750717774 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17698,11 +17965,14 @@
1769817965 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1769917966 static IntBuffer bigAAbuffer;
1770017967 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17701
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17968
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1770217969 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1770317970 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1770417971 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17705
- 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
+
1770617976 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1770717977 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1770817978 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();