Normand Briere
2019-08-22 6a145f6c81dfcbe0653eda27d042efb48daa7512
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
....@@ -524,7 +542,8 @@
524542 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
525543 LA.vecCross(obj.v0, obj.v1, obj.v2);
526544 LA.vecNormalize(obj.v2);
527
- gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
545
+
546
+ SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
528547 }
529548
530549 // P
....@@ -546,7 +565,7 @@
546565 y += ny * obj.NORMALPUSH;
547566 z += nz * obj.NORMALPUSH;
548567
549
- gl.glNormal3f(nx, ny, nz);
568
+ SetGLNormal(gl, nx, ny, nz);
550569 }
551570 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
552571 SetColor(obj, pv);
....@@ -578,7 +597,7 @@
578597 y += ny * obj.NORMALPUSH;
579598 z += nz * obj.NORMALPUSH;
580599
581
- gl.glNormal3f(nx, ny, nz);
600
+ SetGLNormal(gl, nx, ny, nz);
582601 }
583602 //System.out.println("vertexq = " + qv.s + ", " + qv.t);
584603 // boolean locked = false;
....@@ -626,7 +645,7 @@
626645 y += ny * obj.NORMALPUSH;
627646 z += nz * obj.NORMALPUSH;
628647
629
- gl.glNormal3f(nx, ny, nz);
648
+ SetGLNormal(gl, nx, ny, nz);
630649 }
631650
632651 // if ((dot&4) == 0)
....@@ -1232,10 +1251,10 @@
12321251 {
12331252 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12341253 {
1235
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1254
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12361255 } else
12371256 {
1238
- gl.glNormal3f(0, 0, 1);
1257
+ SetGLNormal(gl, 0, 0, 1);
12391258 }
12401259
12411260 if (c != null)
....@@ -1259,10 +1278,10 @@
12591278 {
12601279 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12611280 {
1262
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1281
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12631282 } else
12641283 {
1265
- gl.glNormal3f(0, 0, 1);
1284
+ SetGLNormal(gl, 0, 0, 1);
12661285 }
12671286 if (c != null)
12681287 {
....@@ -1287,10 +1306,10 @@
12871306 {
12881307 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12891308 {
1290
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1309
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12911310 } else
12921311 {
1293
- gl.glNormal3f(0, 0, 1);
1312
+ SetGLNormal(gl, 0, 0, 1);
12941313 }
12951314 if (c != null)
12961315 {
....@@ -1472,7 +1491,7 @@
14721491 {
14731492 if (!selectmode)
14741493 {
1475
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1494
+ SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
14761495 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
14771496
14781497 if (flipV)
....@@ -1484,6 +1503,8 @@
14841503 gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
14851504 }
14861505
1506
+ float[] colorV = new float[4];
1507
+
14871508 void SetColor(Object3D obj, Vertex p0)
14881509 {
14891510 CameraPane display = this;
....@@ -1551,8 +1572,6 @@
15511572 {
15521573 return;
15531574 }
1554
-
1555
- float[] colorV = new float[3];
15561575
15571576 if (false) // marked)
15581577 {
....@@ -1801,7 +1820,7 @@
18011820
18021821 display.modelParams7[0] = 0;
18031822 display.modelParams7[1] = 1000;
1804
- display.modelParams7[2] = 0;
1823
+ display.modelParams7[2] = material.parallax;
18051824 display.modelParams7[3] = 0;
18061825
18071826 //display.modelParams6[0] = 100; // criss de bug de bump
....@@ -2034,9 +2053,9 @@
20342053 switch(viewcode)
20352054 {
20362055 case 0: return "main";
2037
- case 1: return "one";
2038
- case 2: return "two";
2039
- case 3: return "three";
2056
+ case 1: return "Red";
2057
+ case 2: return "Green";
2058
+ case 3: return "Blue";
20402059 case 4: return "light";
20412060 }
20422061
....@@ -2457,6 +2476,18 @@
24572476 return CreateBim(bytes, width, height);
24582477 }
24592478
2479
+ private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz)
2480
+ {
2481
+ gl.glNormal3f(nx, ny, nz);
2482
+
2483
+ if (ny > 0.9 || ny < -0.9)
2484
+ // Ground or ceiling
2485
+ gl.glVertexAttrib3f(4, 1, 0, 0);
2486
+ else
2487
+ // Walls
2488
+ gl.glVertexAttrib3f(4, 0, 1, 0);
2489
+ }
2490
+
24602491 /**/
24612492 class CacheTexture
24622493 {
....@@ -2499,7 +2530,7 @@
24992530 com.sun.opengl.util.texture.TextureIO.newTextureData(
25002531 getClass().getClassLoader().getResourceAsStream(name),
25012532 true,
2502
- com.sun.opengl.util.texture.TextureIO.PNG);
2533
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
25032534 } catch (java.io.IOException e)
25042535 {
25052536 throw new javax.media.opengl.GLException(e);
....@@ -8345,7 +8376,7 @@
83458376 // else
83468377 // if (!texname.startsWith("/"))
83478378 // texname = "/Users/nbriere/Textures/" + texname;
8348
- if (!FileExists(texname))
8379
+ if (!FileExists(texname) && !texname.startsWith("@"))
83498380 {
83508381 texname = fallbackTextureName;
83518382 }
....@@ -8428,6 +8459,15 @@
84288459 new Exception().printStackTrace();
84298460 } else
84308461 {
8462
+ if (texname.startsWith("@"))
8463
+ {
8464
+ // texturecache = textures.get(texname); // suspicious
8465
+ if (texturecache == null)
8466
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8467
+ else
8468
+ new Exception().printStackTrace();
8469
+ } else
8470
+ {
84318471 if (textureon)
84328472 {
84338473 String cachename = texname;
....@@ -8487,6 +8527,7 @@
84878527 texturecache = new CacheTexture(texturedata,resolution);
84888528 //texture = GetTexture(tex, bump);
84898529 }
8530
+ }
84908531 }
84918532 //}
84928533 }
....@@ -8755,10 +8796,12 @@
87558796
87568797 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
87578798 MAXSTACK = temp[0];
8758
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8799
+ if (Globals.DEBUG)
8800
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
87598801 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
87608802 MAXSTACK = temp[0];
8761
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8803
+ if (Globals.DEBUG)
8804
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
87628805
87638806 // Use debug pipeline
87648807 //drawable.setGL(new DebugGL(gl)); //
....@@ -8766,7 +8809,8 @@
87668809 gl = drawable.getGL(); //
87678810
87688811 GL gl3 = getGL();
8769
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8812
+ if (Globals.DEBUG)
8813
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
87708814
87718815
87728816 //float pos[] = { 100, 100, 100, 0 };
....@@ -8931,7 +8975,7 @@
89318975
89328976 if (cubemap == null)
89338977 {
8934
- LoadEnvy(5);
8978
+ //LoadEnvy(1);
89358979 }
89368980
89378981 //cubemap.enable();
....@@ -9207,6 +9251,8 @@
92079251
92089252 void LoadEnvy(int which)
92099253 {
9254
+ assert(false);
9255
+
92109256 String name;
92119257 String ext;
92129258
....@@ -9218,37 +9264,58 @@
92189264 cubemap = null;
92199265 return;
92209266 case 1:
9221
- name = "cubemaps/box_";
9222
- ext = "png";
9267
+ name = "cubemaps/rgb/";
9268
+ ext = "jpg";
92239269 reverseUP = false;
92249270 break;
92259271 case 2:
9226
- name = "cubemaps/uffizi_";
9227
- ext = "png";
9228
- break; // reverseUP = true; break;
9272
+ name = "cubemaps/uffizi/";
9273
+ ext = "jpg";
9274
+ reverseUP = false;
9275
+ break;
92299276 case 3:
9230
- name = "cubemaps/CloudyHills_";
9231
- ext = "tga";
9277
+ name = "cubemaps/CloudyHills/";
9278
+ ext = "jpg";
92329279 reverseUP = false;
92339280 break;
92349281 case 4:
9235
- name = "cubemaps/cornell_";
9282
+ name = "cubemaps/cornell/";
92369283 ext = "png";
92379284 reverseUP = false;
92389285 break;
9286
+ case 5:
9287
+ name = "cubemaps/skycube/";
9288
+ ext = "jpg";
9289
+ reverseUP = false;
9290
+ break;
9291
+ case 6:
9292
+ name = "cubemaps/SaintLazarusChurch3/";
9293
+ ext = "jpg";
9294
+ reverseUP = false;
9295
+ break;
9296
+ case 7:
9297
+ name = "cubemaps/Sodermalmsallen/";
9298
+ ext = "jpg";
9299
+ reverseUP = false;
9300
+ break;
9301
+ case 8:
9302
+ name = "cubemaps/Sodermalmsallen2/";
9303
+ ext = "jpg";
9304
+ reverseUP = false;
9305
+ break;
9306
+ case 9:
9307
+ name = "cubemaps/UnionSquare/";
9308
+ ext = "jpg";
9309
+ reverseUP = false;
9310
+ break;
92399311 default:
9240
- name = "cubemaps/rgb_";
9241
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9312
+ name = "cubemaps/box/";
9313
+ ext = "png"; /*mipmap = true;*/
9314
+ reverseUP = false;
92429315 break;
92439316 }
9244
-
9245
- try
9246
- {
9247
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
9248
- } catch (IOException e)
9249
- {
9250
- throw new RuntimeException(e);
9251
- }
9317
+
9318
+ LoadSkybox(name, ext, mipmap);
92529319 }
92539320
92549321 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -9280,8 +9347,12 @@
92809347 static double[] model = new double[16];
92819348 double[] camera2light = new double[16];
92829349 double[] light2camera = new double[16];
9283
- int newenvy = -1;
9284
- boolean envyoff = true; // false;
9350
+
9351
+ //int newenvy = -1;
9352
+ //boolean envyoff = false;
9353
+
9354
+ String loadedskyboxname;
9355
+
92859356 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
92869357 //float[] light0 = { 0,0,0 };
92879358 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9699,7 +9770,7 @@
96999770
97009771 if (renderCamera != lightCamera)
97019772 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9702
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
9773
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
97039774
97049775 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
97059776
....@@ -9715,7 +9786,7 @@
97159786
97169787 if (renderCamera != lightCamera)
97179788 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9718
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
9789
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
97199790
97209791 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
97219792
....@@ -9761,10 +9832,12 @@
97619832 rati = 1 / rati;
97629833 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
97639834 }
9764
- assert (newenvy == -1);
9835
+
9836
+ //assert (newenvy == -1);
9837
+
97659838 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
97669839 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9767
- DrawSkyBox(gl);
9840
+ DrawSkyBox(gl, (float)rati);
97689841 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
97699842 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
97709843 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -10630,9 +10703,18 @@
1063010703 static boolean init = false;
1063110704
1063210705 double[][] matrix = LA.newMatrix();
10706
+
10707
+ // This is to refresh the UI of the material panel.
10708
+ ObjEditor patchMaterial;
1063310709
1063410710 public void display(GLAutoDrawable drawable)
1063510711 {
10712
+ if (patchMaterial.patchMaterial)
10713
+ {
10714
+ patchMaterial.patchMaterial = false;
10715
+ patchMaterial.objectPanel.setSelectedIndex(1);
10716
+ }
10717
+
1063610718 if (Grafreed.savesound && Grafreed.hassound)
1063710719 {
1063810720 Grafreed.wav.save();
....@@ -10801,7 +10883,7 @@
1080110883
1080210884 if (wait)
1080310885 {
10804
- Sleep(500);
10886
+ Sleep(200); // blocks everything
1080510887
1080610888 wait = false;
1080710889 }
....@@ -10916,7 +10998,7 @@
1091610998 // if (parentcam != renderCamera) // not a light
1091710999 if (cam != lightCamera)
1091811000 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10919
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
11001
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1092011002
1092111003 for (int j = 0; j < 4; j++)
1092211004 {
....@@ -10931,7 +11013,7 @@
1093111013 // if (parentcam != renderCamera) // not a light
1093211014 if (cam != lightCamera)
1093311015 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
11016
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1093511017
1093611018 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1093711019
....@@ -11017,13 +11099,43 @@
1101711099 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1101811100 }
1101911101
11020
- if (newenvy > -1)
11102
+// if (newenvy > -1)
11103
+// {
11104
+// LoadEnvy(newenvy);
11105
+// }
11106
+//
11107
+// newenvy = -1;
11108
+
11109
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1102111110 {
11022
- LoadEnvy(newenvy);
11111
+ if (cubemaprgb == null)
11112
+ {
11113
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
11114
+ }
11115
+
11116
+ cubemap = cubemaprgb;
1102311117 }
11024
-
11025
- newenvy = -1;
11026
-
11118
+ else
11119
+ {
11120
+ if (object.skyboxname != null)
11121
+ {
11122
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11123
+ {
11124
+ if (cubemap != null && cubemap != cubemaprgb)
11125
+ cubemap.dispose();
11126
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11127
+ loadedskyboxname = object.skyboxname;
11128
+ }
11129
+ }
11130
+ else
11131
+ {
11132
+ cubemapcustom = null;
11133
+ loadedskyboxname = null;
11134
+ }
11135
+
11136
+ cubemap = cubemapcustom;
11137
+ }
11138
+
1102711139 ratio = ((double) getWidth()) / getHeight();
1102811140 //System.out.println("ratio = " + ratio);
1102911141
....@@ -11039,7 +11151,7 @@
1103911151
1104011152 if (!IsFrozen() && !ambientOcclusion)
1104111153 {
11042
- DrawSkyBox(gl);
11154
+ DrawSkyBox(gl, (float)ratio);
1104311155 }
1104411156
1104511157 //if (selection_view == -1)
....@@ -11325,7 +11437,7 @@
1132511437
1132611438 // if (cam != lightCamera)
1132711439 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11328
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11440
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1132911441 }
1133011442
1133111443 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12399,50 +12511,74 @@
1239912511
1240012512 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240112513
12402
- String program =
12514
+ String programmin =
1240312515 // Min shader
1240412516 "!!ARBfp1.0\n" +
12405
- "PARAM zero123 = { 0.0, 1.0, 2.0, 3.0 };" +
12517
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
1240612518 "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
1240712519 "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1240812520 "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
1240912521 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12522
+ "PARAM light2cam0 = program.env[10];" +
12523
+ "PARAM light2cam1 = program.env[11];" +
12524
+ "PARAM light2cam2 = program.env[12];" +
1241012525 "TEMP temp;" +
1241112526 "TEMP light;" +
1241212527 "TEMP ndotl;" +
1241312528 "TEMP normal;" +
1241412529 "TEMP depth;" +
12530
+ "TEMP eye;" +
12531
+ "TEMP pos;" +
1241512532
1241612533 "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12417
-
12534
+ Normalize("normal") +
1241812535 "MOV light, state.light[0].position;" +
1241912536 "DP3 ndotl.x, light, normal;" +
1242012537
1242112538 // shadow
12422
- "MOV temp, fragment.texcoord[1];" +
12423
- TextureFetch("depth", "temp", "1") +
12539
+ "MOV pos, fragment.texcoord[1];" +
12540
+ "MOV temp, pos;" +
12541
+ ShadowTextureFetch("depth", "temp", "1") +
1242412542 //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12425
- "SLT temp.x, fragment.texcoord[1].z, depth.z;" +
12426
-
12543
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
1242712544
1242812545 // No shadow when out of frustum
1242912546 //"SGE temp.y, depth.z, zero123.y;" +
1243012547 //"LRP temp.x, temp.y, zero123.y, temp.x;" +
1243112548
12432
- "MUL ndotl.x, ndotl.x, temp.x;" +
12433
- "MAX ndotl.x, ndotl.x, pow2.y;" +
12549
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
1243412550
12551
+ // Backlit
12552
+ "MOV pos.w, zero123.y;" +
12553
+ "DP4 eye.x, pos, light2cam0;" +
12554
+ "DP4 eye.y, pos, light2cam1;" +
12555
+ "DP4 eye.z, pos, light2cam2;" +
12556
+ Normalize("eye") +
12557
+
12558
+ "DP3 ndotl.y, -eye, normal;" +
12559
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12560
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12561
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12562
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12563
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12564
+
12565
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12566
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12567
+
12568
+ // Pigment
1243512569 "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12570
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
1243612571 "MUL temp, temp, ndotl.x;" +
1243712572
1243812573 "MUL temp, temp, zero123.z;" +
1243912574
12440
- "MOV temp.w, zero123.y;" + // reset alpha
12575
+ //"MUL temp, temp, ndotl.y;" +
1244112576
12577
+ "MOV temp.w, zero123.y;" + // reset alpha
1244212578 "MOV result.color, temp;" +
1244312579 "END";
1244412580
12445
- String program2 =
12581
+ String programmax =
1244612582 "!!ARBfp1.0\n" +
1244712583
1244812584 //"OPTION ARB_fragment_program_shadow;" +
....@@ -12470,7 +12606,7 @@
1247012606 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1247112607 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1247212608 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
12473
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12609
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1247412610 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1247512611 "PARAM options1 = program.env[62];" + // fog rgb color
1247612612 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -12580,20 +12716,20 @@
1258012716 "MUL temp, floor, mapgrid.x;" +
1258112717 //"TEX depth0, temp, texture[1], 2D;" +
1258212718 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12583
- TextureFetch("depth0", "temp", "1") +
12719
+ ShadowTextureFetch("depth0", "temp", "1") +
1258412720 "") +
1258512721 "ADD temp.x, temp.x, mapgrid.x;" +
1258612722 //"TEX depth1, temp, texture[1], 2D;" +
1258712723 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12588
- TextureFetch("depth1", "temp", "1") +
12724
+ ShadowTextureFetch("depth1", "temp", "1") +
1258912725 "") +
1259012726 "ADD temp.y, temp.y, mapgrid.x;" +
1259112727 //"TEX depth2, temp, texture[1], 2D;" +
12592
- TextureFetch("depth2", "temp", "1") +
12728
+ ShadowTextureFetch("depth2", "temp", "1") +
1259312729 "SUB temp.x, temp.x, mapgrid.x;" +
1259412730 //"TEX depth3, temp, texture[1], 2D;" +
1259512731 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12596
- TextureFetch("depth3", "temp", "1") +
12732
+ ShadowTextureFetch("depth3", "temp", "1") +
1259712733 "") +
1259812734 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1259912735 //"MOV params, material;" +
....@@ -12715,7 +12851,7 @@
1271512851 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1271612852 // mar 2013 ??? "KIL alpha.a;" +
1271712853 "MOV alpha, texSamp.aaaa;" + // y;" +
12718
- "KIL alpha.a;" +
12854
+ "KIL alpha.a;" + // not sure with parallax mapping
1271912855 /*
1272012856 "MUL temp.xy, temp, two;" +
1272112857 "TXB bump, temp, texture[0], 2D;" +
....@@ -12801,11 +12937,6 @@
1280112937 "SUB bump0, bump0, half;" +
1280212938 "ADD bump, bump, bump0;" +
1280312939
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
-
1280912940 // double-sided
1281012941 /**/
1281112942 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -12822,19 +12953,62 @@
1282212953 "MOV normald, normal;" +
1282312954 "MOV normals, normal;" +
1282412955
12956
+ "MOV temp, fragment.texcoord[4];" +
12957
+
1282512958 // UV base
1282612959 //"DP3 UP.x,state.matrix.modelview.row[0],Y;" +
1282712960 //"DP3 UP.y,state.matrix.modelview.row[1],Y;" +
1282812961 //"DP3 UP.z,state.matrix.modelview.row[2],Y;" +
12829
- "DP3 UP.x,state.matrix.texture[7].row[0],Y;" +
12830
- "DP3 UP.y,state.matrix.texture[7].row[1],Y;" +
12831
- "DP3 UP.z,state.matrix.texture[7].row[2],Y;" +
12962
+ "DP3 UP.x,state.matrix.texture[7].row[0],temp;" +
12963
+ "DP3 UP.y,state.matrix.texture[7].row[1],temp;" +
12964
+ "DP3 UP.z,state.matrix.texture[7].row[2],temp;" +
12965
+ Normalize("UP") +
12966
+
1283212967 "XPD V, normal, UP;" +
1283312968 Normalize("V") +
1283412969 "XPD U, V, normal;" +
1283512970 Normalize("U") +
1283612971
1283712972 // parallax mapping
12973
+
12974
+ "DP3 temp2.x, V, eye;" +
12975
+ "DP3 temp2.y, U, eye;" +
12976
+ "DP3 temp2.z, normal, eye;" +
12977
+ "RCP temp2.z, temp2.z;" +
12978
+
12979
+ "DP3 temp2.w, texSamp, texSamp;" + // Height
12980
+ "RSQ temp2.w, temp2.w;" +
12981
+ "RCP temp2.w, temp2.w;" +
12982
+
12983
+ "SUB temp2.w, temp2.w, half;" +
12984
+// "SGE temp.x, temp2.w, eps.x;" +
12985
+// "MUL temp2.w, temp2.w, temp.x;" +
12986
+
12987
+ //"MOV texSamp, U;" +
12988
+
12989
+ "MUL temp2.z, temp2.z, temp2.w;" +
12990
+ "MUL temp2.z, temp2.z, params7.z;" + // parallax
12991
+
12992
+ "MUL temp2, temp2, temp2.z;" +
12993
+
12994
+ "MOV temp, fragment.texcoord[0];" +
12995
+
12996
+ "SUB temp, temp, temp2;" +
12997
+
12998
+ "TEX temp, temp, texture[0], 2D;" +
12999
+ "POW temp.a, temp.a, params6.w;" + // punch through
13000
+
13001
+ "ADD texSamp, temp, texSamp;" +
13002
+ "MUL texSamp.xyz, half, texSamp;" +
13003
+
13004
+ "MOV alpha, texSamp.aaaa;" +
13005
+
13006
+// parallax mapping
13007
+
13008
+ "MOV temp.x, texSamp.a;" +
13009
+ "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
13010
+ //"LRP texSamp0, params5.x, texSamp0, one;" +
13011
+ "MOV texSamp.a, temp.x;" +
1283813012
1283913013 //"MOV temp, fragment.texcoord[0];" +
1284013014 //
....@@ -12967,7 +13141,7 @@
1296713141 // display shadow only (fakedepth == 0)
1296813142 "SUB temp.x, half.x, shadow.x;" +
1296913143 "MOV temp.y, -params5.z;" + // params6.x;" +
12970
- "SLT temp.z, temp.y, -one2048th.x;" +
13144
+ "SLT temp.z, temp.y, -c256i.x;" +
1297113145 "SUB temp.y, one.x, temp.z;" +
1297213146 "MUL temp.x, temp.x, temp.y;" +
1297313147 "KIL temp.x;" +
....@@ -13298,8 +13472,19 @@
1329813472 //once = true;
1329913473 }
1330013474
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 " : ""));
13475
+ String program = programmax;
13476
+
13477
+ if (Globals.MINSHADER)
13478
+ {
13479
+ program = programmin;
13480
+ }
13481
+
13482
+ if (Globals.DEBUG)
13483
+ {
13484
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13485
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13486
+ }
13487
+
1330313488 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1330413489
1330513490 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13346,7 +13531,8 @@
1334613531 "\n" +
1334713532 "END\n";
1334813533
13349
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13534
+ if (Globals.DEBUG)
13535
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1335013536 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1335113537
1335213538 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13391,25 +13577,26 @@
1339113577 return out;
1339213578 }
1339313579
13394
- String TextureFetch(String dest, String src, String unit)
13580
+ // Also does frustum culling
13581
+ String ShadowTextureFetch(String dest, String src, String unit)
1339513582 {
1339613583 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1339713584 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1339813585 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13586
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13587
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1339913588 "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;" +
13589
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13590
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1340413591 //"SWZ buffer, temp, w,w,w,w;";
13405
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13592
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1340613593 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1340713594 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1340813595 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13409
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13596
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1341013597
13411
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13412
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13598
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13599
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1341313600 }
1341413601
1341513602 String Shadow(String depth, String shadow)
....@@ -13603,7 +13790,7 @@
1360313790 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1360413791 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1360513792 /*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
13793
+ /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax
1360713794
1360813795 //Object3D.cVector2[] vector2buffer;
1360913796
....@@ -13770,7 +13957,7 @@
1377013957 "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" +
1377113958 "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" +
1377213959 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
13773
- "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" +
13960
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1377413961 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1377513962 "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" +
1377613963 //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" +
....@@ -13831,7 +14018,7 @@
1383114018 "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" +
1383214019 "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" +
1383314020 "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" +
13834
- //"MOV result.texcoord, vertex.texcoord;" +
14021
+ //"MOV result.texcoord, vertex.fogcoord;" +
1383514022 "MOV result.texcoord, temp;" +
1383614023 // border fade
1383714024 "MOV result.texcoord[3], vertex.texcoord;" +
....@@ -13878,7 +14065,9 @@
1387814065
1387914066 //"ADD temp.z, temp.z, one;" +
1388014067
13881
- "MOV result.color, temp;"
14068
+ "MOV result.texcoord[4], vertex.attrib[4];" + // U dir
14069
+
14070
+ "MOV result.color, temp;" // Normal
1388214071 : "MOV result.color, vertex.color;") +
1388314072 ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;"
1388414073 : "") +
....@@ -14254,14 +14443,15 @@
1425414443 drag = false;
1425514444 //System.out.println("Mouse DOWN");
1425614445 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);
14446
+ //ClickInfo info = new ClickInfo();
14447
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14448
+ object.clickInfo.pane = this;
14449
+ object.clickInfo.camera = renderCamera;
14450
+ object.clickInfo.x = x;
14451
+ object.clickInfo.y = y;
14452
+ object.clickInfo.modifiers = modifiersex;
14453
+ editObj = object.doEditClick(//info,
14454
+ 0);
1426514455 if (!editObj)
1426614456 {
1426714457 hasMarquee = true;
....@@ -14543,11 +14733,17 @@
1454314733 void GoDown(int mod)
1454414734 {
1454514735 MODIFIERS |= COMMAND;
14736
+ boolean isVR = (mouseMode&VR)!=0;
1454614737 /**/
1454714738 if((mod&SHIFT) == SHIFT)
14548
- manipCamera.RotatePosition(0, -speed);
14739
+ {
14740
+ if (isVR)
14741
+ manipCamera.RotateInterest(0, -speed);
14742
+ else
14743
+ manipCamera.RotatePosition(0, -speed);
14744
+ }
1454914745 else
14550
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14746
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1455114747 /**/
1455214748 if ((mod & SHIFT) == SHIFT)
1455314749 {
....@@ -14557,6 +14753,8 @@
1455714753 mouseMode |= BACKFORTH;
1455814754 }
1455914755
14756
+ targetLookAt.set(manipCamera.lookAt);
14757
+
1456014758 //prevX = X = anchorX;
1456114759 prevY = Y = anchorY - (int) (renderCamera.Distance());
1456214760 }
....@@ -14565,10 +14763,17 @@
1456514763 {
1456614764 MODIFIERS |= COMMAND;
1456714765 /**/
14766
+ boolean isVR = (mouseMode&VR)!=0;
14767
+
1456814768 if((mod&SHIFT) == SHIFT)
14569
- manipCamera.RotatePosition(0, speed);
14769
+ {
14770
+ if (isVR)
14771
+ manipCamera.RotateInterest(0, speed);
14772
+ else
14773
+ manipCamera.RotatePosition(0, speed);
14774
+ }
1457014775 else
14571
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14776
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1457214777 /**/
1457314778 if ((mod & SHIFT) == SHIFT)
1457414779 {
....@@ -14578,6 +14783,8 @@
1457814783 mouseMode |= BACKFORTH;
1457914784 }
1458014785
14786
+ targetLookAt.set(manipCamera.lookAt);
14787
+
1458114788 //prevX = X = anchorX;
1458214789 prevY = Y = anchorY + (int) (renderCamera.Distance());
1458314790 }
....@@ -14587,9 +14794,14 @@
1458714794 MODIFIERS |= COMMAND;
1458814795 /**/
1458914796 if((mod&SHIFT) == SHIFT)
14590
- manipCamera.Translate(speed*delta, 0, getWidth());
14797
+ manipCamera.Translate(speed*delta, 0, getWidth());
1459114798 else
14592
- manipCamera.RotatePosition(speed, 0);
14799
+ {
14800
+ if ((mouseMode&VR)!=0)
14801
+ manipCamera.RotateInterest(-speed, 0);
14802
+ else
14803
+ manipCamera.RotatePosition(speed, 0);
14804
+ }
1459314805 /**/
1459414806 if ((mod & SHIFT) == SHIFT)
1459514807 {
....@@ -14599,6 +14811,8 @@
1459914811 mouseMode |= ROTATE;
1460014812 } // TRANSLATE;
1460114813
14814
+ targetLookAt.set(manipCamera.lookAt);
14815
+
1460214816 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1460314817 prevY = Y = anchorY;
1460414818 }
....@@ -14608,9 +14822,15 @@
1460814822 MODIFIERS |= COMMAND;
1460914823 /**/
1461014824 if((mod&SHIFT) == SHIFT)
14611
- manipCamera.Translate(-speed*delta, 0, getWidth());
14825
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1461214826 else
14613
- manipCamera.RotatePosition(-speed, 0);
14827
+ {
14828
+ if ((mouseMode&VR)!=0)
14829
+ manipCamera.RotateInterest(speed, 0);
14830
+ else
14831
+ manipCamera.RotatePosition(-speed, 0);
14832
+ }
14833
+
1461414834 /**/
1461514835 if ((mod & SHIFT) == SHIFT)
1461614836 {
....@@ -14620,6 +14840,8 @@
1462014840 mouseMode |= ROTATE;
1462114841 } // TRANSLATE;
1462214842
14843
+ targetLookAt.set(manipCamera.lookAt);
14844
+
1462314845 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1462414846 prevY = Y = anchorY;
1462514847 }
....@@ -14661,15 +14883,16 @@
1466114883 if (editObj)
1466214884 {
1466314885 drag = true;
14664
- ClickInfo info = new ClickInfo();
14665
- info.bounds.setBounds(0, 0,
14886
+ //ClickInfo info = new ClickInfo();
14887
+ object.clickInfo.bounds.setBounds(0, 0,
1466614888 (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);
14889
+ object.clickInfo.pane = this;
14890
+ object.clickInfo.camera = renderCamera;
14891
+ object.clickInfo.x = x;
14892
+ object.clickInfo.y = y;
14893
+ object //.GetWindow().copy
14894
+ .doEditDrag(//info,
14895
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1467314896 } else
1467414897 {
1467514898 if (x < startX)
....@@ -14818,24 +15041,27 @@
1481815041 }
1481915042 }
1482015043
15044
+// ClickInfo clickInfo = new ClickInfo();
15045
+
1482115046 public void mouseMoved(MouseEvent e)
1482215047 {
1482315048 //System.out.println("mouseMoved: " + e);
1482415049 if (isRenderer)
1482515050 return;
1482615051
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;
15052
+ // Mouse cursor feedback
15053
+ object.clickInfo.x = e.getX();
15054
+ object.clickInfo.y = e.getY();
15055
+ object.clickInfo.modifiers = e.getModifiersEx();
15056
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
15057
+ object.clickInfo.pane = this;
15058
+ object.clickInfo.camera = renderCamera;
1483415059 if (!isRenderer)
1483515060 {
1483615061 //ObjEditor editWindow = object.editWindow;
1483715062 //Object3D copy = editWindow.copy;
14838
- if (object.doEditClick(ci, 0))
15063
+ if (object.doEditClick(//clickInfo,
15064
+ 0))
1483915065 {
1484015066 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1484115067 } else
....@@ -15118,8 +15344,8 @@
1511815344 case 'K':
1511915345 KOMPACTTEXTURE ^= true;
1512015346 //textures.clear();
15121
- break;
15122
- case 'P': // Texture Projection macros
15347
+ // break;
15348
+ //case 'P': // Texture Projection macros
1512315349 // SAVETEXTURE ^= true;
1512415350 macromode = true;
1512515351 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -15240,7 +15466,7 @@
1524015466 targetLookAt.set(manipCamera.lookAt);
1524115467 repaint();
1524215468 break;
15243
- case 'p':
15469
+ case 'P': // p':
1524415470 // c'est quoi ca au juste? spherical ^= true;
1524515471 Skinshader ^= true; programInitialized = false;
1524615472 repaint();
....@@ -15285,20 +15511,24 @@
1528515511 OCCLUSION_CULLING ^= true;
1528615512 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1528715513 break;
15288
- case '0': envyoff ^= true; repaint(); break;
15514
+ //case '0': envyoff ^= true; repaint(); break;
1528915515 case '1':
1529015516 case '2':
1529115517 case '3':
1529215518 case '4':
1529315519 case '5':
15294
- newenvy = Character.getNumericValue(key);
15295
- repaint();
15296
- break;
1529715520 case '6':
1529815521 case '7':
1529915522 case '8':
1530015523 case '9':
15301
- BGcolor = (key - '6')/3.f;
15524
+ if (true) // envyoff)
15525
+ {
15526
+ BGcolor = (key - '1')/8.f;
15527
+ }
15528
+ else
15529
+ {
15530
+ //newenvy = Character.getNumericValue(key);
15531
+ }
1530215532 repaint();
1530315533 break;
1530415534 case '!':
....@@ -15861,8 +16091,6 @@
1586116091
1586216092 int width = getBounds().width;
1586316093 int height = getBounds().height;
15864
- ClickInfo info = new ClickInfo();
15865
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1586616094 //Image img = CreateImage(width, height);
1586716095 //System.out.println("width = " + width + "; height = " + height + "\n");
1586816096
....@@ -15939,31 +16167,37 @@
1593916167 }
1594016168 if (object != null && !hasMarquee)
1594116169 {
16170
+ if (object.clickInfo == null)
16171
+ object.clickInfo = new ClickInfo();
16172
+ ClickInfo info = object.clickInfo;
16173
+ //ClickInfo info = new ClickInfo();
16174
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
16175
+
1594216176 if (isRenderer)
1594316177 {
15944
- info.flags++;
16178
+ object.clickInfo.flags++;
1594516179 double frameAspect = (double) width / (double) height;
1594616180 if (frameAspect > renderCamera.aspect)
1594716181 {
1594816182 int desired = (int) ((double) height * renderCamera.aspect);
15949
- info.bounds.width -= width - desired;
15950
- info.bounds.x += (width - desired) / 2;
16183
+ object.clickInfo.bounds.width -= width - desired;
16184
+ object.clickInfo.bounds.x += (width - desired) / 2;
1595116185 } else
1595216186 {
1595316187 int desired = (int) ((double) width / renderCamera.aspect);
15954
- info.bounds.height -= height - desired;
15955
- info.bounds.y += (height - desired) / 2;
16188
+ object.clickInfo.bounds.height -= height - desired;
16189
+ object.clickInfo.bounds.y += (height - desired) / 2;
1595616190 }
1595716191 }
1595816192
15959
- info.g = gr;
15960
- info.camera = renderCamera;
16193
+ object.clickInfo.g = gr;
16194
+ object.clickInfo.camera = renderCamera;
1596116195 /*
1596216196 // Memory intensive (brep.verticescopy)
1596316197 if (!(object instanceof Composite))
1596416198 object.draw(info, 0, false); // SLOW :
1596516199 */
15966
- if (!isRenderer)
16200
+ if (!isRenderer) // && drag)
1596716201 {
1596816202 Grafreed.Assert(object != null);
1596916203 Grafreed.Assert(object.selection != null);
....@@ -15971,9 +16205,9 @@
1597116205 {
1597216206 int hitSomething = object.selection.get(0).hitSomething;
1597316207
15974
- info.DX = 0;
15975
- info.DY = 0;
15976
- info.W = 1;
16208
+ object.clickInfo.DX = 0;
16209
+ object.clickInfo.DY = 0;
16210
+ object.clickInfo.W = 1;
1597716211 if (hitSomething == Object3D.hitCenter)
1597816212 {
1597916213 info.DX = X;
....@@ -15985,13 +16219,14 @@
1598516219 info.DY -= info.bounds.height/2;
1598616220 }
1598716221
15988
- object.drawEditHandles(info, 0);
16222
+ object.drawEditHandles(//info,
16223
+ 0);
1598916224
1599016225 if (drag && (X != 0 || Y != 0))
1599116226 {
1599216227 switch (hitSomething)
1599316228 {
15994
- case Object3D.hitCenter: gr.setColor(Color.pink);
16229
+ case Object3D.hitCenter: gr.setColor(Color.white);
1599516230 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1599616231 break;
1599716232 case Object3D.hitRotate: gr.setColor(Color.yellow);
....@@ -16017,7 +16252,7 @@
1601716252 if (hasMarquee)
1601816253 {
1601916254 gr.setXORMode(Color.white);
16020
- gr.setColor(Color.red);
16255
+ gr.setColor(Color.white);
1602116256 if (!firstime)
1602216257 {
1602316258 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16484,6 +16719,8 @@
1648416719 private /*static*/ boolean firstime;
1648516720 private /*static*/ cVector newView = new cVector();
1648616721 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16722
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16723
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1648716724 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1648816725 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1648916726 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16496,29 +16733,67 @@
1649616733 {
1649716734 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1649816735
16736
+ int usedsuf = 0;
16737
+
1649916738 for (int i = 0; i < suffixes.length; i++)
1650016739 {
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)
16740
+ String[] suffixe = suffixes;
16741
+ String[] fallback = suffixes2;
16742
+ String[] fallfallback = suffixes3;
16743
+
16744
+ for (int c=usedsuf; --c>=0;)
1650616745 {
16507
- throw new IOException("Unable to load texture " + resourceName);
16746
+// String[] temp = suffixe;
16747
+// suffixe = fallback;
16748
+// fallback = fallfallback;
16749
+// fallfallback = temp;
1650816750 }
16751
+
16752
+ String resourceName = basename + suffixe[i] + "." + suffix;
16753
+ TextureData data;
16754
+
16755
+ try
16756
+ {
16757
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16758
+ mipmapped,
16759
+ FileUtil.getFileSuffix(resourceName));
16760
+ }
16761
+ catch (Exception e)
16762
+ {
16763
+ try
16764
+ {
16765
+ resourceName = basename + fallback[i] + "." + suffix;
16766
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16767
+ mipmapped,
16768
+ FileUtil.getFileSuffix(resourceName));
16769
+ }
16770
+ catch (Exception e2)
16771
+ {
16772
+ resourceName = basename + fallfallback[i] + "." + suffix;
16773
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16774
+ mipmapped,
16775
+ FileUtil.getFileSuffix(resourceName));
16776
+ }
16777
+ }
16778
+
1650916779 //System.out.println("Target = " + targets[i]);
1651016780 cubemap.updateImage(data, targets[i]);
1651116781 }
1651216782
1651316783 return cubemap;
1651416784 }
16785
+
1651516786 int bigsphere = -1;
1651616787
1651716788 float BGcolor = 0.5f;
1651816789
16519
- private void DrawSkyBox(GL gl)
16790
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16791
+
16792
+ private void DrawSkyBox(GL gl, float ratio)
1652016793 {
16521
- if (envyoff || cubemap == null)
16794
+ if (//envyoff ||
16795
+ WIREFRAME ||
16796
+ cubemap == null)
1652216797 {
1652316798 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1652416799 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16533,7 +16808,17 @@
1653316808 // Compensates for ExaminerViewer's modification of modelview matrix
1653416809 gl.glMatrixMode(GL.GL_MODELVIEW);
1653516810 gl.glLoadIdentity();
16811
+ gl.glScalef(1,ratio,1);
1653616812
16813
+// colorV[0] = 2;
16814
+// colorV[1] = 2;
16815
+// colorV[2] = 2;
16816
+// colorV[3] = 1;
16817
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16818
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16819
+//
16820
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16821
+
1653716822 //gl.glActiveTexture(GL.GL_TEXTURE1);
1653816823 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1653916824
....@@ -16565,6 +16850,7 @@
1656516850 {
1656616851 gl.glScalef(1.0f, -1.0f, 1.0f);
1656716852 }
16853
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1656816854 gl.glMultMatrixd(viewrot_1, 0);
1656916855 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1657016856 //viewer.updateInverseRotation(gl);
....@@ -16605,7 +16891,8 @@
1660516891 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1660616892
1660716893 cubemap.disable();
16608
- ////cubemap.unbind();
16894
+ //cubemap.dispose();
16895
+
1660916896 if (CULLFACE)
1661016897 {
1661116898 gl.glEnable(gl.GL_CULL_FACE);
....@@ -16661,7 +16948,7 @@
1666116948 gl.glScalef(1.0f, -1.0f, 1.0f);
1666216949 }
1666316950
16664
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
16951
+ SetGLNormal(gl, 0.0f, 0.0f, 1.0f);
1666516952
1666616953 float step = 2; // 0.1666f; //0.25f;
1666716954 float stepv = 2; // step * 1652 / 998;
....@@ -16823,7 +17110,7 @@
1682317110 //new Exception().printStackTrace();
1682417111 System.out.println("select buffer init");
1682517112 // Use debug pipeline
16826
- drawable.setGL(new DebugGL(drawable.getGL()));
17113
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1682717114
1682817115 GL gl = drawable.getGL();
1682917116
....@@ -17141,6 +17428,7 @@
1714117428
1714217429 public void init(GLAutoDrawable drawable)
1714317430 {
17431
+ if (Globals.DEBUG)
1714417432 System.out.println("shadow buffer init");
1714517433
1714617434 GL gl = drawable.getGL();
....@@ -17369,10 +17657,14 @@
1736917657 gl.glFlush();
1737017658
1737117659 /**/
17372
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17660
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1737317661
17374
- float[] pixels = occlusionsizebuffer.array();
17662
+ float[] depths = occlusiondepthbuffer.array();
1737517663
17664
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17665
+
17666
+ int[] pixels = selectsizebuffer.array();
17667
+
1737617668 double r = 0, g = 0, b = 0;
1737717669
1737817670 double count = 0;
....@@ -17383,7 +17675,7 @@
1738317675
1738417676 double FACTOR = 1;
1738517677
17386
- for (int i = 0; i < pixels.length; i++)
17678
+ for (int i = 0; i < depths.length; i++)
1738717679 {
1738817680 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1738917681 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17466,7 +17758,7 @@
1746617758
1746717759 double scale = ray.z; // 1; // cos
1746817760
17469
- float depth = pixels[newindex];
17761
+ float depth = depths[newindex];
1747017762
1747117763 /*
1747217764 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17663,11 +17955,14 @@
1766317955 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1766417956 static IntBuffer bigAAbuffer;
1766517957 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17666
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17958
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1766717959 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1766817960 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1766917961 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17670
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17962
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17963
+
17964
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17965
+
1767117966 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1767217967 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1767317968 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();