Normand Briere
2019-08-13 0cdf3fb57ddea3226f094ba45c836c7e9b123e3a
CameraPane.java
....@@ -173,7 +173,7 @@
173173 static boolean doublesided = false; // true; // reversed normals are awful for conformance
174174 boolean anisotropy = true;
175175 boolean softshadow = true; // slower but better false;
176
- boolean opacityhalo = false;
176
+ boolean opacityhalo = false; // reverse the halo effect (e.g. glass)
177177
178178 boolean macromode = false;
179179
....@@ -187,6 +187,18 @@
187187 }
188188
189189 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
190
+
191
+ public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException
192
+ {
193
+ try
194
+ {
195
+ cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
196
+ } catch (IOException e)
197
+ {
198
+ System.out.println("NAME = " + name);
199
+ e.printStackTrace(); // throw new RuntimeException(e);
200
+ }
201
+ }
190202
191203 void SetAsGLRenderer(boolean b)
192204 {
....@@ -206,7 +218,8 @@
206218
207219 SetCamera(cam);
208220
209
- SetLight(new Camera(new cVector(10, 10, -20)));
221
+ // Warning: not used.
222
+ SetLight(new Camera(new cVector(15, 10, -20)));
210223
211224 object = o;
212225
....@@ -1484,6 +1497,8 @@
14841497 gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
14851498 }
14861499
1500
+ float[] colorV = new float[4];
1501
+
14871502 void SetColor(Object3D obj, Vertex p0)
14881503 {
14891504 CameraPane display = this;
....@@ -1551,8 +1566,6 @@
15511566 {
15521567 return;
15531568 }
1554
-
1555
- float[] colorV = new float[3];
15561569
15571570 if (false) // marked)
15581571 {
....@@ -8345,7 +8358,7 @@
83458358 // else
83468359 // if (!texname.startsWith("/"))
83478360 // texname = "/Users/nbriere/Textures/" + texname;
8348
- if (!FileExists(texname))
8361
+ if (!FileExists(texname) && !texname.startsWith("@"))
83498362 {
83508363 texname = fallbackTextureName;
83518364 }
....@@ -8428,6 +8441,15 @@
84288441 new Exception().printStackTrace();
84298442 } else
84308443 {
8444
+ if (texname.startsWith("@"))
8445
+ {
8446
+ // texturecache = textures.get(texname); // suspicious
8447
+ if (texturecache == null)
8448
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8449
+ else
8450
+ new Exception().printStackTrace();
8451
+ } else
8452
+ {
84318453 if (textureon)
84328454 {
84338455 String cachename = texname;
....@@ -8487,6 +8509,7 @@
84878509 texturecache = new CacheTexture(texturedata,resolution);
84888510 //texture = GetTexture(tex, bump);
84898511 }
8512
+ }
84908513 }
84918514 //}
84928515 }
....@@ -8755,10 +8778,12 @@
87558778
87568779 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
87578780 MAXSTACK = temp[0];
8758
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8781
+ if (Globals.DEBUG)
8782
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
87598783 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
87608784 MAXSTACK = temp[0];
8761
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8785
+ if (Globals.DEBUG)
8786
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
87628787
87638788 // Use debug pipeline
87648789 //drawable.setGL(new DebugGL(gl)); //
....@@ -8766,7 +8791,8 @@
87668791 gl = drawable.getGL(); //
87678792
87688793 GL gl3 = getGL();
8769
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8794
+ if (Globals.DEBUG)
8795
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
87708796
87718797
87728798 //float pos[] = { 100, 100, 100, 0 };
....@@ -8931,7 +8957,7 @@
89318957
89328958 if (cubemap == null)
89338959 {
8934
- LoadEnvy(5);
8960
+ //LoadEnvy(1);
89358961 }
89368962
89378963 //cubemap.enable();
....@@ -9218,37 +9244,58 @@
92189244 cubemap = null;
92199245 return;
92209246 case 1:
9221
- name = "cubemaps/box_";
9222
- ext = "png";
9247
+ name = "cubemaps/rgb/";
9248
+ ext = "jpg";
92239249 reverseUP = false;
92249250 break;
92259251 case 2:
9226
- name = "cubemaps/uffizi_";
9227
- ext = "png";
9228
- break; // reverseUP = true; break;
9252
+ name = "cubemaps/uffizi/";
9253
+ ext = "jpg";
9254
+ reverseUP = false;
9255
+ break;
92299256 case 3:
9230
- name = "cubemaps/CloudyHills_";
9231
- ext = "tga";
9257
+ name = "cubemaps/CloudyHills/";
9258
+ ext = "jpg";
92329259 reverseUP = false;
92339260 break;
92349261 case 4:
9235
- name = "cubemaps/cornell_";
9262
+ name = "cubemaps/cornell/";
92369263 ext = "png";
92379264 reverseUP = false;
92389265 break;
9266
+ case 5:
9267
+ name = "cubemaps/skycube/";
9268
+ ext = "jpg";
9269
+ reverseUP = false;
9270
+ break;
9271
+ case 6:
9272
+ name = "cubemaps/SaintLazarusChurch3/";
9273
+ ext = "jpg";
9274
+ reverseUP = false;
9275
+ break;
9276
+ case 7:
9277
+ name = "cubemaps/Sodermalmsallen/";
9278
+ ext = "jpg";
9279
+ reverseUP = false;
9280
+ break;
9281
+ case 8:
9282
+ name = "cubemaps/Sodermalmsallen2/";
9283
+ ext = "jpg";
9284
+ reverseUP = false;
9285
+ break;
9286
+ case 9:
9287
+ name = "cubemaps/UnionSquare/";
9288
+ ext = "jpg";
9289
+ reverseUP = false;
9290
+ break;
92399291 default:
9240
- name = "cubemaps/rgb_";
9241
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9292
+ name = "cubemaps/box/";
9293
+ ext = "png"; /*mipmap = true;*/
9294
+ reverseUP = false;
92429295 break;
92439296 }
9244
-
9245
- try
9246
- {
9247
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
9248
- } catch (IOException e)
9249
- {
9250
- throw new RuntimeException(e);
9251
- }
9297
+
9298
+ LoadSkybox(name, ext, mipmap);
92529299 }
92539300
92549301 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -9280,8 +9327,12 @@
92809327 static double[] model = new double[16];
92819328 double[] camera2light = new double[16];
92829329 double[] light2camera = new double[16];
9283
- int newenvy = -1;
9284
- boolean envyoff = true; // false;
9330
+
9331
+ //int newenvy = -1;
9332
+ //boolean envyoff = false;
9333
+
9334
+ String loadedskyboxname;
9335
+
92859336 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
92869337 //float[] light0 = { 0,0,0 };
92879338 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9761,10 +9812,12 @@
97619812 rati = 1 / rati;
97629813 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
97639814 }
9764
- assert (newenvy == -1);
9815
+
9816
+ //assert (newenvy == -1);
9817
+
97659818 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
97669819 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9767
- DrawSkyBox(gl);
9820
+ DrawSkyBox(gl, (float)rati);
97689821 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
97699822 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
97709823 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -10801,7 +10854,7 @@
1080110854
1080210855 if (wait)
1080310856 {
10804
- Sleep(500);
10857
+ Sleep(200); // blocks everything
1080510858
1080610859 wait = false;
1080710860 }
....@@ -11017,13 +11070,27 @@
1101711070 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1101811071 }
1101911072
11020
- if (newenvy > -1)
11073
+// if (newenvy > -1)
11074
+// {
11075
+// LoadEnvy(newenvy);
11076
+// }
11077
+//
11078
+// newenvy = -1;
11079
+
11080
+ if (object.skyboxname != null)
1102111081 {
11022
- LoadEnvy(newenvy);
11082
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11083
+ {
11084
+ LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11085
+ loadedskyboxname = object.skyboxname;
11086
+ }
1102311087 }
11024
-
11025
- newenvy = -1;
11026
-
11088
+ else
11089
+ {
11090
+ cubemap = null;
11091
+ loadedskyboxname = null;
11092
+ }
11093
+
1102711094 ratio = ((double) getWidth()) / getHeight();
1102811095 //System.out.println("ratio = " + ratio);
1102911096
....@@ -11039,7 +11106,7 @@
1103911106
1104011107 if (!IsFrozen() && !ambientOcclusion)
1104111108 {
11042
- DrawSkyBox(gl);
11109
+ DrawSkyBox(gl, (float)ratio);
1104311110 }
1104411111
1104511112 //if (selection_view == -1)
....@@ -11325,7 +11392,7 @@
1132511392
1132611393 // if (cam != lightCamera)
1132711394 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11328
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11395
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1132911396 }
1133011397
1133111398 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12399,51 +12466,74 @@
1239912466
1240012467 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240112468
12402
- String program =
12469
+ String programmin =
1240312470 // Min shader
1240412471 "!!ARBfp1.0\n" +
12405
- "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" +
12472
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
1240612473 "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
1240712474 "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1240812475 "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
1240912476 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12477
+ "PARAM light2cam0 = program.env[10];" +
12478
+ "PARAM light2cam1 = program.env[11];" +
12479
+ "PARAM light2cam2 = program.env[12];" +
1241012480 "TEMP temp;" +
1241112481 "TEMP light;" +
1241212482 "TEMP ndotl;" +
1241312483 "TEMP normal;" +
1241412484 "TEMP depth;" +
12485
+ "TEMP eye;" +
12486
+ "TEMP pos;" +
1241512487
1241612488 "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12417
-
12489
+ Normalize("normal") +
1241812490 "MOV light, state.light[0].position;" +
1241912491 "DP3 ndotl.x, light, normal;" +
1242012492
1242112493 // shadow
12422
- "MOV temp, fragment.texcoord[1];" +
12423
- TextureFetch("depth", "temp", "1") +
12494
+ "MOV pos, fragment.texcoord[1];" +
12495
+ "MOV temp, pos;" +
12496
+ ShadowTextureFetch("depth", "temp", "1") +
1242412497 //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12425
- "SLT temp.x, fragment.texcoord[1].z, depth.z;" +
12426
-
12498
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
1242712499
1242812500 // No shadow when out of frustum
1242912501 //"SGE temp.y, depth.z, zero123.y;" +
1243012502 //"LRP temp.x, temp.y, zero123.y, temp.x;" +
1243112503
12432
- "MUL ndotl.x, ndotl.x, temp.x;" +
12433
- "MAX ndotl.x, ndotl.x, pow2.y;" +
12504
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
1243412505
12506
+ // Backlit
12507
+ "MOV pos.w, zero123.y;" +
12508
+ "DP4 eye.x, pos, light2cam0;" +
12509
+ "DP4 eye.y, pos, light2cam1;" +
12510
+ "DP4 eye.z, pos, light2cam2;" +
12511
+ Normalize("eye") +
12512
+
12513
+ "DP3 ndotl.y, -eye, normal;" +
12514
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12515
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12516
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12517
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12518
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12519
+
12520
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12521
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12522
+
12523
+ // Pigment
1243512524 "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
1243612525 "LRP temp, zero123.w, temp, one;" + // texture proportion
1243712526 "MUL temp, temp, ndotl.x;" +
1243812527
1243912528 "MUL temp, temp, zero123.z;" +
1244012529
12441
- "MOV temp.w, zero123.y;" + // reset alpha
12530
+ //"MUL temp, temp, ndotl.y;" +
1244212531
12532
+ "MOV temp.w, zero123.y;" + // reset alpha
1244312533 "MOV result.color, temp;" +
1244412534 "END";
1244512535
12446
- String program2 =
12536
+ String programmax =
1244712537 "!!ARBfp1.0\n" +
1244812538
1244912539 //"OPTION ARB_fragment_program_shadow;" +
....@@ -12581,20 +12671,20 @@
1258112671 "MUL temp, floor, mapgrid.x;" +
1258212672 //"TEX depth0, temp, texture[1], 2D;" +
1258312673 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12584
- TextureFetch("depth0", "temp", "1") +
12674
+ ShadowTextureFetch("depth0", "temp", "1") +
1258512675 "") +
1258612676 "ADD temp.x, temp.x, mapgrid.x;" +
1258712677 //"TEX depth1, temp, texture[1], 2D;" +
1258812678 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12589
- TextureFetch("depth1", "temp", "1") +
12679
+ ShadowTextureFetch("depth1", "temp", "1") +
1259012680 "") +
1259112681 "ADD temp.y, temp.y, mapgrid.x;" +
1259212682 //"TEX depth2, temp, texture[1], 2D;" +
12593
- TextureFetch("depth2", "temp", "1") +
12683
+ ShadowTextureFetch("depth2", "temp", "1") +
1259412684 "SUB temp.x, temp.x, mapgrid.x;" +
1259512685 //"TEX depth3, temp, texture[1], 2D;" +
1259612686 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12597
- TextureFetch("depth3", "temp", "1") +
12687
+ ShadowTextureFetch("depth3", "temp", "1") +
1259812688 "") +
1259912689 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1260012690 //"MOV params, material;" +
....@@ -12968,7 +13058,7 @@
1296813058 // display shadow only (fakedepth == 0)
1296913059 "SUB temp.x, half.x, shadow.x;" +
1297013060 "MOV temp.y, -params5.z;" + // params6.x;" +
12971
- "SLT temp.z, temp.y, -one2048th.x;" +
13061
+ "SLT temp.z, temp.y, -c256i.x;" +
1297213062 "SUB temp.y, one.x, temp.z;" +
1297313063 "MUL temp.x, temp.x, temp.y;" +
1297413064 "KIL temp.x;" +
....@@ -13299,6 +13389,13 @@
1329913389 //once = true;
1330013390 }
1330113391
13392
+ String program = programmax;
13393
+
13394
+ if (Globals.MINSHADER)
13395
+ {
13396
+ program = programmin;
13397
+ }
13398
+
1330213399 System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1330313400 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1330413401 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
....@@ -13392,7 +13489,8 @@
1339213489 return out;
1339313490 }
1339413491
13395
- String TextureFetch(String dest, String src, String unit)
13492
+ // Also does frustum culling
13493
+ String ShadowTextureFetch(String dest, String src, String unit)
1339613494 {
1339713495 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1339813496 "SGE " + src + ".w, " + src + ".x, eps.x;" +
....@@ -14547,9 +14645,9 @@
1454714645 MODIFIERS |= COMMAND;
1454814646 /**/
1454914647 if((mod&SHIFT) == SHIFT)
14550
- manipCamera.RotatePosition(0, -speed);
14551
- else
1455214648 manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14649
+ else
14650
+ manipCamera.RotatePosition(0, -speed);
1455314651 /**/
1455414652 if ((mod & SHIFT) == SHIFT)
1455514653 {
....@@ -14568,9 +14666,9 @@
1456814666 MODIFIERS |= COMMAND;
1456914667 /**/
1457014668 if((mod&SHIFT) == SHIFT)
14571
- manipCamera.RotatePosition(0, speed);
14572
- else
1457314669 manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14670
+ else
14671
+ manipCamera.RotatePosition(0, speed);
1457414672 /**/
1457514673 if ((mod & SHIFT) == SHIFT)
1457614674 {
....@@ -15291,20 +15389,24 @@
1529115389 OCCLUSION_CULLING ^= true;
1529215390 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1529315391 break;
15294
- case '0': envyoff ^= true; repaint(); break;
15392
+ //case '0': envyoff ^= true; repaint(); break;
1529515393 case '1':
1529615394 case '2':
1529715395 case '3':
1529815396 case '4':
1529915397 case '5':
15300
- newenvy = Character.getNumericValue(key);
15301
- repaint();
15302
- break;
1530315398 case '6':
1530415399 case '7':
1530515400 case '8':
1530615401 case '9':
15307
- BGcolor = (key - '6')/3.f;
15402
+ if (true) // envyoff)
15403
+ {
15404
+ BGcolor = (key - '1')/8.f;
15405
+ }
15406
+ else
15407
+ {
15408
+ //newenvy = Character.getNumericValue(key);
15409
+ }
1530815410 repaint();
1530915411 break;
1531015412 case '!':
....@@ -16009,7 +16111,7 @@
1600916111 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1601016112 break;
1601116113 case Object3D.hitScale: gr.setColor(Color.cyan);
16012
- gr.drawLine(X, Y, 0, 0);
16114
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1601316115 break;
1601416116 }
1601516117
....@@ -16495,6 +16597,8 @@
1649516597 private /*static*/ boolean firstime;
1649616598 private /*static*/ cVector newView = new cVector();
1649716599 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16600
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16601
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1649816602 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1649916603 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1650016604 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16507,29 +16611,67 @@
1650716611 {
1650816612 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1650916613
16614
+ int usedsuf = 0;
16615
+
1651016616 for (int i = 0; i < suffixes.length; i++)
1651116617 {
16512
- String resourceName = basename + suffixes[i] + "." + suffix;
16513
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16514
- mipmapped,
16515
- FileUtil.getFileSuffix(resourceName));
16516
- if (data == null)
16618
+ String[] suffixe = suffixes;
16619
+ String[] fallback = suffixes2;
16620
+ String[] fallfallback = suffixes3;
16621
+
16622
+ for (int c=usedsuf; --c>=0;)
1651716623 {
16518
- throw new IOException("Unable to load texture " + resourceName);
16624
+// String[] temp = suffixe;
16625
+// suffixe = fallback;
16626
+// fallback = fallfallback;
16627
+// fallfallback = temp;
1651916628 }
16629
+
16630
+ String resourceName = basename + suffixe[i] + "." + suffix;
16631
+ TextureData data;
16632
+
16633
+ try
16634
+ {
16635
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16636
+ mipmapped,
16637
+ FileUtil.getFileSuffix(resourceName));
16638
+ }
16639
+ catch (Exception e)
16640
+ {
16641
+ try
16642
+ {
16643
+ resourceName = basename + fallback[i] + "." + suffix;
16644
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16645
+ mipmapped,
16646
+ FileUtil.getFileSuffix(resourceName));
16647
+ }
16648
+ catch (Exception e2)
16649
+ {
16650
+ resourceName = basename + fallfallback[i] + "." + suffix;
16651
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16652
+ mipmapped,
16653
+ FileUtil.getFileSuffix(resourceName));
16654
+ }
16655
+ }
16656
+
1652016657 //System.out.println("Target = " + targets[i]);
1652116658 cubemap.updateImage(data, targets[i]);
1652216659 }
1652316660
1652416661 return cubemap;
1652516662 }
16663
+
1652616664 int bigsphere = -1;
1652716665
1652816666 float BGcolor = 0.5f;
1652916667
16530
- private void DrawSkyBox(GL gl)
16668
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16669
+
16670
+ private void DrawSkyBox(GL gl, float ratio)
1653116671 {
16532
- if (envyoff || cubemap == null)
16672
+ if (//envyoff ||
16673
+ WIREFRAME ||
16674
+ cubemap == null)
1653316675 {
1653416676 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1653516677 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16544,7 +16686,17 @@
1654416686 // Compensates for ExaminerViewer's modification of modelview matrix
1654516687 gl.glMatrixMode(GL.GL_MODELVIEW);
1654616688 gl.glLoadIdentity();
16689
+ gl.glScalef(1,ratio,1);
1654716690
16691
+// colorV[0] = 2;
16692
+// colorV[1] = 2;
16693
+// colorV[2] = 2;
16694
+// colorV[3] = 1;
16695
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16696
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16697
+//
16698
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16699
+
1654816700 //gl.glActiveTexture(GL.GL_TEXTURE1);
1654916701 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1655016702
....@@ -16576,6 +16728,7 @@
1657616728 {
1657716729 gl.glScalef(1.0f, -1.0f, 1.0f);
1657816730 }
16731
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1657916732 gl.glMultMatrixd(viewrot_1, 0);
1658016733 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1658116734 //viewer.updateInverseRotation(gl);
....@@ -16834,7 +16987,7 @@
1683416987 //new Exception().printStackTrace();
1683516988 System.out.println("select buffer init");
1683616989 // Use debug pipeline
16837
- drawable.setGL(new DebugGL(drawable.getGL()));
16990
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1683816991
1683916992 GL gl = drawable.getGL();
1684016993
....@@ -17380,10 +17533,14 @@
1738017533 gl.glFlush();
1738117534
1738217535 /**/
17383
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17536
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1738417537
17385
- float[] pixels = occlusionsizebuffer.array();
17538
+ float[] depths = occlusiondepthbuffer.array();
1738617539
17540
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17541
+
17542
+ int[] pixels = selectsizebuffer.array();
17543
+
1738717544 double r = 0, g = 0, b = 0;
1738817545
1738917546 double count = 0;
....@@ -17394,7 +17551,7 @@
1739417551
1739517552 double FACTOR = 1;
1739617553
17397
- for (int i = 0; i < pixels.length; i++)
17554
+ for (int i = 0; i < depths.length; i++)
1739817555 {
1739917556 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1740017557 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17477,7 +17634,7 @@
1747717634
1747817635 double scale = ray.z; // 1; // cos
1747917636
17480
- float depth = pixels[newindex];
17637
+ float depth = depths[newindex];
1748117638
1748217639 /*
1748317640 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17674,11 +17831,14 @@
1767417831 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1767517832 static IntBuffer bigAAbuffer;
1767617833 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17677
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17834
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1767817835 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1767917836 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1768017837 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17681
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17838
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17839
+
17840
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17841
+
1768217842 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1768317843 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1768417844 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();