Normand Briere
2019-08-12 b1d79b74514041a059b454a9f6fc3970773c0cb8
CameraPane.java
....@@ -187,6 +187,18 @@
187187 }
188188
189189 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
190
+
191
+ public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException
192
+ {
193
+ try
194
+ {
195
+ cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
196
+ } catch (IOException e)
197
+ {
198
+ System.out.println("NAME = " + name);
199
+ e.printStackTrace(); // throw new RuntimeException(e);
200
+ }
201
+ }
190202
191203 void SetAsGLRenderer(boolean b)
192204 {
....@@ -206,7 +218,8 @@
206218
207219 SetCamera(cam);
208220
209
- SetLight(new Camera(new cVector(10, 10, -20)));
221
+ // Warning: not used.
222
+ SetLight(new Camera(new cVector(15, 10, -20)));
210223
211224 object = o;
212225
....@@ -1484,6 +1497,8 @@
14841497 gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
14851498 }
14861499
1500
+ float[] colorV = new float[4];
1501
+
14871502 void SetColor(Object3D obj, Vertex p0)
14881503 {
14891504 CameraPane display = this;
....@@ -1551,8 +1566,6 @@
15511566 {
15521567 return;
15531568 }
1554
-
1555
- float[] colorV = new float[3];
15561569
15571570 if (false) // marked)
15581571 {
....@@ -8345,7 +8358,7 @@
83458358 // else
83468359 // if (!texname.startsWith("/"))
83478360 // texname = "/Users/nbriere/Textures/" + texname;
8348
- if (!FileExists(texname))
8361
+ if (!FileExists(texname) && !texname.startsWith("@"))
83498362 {
83508363 texname = fallbackTextureName;
83518364 }
....@@ -8428,6 +8441,15 @@
84288441 new Exception().printStackTrace();
84298442 } else
84308443 {
8444
+ if (texname.startsWith("@"))
8445
+ {
8446
+ // texturecache = textures.get(texname); // suspicious
8447
+ if (texturecache == null)
8448
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8449
+ else
8450
+ new Exception().printStackTrace();
8451
+ } else
8452
+ {
84318453 if (textureon)
84328454 {
84338455 String cachename = texname;
....@@ -8487,6 +8509,7 @@
84878509 texturecache = new CacheTexture(texturedata,resolution);
84888510 //texture = GetTexture(tex, bump);
84898511 }
8512
+ }
84908513 }
84918514 //}
84928515 }
....@@ -8931,7 +8954,7 @@
89318954
89328955 if (cubemap == null)
89338956 {
8934
- LoadEnvy(5);
8957
+ //LoadEnvy(1);
89358958 }
89368959
89378960 //cubemap.enable();
....@@ -9218,37 +9241,58 @@
92189241 cubemap = null;
92199242 return;
92209243 case 1:
9221
- name = "cubemaps/box_";
9222
- ext = "png";
9244
+ name = "cubemaps/rgb/";
9245
+ ext = "jpg";
92239246 reverseUP = false;
92249247 break;
92259248 case 2:
9226
- name = "cubemaps/uffizi_";
9227
- ext = "png";
9228
- break; // reverseUP = true; break;
9249
+ name = "cubemaps/uffizi/";
9250
+ ext = "jpg";
9251
+ reverseUP = false;
9252
+ break;
92299253 case 3:
9230
- name = "cubemaps/CloudyHills_";
9231
- ext = "tga";
9254
+ name = "cubemaps/CloudyHills/";
9255
+ ext = "jpg";
92329256 reverseUP = false;
92339257 break;
92349258 case 4:
9235
- name = "cubemaps/cornell_";
9259
+ name = "cubemaps/cornell/";
92369260 ext = "png";
92379261 reverseUP = false;
92389262 break;
9263
+ case 5:
9264
+ name = "cubemaps/skycube/";
9265
+ ext = "jpg";
9266
+ reverseUP = false;
9267
+ break;
9268
+ case 6:
9269
+ name = "cubemaps/SaintLazarusChurch3/";
9270
+ ext = "jpg";
9271
+ reverseUP = false;
9272
+ break;
9273
+ case 7:
9274
+ name = "cubemaps/Sodermalmsallen/";
9275
+ ext = "jpg";
9276
+ reverseUP = false;
9277
+ break;
9278
+ case 8:
9279
+ name = "cubemaps/Sodermalmsallen2/";
9280
+ ext = "jpg";
9281
+ reverseUP = false;
9282
+ break;
9283
+ case 9:
9284
+ name = "cubemaps/UnionSquare/";
9285
+ ext = "jpg";
9286
+ reverseUP = false;
9287
+ break;
92399288 default:
9240
- name = "cubemaps/rgb_";
9241
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9289
+ name = "cubemaps/box/";
9290
+ ext = "png"; /*mipmap = true;*/
9291
+ reverseUP = false;
92429292 break;
92439293 }
9244
-
9245
- try
9246
- {
9247
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
9248
- } catch (IOException e)
9249
- {
9250
- throw new RuntimeException(e);
9251
- }
9294
+
9295
+ LoadSkybox(name, ext, mipmap);
92529296 }
92539297
92549298 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -9280,8 +9324,12 @@
92809324 static double[] model = new double[16];
92819325 double[] camera2light = new double[16];
92829326 double[] light2camera = new double[16];
9283
- int newenvy = -1;
9284
- boolean envyoff = true; // false;
9327
+
9328
+ //int newenvy = -1;
9329
+ //boolean envyoff = false;
9330
+
9331
+ String loadedskyboxname;
9332
+
92859333 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
92869334 //float[] light0 = { 0,0,0 };
92879335 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9699,7 +9747,7 @@
96999747
97009748 if (renderCamera != lightCamera)
97019749 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9702
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
9750
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
97039751
97049752 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
97059753
....@@ -9715,7 +9763,7 @@
97159763
97169764 if (renderCamera != lightCamera)
97179765 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9718
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
9766
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
97199767
97209768 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
97219769
....@@ -9761,10 +9809,12 @@
97619809 rati = 1 / rati;
97629810 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
97639811 }
9764
- assert (newenvy == -1);
9812
+
9813
+ //assert (newenvy == -1);
9814
+
97659815 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
97669816 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9767
- DrawSkyBox(gl);
9817
+ DrawSkyBox(gl, (float)rati);
97689818 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
97699819 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
97709820 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -10801,7 +10851,7 @@
1080110851
1080210852 if (wait)
1080310853 {
10804
- Sleep(500);
10854
+ Sleep(200); // blocks everything
1080510855
1080610856 wait = false;
1080710857 }
....@@ -10916,7 +10966,7 @@
1091610966 // if (parentcam != renderCamera) // not a light
1091710967 if (cam != lightCamera)
1091810968 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10919
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
10969
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1092010970
1092110971 for (int j = 0; j < 4; j++)
1092210972 {
....@@ -10931,7 +10981,7 @@
1093110981 // if (parentcam != renderCamera) // not a light
1093210982 if (cam != lightCamera)
1093310983 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
10984
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1093510985
1093610986 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1093710987
....@@ -11017,13 +11067,27 @@
1101711067 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1101811068 }
1101911069
11020
- if (newenvy > -1)
11070
+// if (newenvy > -1)
11071
+// {
11072
+// LoadEnvy(newenvy);
11073
+// }
11074
+//
11075
+// newenvy = -1;
11076
+
11077
+ if (object.skyboxname != null)
1102111078 {
11022
- LoadEnvy(newenvy);
11079
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11080
+ {
11081
+ LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11082
+ loadedskyboxname = object.skyboxname;
11083
+ }
1102311084 }
11024
-
11025
- newenvy = -1;
11026
-
11085
+ else
11086
+ {
11087
+ cubemap = null;
11088
+ loadedskyboxname = null;
11089
+ }
11090
+
1102711091 ratio = ((double) getWidth()) / getHeight();
1102811092 //System.out.println("ratio = " + ratio);
1102911093
....@@ -11039,7 +11103,7 @@
1103911103
1104011104 if (!IsFrozen() && !ambientOcclusion)
1104111105 {
11042
- DrawSkyBox(gl);
11106
+ DrawSkyBox(gl, (float)ratio);
1104311107 }
1104411108
1104511109 //if (selection_view == -1)
....@@ -11325,7 +11389,7 @@
1132511389
1132611390 // if (cam != lightCamera)
1132711391 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11328
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11392
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1132911393 }
1133011394
1133111395 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12399,8 +12463,76 @@
1239912463
1240012464 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240112465
12402
- String program =
12466
+ String programmin =
12467
+ // Min shader
1240312468 "!!ARBfp1.0\n" +
12469
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12470
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12471
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12472
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12473
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12474
+ "PARAM light2cam0 = program.env[10];" +
12475
+ "PARAM light2cam1 = program.env[11];" +
12476
+ "PARAM light2cam2 = program.env[12];" +
12477
+ "TEMP temp;" +
12478
+ "TEMP light;" +
12479
+ "TEMP ndotl;" +
12480
+ "TEMP normal;" +
12481
+ "TEMP depth;" +
12482
+ "TEMP eye;" +
12483
+ "TEMP pos;" +
12484
+
12485
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12486
+ Normalize("normal") +
12487
+ "MOV light, state.light[0].position;" +
12488
+ "DP3 ndotl.x, light, normal;" +
12489
+
12490
+ // shadow
12491
+ "MOV pos, fragment.texcoord[1];" +
12492
+ "MOV temp, pos;" +
12493
+ ShadowTextureFetch("depth", "temp", "1") +
12494
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12495
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
12496
+
12497
+ // No shadow when out of frustum
12498
+ //"SGE temp.y, depth.z, zero123.y;" +
12499
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12500
+
12501
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
12502
+
12503
+ // Backlit
12504
+ "MOV pos.w, zero123.y;" +
12505
+ "DP4 eye.x, pos, light2cam0;" +
12506
+ "DP4 eye.y, pos, light2cam1;" +
12507
+ "DP4 eye.z, pos, light2cam2;" +
12508
+ Normalize("eye") +
12509
+
12510
+ "DP3 ndotl.y, -eye, normal;" +
12511
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12512
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12513
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12514
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12515
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12516
+
12517
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12518
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12519
+
12520
+ // Pigment
12521
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12522
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12523
+ "MUL temp, temp, ndotl.x;" +
12524
+
12525
+ "MUL temp, temp, zero123.z;" +
12526
+
12527
+ //"MUL temp, temp, ndotl.y;" +
12528
+
12529
+ "MOV temp.w, zero123.y;" + // reset alpha
12530
+ "MOV result.color, temp;" +
12531
+ "END";
12532
+
12533
+ String programmax =
12534
+ "!!ARBfp1.0\n" +
12535
+
1240412536 //"OPTION ARB_fragment_program_shadow;" +
1240512537 "PARAM light2cam0 = program.env[10];" +
1240612538 "PARAM light2cam1 = program.env[11];" +
....@@ -12515,8 +12647,7 @@
1251512647 "TEMP shininess;" +
1251612648 "\n" +
1251712649 "MOV texSamp, one;" +
12518
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12519
-
12650
+
1252012651 "MOV mapgrid.x, one2048th.x;" +
1252112652 "MOV temp, fragment.texcoord[1];" +
1252212653 /*
....@@ -12537,20 +12668,20 @@
1253712668 "MUL temp, floor, mapgrid.x;" +
1253812669 //"TEX depth0, temp, texture[1], 2D;" +
1253912670 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12540
- TextureFetch("depth0", "temp", "1") +
12671
+ ShadowTextureFetch("depth0", "temp", "1") +
1254112672 "") +
1254212673 "ADD temp.x, temp.x, mapgrid.x;" +
1254312674 //"TEX depth1, temp, texture[1], 2D;" +
1254412675 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12545
- TextureFetch("depth1", "temp", "1") +
12676
+ ShadowTextureFetch("depth1", "temp", "1") +
1254612677 "") +
1254712678 "ADD temp.y, temp.y, mapgrid.x;" +
1254812679 //"TEX depth2, temp, texture[1], 2D;" +
12549
- TextureFetch("depth2", "temp", "1") +
12680
+ ShadowTextureFetch("depth2", "temp", "1") +
1255012681 "SUB temp.x, temp.x, mapgrid.x;" +
1255112682 //"TEX depth3, temp, texture[1], 2D;" +
1255212683 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12553
- TextureFetch("depth3", "temp", "1") +
12684
+ ShadowTextureFetch("depth3", "temp", "1") +
1255412685 "") +
1255512686 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1255612687 //"MOV params, material;" +
....@@ -12921,10 +13052,10 @@
1292113052 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1292213053 "") +
1292313054
12924
- // display shadow only (bump == 0)
13055
+ // display shadow only (fakedepth == 0)
1292513056 "SUB temp.x, half.x, shadow.x;" +
1292613057 "MOV temp.y, -params5.z;" + // params6.x;" +
12927
- "SLT temp.z, temp.y, -one2048th.x;" +
13058
+ "SLT temp.z, temp.y, -c256i.x;" +
1292813059 "SUB temp.y, one.x, temp.z;" +
1292913060 "MUL temp.x, temp.x, temp.y;" +
1293013061 "KIL temp.x;" +
....@@ -13255,6 +13386,13 @@
1325513386 //once = true;
1325613387 }
1325713388
13389
+ String program = programmax;
13390
+
13391
+ if (Globals.MINSHADER)
13392
+ {
13393
+ program = programmin;
13394
+ }
13395
+
1325813396 System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1325913397 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1326013398 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
....@@ -13348,25 +13486,26 @@
1334813486 return out;
1334913487 }
1335013488
13351
- String TextureFetch(String dest, String src, String unit)
13489
+ // Also does frustum culling
13490
+ String ShadowTextureFetch(String dest, String src, String unit)
1335213491 {
1335313492 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1335413493 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1335513494 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13495
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13496
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1335613497 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13357
- "SLT " + src + ".z, " + src + ".x, one.x;" +
13358
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13359
- "SLT " + src + ".z, " + src + ".y, one.x;" +
13360
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13498
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13499
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1336113500 //"SWZ buffer, temp, w,w,w,w;";
13362
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13501
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1336313502 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1336413503 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1336513504 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13366
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13505
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1336713506
13368
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13369
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13507
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13508
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1337013509 }
1337113510
1337213511 String Shadow(String depth, String shadow)
....@@ -13413,7 +13552,7 @@
1341313552 "SLT temp.x, temp.x, zero.x;" + // shadoweps
1341413553 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1341513554
13416
- // No shadow when out of frustrum
13555
+ // No shadow when out of frustum
1341713556 "SGE temp.x, " + depth + ".z, one.z;" +
1341813557 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1341913558 "";
....@@ -14211,14 +14350,15 @@
1421114350 drag = false;
1421214351 //System.out.println("Mouse DOWN");
1421314352 editObj = false;
14214
- ClickInfo info = new ClickInfo();
14215
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14216
- info.pane = this;
14217
- info.camera = renderCamera;
14218
- info.x = x;
14219
- info.y = y;
14220
- info.modifiers = modifiersex;
14221
- editObj = object.doEditClick(info, 0);
14353
+ //ClickInfo info = new ClickInfo();
14354
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14355
+ object.clickInfo.pane = this;
14356
+ object.clickInfo.camera = renderCamera;
14357
+ object.clickInfo.x = x;
14358
+ object.clickInfo.y = y;
14359
+ object.clickInfo.modifiers = modifiersex;
14360
+ editObj = object.doEditClick(//info,
14361
+ 0);
1422214362 if (!editObj)
1422314363 {
1422414364 hasMarquee = true;
....@@ -14502,9 +14642,9 @@
1450214642 MODIFIERS |= COMMAND;
1450314643 /**/
1450414644 if((mod&SHIFT) == SHIFT)
14505
- manipCamera.RotatePosition(0, -speed);
14506
- else
1450714645 manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14646
+ else
14647
+ manipCamera.RotatePosition(0, -speed);
1450814648 /**/
1450914649 if ((mod & SHIFT) == SHIFT)
1451014650 {
....@@ -14523,9 +14663,9 @@
1452314663 MODIFIERS |= COMMAND;
1452414664 /**/
1452514665 if((mod&SHIFT) == SHIFT)
14526
- manipCamera.RotatePosition(0, speed);
14527
- else
1452814666 manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14667
+ else
14668
+ manipCamera.RotatePosition(0, speed);
1452914669 /**/
1453014670 if ((mod & SHIFT) == SHIFT)
1453114671 {
....@@ -14618,15 +14758,16 @@
1461814758 if (editObj)
1461914759 {
1462014760 drag = true;
14621
- ClickInfo info = new ClickInfo();
14622
- info.bounds.setBounds(0, 0,
14761
+ //ClickInfo info = new ClickInfo();
14762
+ object.clickInfo.bounds.setBounds(0, 0,
1462314763 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14624
- info.pane = this;
14625
- info.camera = renderCamera;
14626
- info.x = x;
14627
- info.y = y;
14628
- object.GetWindow().copy
14629
- .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14764
+ object.clickInfo.pane = this;
14765
+ object.clickInfo.camera = renderCamera;
14766
+ object.clickInfo.x = x;
14767
+ object.clickInfo.y = y;
14768
+ object //.GetWindow().copy
14769
+ .doEditDrag(//info,
14770
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1463014771 } else
1463114772 {
1463214773 if (x < startX)
....@@ -14775,24 +14916,27 @@
1477514916 }
1477614917 }
1477714918
14919
+// ClickInfo clickInfo = new ClickInfo();
14920
+
1477814921 public void mouseMoved(MouseEvent e)
1477914922 {
1478014923 //System.out.println("mouseMoved: " + e);
1478114924 if (isRenderer)
1478214925 return;
1478314926
14784
- ClickInfo ci = new ClickInfo();
14785
- ci.x = e.getX();
14786
- ci.y = e.getY();
14787
- ci.modifiers = e.getModifiersEx();
14788
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14789
- ci.pane = this;
14790
- ci.camera = renderCamera;
14927
+ // Mouse cursor feedback
14928
+ object.clickInfo.x = e.getX();
14929
+ object.clickInfo.y = e.getY();
14930
+ object.clickInfo.modifiers = e.getModifiersEx();
14931
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14932
+ object.clickInfo.pane = this;
14933
+ object.clickInfo.camera = renderCamera;
1479114934 if (!isRenderer)
1479214935 {
1479314936 //ObjEditor editWindow = object.editWindow;
1479414937 //Object3D copy = editWindow.copy;
14795
- if (object.doEditClick(ci, 0))
14938
+ if (object.doEditClick(//clickInfo,
14939
+ 0))
1479614940 {
1479714941 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1479814942 } else
....@@ -15242,20 +15386,24 @@
1524215386 OCCLUSION_CULLING ^= true;
1524315387 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1524415388 break;
15245
- case '0': envyoff ^= true; repaint(); break;
15389
+ //case '0': envyoff ^= true; repaint(); break;
1524615390 case '1':
1524715391 case '2':
1524815392 case '3':
1524915393 case '4':
1525015394 case '5':
15251
- newenvy = Character.getNumericValue(key);
15252
- repaint();
15253
- break;
1525415395 case '6':
1525515396 case '7':
1525615397 case '8':
1525715398 case '9':
15258
- BGcolor = (key - '6')/3.f;
15399
+ if (true) // envyoff)
15400
+ {
15401
+ BGcolor = (key - '1')/8.f;
15402
+ }
15403
+ else
15404
+ {
15405
+ //newenvy = Character.getNumericValue(key);
15406
+ }
1525915407 repaint();
1526015408 break;
1526115409 case '!':
....@@ -15818,8 +15966,6 @@
1581815966
1581915967 int width = getBounds().width;
1582015968 int height = getBounds().height;
15821
- ClickInfo info = new ClickInfo();
15822
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1582315969 //Image img = CreateImage(width, height);
1582415970 //System.out.println("width = " + width + "; height = " + height + "\n");
1582515971
....@@ -15896,31 +16042,37 @@
1589616042 }
1589716043 if (object != null && !hasMarquee)
1589816044 {
16045
+ if (object.clickInfo == null)
16046
+ object.clickInfo = new ClickInfo();
16047
+ ClickInfo info = object.clickInfo;
16048
+ //ClickInfo info = new ClickInfo();
16049
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
16050
+
1589916051 if (isRenderer)
1590016052 {
15901
- info.flags++;
16053
+ object.clickInfo.flags++;
1590216054 double frameAspect = (double) width / (double) height;
1590316055 if (frameAspect > renderCamera.aspect)
1590416056 {
1590516057 int desired = (int) ((double) height * renderCamera.aspect);
15906
- info.bounds.width -= width - desired;
15907
- info.bounds.x += (width - desired) / 2;
16058
+ object.clickInfo.bounds.width -= width - desired;
16059
+ object.clickInfo.bounds.x += (width - desired) / 2;
1590816060 } else
1590916061 {
1591016062 int desired = (int) ((double) width / renderCamera.aspect);
15911
- info.bounds.height -= height - desired;
15912
- info.bounds.y += (height - desired) / 2;
16063
+ object.clickInfo.bounds.height -= height - desired;
16064
+ object.clickInfo.bounds.y += (height - desired) / 2;
1591316065 }
1591416066 }
1591516067
15916
- info.g = gr;
15917
- info.camera = renderCamera;
16068
+ object.clickInfo.g = gr;
16069
+ object.clickInfo.camera = renderCamera;
1591816070 /*
1591916071 // Memory intensive (brep.verticescopy)
1592016072 if (!(object instanceof Composite))
1592116073 object.draw(info, 0, false); // SLOW :
1592216074 */
15923
- if (!isRenderer)
16075
+ if (!isRenderer) // && drag)
1592416076 {
1592516077 Grafreed.Assert(object != null);
1592616078 Grafreed.Assert(object.selection != null);
....@@ -15928,9 +16080,9 @@
1592816080 {
1592916081 int hitSomething = object.selection.get(0).hitSomething;
1593016082
15931
- info.DX = 0;
15932
- info.DY = 0;
15933
- info.W = 1;
16083
+ object.clickInfo.DX = 0;
16084
+ object.clickInfo.DY = 0;
16085
+ object.clickInfo.W = 1;
1593416086 if (hitSomething == Object3D.hitCenter)
1593516087 {
1593616088 info.DX = X;
....@@ -15942,7 +16094,8 @@
1594216094 info.DY -= info.bounds.height/2;
1594316095 }
1594416096
15945
- object.drawEditHandles(info, 0);
16097
+ object.drawEditHandles(//info,
16098
+ 0);
1594616099
1594716100 if (drag && (X != 0 || Y != 0))
1594816101 {
....@@ -16441,6 +16594,8 @@
1644116594 private /*static*/ boolean firstime;
1644216595 private /*static*/ cVector newView = new cVector();
1644316596 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16597
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16598
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1644416599 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1644516600 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1644616601 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16453,29 +16608,67 @@
1645316608 {
1645416609 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1645516610
16611
+ int usedsuf = 0;
16612
+
1645616613 for (int i = 0; i < suffixes.length; i++)
1645716614 {
16458
- String resourceName = basename + suffixes[i] + "." + suffix;
16459
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16460
- mipmapped,
16461
- FileUtil.getFileSuffix(resourceName));
16462
- if (data == null)
16615
+ String[] suffixe = suffixes;
16616
+ String[] fallback = suffixes2;
16617
+ String[] fallfallback = suffixes3;
16618
+
16619
+ for (int c=usedsuf; --c>=0;)
1646316620 {
16464
- throw new IOException("Unable to load texture " + resourceName);
16621
+// String[] temp = suffixe;
16622
+// suffixe = fallback;
16623
+// fallback = fallfallback;
16624
+// fallfallback = temp;
1646516625 }
16626
+
16627
+ String resourceName = basename + suffixe[i] + "." + suffix;
16628
+ TextureData data;
16629
+
16630
+ try
16631
+ {
16632
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16633
+ mipmapped,
16634
+ FileUtil.getFileSuffix(resourceName));
16635
+ }
16636
+ catch (Exception e)
16637
+ {
16638
+ try
16639
+ {
16640
+ resourceName = basename + fallback[i] + "." + suffix;
16641
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16642
+ mipmapped,
16643
+ FileUtil.getFileSuffix(resourceName));
16644
+ }
16645
+ catch (Exception e2)
16646
+ {
16647
+ resourceName = basename + fallfallback[i] + "." + suffix;
16648
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16649
+ mipmapped,
16650
+ FileUtil.getFileSuffix(resourceName));
16651
+ }
16652
+ }
16653
+
1646616654 //System.out.println("Target = " + targets[i]);
1646716655 cubemap.updateImage(data, targets[i]);
1646816656 }
1646916657
1647016658 return cubemap;
1647116659 }
16660
+
1647216661 int bigsphere = -1;
1647316662
1647416663 float BGcolor = 0.5f;
1647516664
16476
- private void DrawSkyBox(GL gl)
16665
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16666
+
16667
+ private void DrawSkyBox(GL gl, float ratio)
1647716668 {
16478
- if (envyoff || cubemap == null)
16669
+ if (//envyoff ||
16670
+ WIREFRAME ||
16671
+ cubemap == null)
1647916672 {
1648016673 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1648116674 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16490,7 +16683,17 @@
1649016683 // Compensates for ExaminerViewer's modification of modelview matrix
1649116684 gl.glMatrixMode(GL.GL_MODELVIEW);
1649216685 gl.glLoadIdentity();
16686
+ gl.glScalef(1,ratio,1);
1649316687
16688
+// colorV[0] = 2;
16689
+// colorV[1] = 2;
16690
+// colorV[2] = 2;
16691
+// colorV[3] = 1;
16692
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16693
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16694
+//
16695
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16696
+
1649416697 //gl.glActiveTexture(GL.GL_TEXTURE1);
1649516698 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1649616699
....@@ -16522,6 +16725,7 @@
1652216725 {
1652316726 gl.glScalef(1.0f, -1.0f, 1.0f);
1652416727 }
16728
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1652516729 gl.glMultMatrixd(viewrot_1, 0);
1652616730 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1652716731 //viewer.updateInverseRotation(gl);
....@@ -16780,7 +16984,7 @@
1678016984 //new Exception().printStackTrace();
1678116985 System.out.println("select buffer init");
1678216986 // Use debug pipeline
16783
- drawable.setGL(new DebugGL(drawable.getGL()));
16987
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1678416988
1678516989 GL gl = drawable.getGL();
1678616990