Normand Briere
2019-08-16 64e20f390e4b8e58bd0006dde8fa10fba1dac1d5
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
....@@ -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
....@@ -2512,7 +2517,7 @@
25122517 com.sun.opengl.util.texture.TextureIO.newTextureData(
25132518 getClass().getClassLoader().getResourceAsStream(name),
25142519 true,
2515
- com.sun.opengl.util.texture.TextureIO.PNG);
2520
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
25162521 } catch (java.io.IOException e)
25172522 {
25182523 throw new javax.media.opengl.GLException(e);
....@@ -8358,7 +8363,7 @@
83588363 // else
83598364 // if (!texname.startsWith("/"))
83608365 // texname = "/Users/nbriere/Textures/" + texname;
8361
- if (!FileExists(texname))
8366
+ if (!FileExists(texname) && !texname.startsWith("@"))
83628367 {
83638368 texname = fallbackTextureName;
83648369 }
....@@ -8441,6 +8446,15 @@
84418446 new Exception().printStackTrace();
84428447 } else
84438448 {
8449
+ if (texname.startsWith("@"))
8450
+ {
8451
+ // texturecache = textures.get(texname); // suspicious
8452
+ if (texturecache == null)
8453
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8454
+ else
8455
+ new Exception().printStackTrace();
8456
+ } else
8457
+ {
84448458 if (textureon)
84458459 {
84468460 String cachename = texname;
....@@ -8500,6 +8514,7 @@
85008514 texturecache = new CacheTexture(texturedata,resolution);
85018515 //texture = GetTexture(tex, bump);
85028516 }
8517
+ }
85038518 }
85048519 //}
85058520 }
....@@ -8768,10 +8783,12 @@
87688783
87698784 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
87708785 MAXSTACK = temp[0];
8771
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8786
+ if (Globals.DEBUG)
8787
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
87728788 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
87738789 MAXSTACK = temp[0];
8774
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8790
+ if (Globals.DEBUG)
8791
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
87758792
87768793 // Use debug pipeline
87778794 //drawable.setGL(new DebugGL(gl)); //
....@@ -8779,7 +8796,8 @@
87798796 gl = drawable.getGL(); //
87808797
87818798 GL gl3 = getGL();
8782
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8799
+ if (Globals.DEBUG)
8800
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
87838801
87848802
87858803 //float pos[] = { 100, 100, 100, 0 };
....@@ -9220,6 +9238,8 @@
92209238
92219239 void LoadEnvy(int which)
92229240 {
9241
+ assert(false);
9242
+
92239243 String name;
92249244 String ext;
92259245
....@@ -9316,10 +9336,9 @@
93169336 double[] light2camera = new double[16];
93179337
93189338 //int newenvy = -1;
9319
- boolean envyoff = true; // false;
9320
- String skyboxname = "";
9321
- String skyboxext;
9322
- String loadedskyboxname = "";
9339
+ //boolean envyoff = false;
9340
+
9341
+ String loadedskyboxname;
93239342
93249343 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
93259344 //float[] light0 = { 0,0,0 };
....@@ -10842,7 +10861,7 @@
1084210861
1084310862 if (wait)
1084410863 {
10845
- Sleep(500);
10864
+ Sleep(200); // blocks everything
1084610865
1084710866 wait = false;
1084810867 }
....@@ -11065,10 +11084,34 @@
1106511084 //
1106611085 // newenvy = -1;
1106711086
11068
- if (!skyboxname.equals(this.loadedskyboxname))
11087
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1106911088 {
11070
- LoadSkybox(skyboxname + "/", skyboxext, false);
11071
- loadedskyboxname = skyboxname;
11089
+ if (cubemaprgb == null)
11090
+ {
11091
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
11092
+ }
11093
+
11094
+ cubemap = cubemaprgb;
11095
+ }
11096
+ else
11097
+ {
11098
+ if (object.skyboxname != null)
11099
+ {
11100
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11101
+ {
11102
+ if (cubemap != null && cubemap != cubemaprgb)
11103
+ cubemap.dispose();
11104
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11105
+ loadedskyboxname = object.skyboxname;
11106
+ }
11107
+ }
11108
+ else
11109
+ {
11110
+ cubemapcustom = null;
11111
+ loadedskyboxname = null;
11112
+ }
11113
+
11114
+ cubemap = cubemapcustom;
1107211115 }
1107311116
1107411117 ratio = ((double) getWidth()) / getHeight();
....@@ -11372,7 +11415,7 @@
1137211415
1137311416 // if (cam != lightCamera)
1137411417 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11375
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11418
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1137611419 }
1137711420
1137811421 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12446,7 +12489,7 @@
1244612489
1244712490 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1244812491
12449
- String program0 =
12492
+ String programmin =
1245012493 // Min shader
1245112494 "!!ARBfp1.0\n" +
1245212495 "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
....@@ -12513,7 +12556,7 @@
1251312556 "MOV result.color, temp;" +
1251412557 "END";
1251512558
12516
- String program =
12559
+ String programmax =
1251712560 "!!ARBfp1.0\n" +
1251812561
1251912562 //"OPTION ARB_fragment_program_shadow;" +
....@@ -13038,7 +13081,7 @@
1303813081 // display shadow only (fakedepth == 0)
1303913082 "SUB temp.x, half.x, shadow.x;" +
1304013083 "MOV temp.y, -params5.z;" + // params6.x;" +
13041
- "SLT temp.z, temp.y, -one2048th.x;" +
13084
+ "SLT temp.z, temp.y, -c256i.x;" +
1304213085 "SUB temp.y, one.x, temp.z;" +
1304313086 "MUL temp.x, temp.x, temp.y;" +
1304413087 "KIL temp.x;" +
....@@ -13369,8 +13412,19 @@
1336913412 //once = true;
1337013413 }
1337113414
13372
- System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13373
- System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13415
+ String program = programmax;
13416
+
13417
+ if (Globals.MINSHADER)
13418
+ {
13419
+ program = programmin;
13420
+ }
13421
+
13422
+ if (Globals.DEBUG)
13423
+ {
13424
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13425
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13426
+ }
13427
+
1337413428 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1337513429
1337613430 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13417,7 +13471,8 @@
1341713471 "\n" +
1341813472 "END\n";
1341913473
13420
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13474
+ if (Globals.DEBUG)
13475
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1342113476 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1342213477
1342313478 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -14616,11 +14671,17 @@
1461614671 void GoDown(int mod)
1461714672 {
1461814673 MODIFIERS |= COMMAND;
14674
+ boolean isVR = (mouseMode&VR)!=0;
1461914675 /**/
1462014676 if((mod&SHIFT) == SHIFT)
14621
- manipCamera.RotatePosition(0, -speed);
14677
+ {
14678
+ if (isVR)
14679
+ manipCamera.RotateInterest(0, -speed);
14680
+ else
14681
+ manipCamera.RotatePosition(0, -speed);
14682
+ }
1462214683 else
14623
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14684
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1462414685 /**/
1462514686 if ((mod & SHIFT) == SHIFT)
1462614687 {
....@@ -14630,6 +14691,8 @@
1463014691 mouseMode |= BACKFORTH;
1463114692 }
1463214693
14694
+ targetLookAt.set(manipCamera.lookAt);
14695
+
1463314696 //prevX = X = anchorX;
1463414697 prevY = Y = anchorY - (int) (renderCamera.Distance());
1463514698 }
....@@ -14638,10 +14701,17 @@
1463814701 {
1463914702 MODIFIERS |= COMMAND;
1464014703 /**/
14704
+ boolean isVR = (mouseMode&VR)!=0;
14705
+
1464114706 if((mod&SHIFT) == SHIFT)
14642
- manipCamera.RotatePosition(0, speed);
14707
+ {
14708
+ if (isVR)
14709
+ manipCamera.RotateInterest(0, speed);
14710
+ else
14711
+ manipCamera.RotatePosition(0, speed);
14712
+ }
1464314713 else
14644
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14714
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1464514715 /**/
1464614716 if ((mod & SHIFT) == SHIFT)
1464714717 {
....@@ -14651,6 +14721,8 @@
1465114721 mouseMode |= BACKFORTH;
1465214722 }
1465314723
14724
+ targetLookAt.set(manipCamera.lookAt);
14725
+
1465414726 //prevX = X = anchorX;
1465514727 prevY = Y = anchorY + (int) (renderCamera.Distance());
1465614728 }
....@@ -14660,9 +14732,14 @@
1466014732 MODIFIERS |= COMMAND;
1466114733 /**/
1466214734 if((mod&SHIFT) == SHIFT)
14663
- manipCamera.Translate(speed*delta, 0, getWidth());
14735
+ manipCamera.Translate(speed*delta, 0, getWidth());
1466414736 else
14665
- manipCamera.RotatePosition(speed, 0);
14737
+ {
14738
+ if ((mouseMode&VR)!=0)
14739
+ manipCamera.RotateInterest(-speed, 0);
14740
+ else
14741
+ manipCamera.RotatePosition(speed, 0);
14742
+ }
1466614743 /**/
1466714744 if ((mod & SHIFT) == SHIFT)
1466814745 {
....@@ -14672,6 +14749,8 @@
1467214749 mouseMode |= ROTATE;
1467314750 } // TRANSLATE;
1467414751
14752
+ targetLookAt.set(manipCamera.lookAt);
14753
+
1467514754 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1467614755 prevY = Y = anchorY;
1467714756 }
....@@ -14681,9 +14760,15 @@
1468114760 MODIFIERS |= COMMAND;
1468214761 /**/
1468314762 if((mod&SHIFT) == SHIFT)
14684
- manipCamera.Translate(-speed*delta, 0, getWidth());
14763
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1468514764 else
14686
- manipCamera.RotatePosition(-speed, 0);
14765
+ {
14766
+ if ((mouseMode&VR)!=0)
14767
+ manipCamera.RotateInterest(speed, 0);
14768
+ else
14769
+ manipCamera.RotatePosition(-speed, 0);
14770
+ }
14771
+
1468714772 /**/
1468814773 if ((mod & SHIFT) == SHIFT)
1468914774 {
....@@ -14693,6 +14778,8 @@
1469314778 mouseMode |= ROTATE;
1469414779 } // TRANSLATE;
1469514780
14781
+ targetLookAt.set(manipCamera.lookAt);
14782
+
1469614783 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1469714784 prevY = Y = anchorY;
1469814785 }
....@@ -15362,7 +15449,7 @@
1536215449 OCCLUSION_CULLING ^= true;
1536315450 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1536415451 break;
15365
- case '0': envyoff ^= true; repaint(); break;
15452
+ //case '0': envyoff ^= true; repaint(); break;
1536615453 case '1':
1536715454 case '2':
1536815455 case '3':
....@@ -15372,7 +15459,7 @@
1537215459 case '7':
1537315460 case '8':
1537415461 case '9':
15375
- if (envyoff)
15462
+ if (true) // envyoff)
1537615463 {
1537715464 BGcolor = (key - '1')/8.f;
1537815465 }
....@@ -16077,14 +16164,14 @@
1607716164 {
1607816165 switch (hitSomething)
1607916166 {
16080
- case Object3D.hitCenter: gr.setColor(Color.pink);
16167
+ case Object3D.hitCenter: gr.setColor(Color.white);
1608116168 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608216169 break;
1608316170 case Object3D.hitRotate: gr.setColor(Color.yellow);
1608416171 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608516172 break;
1608616173 case Object3D.hitScale: gr.setColor(Color.cyan);
16087
- gr.drawLine(X, Y, 0, 0);
16174
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608816175 break;
1608916176 }
1609016177
....@@ -16103,7 +16190,7 @@
1610316190 if (hasMarquee)
1610416191 {
1610516192 gr.setXORMode(Color.white);
16106
- gr.setColor(Color.red);
16193
+ gr.setColor(Color.white);
1610716194 if (!firstime)
1610816195 {
1610916196 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16570,6 +16657,8 @@
1657016657 private /*static*/ boolean firstime;
1657116658 private /*static*/ cVector newView = new cVector();
1657216659 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16660
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16661
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1657316662 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1657416663 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1657516664 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16582,22 +16671,56 @@
1658216671 {
1658316672 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1658416673
16674
+ int usedsuf = 0;
16675
+
1658516676 for (int i = 0; i < suffixes.length; i++)
1658616677 {
16587
- String resourceName = basename + suffixes[i] + "." + suffix;
16588
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16589
- mipmapped,
16590
- FileUtil.getFileSuffix(resourceName));
16591
- if (data == null)
16678
+ String[] suffixe = suffixes;
16679
+ String[] fallback = suffixes2;
16680
+ String[] fallfallback = suffixes3;
16681
+
16682
+ for (int c=usedsuf; --c>=0;)
1659216683 {
16593
- throw new IOException("Unable to load texture " + resourceName);
16684
+// String[] temp = suffixe;
16685
+// suffixe = fallback;
16686
+// fallback = fallfallback;
16687
+// fallfallback = temp;
1659416688 }
16689
+
16690
+ String resourceName = basename + suffixe[i] + "." + suffix;
16691
+ TextureData data;
16692
+
16693
+ try
16694
+ {
16695
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16696
+ mipmapped,
16697
+ FileUtil.getFileSuffix(resourceName));
16698
+ }
16699
+ catch (Exception e)
16700
+ {
16701
+ try
16702
+ {
16703
+ resourceName = basename + fallback[i] + "." + suffix;
16704
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16705
+ mipmapped,
16706
+ FileUtil.getFileSuffix(resourceName));
16707
+ }
16708
+ catch (Exception e2)
16709
+ {
16710
+ resourceName = basename + fallfallback[i] + "." + suffix;
16711
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16712
+ mipmapped,
16713
+ FileUtil.getFileSuffix(resourceName));
16714
+ }
16715
+ }
16716
+
1659516717 //System.out.println("Target = " + targets[i]);
1659616718 cubemap.updateImage(data, targets[i]);
1659716719 }
1659816720
1659916721 return cubemap;
1660016722 }
16723
+
1660116724 int bigsphere = -1;
1660216725
1660316726 float BGcolor = 0.5f;
....@@ -16606,7 +16729,9 @@
1660616729
1660716730 private void DrawSkyBox(GL gl, float ratio)
1660816731 {
16609
- if (envyoff || cubemap == null)
16732
+ if (//envyoff ||
16733
+ WIREFRAME ||
16734
+ cubemap == null)
1661016735 {
1661116736 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1661216737 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16623,14 +16748,14 @@
1662316748 gl.glLoadIdentity();
1662416749 gl.glScalef(1,ratio,1);
1662516750
16626
- colorV[0] = 2;
16627
- colorV[1] = 2;
16628
- colorV[2] = 2;
16629
- colorV[3] = 1;
16630
- gl.glDisable(gl.GL_COLOR_MATERIAL);
16631
- gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16632
-
16633
- gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16751
+// colorV[0] = 2;
16752
+// colorV[1] = 2;
16753
+// colorV[2] = 2;
16754
+// colorV[3] = 1;
16755
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16756
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16757
+//
16758
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
1663416759
1663516760 //gl.glActiveTexture(GL.GL_TEXTURE1);
1663616761 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
....@@ -16644,7 +16769,7 @@
1664416769 // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting
1664516770 // causes the normals to be sent down. Thanks to Ken Dyke.
1664616771 //gl.glEnable(GL.GL_LIGHTING);
16647
- gl.glEnable(GL.GL_LIGHTING);
16772
+ gl.glDisable(GL.GL_LIGHTING);
1664816773
1664916774 gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
1665016775 gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
....@@ -16663,6 +16788,7 @@
1666316788 {
1666416789 gl.glScalef(1.0f, -1.0f, 1.0f);
1666516790 }
16791
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1666616792 gl.glMultMatrixd(viewrot_1, 0);
1666716793 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1666816794 //viewer.updateInverseRotation(gl);
....@@ -16703,7 +16829,8 @@
1670316829 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1670416830
1670516831 cubemap.disable();
16706
- ////cubemap.unbind();
16832
+ //cubemap.dispose();
16833
+
1670716834 if (CULLFACE)
1670816835 {
1670916836 gl.glEnable(gl.GL_CULL_FACE);
....@@ -17239,6 +17366,7 @@
1723917366
1724017367 public void init(GLAutoDrawable drawable)
1724117368 {
17369
+ if (Globals.DEBUG)
1724217370 System.out.println("shadow buffer init");
1724317371
1724417372 GL gl = drawable.getGL();
....@@ -17467,10 +17595,14 @@
1746717595 gl.glFlush();
1746817596
1746917597 /**/
17470
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17598
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1747117599
17472
- float[] pixels = occlusionsizebuffer.array();
17600
+ float[] depths = occlusiondepthbuffer.array();
1747317601
17602
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17603
+
17604
+ int[] pixels = selectsizebuffer.array();
17605
+
1747417606 double r = 0, g = 0, b = 0;
1747517607
1747617608 double count = 0;
....@@ -17481,7 +17613,7 @@
1748117613
1748217614 double FACTOR = 1;
1748317615
17484
- for (int i = 0; i < pixels.length; i++)
17616
+ for (int i = 0; i < depths.length; i++)
1748517617 {
1748617618 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1748717619 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17564,7 +17696,7 @@
1756417696
1756517697 double scale = ray.z; // 1; // cos
1756617698
17567
- float depth = pixels[newindex];
17699
+ float depth = depths[newindex];
1756817700
1756917701 /*
1757017702 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17761,11 +17893,14 @@
1776117893 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1776217894 static IntBuffer bigAAbuffer;
1776317895 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17764
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17896
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1776517897 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1776617898 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1776717899 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17768
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17900
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17901
+
17902
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17903
+
1776917904 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1777017905 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1777117906 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();