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
....@@ -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 {
....@@ -206,7 +223,8 @@
206223
207224 SetCamera(cam);
208225
209
- SetLight(new Camera(new cVector(10, 10, -20)));
226
+ // Warning: not used.
227
+ SetLight(new Camera(new cVector(15, 10, -20)));
210228
211229 object = o;
212230
....@@ -1484,6 +1502,8 @@
14841502 gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
14851503 }
14861504
1505
+ float[] colorV = new float[4];
1506
+
14871507 void SetColor(Object3D obj, Vertex p0)
14881508 {
14891509 CameraPane display = this;
....@@ -1551,8 +1571,6 @@
15511571 {
15521572 return;
15531573 }
1554
-
1555
- float[] colorV = new float[3];
15561574
15571575 if (false) // marked)
15581576 {
....@@ -1801,7 +1819,7 @@
18011819
18021820 display.modelParams7[0] = 0;
18031821 display.modelParams7[1] = 1000;
1804
- display.modelParams7[2] = 0;
1822
+ display.modelParams7[2] = material.parallax;
18051823 display.modelParams7[3] = 0;
18061824
18071825 //display.modelParams6[0] = 100; // criss de bug de bump
....@@ -2034,9 +2052,9 @@
20342052 switch(viewcode)
20352053 {
20362054 case 0: return "main";
2037
- case 1: return "one";
2038
- case 2: return "two";
2039
- case 3: return "three";
2055
+ case 1: return "Red";
2056
+ case 2: return "Green";
2057
+ case 3: return "Blue";
20402058 case 4: return "light";
20412059 }
20422060
....@@ -2499,7 +2517,7 @@
24992517 com.sun.opengl.util.texture.TextureIO.newTextureData(
25002518 getClass().getClassLoader().getResourceAsStream(name),
25012519 true,
2502
- com.sun.opengl.util.texture.TextureIO.PNG);
2520
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
25032521 } catch (java.io.IOException e)
25042522 {
25052523 throw new javax.media.opengl.GLException(e);
....@@ -8345,7 +8363,7 @@
83458363 // else
83468364 // if (!texname.startsWith("/"))
83478365 // texname = "/Users/nbriere/Textures/" + texname;
8348
- if (!FileExists(texname))
8366
+ if (!FileExists(texname) && !texname.startsWith("@"))
83498367 {
83508368 texname = fallbackTextureName;
83518369 }
....@@ -8428,6 +8446,15 @@
84288446 new Exception().printStackTrace();
84298447 } else
84308448 {
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
+ {
84318458 if (textureon)
84328459 {
84338460 String cachename = texname;
....@@ -8487,6 +8514,7 @@
84878514 texturecache = new CacheTexture(texturedata,resolution);
84888515 //texture = GetTexture(tex, bump);
84898516 }
8517
+ }
84908518 }
84918519 //}
84928520 }
....@@ -8755,10 +8783,12 @@
87558783
87568784 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
87578785 MAXSTACK = temp[0];
8758
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8786
+ if (Globals.DEBUG)
8787
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
87598788 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
87608789 MAXSTACK = temp[0];
8761
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8790
+ if (Globals.DEBUG)
8791
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
87628792
87638793 // Use debug pipeline
87648794 //drawable.setGL(new DebugGL(gl)); //
....@@ -8766,7 +8796,8 @@
87668796 gl = drawable.getGL(); //
87678797
87688798 GL gl3 = getGL();
8769
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8799
+ if (Globals.DEBUG)
8800
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
87708801
87718802
87728803 //float pos[] = { 100, 100, 100, 0 };
....@@ -8931,7 +8962,7 @@
89318962
89328963 if (cubemap == null)
89338964 {
8934
- LoadEnvy(5);
8965
+ //LoadEnvy(1);
89358966 }
89368967
89378968 //cubemap.enable();
....@@ -9207,6 +9238,8 @@
92079238
92089239 void LoadEnvy(int which)
92099240 {
9241
+ assert(false);
9242
+
92109243 String name;
92119244 String ext;
92129245
....@@ -9218,37 +9251,58 @@
92189251 cubemap = null;
92199252 return;
92209253 case 1:
9221
- name = "cubemaps/box_";
9222
- ext = "png";
9254
+ name = "cubemaps/rgb/";
9255
+ ext = "jpg";
92239256 reverseUP = false;
92249257 break;
92259258 case 2:
9226
- name = "cubemaps/uffizi_";
9227
- ext = "png";
9228
- break; // reverseUP = true; break;
9259
+ name = "cubemaps/uffizi/";
9260
+ ext = "jpg";
9261
+ reverseUP = false;
9262
+ break;
92299263 case 3:
9230
- name = "cubemaps/CloudyHills_";
9231
- ext = "tga";
9264
+ name = "cubemaps/CloudyHills/";
9265
+ ext = "jpg";
92329266 reverseUP = false;
92339267 break;
92349268 case 4:
9235
- name = "cubemaps/cornell_";
9269
+ name = "cubemaps/cornell/";
92369270 ext = "png";
92379271 reverseUP = false;
92389272 break;
9273
+ case 5:
9274
+ name = "cubemaps/skycube/";
9275
+ ext = "jpg";
9276
+ reverseUP = false;
9277
+ break;
9278
+ case 6:
9279
+ name = "cubemaps/SaintLazarusChurch3/";
9280
+ ext = "jpg";
9281
+ reverseUP = false;
9282
+ break;
9283
+ case 7:
9284
+ name = "cubemaps/Sodermalmsallen/";
9285
+ ext = "jpg";
9286
+ reverseUP = false;
9287
+ break;
9288
+ case 8:
9289
+ name = "cubemaps/Sodermalmsallen2/";
9290
+ ext = "jpg";
9291
+ reverseUP = false;
9292
+ break;
9293
+ case 9:
9294
+ name = "cubemaps/UnionSquare/";
9295
+ ext = "jpg";
9296
+ reverseUP = false;
9297
+ break;
92399298 default:
9240
- name = "cubemaps/rgb_";
9241
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9299
+ name = "cubemaps/box/";
9300
+ ext = "png"; /*mipmap = true;*/
9301
+ reverseUP = false;
92429302 break;
92439303 }
9244
-
9245
- try
9246
- {
9247
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
9248
- } catch (IOException e)
9249
- {
9250
- throw new RuntimeException(e);
9251
- }
9304
+
9305
+ LoadSkybox(name, ext, mipmap);
92529306 }
92539307
92549308 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -9280,8 +9334,12 @@
92809334 static double[] model = new double[16];
92819335 double[] camera2light = new double[16];
92829336 double[] light2camera = new double[16];
9283
- int newenvy = -1;
9284
- boolean envyoff = true; // false;
9337
+
9338
+ //int newenvy = -1;
9339
+ //boolean envyoff = false;
9340
+
9341
+ String loadedskyboxname;
9342
+
92859343 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
92869344 //float[] light0 = { 0,0,0 };
92879345 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9699,7 +9757,7 @@
96999757
97009758 if (renderCamera != lightCamera)
97019759 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9702
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
9760
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
97039761
97049762 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
97059763
....@@ -9715,7 +9773,7 @@
97159773
97169774 if (renderCamera != lightCamera)
97179775 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9718
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
9776
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
97199777
97209778 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
97219779
....@@ -9761,10 +9819,12 @@
97619819 rati = 1 / rati;
97629820 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
97639821 }
9764
- assert (newenvy == -1);
9822
+
9823
+ //assert (newenvy == -1);
9824
+
97659825 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
97669826 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9767
- DrawSkyBox(gl);
9827
+ DrawSkyBox(gl, (float)rati);
97689828 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
97699829 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
97709830 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -10630,9 +10690,18 @@
1063010690 static boolean init = false;
1063110691
1063210692 double[][] matrix = LA.newMatrix();
10693
+
10694
+ // This is to refresh the UI of the material panel.
10695
+ ObjEditor patchMaterial;
1063310696
1063410697 public void display(GLAutoDrawable drawable)
1063510698 {
10699
+ if (patchMaterial.patchMaterial)
10700
+ {
10701
+ patchMaterial.patchMaterial = false;
10702
+ patchMaterial.objectPanel.setSelectedIndex(1);
10703
+ }
10704
+
1063610705 if (Grafreed.savesound && Grafreed.hassound)
1063710706 {
1063810707 Grafreed.wav.save();
....@@ -10801,7 +10870,7 @@
1080110870
1080210871 if (wait)
1080310872 {
10804
- Sleep(500);
10873
+ Sleep(200); // blocks everything
1080510874
1080610875 wait = false;
1080710876 }
....@@ -10916,7 +10985,7 @@
1091610985 // if (parentcam != renderCamera) // not a light
1091710986 if (cam != lightCamera)
1091810987 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10919
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
10988
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1092010989
1092110990 for (int j = 0; j < 4; j++)
1092210991 {
....@@ -10931,7 +11000,7 @@
1093111000 // if (parentcam != renderCamera) // not a light
1093211001 if (cam != lightCamera)
1093311002 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
11003
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1093511004
1093611005 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1093711006
....@@ -11017,13 +11086,43 @@
1101711086 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1101811087 }
1101911088
11020
- if (newenvy > -1)
11089
+// if (newenvy > -1)
11090
+// {
11091
+// LoadEnvy(newenvy);
11092
+// }
11093
+//
11094
+// newenvy = -1;
11095
+
11096
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1102111097 {
11022
- LoadEnvy(newenvy);
11098
+ if (cubemaprgb == null)
11099
+ {
11100
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
11101
+ }
11102
+
11103
+ cubemap = cubemaprgb;
1102311104 }
11024
-
11025
- newenvy = -1;
11026
-
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;
11124
+ }
11125
+
1102711126 ratio = ((double) getWidth()) / getHeight();
1102811127 //System.out.println("ratio = " + ratio);
1102911128
....@@ -11039,7 +11138,7 @@
1103911138
1104011139 if (!IsFrozen() && !ambientOcclusion)
1104111140 {
11042
- DrawSkyBox(gl);
11141
+ DrawSkyBox(gl, (float)ratio);
1104311142 }
1104411143
1104511144 //if (selection_view == -1)
....@@ -11325,7 +11424,7 @@
1132511424
1132611425 // if (cam != lightCamera)
1132711426 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11328
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11427
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1132911428 }
1133011429
1133111430 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12399,8 +12498,76 @@
1239912498
1240012499 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240112500
12402
- String program =
12501
+ String programmin =
12502
+ // Min shader
1240312503 "!!ARBfp1.0\n" +
12504
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12505
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12506
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12507
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12508
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12509
+ "PARAM light2cam0 = program.env[10];" +
12510
+ "PARAM light2cam1 = program.env[11];" +
12511
+ "PARAM light2cam2 = program.env[12];" +
12512
+ "TEMP temp;" +
12513
+ "TEMP light;" +
12514
+ "TEMP ndotl;" +
12515
+ "TEMP normal;" +
12516
+ "TEMP depth;" +
12517
+ "TEMP eye;" +
12518
+ "TEMP pos;" +
12519
+
12520
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12521
+ Normalize("normal") +
12522
+ "MOV light, state.light[0].position;" +
12523
+ "DP3 ndotl.x, light, normal;" +
12524
+
12525
+ // shadow
12526
+ "MOV pos, fragment.texcoord[1];" +
12527
+ "MOV temp, pos;" +
12528
+ ShadowTextureFetch("depth", "temp", "1") +
12529
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12530
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
12531
+
12532
+ // No shadow when out of frustum
12533
+ //"SGE temp.y, depth.z, zero123.y;" +
12534
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12535
+
12536
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
12537
+
12538
+ // Backlit
12539
+ "MOV pos.w, zero123.y;" +
12540
+ "DP4 eye.x, pos, light2cam0;" +
12541
+ "DP4 eye.y, pos, light2cam1;" +
12542
+ "DP4 eye.z, pos, light2cam2;" +
12543
+ Normalize("eye") +
12544
+
12545
+ "DP3 ndotl.y, -eye, normal;" +
12546
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12547
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12548
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12549
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12550
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12551
+
12552
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12553
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12554
+
12555
+ // Pigment
12556
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12557
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12558
+ "MUL temp, temp, ndotl.x;" +
12559
+
12560
+ "MUL temp, temp, zero123.z;" +
12561
+
12562
+ //"MUL temp, temp, ndotl.y;" +
12563
+
12564
+ "MOV temp.w, zero123.y;" + // reset alpha
12565
+ "MOV result.color, temp;" +
12566
+ "END";
12567
+
12568
+ String programmax =
12569
+ "!!ARBfp1.0\n" +
12570
+
1240412571 //"OPTION ARB_fragment_program_shadow;" +
1240512572 "PARAM light2cam0 = program.env[10];" +
1240612573 "PARAM light2cam1 = program.env[11];" +
....@@ -12426,7 +12593,7 @@
1242612593 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1242712594 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1242812595 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
12429
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12596
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1243012597 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1243112598 "PARAM options1 = program.env[62];" + // fog rgb color
1243212599 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -12515,8 +12682,7 @@
1251512682 "TEMP shininess;" +
1251612683 "\n" +
1251712684 "MOV texSamp, one;" +
12518
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12519
-
12685
+
1252012686 "MOV mapgrid.x, one2048th.x;" +
1252112687 "MOV temp, fragment.texcoord[1];" +
1252212688 /*
....@@ -12537,20 +12703,20 @@
1253712703 "MUL temp, floor, mapgrid.x;" +
1253812704 //"TEX depth0, temp, texture[1], 2D;" +
1253912705 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12540
- TextureFetch("depth0", "temp", "1") +
12706
+ ShadowTextureFetch("depth0", "temp", "1") +
1254112707 "") +
1254212708 "ADD temp.x, temp.x, mapgrid.x;" +
1254312709 //"TEX depth1, temp, texture[1], 2D;" +
1254412710 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12545
- TextureFetch("depth1", "temp", "1") +
12711
+ ShadowTextureFetch("depth1", "temp", "1") +
1254612712 "") +
1254712713 "ADD temp.y, temp.y, mapgrid.x;" +
1254812714 //"TEX depth2, temp, texture[1], 2D;" +
12549
- TextureFetch("depth2", "temp", "1") +
12715
+ ShadowTextureFetch("depth2", "temp", "1") +
1255012716 "SUB temp.x, temp.x, mapgrid.x;" +
1255112717 //"TEX depth3, temp, texture[1], 2D;" +
1255212718 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12553
- TextureFetch("depth3", "temp", "1") +
12719
+ ShadowTextureFetch("depth3", "temp", "1") +
1255412720 "") +
1255512721 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1255612722 //"MOV params, material;" +
....@@ -12672,7 +12838,7 @@
1267212838 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1267312839 // mar 2013 ??? "KIL alpha.a;" +
1267412840 "MOV alpha, texSamp.aaaa;" + // y;" +
12675
- "KIL alpha.a;" +
12841
+ "KIL alpha.a;" + // not sure with parallax mapping
1267612842 /*
1267712843 "MUL temp.xy, temp, two;" +
1267812844 "TXB bump, temp, texture[0], 2D;" +
....@@ -12758,11 +12924,6 @@
1275812924 "SUB bump0, bump0, half;" +
1275912925 "ADD bump, bump, bump0;" +
1276012926
12761
- "MOV temp.x, texSamp.a;" +
12762
- "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12763
- //"LRP texSamp0, params5.x, texSamp0, one;" +
12764
- "MOV texSamp.a, temp.x;" +
12765
-
1276612927 // double-sided
1276712928 /**/
1276812929 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -12792,6 +12953,41 @@
1279212953 Normalize("U") +
1279312954
1279412955 // 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;" +
1279512991
1279612992 //"MOV temp, fragment.texcoord[0];" +
1279712993 //
....@@ -12921,10 +13117,10 @@
1292113117 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1292213118 "") +
1292313119
12924
- // display shadow only (bump == 0)
13120
+ // display shadow only (fakedepth == 0)
1292513121 "SUB temp.x, half.x, shadow.x;" +
1292613122 "MOV temp.y, -params5.z;" + // params6.x;" +
12927
- "SLT temp.z, temp.y, -one2048th.x;" +
13123
+ "SLT temp.z, temp.y, -c256i.x;" +
1292813124 "SUB temp.y, one.x, temp.z;" +
1292913125 "MUL temp.x, temp.x, temp.y;" +
1293013126 "KIL temp.x;" +
....@@ -13255,8 +13451,19 @@
1325513451 //once = true;
1325613452 }
1325713453
13258
- System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13259
- 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
+
1326013467 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1326113468
1326213469 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13303,7 +13510,8 @@
1330313510 "\n" +
1330413511 "END\n";
1330513512
13306
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13513
+ if (Globals.DEBUG)
13514
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1330713515 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1330813516
1330913517 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13348,25 +13556,26 @@
1334813556 return out;
1334913557 }
1335013558
13351
- String TextureFetch(String dest, String src, String unit)
13559
+ // Also does frustum culling
13560
+ String ShadowTextureFetch(String dest, String src, String unit)
1335213561 {
1335313562 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1335413563 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1335513564 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13565
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13566
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1335613567 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13357
- "SLT " + src + ".z, " + src + ".x, one.x;" +
13358
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13359
- "SLT " + src + ".z, " + src + ".y, one.x;" +
13360
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13568
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13569
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1336113570 //"SWZ buffer, temp, w,w,w,w;";
13362
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13571
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1336313572 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1336413573 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1336513574 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13366
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13575
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1336713576
13368
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13369
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13577
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13578
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1337013579 }
1337113580
1337213581 String Shadow(String depth, String shadow)
....@@ -13413,7 +13622,7 @@
1341313622 "SLT temp.x, temp.x, zero.x;" + // shadoweps
1341413623 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1341513624
13416
- // No shadow when out of frustrum
13625
+ // No shadow when out of frustum
1341713626 "SGE temp.x, " + depth + ".z, one.z;" +
1341813627 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1341913628 "";
....@@ -13560,7 +13769,7 @@
1356013769 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1356113770 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1356213771 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
13563
- /*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
1356413773
1356513774 //Object3D.cVector2[] vector2buffer;
1356613775
....@@ -14211,14 +14420,15 @@
1421114420 drag = false;
1421214421 //System.out.println("Mouse DOWN");
1421314422 editObj = false;
14214
- ClickInfo info = new ClickInfo();
14215
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14216
- info.pane = this;
14217
- info.camera = renderCamera;
14218
- info.x = x;
14219
- info.y = y;
14220
- info.modifiers = modifiersex;
14221
- editObj = object.doEditClick(info, 0);
14423
+ //ClickInfo info = new ClickInfo();
14424
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14425
+ object.clickInfo.pane = this;
14426
+ object.clickInfo.camera = renderCamera;
14427
+ object.clickInfo.x = x;
14428
+ object.clickInfo.y = y;
14429
+ object.clickInfo.modifiers = modifiersex;
14430
+ editObj = object.doEditClick(//info,
14431
+ 0);
1422214432 if (!editObj)
1422314433 {
1422414434 hasMarquee = true;
....@@ -14500,11 +14710,17 @@
1450014710 void GoDown(int mod)
1450114711 {
1450214712 MODIFIERS |= COMMAND;
14713
+ boolean isVR = (mouseMode&VR)!=0;
1450314714 /**/
1450414715 if((mod&SHIFT) == SHIFT)
14505
- manipCamera.RotatePosition(0, -speed);
14716
+ {
14717
+ if (isVR)
14718
+ manipCamera.RotateInterest(0, -speed);
14719
+ else
14720
+ manipCamera.RotatePosition(0, -speed);
14721
+ }
1450614722 else
14507
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14723
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1450814724 /**/
1450914725 if ((mod & SHIFT) == SHIFT)
1451014726 {
....@@ -14514,6 +14730,8 @@
1451414730 mouseMode |= BACKFORTH;
1451514731 }
1451614732
14733
+ targetLookAt.set(manipCamera.lookAt);
14734
+
1451714735 //prevX = X = anchorX;
1451814736 prevY = Y = anchorY - (int) (renderCamera.Distance());
1451914737 }
....@@ -14522,10 +14740,17 @@
1452214740 {
1452314741 MODIFIERS |= COMMAND;
1452414742 /**/
14743
+ boolean isVR = (mouseMode&VR)!=0;
14744
+
1452514745 if((mod&SHIFT) == SHIFT)
14526
- manipCamera.RotatePosition(0, speed);
14746
+ {
14747
+ if (isVR)
14748
+ manipCamera.RotateInterest(0, speed);
14749
+ else
14750
+ manipCamera.RotatePosition(0, speed);
14751
+ }
1452714752 else
14528
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14753
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1452914754 /**/
1453014755 if ((mod & SHIFT) == SHIFT)
1453114756 {
....@@ -14535,6 +14760,8 @@
1453514760 mouseMode |= BACKFORTH;
1453614761 }
1453714762
14763
+ targetLookAt.set(manipCamera.lookAt);
14764
+
1453814765 //prevX = X = anchorX;
1453914766 prevY = Y = anchorY + (int) (renderCamera.Distance());
1454014767 }
....@@ -14544,9 +14771,14 @@
1454414771 MODIFIERS |= COMMAND;
1454514772 /**/
1454614773 if((mod&SHIFT) == SHIFT)
14547
- manipCamera.Translate(speed*delta, 0, getWidth());
14774
+ manipCamera.Translate(speed*delta, 0, getWidth());
1454814775 else
14549
- manipCamera.RotatePosition(speed, 0);
14776
+ {
14777
+ if ((mouseMode&VR)!=0)
14778
+ manipCamera.RotateInterest(-speed, 0);
14779
+ else
14780
+ manipCamera.RotatePosition(speed, 0);
14781
+ }
1455014782 /**/
1455114783 if ((mod & SHIFT) == SHIFT)
1455214784 {
....@@ -14556,6 +14788,8 @@
1455614788 mouseMode |= ROTATE;
1455714789 } // TRANSLATE;
1455814790
14791
+ targetLookAt.set(manipCamera.lookAt);
14792
+
1455914793 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1456014794 prevY = Y = anchorY;
1456114795 }
....@@ -14565,9 +14799,15 @@
1456514799 MODIFIERS |= COMMAND;
1456614800 /**/
1456714801 if((mod&SHIFT) == SHIFT)
14568
- manipCamera.Translate(-speed*delta, 0, getWidth());
14802
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1456914803 else
14570
- manipCamera.RotatePosition(-speed, 0);
14804
+ {
14805
+ if ((mouseMode&VR)!=0)
14806
+ manipCamera.RotateInterest(speed, 0);
14807
+ else
14808
+ manipCamera.RotatePosition(-speed, 0);
14809
+ }
14810
+
1457114811 /**/
1457214812 if ((mod & SHIFT) == SHIFT)
1457314813 {
....@@ -14577,6 +14817,8 @@
1457714817 mouseMode |= ROTATE;
1457814818 } // TRANSLATE;
1457914819
14820
+ targetLookAt.set(manipCamera.lookAt);
14821
+
1458014822 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1458114823 prevY = Y = anchorY;
1458214824 }
....@@ -14618,15 +14860,16 @@
1461814860 if (editObj)
1461914861 {
1462014862 drag = true;
14621
- ClickInfo info = new ClickInfo();
14622
- info.bounds.setBounds(0, 0,
14863
+ //ClickInfo info = new ClickInfo();
14864
+ object.clickInfo.bounds.setBounds(0, 0,
1462314865 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14624
- info.pane = this;
14625
- info.camera = renderCamera;
14626
- info.x = x;
14627
- info.y = y;
14628
- object.GetWindow().copy
14629
- .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14866
+ object.clickInfo.pane = this;
14867
+ object.clickInfo.camera = renderCamera;
14868
+ object.clickInfo.x = x;
14869
+ object.clickInfo.y = y;
14870
+ object //.GetWindow().copy
14871
+ .doEditDrag(//info,
14872
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1463014873 } else
1463114874 {
1463214875 if (x < startX)
....@@ -14775,24 +15018,27 @@
1477515018 }
1477615019 }
1477715020
15021
+// ClickInfo clickInfo = new ClickInfo();
15022
+
1477815023 public void mouseMoved(MouseEvent e)
1477915024 {
1478015025 //System.out.println("mouseMoved: " + e);
1478115026 if (isRenderer)
1478215027 return;
1478315028
14784
- ClickInfo ci = new ClickInfo();
14785
- ci.x = e.getX();
14786
- ci.y = e.getY();
14787
- ci.modifiers = e.getModifiersEx();
14788
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14789
- ci.pane = this;
14790
- ci.camera = renderCamera;
15029
+ // Mouse cursor feedback
15030
+ object.clickInfo.x = e.getX();
15031
+ object.clickInfo.y = e.getY();
15032
+ object.clickInfo.modifiers = e.getModifiersEx();
15033
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
15034
+ object.clickInfo.pane = this;
15035
+ object.clickInfo.camera = renderCamera;
1479115036 if (!isRenderer)
1479215037 {
1479315038 //ObjEditor editWindow = object.editWindow;
1479415039 //Object3D copy = editWindow.copy;
14795
- if (object.doEditClick(ci, 0))
15040
+ if (object.doEditClick(//clickInfo,
15041
+ 0))
1479615042 {
1479715043 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1479815044 } else
....@@ -15075,8 +15321,8 @@
1507515321 case 'K':
1507615322 KOMPACTTEXTURE ^= true;
1507715323 //textures.clear();
15078
- break;
15079
- case 'P': // Texture Projection macros
15324
+ // break;
15325
+ //case 'P': // Texture Projection macros
1508015326 // SAVETEXTURE ^= true;
1508115327 macromode = true;
1508215328 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -15197,7 +15443,7 @@
1519715443 targetLookAt.set(manipCamera.lookAt);
1519815444 repaint();
1519915445 break;
15200
- case 'p':
15446
+ case 'P': // p':
1520115447 // c'est quoi ca au juste? spherical ^= true;
1520215448 Skinshader ^= true; programInitialized = false;
1520315449 repaint();
....@@ -15242,20 +15488,24 @@
1524215488 OCCLUSION_CULLING ^= true;
1524315489 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1524415490 break;
15245
- case '0': envyoff ^= true; repaint(); break;
15491
+ //case '0': envyoff ^= true; repaint(); break;
1524615492 case '1':
1524715493 case '2':
1524815494 case '3':
1524915495 case '4':
1525015496 case '5':
15251
- newenvy = Character.getNumericValue(key);
15252
- repaint();
15253
- break;
1525415497 case '6':
1525515498 case '7':
1525615499 case '8':
1525715500 case '9':
15258
- BGcolor = (key - '6')/3.f;
15501
+ if (true) // envyoff)
15502
+ {
15503
+ BGcolor = (key - '1')/8.f;
15504
+ }
15505
+ else
15506
+ {
15507
+ //newenvy = Character.getNumericValue(key);
15508
+ }
1525915509 repaint();
1526015510 break;
1526115511 case '!':
....@@ -15818,8 +16068,6 @@
1581816068
1581916069 int width = getBounds().width;
1582016070 int height = getBounds().height;
15821
- ClickInfo info = new ClickInfo();
15822
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1582316071 //Image img = CreateImage(width, height);
1582416072 //System.out.println("width = " + width + "; height = " + height + "\n");
1582516073
....@@ -15896,31 +16144,37 @@
1589616144 }
1589716145 if (object != null && !hasMarquee)
1589816146 {
16147
+ if (object.clickInfo == null)
16148
+ object.clickInfo = new ClickInfo();
16149
+ ClickInfo info = object.clickInfo;
16150
+ //ClickInfo info = new ClickInfo();
16151
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
16152
+
1589916153 if (isRenderer)
1590016154 {
15901
- info.flags++;
16155
+ object.clickInfo.flags++;
1590216156 double frameAspect = (double) width / (double) height;
1590316157 if (frameAspect > renderCamera.aspect)
1590416158 {
1590516159 int desired = (int) ((double) height * renderCamera.aspect);
15906
- info.bounds.width -= width - desired;
15907
- info.bounds.x += (width - desired) / 2;
16160
+ object.clickInfo.bounds.width -= width - desired;
16161
+ object.clickInfo.bounds.x += (width - desired) / 2;
1590816162 } else
1590916163 {
1591016164 int desired = (int) ((double) width / renderCamera.aspect);
15911
- info.bounds.height -= height - desired;
15912
- info.bounds.y += (height - desired) / 2;
16165
+ object.clickInfo.bounds.height -= height - desired;
16166
+ object.clickInfo.bounds.y += (height - desired) / 2;
1591316167 }
1591416168 }
1591516169
15916
- info.g = gr;
15917
- info.camera = renderCamera;
16170
+ object.clickInfo.g = gr;
16171
+ object.clickInfo.camera = renderCamera;
1591816172 /*
1591916173 // Memory intensive (brep.verticescopy)
1592016174 if (!(object instanceof Composite))
1592116175 object.draw(info, 0, false); // SLOW :
1592216176 */
15923
- if (!isRenderer)
16177
+ if (!isRenderer) // && drag)
1592416178 {
1592516179 Grafreed.Assert(object != null);
1592616180 Grafreed.Assert(object.selection != null);
....@@ -15928,9 +16182,9 @@
1592816182 {
1592916183 int hitSomething = object.selection.get(0).hitSomething;
1593016184
15931
- info.DX = 0;
15932
- info.DY = 0;
15933
- info.W = 1;
16185
+ object.clickInfo.DX = 0;
16186
+ object.clickInfo.DY = 0;
16187
+ object.clickInfo.W = 1;
1593416188 if (hitSomething == Object3D.hitCenter)
1593516189 {
1593616190 info.DX = X;
....@@ -15942,13 +16196,14 @@
1594216196 info.DY -= info.bounds.height/2;
1594316197 }
1594416198
15945
- object.drawEditHandles(info, 0);
16199
+ object.drawEditHandles(//info,
16200
+ 0);
1594616201
1594716202 if (drag && (X != 0 || Y != 0))
1594816203 {
1594916204 switch (hitSomething)
1595016205 {
15951
- case Object3D.hitCenter: gr.setColor(Color.pink);
16206
+ case Object3D.hitCenter: gr.setColor(Color.white);
1595216207 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1595316208 break;
1595416209 case Object3D.hitRotate: gr.setColor(Color.yellow);
....@@ -15974,7 +16229,7 @@
1597416229 if (hasMarquee)
1597516230 {
1597616231 gr.setXORMode(Color.white);
15977
- gr.setColor(Color.red);
16232
+ gr.setColor(Color.white);
1597816233 if (!firstime)
1597916234 {
1598016235 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16441,6 +16696,8 @@
1644116696 private /*static*/ boolean firstime;
1644216697 private /*static*/ cVector newView = new cVector();
1644316698 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16699
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16700
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1644416701 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1644516702 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1644616703 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16453,29 +16710,67 @@
1645316710 {
1645416711 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1645516712
16713
+ int usedsuf = 0;
16714
+
1645616715 for (int i = 0; i < suffixes.length; i++)
1645716716 {
16458
- String resourceName = basename + suffixes[i] + "." + suffix;
16459
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16460
- mipmapped,
16461
- FileUtil.getFileSuffix(resourceName));
16462
- if (data == null)
16717
+ String[] suffixe = suffixes;
16718
+ String[] fallback = suffixes2;
16719
+ String[] fallfallback = suffixes3;
16720
+
16721
+ for (int c=usedsuf; --c>=0;)
1646316722 {
16464
- throw new IOException("Unable to load texture " + resourceName);
16723
+// String[] temp = suffixe;
16724
+// suffixe = fallback;
16725
+// fallback = fallfallback;
16726
+// fallfallback = temp;
1646516727 }
16728
+
16729
+ String resourceName = basename + suffixe[i] + "." + suffix;
16730
+ TextureData data;
16731
+
16732
+ try
16733
+ {
16734
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16735
+ mipmapped,
16736
+ FileUtil.getFileSuffix(resourceName));
16737
+ }
16738
+ catch (Exception e)
16739
+ {
16740
+ try
16741
+ {
16742
+ resourceName = basename + fallback[i] + "." + suffix;
16743
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16744
+ mipmapped,
16745
+ FileUtil.getFileSuffix(resourceName));
16746
+ }
16747
+ catch (Exception e2)
16748
+ {
16749
+ resourceName = basename + fallfallback[i] + "." + suffix;
16750
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16751
+ mipmapped,
16752
+ FileUtil.getFileSuffix(resourceName));
16753
+ }
16754
+ }
16755
+
1646616756 //System.out.println("Target = " + targets[i]);
1646716757 cubemap.updateImage(data, targets[i]);
1646816758 }
1646916759
1647016760 return cubemap;
1647116761 }
16762
+
1647216763 int bigsphere = -1;
1647316764
1647416765 float BGcolor = 0.5f;
1647516766
16476
- private void DrawSkyBox(GL gl)
16767
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16768
+
16769
+ private void DrawSkyBox(GL gl, float ratio)
1647716770 {
16478
- if (envyoff || cubemap == null)
16771
+ if (//envyoff ||
16772
+ WIREFRAME ||
16773
+ cubemap == null)
1647916774 {
1648016775 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1648116776 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16490,7 +16785,17 @@
1649016785 // Compensates for ExaminerViewer's modification of modelview matrix
1649116786 gl.glMatrixMode(GL.GL_MODELVIEW);
1649216787 gl.glLoadIdentity();
16788
+ gl.glScalef(1,ratio,1);
1649316789
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);
16798
+
1649416799 //gl.glActiveTexture(GL.GL_TEXTURE1);
1649516800 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1649616801
....@@ -16522,6 +16827,7 @@
1652216827 {
1652316828 gl.glScalef(1.0f, -1.0f, 1.0f);
1652416829 }
16830
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1652516831 gl.glMultMatrixd(viewrot_1, 0);
1652616832 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1652716833 //viewer.updateInverseRotation(gl);
....@@ -16562,7 +16868,8 @@
1656216868 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1656316869
1656416870 cubemap.disable();
16565
- ////cubemap.unbind();
16871
+ //cubemap.dispose();
16872
+
1656616873 if (CULLFACE)
1656716874 {
1656816875 gl.glEnable(gl.GL_CULL_FACE);
....@@ -16780,7 +17087,7 @@
1678017087 //new Exception().printStackTrace();
1678117088 System.out.println("select buffer init");
1678217089 // Use debug pipeline
16783
- drawable.setGL(new DebugGL(drawable.getGL()));
17090
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1678417091
1678517092 GL gl = drawable.getGL();
1678617093
....@@ -17098,6 +17405,7 @@
1709817405
1709917406 public void init(GLAutoDrawable drawable)
1710017407 {
17408
+ if (Globals.DEBUG)
1710117409 System.out.println("shadow buffer init");
1710217410
1710317411 GL gl = drawable.getGL();
....@@ -17326,10 +17634,14 @@
1732617634 gl.glFlush();
1732717635
1732817636 /**/
17329
- 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);
1733017638
17331
- float[] pixels = occlusionsizebuffer.array();
17639
+ float[] depths = occlusiondepthbuffer.array();
1733217640
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
+
1733317645 double r = 0, g = 0, b = 0;
1733417646
1733517647 double count = 0;
....@@ -17340,7 +17652,7 @@
1734017652
1734117653 double FACTOR = 1;
1734217654
17343
- for (int i = 0; i < pixels.length; i++)
17655
+ for (int i = 0; i < depths.length; i++)
1734417656 {
1734517657 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1734617658 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17423,7 +17735,7 @@
1742317735
1742417736 double scale = ray.z; // 1; // cos
1742517737
17426
- float depth = pixels[newindex];
17738
+ float depth = depths[newindex];
1742717739
1742817740 /*
1742917741 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17620,11 +17932,14 @@
1762017932 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1762117933 static IntBuffer bigAAbuffer;
1762217934 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17623
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17935
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1762417936 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1762517937 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1762617938 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17627
- 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
+
1762817943 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1762917944 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1763017945 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();