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,50 +12498,74 @@
1239912498
1240012499 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240112500
12402
- String program =
12501
+ String programmin =
1240312502 // Min shader
1240412503 "!!ARBfp1.0\n" +
12405
- "PARAM zero123 = { 0.0, 1.0, 2.0, 3.0 };" +
12504
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
1240612505 "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
1240712506 "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1240812507 "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
1240912508 "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];" +
1241012512 "TEMP temp;" +
1241112513 "TEMP light;" +
1241212514 "TEMP ndotl;" +
1241312515 "TEMP normal;" +
1241412516 "TEMP depth;" +
12517
+ "TEMP eye;" +
12518
+ "TEMP pos;" +
1241512519
1241612520 "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12417
-
12521
+ Normalize("normal") +
1241812522 "MOV light, state.light[0].position;" +
1241912523 "DP3 ndotl.x, light, normal;" +
1242012524
1242112525 // shadow
12422
- "MOV temp, fragment.texcoord[1];" +
12423
- TextureFetch("depth", "temp", "1") +
12526
+ "MOV pos, fragment.texcoord[1];" +
12527
+ "MOV temp, pos;" +
12528
+ ShadowTextureFetch("depth", "temp", "1") +
1242412529 //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12425
- "SLT temp.x, fragment.texcoord[1].z, depth.z;" +
12426
-
12530
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
1242712531
1242812532 // No shadow when out of frustum
1242912533 //"SGE temp.y, depth.z, zero123.y;" +
1243012534 //"LRP temp.x, temp.y, zero123.y, temp.x;" +
1243112535
12432
- "MUL ndotl.x, ndotl.x, temp.x;" +
12433
- "MAX ndotl.x, ndotl.x, pow2.y;" +
12536
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
1243412537
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
1243512556 "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12557
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
1243612558 "MUL temp, temp, ndotl.x;" +
1243712559
1243812560 "MUL temp, temp, zero123.z;" +
1243912561
12440
- "MOV temp.w, zero123.y;" + // reset alpha
12562
+ //"MUL temp, temp, ndotl.y;" +
1244112563
12564
+ "MOV temp.w, zero123.y;" + // reset alpha
1244212565 "MOV result.color, temp;" +
1244312566 "END";
1244412567
12445
- String program2 =
12568
+ String programmax =
1244612569 "!!ARBfp1.0\n" +
1244712570
1244812571 //"OPTION ARB_fragment_program_shadow;" +
....@@ -12470,7 +12593,7 @@
1247012593 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1247112594 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1247212595 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
12473
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12596
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1247412597 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1247512598 "PARAM options1 = program.env[62];" + // fog rgb color
1247612599 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -12580,20 +12703,20 @@
1258012703 "MUL temp, floor, mapgrid.x;" +
1258112704 //"TEX depth0, temp, texture[1], 2D;" +
1258212705 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12583
- TextureFetch("depth0", "temp", "1") +
12706
+ ShadowTextureFetch("depth0", "temp", "1") +
1258412707 "") +
1258512708 "ADD temp.x, temp.x, mapgrid.x;" +
1258612709 //"TEX depth1, temp, texture[1], 2D;" +
1258712710 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12588
- TextureFetch("depth1", "temp", "1") +
12711
+ ShadowTextureFetch("depth1", "temp", "1") +
1258912712 "") +
1259012713 "ADD temp.y, temp.y, mapgrid.x;" +
1259112714 //"TEX depth2, temp, texture[1], 2D;" +
12592
- TextureFetch("depth2", "temp", "1") +
12715
+ ShadowTextureFetch("depth2", "temp", "1") +
1259312716 "SUB temp.x, temp.x, mapgrid.x;" +
1259412717 //"TEX depth3, temp, texture[1], 2D;" +
1259512718 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12596
- TextureFetch("depth3", "temp", "1") +
12719
+ ShadowTextureFetch("depth3", "temp", "1") +
1259712720 "") +
1259812721 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1259912722 //"MOV params, material;" +
....@@ -12715,7 +12838,7 @@
1271512838 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1271612839 // mar 2013 ??? "KIL alpha.a;" +
1271712840 "MOV alpha, texSamp.aaaa;" + // y;" +
12718
- "KIL alpha.a;" +
12841
+ "KIL alpha.a;" + // not sure with parallax mapping
1271912842 /*
1272012843 "MUL temp.xy, temp, two;" +
1272112844 "TXB bump, temp, texture[0], 2D;" +
....@@ -12801,11 +12924,6 @@
1280112924 "SUB bump0, bump0, half;" +
1280212925 "ADD bump, bump, bump0;" +
1280312926
12804
- "MOV temp.x, texSamp.a;" +
12805
- "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12806
- //"LRP texSamp0, params5.x, texSamp0, one;" +
12807
- "MOV texSamp.a, temp.x;" +
12808
-
1280912927 // double-sided
1281012928 /**/
1281112929 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -12835,6 +12953,41 @@
1283512953 Normalize("U") +
1283612954
1283712955 // 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;" +
1283812991
1283912992 //"MOV temp, fragment.texcoord[0];" +
1284012993 //
....@@ -12967,7 +13120,7 @@
1296713120 // display shadow only (fakedepth == 0)
1296813121 "SUB temp.x, half.x, shadow.x;" +
1296913122 "MOV temp.y, -params5.z;" + // params6.x;" +
12970
- "SLT temp.z, temp.y, -one2048th.x;" +
13123
+ "SLT temp.z, temp.y, -c256i.x;" +
1297113124 "SUB temp.y, one.x, temp.z;" +
1297213125 "MUL temp.x, temp.x, temp.y;" +
1297313126 "KIL temp.x;" +
....@@ -13298,8 +13451,19 @@
1329813451 //once = true;
1329913452 }
1330013453
13301
- System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13302
- 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
+
1330313467 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1330413468
1330513469 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13346,7 +13510,8 @@
1334613510 "\n" +
1334713511 "END\n";
1334813512
13349
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13513
+ if (Globals.DEBUG)
13514
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1335013515 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1335113516
1335213517 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13391,25 +13556,26 @@
1339113556 return out;
1339213557 }
1339313558
13394
- String TextureFetch(String dest, String src, String unit)
13559
+ // Also does frustum culling
13560
+ String ShadowTextureFetch(String dest, String src, String unit)
1339513561 {
1339613562 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1339713563 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1339813564 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13565
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13566
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1339913567 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13400
- "SLT " + src + ".z, " + src + ".x, one.x;" +
13401
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13402
- "SLT " + src + ".z, " + src + ".y, one.x;" +
13403
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13568
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13569
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1340413570 //"SWZ buffer, temp, w,w,w,w;";
13405
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13571
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1340613572 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1340713573 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1340813574 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13409
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13575
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1341013576
13411
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13412
- //"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;";
1341313579 }
1341413580
1341513581 String Shadow(String depth, String shadow)
....@@ -13603,7 +13769,7 @@
1360313769 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1360413770 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1360513771 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
13606
- /*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
1360713773
1360813774 //Object3D.cVector2[] vector2buffer;
1360913775
....@@ -14254,14 +14420,15 @@
1425414420 drag = false;
1425514421 //System.out.println("Mouse DOWN");
1425614422 editObj = false;
14257
- ClickInfo info = new ClickInfo();
14258
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14259
- info.pane = this;
14260
- info.camera = renderCamera;
14261
- info.x = x;
14262
- info.y = y;
14263
- info.modifiers = modifiersex;
14264
- 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);
1426514432 if (!editObj)
1426614433 {
1426714434 hasMarquee = true;
....@@ -14543,11 +14710,17 @@
1454314710 void GoDown(int mod)
1454414711 {
1454514712 MODIFIERS |= COMMAND;
14713
+ boolean isVR = (mouseMode&VR)!=0;
1454614714 /**/
1454714715 if((mod&SHIFT) == SHIFT)
14548
- manipCamera.RotatePosition(0, -speed);
14716
+ {
14717
+ if (isVR)
14718
+ manipCamera.RotateInterest(0, -speed);
14719
+ else
14720
+ manipCamera.RotatePosition(0, -speed);
14721
+ }
1454914722 else
14550
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14723
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1455114724 /**/
1455214725 if ((mod & SHIFT) == SHIFT)
1455314726 {
....@@ -14557,6 +14730,8 @@
1455714730 mouseMode |= BACKFORTH;
1455814731 }
1455914732
14733
+ targetLookAt.set(manipCamera.lookAt);
14734
+
1456014735 //prevX = X = anchorX;
1456114736 prevY = Y = anchorY - (int) (renderCamera.Distance());
1456214737 }
....@@ -14565,10 +14740,17 @@
1456514740 {
1456614741 MODIFIERS |= COMMAND;
1456714742 /**/
14743
+ boolean isVR = (mouseMode&VR)!=0;
14744
+
1456814745 if((mod&SHIFT) == SHIFT)
14569
- manipCamera.RotatePosition(0, speed);
14746
+ {
14747
+ if (isVR)
14748
+ manipCamera.RotateInterest(0, speed);
14749
+ else
14750
+ manipCamera.RotatePosition(0, speed);
14751
+ }
1457014752 else
14571
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14753
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1457214754 /**/
1457314755 if ((mod & SHIFT) == SHIFT)
1457414756 {
....@@ -14578,6 +14760,8 @@
1457814760 mouseMode |= BACKFORTH;
1457914761 }
1458014762
14763
+ targetLookAt.set(manipCamera.lookAt);
14764
+
1458114765 //prevX = X = anchorX;
1458214766 prevY = Y = anchorY + (int) (renderCamera.Distance());
1458314767 }
....@@ -14587,9 +14771,14 @@
1458714771 MODIFIERS |= COMMAND;
1458814772 /**/
1458914773 if((mod&SHIFT) == SHIFT)
14590
- manipCamera.Translate(speed*delta, 0, getWidth());
14774
+ manipCamera.Translate(speed*delta, 0, getWidth());
1459114775 else
14592
- manipCamera.RotatePosition(speed, 0);
14776
+ {
14777
+ if ((mouseMode&VR)!=0)
14778
+ manipCamera.RotateInterest(-speed, 0);
14779
+ else
14780
+ manipCamera.RotatePosition(speed, 0);
14781
+ }
1459314782 /**/
1459414783 if ((mod & SHIFT) == SHIFT)
1459514784 {
....@@ -14599,6 +14788,8 @@
1459914788 mouseMode |= ROTATE;
1460014789 } // TRANSLATE;
1460114790
14791
+ targetLookAt.set(manipCamera.lookAt);
14792
+
1460214793 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1460314794 prevY = Y = anchorY;
1460414795 }
....@@ -14608,9 +14799,15 @@
1460814799 MODIFIERS |= COMMAND;
1460914800 /**/
1461014801 if((mod&SHIFT) == SHIFT)
14611
- manipCamera.Translate(-speed*delta, 0, getWidth());
14802
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1461214803 else
14613
- manipCamera.RotatePosition(-speed, 0);
14804
+ {
14805
+ if ((mouseMode&VR)!=0)
14806
+ manipCamera.RotateInterest(speed, 0);
14807
+ else
14808
+ manipCamera.RotatePosition(-speed, 0);
14809
+ }
14810
+
1461414811 /**/
1461514812 if ((mod & SHIFT) == SHIFT)
1461614813 {
....@@ -14620,6 +14817,8 @@
1462014817 mouseMode |= ROTATE;
1462114818 } // TRANSLATE;
1462214819
14820
+ targetLookAt.set(manipCamera.lookAt);
14821
+
1462314822 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1462414823 prevY = Y = anchorY;
1462514824 }
....@@ -14661,15 +14860,16 @@
1466114860 if (editObj)
1466214861 {
1466314862 drag = true;
14664
- ClickInfo info = new ClickInfo();
14665
- info.bounds.setBounds(0, 0,
14863
+ //ClickInfo info = new ClickInfo();
14864
+ object.clickInfo.bounds.setBounds(0, 0,
1466614865 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14667
- info.pane = this;
14668
- info.camera = renderCamera;
14669
- info.x = x;
14670
- info.y = y;
14671
- object.GetWindow().copy
14672
- .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);
1467314873 } else
1467414874 {
1467514875 if (x < startX)
....@@ -14818,24 +15018,27 @@
1481815018 }
1481915019 }
1482015020
15021
+// ClickInfo clickInfo = new ClickInfo();
15022
+
1482115023 public void mouseMoved(MouseEvent e)
1482215024 {
1482315025 //System.out.println("mouseMoved: " + e);
1482415026 if (isRenderer)
1482515027 return;
1482615028
14827
- ClickInfo ci = new ClickInfo();
14828
- ci.x = e.getX();
14829
- ci.y = e.getY();
14830
- ci.modifiers = e.getModifiersEx();
14831
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14832
- ci.pane = this;
14833
- 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;
1483415036 if (!isRenderer)
1483515037 {
1483615038 //ObjEditor editWindow = object.editWindow;
1483715039 //Object3D copy = editWindow.copy;
14838
- if (object.doEditClick(ci, 0))
15040
+ if (object.doEditClick(//clickInfo,
15041
+ 0))
1483915042 {
1484015043 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1484115044 } else
....@@ -15118,8 +15321,8 @@
1511815321 case 'K':
1511915322 KOMPACTTEXTURE ^= true;
1512015323 //textures.clear();
15121
- break;
15122
- case 'P': // Texture Projection macros
15324
+ // break;
15325
+ //case 'P': // Texture Projection macros
1512315326 // SAVETEXTURE ^= true;
1512415327 macromode = true;
1512515328 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -15240,7 +15443,7 @@
1524015443 targetLookAt.set(manipCamera.lookAt);
1524115444 repaint();
1524215445 break;
15243
- case 'p':
15446
+ case 'P': // p':
1524415447 // c'est quoi ca au juste? spherical ^= true;
1524515448 Skinshader ^= true; programInitialized = false;
1524615449 repaint();
....@@ -15285,20 +15488,24 @@
1528515488 OCCLUSION_CULLING ^= true;
1528615489 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1528715490 break;
15288
- case '0': envyoff ^= true; repaint(); break;
15491
+ //case '0': envyoff ^= true; repaint(); break;
1528915492 case '1':
1529015493 case '2':
1529115494 case '3':
1529215495 case '4':
1529315496 case '5':
15294
- newenvy = Character.getNumericValue(key);
15295
- repaint();
15296
- break;
1529715497 case '6':
1529815498 case '7':
1529915499 case '8':
1530015500 case '9':
15301
- 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
+ }
1530215509 repaint();
1530315510 break;
1530415511 case '!':
....@@ -15861,8 +16068,6 @@
1586116068
1586216069 int width = getBounds().width;
1586316070 int height = getBounds().height;
15864
- ClickInfo info = new ClickInfo();
15865
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1586616071 //Image img = CreateImage(width, height);
1586716072 //System.out.println("width = " + width + "; height = " + height + "\n");
1586816073
....@@ -15939,31 +16144,37 @@
1593916144 }
1594016145 if (object != null && !hasMarquee)
1594116146 {
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
+
1594216153 if (isRenderer)
1594316154 {
15944
- info.flags++;
16155
+ object.clickInfo.flags++;
1594516156 double frameAspect = (double) width / (double) height;
1594616157 if (frameAspect > renderCamera.aspect)
1594716158 {
1594816159 int desired = (int) ((double) height * renderCamera.aspect);
15949
- info.bounds.width -= width - desired;
15950
- info.bounds.x += (width - desired) / 2;
16160
+ object.clickInfo.bounds.width -= width - desired;
16161
+ object.clickInfo.bounds.x += (width - desired) / 2;
1595116162 } else
1595216163 {
1595316164 int desired = (int) ((double) width / renderCamera.aspect);
15954
- info.bounds.height -= height - desired;
15955
- info.bounds.y += (height - desired) / 2;
16165
+ object.clickInfo.bounds.height -= height - desired;
16166
+ object.clickInfo.bounds.y += (height - desired) / 2;
1595616167 }
1595716168 }
1595816169
15959
- info.g = gr;
15960
- info.camera = renderCamera;
16170
+ object.clickInfo.g = gr;
16171
+ object.clickInfo.camera = renderCamera;
1596116172 /*
1596216173 // Memory intensive (brep.verticescopy)
1596316174 if (!(object instanceof Composite))
1596416175 object.draw(info, 0, false); // SLOW :
1596516176 */
15966
- if (!isRenderer)
16177
+ if (!isRenderer) // && drag)
1596716178 {
1596816179 Grafreed.Assert(object != null);
1596916180 Grafreed.Assert(object.selection != null);
....@@ -15971,9 +16182,9 @@
1597116182 {
1597216183 int hitSomething = object.selection.get(0).hitSomething;
1597316184
15974
- info.DX = 0;
15975
- info.DY = 0;
15976
- info.W = 1;
16185
+ object.clickInfo.DX = 0;
16186
+ object.clickInfo.DY = 0;
16187
+ object.clickInfo.W = 1;
1597716188 if (hitSomething == Object3D.hitCenter)
1597816189 {
1597916190 info.DX = X;
....@@ -15985,13 +16196,14 @@
1598516196 info.DY -= info.bounds.height/2;
1598616197 }
1598716198
15988
- object.drawEditHandles(info, 0);
16199
+ object.drawEditHandles(//info,
16200
+ 0);
1598916201
1599016202 if (drag && (X != 0 || Y != 0))
1599116203 {
1599216204 switch (hitSomething)
1599316205 {
15994
- case Object3D.hitCenter: gr.setColor(Color.pink);
16206
+ case Object3D.hitCenter: gr.setColor(Color.white);
1599516207 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1599616208 break;
1599716209 case Object3D.hitRotate: gr.setColor(Color.yellow);
....@@ -16017,7 +16229,7 @@
1601716229 if (hasMarquee)
1601816230 {
1601916231 gr.setXORMode(Color.white);
16020
- gr.setColor(Color.red);
16232
+ gr.setColor(Color.white);
1602116233 if (!firstime)
1602216234 {
1602316235 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16484,6 +16696,8 @@
1648416696 private /*static*/ boolean firstime;
1648516697 private /*static*/ cVector newView = new cVector();
1648616698 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"};
1648716701 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1648816702 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1648916703 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16496,29 +16710,67 @@
1649616710 {
1649716711 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1649816712
16713
+ int usedsuf = 0;
16714
+
1649916715 for (int i = 0; i < suffixes.length; i++)
1650016716 {
16501
- String resourceName = basename + suffixes[i] + "." + suffix;
16502
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16503
- mipmapped,
16504
- FileUtil.getFileSuffix(resourceName));
16505
- if (data == null)
16717
+ String[] suffixe = suffixes;
16718
+ String[] fallback = suffixes2;
16719
+ String[] fallfallback = suffixes3;
16720
+
16721
+ for (int c=usedsuf; --c>=0;)
1650616722 {
16507
- throw new IOException("Unable to load texture " + resourceName);
16723
+// String[] temp = suffixe;
16724
+// suffixe = fallback;
16725
+// fallback = fallfallback;
16726
+// fallfallback = temp;
1650816727 }
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
+
1650916756 //System.out.println("Target = " + targets[i]);
1651016757 cubemap.updateImage(data, targets[i]);
1651116758 }
1651216759
1651316760 return cubemap;
1651416761 }
16762
+
1651516763 int bigsphere = -1;
1651616764
1651716765 float BGcolor = 0.5f;
1651816766
16519
- private void DrawSkyBox(GL gl)
16767
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16768
+
16769
+ private void DrawSkyBox(GL gl, float ratio)
1652016770 {
16521
- if (envyoff || cubemap == null)
16771
+ if (//envyoff ||
16772
+ WIREFRAME ||
16773
+ cubemap == null)
1652216774 {
1652316775 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1652416776 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16533,7 +16785,17 @@
1653316785 // Compensates for ExaminerViewer's modification of modelview matrix
1653416786 gl.glMatrixMode(GL.GL_MODELVIEW);
1653516787 gl.glLoadIdentity();
16788
+ gl.glScalef(1,ratio,1);
1653616789
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
+
1653716799 //gl.glActiveTexture(GL.GL_TEXTURE1);
1653816800 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1653916801
....@@ -16565,6 +16827,7 @@
1656516827 {
1656616828 gl.glScalef(1.0f, -1.0f, 1.0f);
1656716829 }
16830
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1656816831 gl.glMultMatrixd(viewrot_1, 0);
1656916832 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1657016833 //viewer.updateInverseRotation(gl);
....@@ -16605,7 +16868,8 @@
1660516868 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1660616869
1660716870 cubemap.disable();
16608
- ////cubemap.unbind();
16871
+ //cubemap.dispose();
16872
+
1660916873 if (CULLFACE)
1661016874 {
1661116875 gl.glEnable(gl.GL_CULL_FACE);
....@@ -16823,7 +17087,7 @@
1682317087 //new Exception().printStackTrace();
1682417088 System.out.println("select buffer init");
1682517089 // Use debug pipeline
16826
- drawable.setGL(new DebugGL(drawable.getGL()));
17090
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1682717091
1682817092 GL gl = drawable.getGL();
1682917093
....@@ -17141,6 +17405,7 @@
1714117405
1714217406 public void init(GLAutoDrawable drawable)
1714317407 {
17408
+ if (Globals.DEBUG)
1714417409 System.out.println("shadow buffer init");
1714517410
1714617411 GL gl = drawable.getGL();
....@@ -17369,10 +17634,14 @@
1736917634 gl.glFlush();
1737017635
1737117636 /**/
17372
- 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);
1737317638
17374
- float[] pixels = occlusionsizebuffer.array();
17639
+ float[] depths = occlusiondepthbuffer.array();
1737517640
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
+
1737617645 double r = 0, g = 0, b = 0;
1737717646
1737817647 double count = 0;
....@@ -17383,7 +17652,7 @@
1738317652
1738417653 double FACTOR = 1;
1738517654
17386
- for (int i = 0; i < pixels.length; i++)
17655
+ for (int i = 0; i < depths.length; i++)
1738717656 {
1738817657 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1738917658 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17466,7 +17735,7 @@
1746617735
1746717736 double scale = ray.z; // 1; // cos
1746817737
17469
- float depth = pixels[newindex];
17738
+ float depth = depths[newindex];
1747017739
1747117740 /*
1747217741 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17663,11 +17932,14 @@
1766317932 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1766417933 static IntBuffer bigAAbuffer;
1766517934 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17666
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17935
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1766717936 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1766817937 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1766917938 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17670
- 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
+
1767117943 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1767217944 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1767317945 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();