Normand Briere
2019-08-17 5892f05411c3d4dce2d8a59e0966dc2e1843a971
CameraPane.java
....@@ -110,7 +110,11 @@
110110 //private Mat4f spotlightTransform = new Mat4f();
111111 //private Mat4f spotlightInverseTransform = new Mat4f();
112112 static GLContext glcontext = null;
113
- /*static*/ com.sun.opengl.util.texture.Texture cubemap;
113
+ /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb
114
+ /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom;
115
+ /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb;
116
+ boolean transformMode;
117
+
114118 boolean reverseUP = false;
115119 static boolean frozen = false;
116120 boolean enablebackspace = false; // patch for back buffer refresh
....@@ -164,7 +168,7 @@
164168
165169
166170 // OPTIONS
167
- boolean Skinshader = true;
171
+ boolean Skinshader = false; // true;
168172 boolean cameraLight = false;
169173 boolean UVdebug = false;
170174 boolean Udebug = false;
....@@ -173,7 +177,7 @@
173177 static boolean doublesided = false; // true; // reversed normals are awful for conformance
174178 boolean anisotropy = true;
175179 boolean softshadow = true; // slower but better false;
176
- boolean opacityhalo = false;
180
+ boolean opacityhalo = false; // reverse the halo effect (e.g. glass)
177181
178182 boolean macromode = false;
179183
....@@ -188,15 +192,16 @@
188192
189193 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
190194
191
- public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException
195
+ public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
192196 {
193197 try
194198 {
195
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
199
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
196200 } catch (IOException e)
197201 {
198202 System.out.println("NAME = " + name);
199203 e.printStackTrace(); // throw new RuntimeException(e);
204
+ return null;
200205 }
201206 }
202207
....@@ -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 };
....@@ -10671,9 +10690,18 @@
1067110690 static boolean init = false;
1067210691
1067310692 double[][] matrix = LA.newMatrix();
10693
+
10694
+ // This is to refresh the UI of the material panel.
10695
+ ObjEditor patchMaterial;
1067410696
1067510697 public void display(GLAutoDrawable drawable)
1067610698 {
10699
+ if (patchMaterial.patchMaterial)
10700
+ {
10701
+ patchMaterial.patchMaterial = false;
10702
+ patchMaterial.objectPanel.setSelectedIndex(0);
10703
+ }
10704
+
1067710705 if (Grafreed.savesound && Grafreed.hassound)
1067810706 {
1067910707 Grafreed.wav.save();
....@@ -10842,7 +10870,7 @@
1084210870
1084310871 if (wait)
1084410872 {
10845
- Sleep(500);
10873
+ Sleep(200); // blocks everything
1084610874
1084710875 wait = false;
1084810876 }
....@@ -11065,10 +11093,34 @@
1106511093 //
1106611094 // newenvy = -1;
1106711095
11068
- if (!skyboxname.equals(this.loadedskyboxname))
11096
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1106911097 {
11070
- LoadSkybox(skyboxname + "/", skyboxext, false);
11071
- loadedskyboxname = skyboxname;
11098
+ if (cubemaprgb == null)
11099
+ {
11100
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
11101
+ }
11102
+
11103
+ cubemap = cubemaprgb;
11104
+ }
11105
+ else
11106
+ {
11107
+ if (object.skyboxname != null)
11108
+ {
11109
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11110
+ {
11111
+ if (cubemap != null && cubemap != cubemaprgb)
11112
+ cubemap.dispose();
11113
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11114
+ loadedskyboxname = object.skyboxname;
11115
+ }
11116
+ }
11117
+ else
11118
+ {
11119
+ cubemapcustom = null;
11120
+ loadedskyboxname = null;
11121
+ }
11122
+
11123
+ cubemap = cubemapcustom;
1107211124 }
1107311125
1107411126 ratio = ((double) getWidth()) / getHeight();
....@@ -11372,7 +11424,7 @@
1137211424
1137311425 // if (cam != lightCamera)
1137411426 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11375
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11427
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1137611428 }
1137711429
1137811430 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12446,7 +12498,7 @@
1244612498
1244712499 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1244812500
12449
- String program0 =
12501
+ String programmin =
1245012502 // Min shader
1245112503 "!!ARBfp1.0\n" +
1245212504 "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
....@@ -12513,7 +12565,7 @@
1251312565 "MOV result.color, temp;" +
1251412566 "END";
1251512567
12516
- String program =
12568
+ String programmax =
1251712569 "!!ARBfp1.0\n" +
1251812570
1251912571 //"OPTION ARB_fragment_program_shadow;" +
....@@ -13369,8 +13421,19 @@
1336913421 //once = true;
1337013422 }
1337113423
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 " : ""));
13424
+ String program = programmax;
13425
+
13426
+ if (Globals.MINSHADER)
13427
+ {
13428
+ program = programmin;
13429
+ }
13430
+
13431
+ if (Globals.DEBUG)
13432
+ {
13433
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13434
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13435
+ }
13436
+
1337413437 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1337513438
1337613439 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13417,7 +13480,8 @@
1341713480 "\n" +
1341813481 "END\n";
1341913482
13420
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13483
+ if (Globals.DEBUG)
13484
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1342113485 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1342213486
1342313487 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -14616,11 +14680,17 @@
1461614680 void GoDown(int mod)
1461714681 {
1461814682 MODIFIERS |= COMMAND;
14683
+ boolean isVR = (mouseMode&VR)!=0;
1461914684 /**/
1462014685 if((mod&SHIFT) == SHIFT)
14621
- manipCamera.RotatePosition(0, -speed);
14686
+ {
14687
+ if (isVR)
14688
+ manipCamera.RotateInterest(0, -speed);
14689
+ else
14690
+ manipCamera.RotatePosition(0, -speed);
14691
+ }
1462214692 else
14623
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14693
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1462414694 /**/
1462514695 if ((mod & SHIFT) == SHIFT)
1462614696 {
....@@ -14630,6 +14700,8 @@
1463014700 mouseMode |= BACKFORTH;
1463114701 }
1463214702
14703
+ targetLookAt.set(manipCamera.lookAt);
14704
+
1463314705 //prevX = X = anchorX;
1463414706 prevY = Y = anchorY - (int) (renderCamera.Distance());
1463514707 }
....@@ -14638,10 +14710,17 @@
1463814710 {
1463914711 MODIFIERS |= COMMAND;
1464014712 /**/
14713
+ boolean isVR = (mouseMode&VR)!=0;
14714
+
1464114715 if((mod&SHIFT) == SHIFT)
14642
- manipCamera.RotatePosition(0, speed);
14716
+ {
14717
+ if (isVR)
14718
+ manipCamera.RotateInterest(0, speed);
14719
+ else
14720
+ manipCamera.RotatePosition(0, speed);
14721
+ }
1464314722 else
14644
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14723
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1464514724 /**/
1464614725 if ((mod & SHIFT) == SHIFT)
1464714726 {
....@@ -14651,6 +14730,8 @@
1465114730 mouseMode |= BACKFORTH;
1465214731 }
1465314732
14733
+ targetLookAt.set(manipCamera.lookAt);
14734
+
1465414735 //prevX = X = anchorX;
1465514736 prevY = Y = anchorY + (int) (renderCamera.Distance());
1465614737 }
....@@ -14660,9 +14741,14 @@
1466014741 MODIFIERS |= COMMAND;
1466114742 /**/
1466214743 if((mod&SHIFT) == SHIFT)
14663
- manipCamera.Translate(speed*delta, 0, getWidth());
14744
+ manipCamera.Translate(speed*delta, 0, getWidth());
1466414745 else
14665
- manipCamera.RotatePosition(speed, 0);
14746
+ {
14747
+ if ((mouseMode&VR)!=0)
14748
+ manipCamera.RotateInterest(-speed, 0);
14749
+ else
14750
+ manipCamera.RotatePosition(speed, 0);
14751
+ }
1466614752 /**/
1466714753 if ((mod & SHIFT) == SHIFT)
1466814754 {
....@@ -14672,6 +14758,8 @@
1467214758 mouseMode |= ROTATE;
1467314759 } // TRANSLATE;
1467414760
14761
+ targetLookAt.set(manipCamera.lookAt);
14762
+
1467514763 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1467614764 prevY = Y = anchorY;
1467714765 }
....@@ -14681,9 +14769,15 @@
1468114769 MODIFIERS |= COMMAND;
1468214770 /**/
1468314771 if((mod&SHIFT) == SHIFT)
14684
- manipCamera.Translate(-speed*delta, 0, getWidth());
14772
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1468514773 else
14686
- manipCamera.RotatePosition(-speed, 0);
14774
+ {
14775
+ if ((mouseMode&VR)!=0)
14776
+ manipCamera.RotateInterest(speed, 0);
14777
+ else
14778
+ manipCamera.RotatePosition(-speed, 0);
14779
+ }
14780
+
1468714781 /**/
1468814782 if ((mod & SHIFT) == SHIFT)
1468914783 {
....@@ -14693,6 +14787,8 @@
1469314787 mouseMode |= ROTATE;
1469414788 } // TRANSLATE;
1469514789
14790
+ targetLookAt.set(manipCamera.lookAt);
14791
+
1469614792 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1469714793 prevY = Y = anchorY;
1469814794 }
....@@ -15195,8 +15291,8 @@
1519515291 case 'K':
1519615292 KOMPACTTEXTURE ^= true;
1519715293 //textures.clear();
15198
- break;
15199
- case 'P': // Texture Projection macros
15294
+ // break;
15295
+ //case 'P': // Texture Projection macros
1520015296 // SAVETEXTURE ^= true;
1520115297 macromode = true;
1520215298 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -15317,7 +15413,7 @@
1531715413 targetLookAt.set(manipCamera.lookAt);
1531815414 repaint();
1531915415 break;
15320
- case 'p':
15416
+ case 'P': // p':
1532115417 // c'est quoi ca au juste? spherical ^= true;
1532215418 Skinshader ^= true; programInitialized = false;
1532315419 repaint();
....@@ -15362,7 +15458,7 @@
1536215458 OCCLUSION_CULLING ^= true;
1536315459 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1536415460 break;
15365
- case '0': envyoff ^= true; repaint(); break;
15461
+ //case '0': envyoff ^= true; repaint(); break;
1536615462 case '1':
1536715463 case '2':
1536815464 case '3':
....@@ -15372,7 +15468,7 @@
1537215468 case '7':
1537315469 case '8':
1537415470 case '9':
15375
- if (envyoff)
15471
+ if (true) // envyoff)
1537615472 {
1537715473 BGcolor = (key - '1')/8.f;
1537815474 }
....@@ -16077,14 +16173,14 @@
1607716173 {
1607816174 switch (hitSomething)
1607916175 {
16080
- case Object3D.hitCenter: gr.setColor(Color.pink);
16176
+ case Object3D.hitCenter: gr.setColor(Color.white);
1608116177 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608216178 break;
1608316179 case Object3D.hitRotate: gr.setColor(Color.yellow);
1608416180 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608516181 break;
1608616182 case Object3D.hitScale: gr.setColor(Color.cyan);
16087
- gr.drawLine(X, Y, 0, 0);
16183
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608816184 break;
1608916185 }
1609016186
....@@ -16103,7 +16199,7 @@
1610316199 if (hasMarquee)
1610416200 {
1610516201 gr.setXORMode(Color.white);
16106
- gr.setColor(Color.red);
16202
+ gr.setColor(Color.white);
1610716203 if (!firstime)
1610816204 {
1610916205 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16570,6 +16666,8 @@
1657016666 private /*static*/ boolean firstime;
1657116667 private /*static*/ cVector newView = new cVector();
1657216668 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16669
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16670
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1657316671 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1657416672 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1657516673 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16582,22 +16680,56 @@
1658216680 {
1658316681 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1658416682
16683
+ int usedsuf = 0;
16684
+
1658516685 for (int i = 0; i < suffixes.length; i++)
1658616686 {
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)
16687
+ String[] suffixe = suffixes;
16688
+ String[] fallback = suffixes2;
16689
+ String[] fallfallback = suffixes3;
16690
+
16691
+ for (int c=usedsuf; --c>=0;)
1659216692 {
16593
- throw new IOException("Unable to load texture " + resourceName);
16693
+// String[] temp = suffixe;
16694
+// suffixe = fallback;
16695
+// fallback = fallfallback;
16696
+// fallfallback = temp;
1659416697 }
16698
+
16699
+ String resourceName = basename + suffixe[i] + "." + suffix;
16700
+ TextureData data;
16701
+
16702
+ try
16703
+ {
16704
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16705
+ mipmapped,
16706
+ FileUtil.getFileSuffix(resourceName));
16707
+ }
16708
+ catch (Exception e)
16709
+ {
16710
+ try
16711
+ {
16712
+ resourceName = basename + fallback[i] + "." + suffix;
16713
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16714
+ mipmapped,
16715
+ FileUtil.getFileSuffix(resourceName));
16716
+ }
16717
+ catch (Exception e2)
16718
+ {
16719
+ resourceName = basename + fallfallback[i] + "." + suffix;
16720
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16721
+ mipmapped,
16722
+ FileUtil.getFileSuffix(resourceName));
16723
+ }
16724
+ }
16725
+
1659516726 //System.out.println("Target = " + targets[i]);
1659616727 cubemap.updateImage(data, targets[i]);
1659716728 }
1659816729
1659916730 return cubemap;
1660016731 }
16732
+
1660116733 int bigsphere = -1;
1660216734
1660316735 float BGcolor = 0.5f;
....@@ -16606,7 +16738,9 @@
1660616738
1660716739 private void DrawSkyBox(GL gl, float ratio)
1660816740 {
16609
- if (envyoff || cubemap == null)
16741
+ if (//envyoff ||
16742
+ WIREFRAME ||
16743
+ cubemap == null)
1661016744 {
1661116745 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1661216746 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16623,14 +16757,14 @@
1662316757 gl.glLoadIdentity();
1662416758 gl.glScalef(1,ratio,1);
1662516759
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);
16760
+// colorV[0] = 2;
16761
+// colorV[1] = 2;
16762
+// colorV[2] = 2;
16763
+// colorV[3] = 1;
16764
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16765
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16766
+//
16767
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
1663416768
1663516769 //gl.glActiveTexture(GL.GL_TEXTURE1);
1663616770 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
....@@ -16644,7 +16778,7 @@
1664416778 // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting
1664516779 // causes the normals to be sent down. Thanks to Ken Dyke.
1664616780 //gl.glEnable(GL.GL_LIGHTING);
16647
- gl.glEnable(GL.GL_LIGHTING);
16781
+ gl.glDisable(GL.GL_LIGHTING);
1664816782
1664916783 gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
1665016784 gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
....@@ -16663,6 +16797,7 @@
1666316797 {
1666416798 gl.glScalef(1.0f, -1.0f, 1.0f);
1666516799 }
16800
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1666616801 gl.glMultMatrixd(viewrot_1, 0);
1666716802 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1666816803 //viewer.updateInverseRotation(gl);
....@@ -16703,7 +16838,8 @@
1670316838 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1670416839
1670516840 cubemap.disable();
16706
- ////cubemap.unbind();
16841
+ //cubemap.dispose();
16842
+
1670716843 if (CULLFACE)
1670816844 {
1670916845 gl.glEnable(gl.GL_CULL_FACE);
....@@ -17239,6 +17375,7 @@
1723917375
1724017376 public void init(GLAutoDrawable drawable)
1724117377 {
17378
+ if (Globals.DEBUG)
1724217379 System.out.println("shadow buffer init");
1724317380
1724417381 GL gl = drawable.getGL();
....@@ -17467,10 +17604,14 @@
1746717604 gl.glFlush();
1746817605
1746917606 /**/
17470
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17607
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1747117608
17472
- float[] pixels = occlusionsizebuffer.array();
17609
+ float[] depths = occlusiondepthbuffer.array();
1747317610
17611
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17612
+
17613
+ int[] pixels = selectsizebuffer.array();
17614
+
1747417615 double r = 0, g = 0, b = 0;
1747517616
1747617617 double count = 0;
....@@ -17481,7 +17622,7 @@
1748117622
1748217623 double FACTOR = 1;
1748317624
17484
- for (int i = 0; i < pixels.length; i++)
17625
+ for (int i = 0; i < depths.length; i++)
1748517626 {
1748617627 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1748717628 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17564,7 +17705,7 @@
1756417705
1756517706 double scale = ray.z; // 1; // cos
1756617707
17567
- float depth = pixels[newindex];
17708
+ float depth = depths[newindex];
1756817709
1756917710 /*
1757017711 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17761,11 +17902,14 @@
1776117902 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1776217903 static IntBuffer bigAAbuffer;
1776317904 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17764
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17905
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1776517906 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1776617907 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1776717908 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17768
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17909
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17910
+
17911
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17912
+
1776917913 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1777017914 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1777117915 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();