Normand Briere
2019-08-20 564f4d12d93813b5d680fc24d4f118c3886d96ed
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
....@@ -1814,7 +1819,7 @@
18141819
18151820 display.modelParams7[0] = 0;
18161821 display.modelParams7[1] = 1000;
1817
- display.modelParams7[2] = 0;
1822
+ display.modelParams7[2] = material.parallax;
18181823 display.modelParams7[3] = 0;
18191824
18201825 //display.modelParams6[0] = 100; // criss de bug de bump
....@@ -2047,9 +2052,9 @@
20472052 switch(viewcode)
20482053 {
20492054 case 0: return "main";
2050
- case 1: return "one";
2051
- case 2: return "two";
2052
- case 3: return "three";
2055
+ case 1: return "Red";
2056
+ case 2: return "Green";
2057
+ case 3: return "Blue";
20532058 case 4: return "light";
20542059 }
20552060
....@@ -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(1);
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;" +
....@@ -12541,7 +12593,7 @@
1254112593 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1254212594 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1254312595 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
12544
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12596
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1254512597 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1254612598 "PARAM options1 = program.env[62];" + // fog rgb color
1254712599 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -12786,7 +12838,7 @@
1278612838 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1278712839 // mar 2013 ??? "KIL alpha.a;" +
1278812840 "MOV alpha, texSamp.aaaa;" + // y;" +
12789
- "KIL alpha.a;" +
12841
+ "KIL alpha.a;" + // not sure with parallax mapping
1279012842 /*
1279112843 "MUL temp.xy, temp, two;" +
1279212844 "TXB bump, temp, texture[0], 2D;" +
....@@ -12872,11 +12924,6 @@
1287212924 "SUB bump0, bump0, half;" +
1287312925 "ADD bump, bump, bump0;" +
1287412926
12875
- "MOV temp.x, texSamp.a;" +
12876
- "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12877
- //"LRP texSamp0, params5.x, texSamp0, one;" +
12878
- "MOV texSamp.a, temp.x;" +
12879
-
1288012927 // double-sided
1288112928 /**/
1288212929 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -12906,6 +12953,41 @@
1290612953 Normalize("U") +
1290712954
1290812955 // parallax mapping
12956
+
12957
+ "DP3 temp2.x, V, eye;" +
12958
+ "DP3 temp2.y, U, eye;" +
12959
+ "DP3 temp2.z, normal, eye;" +
12960
+ "RCP temp2.z, temp2.z;" +
12961
+
12962
+ "DP3 temp2.w, texSamp, texSamp;" + // Height
12963
+ "RSQ temp2.w, temp2.w;" +
12964
+ "RCP temp2.w, temp2.w;" +
12965
+
12966
+ "SUB temp2.w, temp2.w, half;" +
12967
+// "SGE temp.x, temp2.w, eps.x;" +
12968
+// "MUL temp2.w, temp2.w, temp.x;" +
12969
+
12970
+ //"MOV texSamp, U;" +
12971
+
12972
+ "MUL temp2.z, temp2.z, temp2.w;" +
12973
+ "MUL temp2.z, temp2.z, params7.z;" + // parallax
12974
+
12975
+ "MUL temp2, temp2, temp2.z;" +
12976
+
12977
+ "MOV temp, fragment.texcoord[0];" +
12978
+
12979
+ "SUB temp, temp, temp2;" +
12980
+
12981
+ "TEX texSamp, temp, texture[0], 2D;" +
12982
+ "POW texSamp.a, texSamp.a, params6.w;" + // punch through
12983
+ "MOV alpha, texSamp.aaaa;" +
12984
+
12985
+// parallax mapping
12986
+
12987
+ "MOV temp.x, texSamp.a;" +
12988
+ "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12989
+ //"LRP texSamp0, params5.x, texSamp0, one;" +
12990
+ "MOV texSamp.a, temp.x;" +
1290912991
1291012992 //"MOV temp, fragment.texcoord[0];" +
1291112993 //
....@@ -13369,8 +13451,19 @@
1336913451 //once = true;
1337013452 }
1337113453
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 " : ""));
13454
+ String program = programmax;
13455
+
13456
+ if (Globals.MINSHADER)
13457
+ {
13458
+ program = programmin;
13459
+ }
13460
+
13461
+ if (Globals.DEBUG)
13462
+ {
13463
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13464
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13465
+ }
13466
+
1337413467 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1337513468
1337613469 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13417,7 +13510,8 @@
1341713510 "\n" +
1341813511 "END\n";
1341913512
13420
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13513
+ if (Globals.DEBUG)
13514
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1342113515 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1342213516
1342313517 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13675,7 +13769,7 @@
1367513769 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1367613770 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1367713771 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
13678
- /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13772
+ /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax
1367913773
1368013774 //Object3D.cVector2[] vector2buffer;
1368113775
....@@ -14616,11 +14710,17 @@
1461614710 void GoDown(int mod)
1461714711 {
1461814712 MODIFIERS |= COMMAND;
14713
+ boolean isVR = (mouseMode&VR)!=0;
1461914714 /**/
1462014715 if((mod&SHIFT) == SHIFT)
14621
- manipCamera.RotatePosition(0, -speed);
14716
+ {
14717
+ if (isVR)
14718
+ manipCamera.RotateInterest(0, -speed);
14719
+ else
14720
+ manipCamera.RotatePosition(0, -speed);
14721
+ }
1462214722 else
14623
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14723
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1462414724 /**/
1462514725 if ((mod & SHIFT) == SHIFT)
1462614726 {
....@@ -14630,6 +14730,8 @@
1463014730 mouseMode |= BACKFORTH;
1463114731 }
1463214732
14733
+ targetLookAt.set(manipCamera.lookAt);
14734
+
1463314735 //prevX = X = anchorX;
1463414736 prevY = Y = anchorY - (int) (renderCamera.Distance());
1463514737 }
....@@ -14638,10 +14740,17 @@
1463814740 {
1463914741 MODIFIERS |= COMMAND;
1464014742 /**/
14743
+ boolean isVR = (mouseMode&VR)!=0;
14744
+
1464114745 if((mod&SHIFT) == SHIFT)
14642
- manipCamera.RotatePosition(0, speed);
14746
+ {
14747
+ if (isVR)
14748
+ manipCamera.RotateInterest(0, speed);
14749
+ else
14750
+ manipCamera.RotatePosition(0, speed);
14751
+ }
1464314752 else
14644
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14753
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1464514754 /**/
1464614755 if ((mod & SHIFT) == SHIFT)
1464714756 {
....@@ -14651,6 +14760,8 @@
1465114760 mouseMode |= BACKFORTH;
1465214761 }
1465314762
14763
+ targetLookAt.set(manipCamera.lookAt);
14764
+
1465414765 //prevX = X = anchorX;
1465514766 prevY = Y = anchorY + (int) (renderCamera.Distance());
1465614767 }
....@@ -14660,9 +14771,14 @@
1466014771 MODIFIERS |= COMMAND;
1466114772 /**/
1466214773 if((mod&SHIFT) == SHIFT)
14663
- manipCamera.Translate(speed*delta, 0, getWidth());
14774
+ manipCamera.Translate(speed*delta, 0, getWidth());
1466414775 else
14665
- manipCamera.RotatePosition(speed, 0);
14776
+ {
14777
+ if ((mouseMode&VR)!=0)
14778
+ manipCamera.RotateInterest(-speed, 0);
14779
+ else
14780
+ manipCamera.RotatePosition(speed, 0);
14781
+ }
1466614782 /**/
1466714783 if ((mod & SHIFT) == SHIFT)
1466814784 {
....@@ -14672,6 +14788,8 @@
1467214788 mouseMode |= ROTATE;
1467314789 } // TRANSLATE;
1467414790
14791
+ targetLookAt.set(manipCamera.lookAt);
14792
+
1467514793 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1467614794 prevY = Y = anchorY;
1467714795 }
....@@ -14681,9 +14799,15 @@
1468114799 MODIFIERS |= COMMAND;
1468214800 /**/
1468314801 if((mod&SHIFT) == SHIFT)
14684
- manipCamera.Translate(-speed*delta, 0, getWidth());
14802
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1468514803 else
14686
- manipCamera.RotatePosition(-speed, 0);
14804
+ {
14805
+ if ((mouseMode&VR)!=0)
14806
+ manipCamera.RotateInterest(speed, 0);
14807
+ else
14808
+ manipCamera.RotatePosition(-speed, 0);
14809
+ }
14810
+
1468714811 /**/
1468814812 if ((mod & SHIFT) == SHIFT)
1468914813 {
....@@ -14693,6 +14817,8 @@
1469314817 mouseMode |= ROTATE;
1469414818 } // TRANSLATE;
1469514819
14820
+ targetLookAt.set(manipCamera.lookAt);
14821
+
1469614822 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1469714823 prevY = Y = anchorY;
1469814824 }
....@@ -15195,8 +15321,8 @@
1519515321 case 'K':
1519615322 KOMPACTTEXTURE ^= true;
1519715323 //textures.clear();
15198
- break;
15199
- case 'P': // Texture Projection macros
15324
+ // break;
15325
+ //case 'P': // Texture Projection macros
1520015326 // SAVETEXTURE ^= true;
1520115327 macromode = true;
1520215328 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -15317,7 +15443,7 @@
1531715443 targetLookAt.set(manipCamera.lookAt);
1531815444 repaint();
1531915445 break;
15320
- case 'p':
15446
+ case 'P': // p':
1532115447 // c'est quoi ca au juste? spherical ^= true;
1532215448 Skinshader ^= true; programInitialized = false;
1532315449 repaint();
....@@ -15362,7 +15488,7 @@
1536215488 OCCLUSION_CULLING ^= true;
1536315489 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1536415490 break;
15365
- case '0': envyoff ^= true; repaint(); break;
15491
+ //case '0': envyoff ^= true; repaint(); break;
1536615492 case '1':
1536715493 case '2':
1536815494 case '3':
....@@ -15372,7 +15498,7 @@
1537215498 case '7':
1537315499 case '8':
1537415500 case '9':
15375
- if (envyoff)
15501
+ if (true) // envyoff)
1537615502 {
1537715503 BGcolor = (key - '1')/8.f;
1537815504 }
....@@ -16077,14 +16203,14 @@
1607716203 {
1607816204 switch (hitSomething)
1607916205 {
16080
- case Object3D.hitCenter: gr.setColor(Color.pink);
16206
+ case Object3D.hitCenter: gr.setColor(Color.white);
1608116207 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608216208 break;
1608316209 case Object3D.hitRotate: gr.setColor(Color.yellow);
1608416210 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608516211 break;
1608616212 case Object3D.hitScale: gr.setColor(Color.cyan);
16087
- gr.drawLine(X, Y, 0, 0);
16213
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1608816214 break;
1608916215 }
1609016216
....@@ -16103,7 +16229,7 @@
1610316229 if (hasMarquee)
1610416230 {
1610516231 gr.setXORMode(Color.white);
16106
- gr.setColor(Color.red);
16232
+ gr.setColor(Color.white);
1610716233 if (!firstime)
1610816234 {
1610916235 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16633,6 +16759,7 @@
1663316759
1663416760 return cubemap;
1663516761 }
16762
+
1663616763 int bigsphere = -1;
1663716764
1663816765 float BGcolor = 0.5f;
....@@ -16641,7 +16768,9 @@
1664116768
1664216769 private void DrawSkyBox(GL gl, float ratio)
1664316770 {
16644
- if (envyoff || cubemap == null)
16771
+ if (//envyoff ||
16772
+ WIREFRAME ||
16773
+ cubemap == null)
1664516774 {
1664616775 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1664716776 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16658,14 +16787,14 @@
1665816787 gl.glLoadIdentity();
1665916788 gl.glScalef(1,ratio,1);
1666016789
16661
- colorV[0] = 2;
16662
- colorV[1] = 2;
16663
- colorV[2] = 2;
16664
- colorV[3] = 1;
16665
- gl.glDisable(gl.GL_COLOR_MATERIAL);
16666
- gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16667
-
16668
- gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16790
+// colorV[0] = 2;
16791
+// colorV[1] = 2;
16792
+// colorV[2] = 2;
16793
+// colorV[3] = 1;
16794
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16795
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16796
+//
16797
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
1666916798
1667016799 //gl.glActiveTexture(GL.GL_TEXTURE1);
1667116800 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
....@@ -16679,7 +16808,7 @@
1667916808 // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting
1668016809 // causes the normals to be sent down. Thanks to Ken Dyke.
1668116810 //gl.glEnable(GL.GL_LIGHTING);
16682
- gl.glEnable(GL.GL_LIGHTING);
16811
+ gl.glDisable(GL.GL_LIGHTING);
1668316812
1668416813 gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
1668516814 gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
....@@ -16739,7 +16868,8 @@
1673916868 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1674016869
1674116870 cubemap.disable();
16742
- ////cubemap.unbind();
16871
+ //cubemap.dispose();
16872
+
1674316873 if (CULLFACE)
1674416874 {
1674516875 gl.glEnable(gl.GL_CULL_FACE);
....@@ -17275,6 +17405,7 @@
1727517405
1727617406 public void init(GLAutoDrawable drawable)
1727717407 {
17408
+ if (Globals.DEBUG)
1727817409 System.out.println("shadow buffer init");
1727917410
1728017411 GL gl = drawable.getGL();
....@@ -17503,10 +17634,14 @@
1750317634 gl.glFlush();
1750417635
1750517636 /**/
17506
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17637
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1750717638
17508
- float[] pixels = occlusionsizebuffer.array();
17639
+ float[] depths = occlusiondepthbuffer.array();
1750917640
17641
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17642
+
17643
+ int[] pixels = selectsizebuffer.array();
17644
+
1751017645 double r = 0, g = 0, b = 0;
1751117646
1751217647 double count = 0;
....@@ -17517,7 +17652,7 @@
1751717652
1751817653 double FACTOR = 1;
1751917654
17520
- for (int i = 0; i < pixels.length; i++)
17655
+ for (int i = 0; i < depths.length; i++)
1752117656 {
1752217657 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1752317658 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17600,7 +17735,7 @@
1760017735
1760117736 double scale = ray.z; // 1; // cos
1760217737
17603
- float depth = pixels[newindex];
17738
+ float depth = depths[newindex];
1760417739
1760517740 /*
1760617741 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17797,11 +17932,14 @@
1779717932 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1779817933 static IntBuffer bigAAbuffer;
1779917934 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17800
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17935
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1780117936 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1780217937 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1780317938 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17804
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17939
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17940
+
17941
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17942
+
1780517943 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1780617944 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1780717945 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();