Normand Briere
2019-08-09 912749d2520afedd9b56458d771400c261fe2b88
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,50 +12463,74 @@
1239912463
1240012464 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240112465
12402
- String program =
12466
+ String programmin =
1240312467 // Min shader
1240412468 "!!ARBfp1.0\n" +
12405
- "PARAM zero123 = { 0.0, 1.0, 2.0, 3.0 };" +
12469
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
1240612470 "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
1240712471 "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1240812472 "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
1240912473 "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];" +
1241012477 "TEMP temp;" +
1241112478 "TEMP light;" +
1241212479 "TEMP ndotl;" +
1241312480 "TEMP normal;" +
1241412481 "TEMP depth;" +
12482
+ "TEMP eye;" +
12483
+ "TEMP pos;" +
1241512484
1241612485 "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12417
-
12486
+ Normalize("normal") +
1241812487 "MOV light, state.light[0].position;" +
1241912488 "DP3 ndotl.x, light, normal;" +
1242012489
1242112490 // shadow
12422
- "MOV temp, fragment.texcoord[1];" +
12423
- TextureFetch("depth", "temp", "1") +
12491
+ "MOV pos, fragment.texcoord[1];" +
12492
+ "MOV temp, pos;" +
12493
+ ShadowTextureFetch("depth", "temp", "1") +
1242412494 //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12425
- "SLT temp.x, fragment.texcoord[1].z, depth.z;" +
12426
-
12495
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
1242712496
1242812497 // No shadow when out of frustum
1242912498 //"SGE temp.y, depth.z, zero123.y;" +
1243012499 //"LRP temp.x, temp.y, zero123.y, temp.x;" +
1243112500
12432
- "MUL ndotl.x, ndotl.x, temp.x;" +
12433
- "MAX ndotl.x, ndotl.x, pow2.y;" +
12501
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
1243412502
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
1243512521 "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12522
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
1243612523 "MUL temp, temp, ndotl.x;" +
1243712524
1243812525 "MUL temp, temp, zero123.z;" +
1243912526
12440
- "MOV temp.w, zero123.y;" + // reset alpha
12527
+ //"MUL temp, temp, ndotl.y;" +
1244112528
12529
+ "MOV temp.w, zero123.y;" + // reset alpha
1244212530 "MOV result.color, temp;" +
1244312531 "END";
1244412532
12445
- String program2 =
12533
+ String programmax =
1244612534 "!!ARBfp1.0\n" +
1244712535
1244812536 //"OPTION ARB_fragment_program_shadow;" +
....@@ -12580,20 +12668,20 @@
1258012668 "MUL temp, floor, mapgrid.x;" +
1258112669 //"TEX depth0, temp, texture[1], 2D;" +
1258212670 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12583
- TextureFetch("depth0", "temp", "1") +
12671
+ ShadowTextureFetch("depth0", "temp", "1") +
1258412672 "") +
1258512673 "ADD temp.x, temp.x, mapgrid.x;" +
1258612674 //"TEX depth1, temp, texture[1], 2D;" +
1258712675 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12588
- TextureFetch("depth1", "temp", "1") +
12676
+ ShadowTextureFetch("depth1", "temp", "1") +
1258912677 "") +
1259012678 "ADD temp.y, temp.y, mapgrid.x;" +
1259112679 //"TEX depth2, temp, texture[1], 2D;" +
12592
- TextureFetch("depth2", "temp", "1") +
12680
+ ShadowTextureFetch("depth2", "temp", "1") +
1259312681 "SUB temp.x, temp.x, mapgrid.x;" +
1259412682 //"TEX depth3, temp, texture[1], 2D;" +
1259512683 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12596
- TextureFetch("depth3", "temp", "1") +
12684
+ ShadowTextureFetch("depth3", "temp", "1") +
1259712685 "") +
1259812686 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1259912687 //"MOV params, material;" +
....@@ -12967,7 +13055,7 @@
1296713055 // display shadow only (fakedepth == 0)
1296813056 "SUB temp.x, half.x, shadow.x;" +
1296913057 "MOV temp.y, -params5.z;" + // params6.x;" +
12970
- "SLT temp.z, temp.y, -one2048th.x;" +
13058
+ "SLT temp.z, temp.y, -c256i.x;" +
1297113059 "SUB temp.y, one.x, temp.z;" +
1297213060 "MUL temp.x, temp.x, temp.y;" +
1297313061 "KIL temp.x;" +
....@@ -13298,6 +13386,13 @@
1329813386 //once = true;
1329913387 }
1330013388
13389
+ String program = programmax;
13390
+
13391
+ if (Globals.MINSHADER)
13392
+ {
13393
+ program = programmin;
13394
+ }
13395
+
1330113396 System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1330213397 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1330313398 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
....@@ -13391,25 +13486,26 @@
1339113486 return out;
1339213487 }
1339313488
13394
- String TextureFetch(String dest, String src, String unit)
13489
+ // Also does frustum culling
13490
+ String ShadowTextureFetch(String dest, String src, String unit)
1339513491 {
1339613492 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1339713493 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1339813494 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13495
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13496
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1339913497 "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;" +
13498
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13499
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1340413500 //"SWZ buffer, temp, w,w,w,w;";
13405
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13501
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1340613502 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1340713503 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1340813504 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13409
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13505
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1341013506
13411
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13412
- //"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;";
1341313509 }
1341413510
1341513511 String Shadow(String depth, String shadow)
....@@ -14254,14 +14350,15 @@
1425414350 drag = false;
1425514351 //System.out.println("Mouse DOWN");
1425614352 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);
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);
1426514362 if (!editObj)
1426614363 {
1426714364 hasMarquee = true;
....@@ -14545,9 +14642,9 @@
1454514642 MODIFIERS |= COMMAND;
1454614643 /**/
1454714644 if((mod&SHIFT) == SHIFT)
14548
- manipCamera.RotatePosition(0, -speed);
14549
- else
1455014645 manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14646
+ else
14647
+ manipCamera.RotatePosition(0, -speed);
1455114648 /**/
1455214649 if ((mod & SHIFT) == SHIFT)
1455314650 {
....@@ -14566,9 +14663,9 @@
1456614663 MODIFIERS |= COMMAND;
1456714664 /**/
1456814665 if((mod&SHIFT) == SHIFT)
14569
- manipCamera.RotatePosition(0, speed);
14570
- else
1457114666 manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14667
+ else
14668
+ manipCamera.RotatePosition(0, speed);
1457214669 /**/
1457314670 if ((mod & SHIFT) == SHIFT)
1457414671 {
....@@ -14661,15 +14758,16 @@
1466114758 if (editObj)
1466214759 {
1466314760 drag = true;
14664
- ClickInfo info = new ClickInfo();
14665
- info.bounds.setBounds(0, 0,
14761
+ //ClickInfo info = new ClickInfo();
14762
+ object.clickInfo.bounds.setBounds(0, 0,
1466614763 (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);
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);
1467314771 } else
1467414772 {
1467514773 if (x < startX)
....@@ -14818,24 +14916,27 @@
1481814916 }
1481914917 }
1482014918
14919
+// ClickInfo clickInfo = new ClickInfo();
14920
+
1482114921 public void mouseMoved(MouseEvent e)
1482214922 {
1482314923 //System.out.println("mouseMoved: " + e);
1482414924 if (isRenderer)
1482514925 return;
1482614926
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;
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;
1483414934 if (!isRenderer)
1483514935 {
1483614936 //ObjEditor editWindow = object.editWindow;
1483714937 //Object3D copy = editWindow.copy;
14838
- if (object.doEditClick(ci, 0))
14938
+ if (object.doEditClick(//clickInfo,
14939
+ 0))
1483914940 {
1484014941 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1484114942 } else
....@@ -15285,20 +15386,24 @@
1528515386 OCCLUSION_CULLING ^= true;
1528615387 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1528715388 break;
15288
- case '0': envyoff ^= true; repaint(); break;
15389
+ //case '0': envyoff ^= true; repaint(); break;
1528915390 case '1':
1529015391 case '2':
1529115392 case '3':
1529215393 case '4':
1529315394 case '5':
15294
- newenvy = Character.getNumericValue(key);
15295
- repaint();
15296
- break;
1529715395 case '6':
1529815396 case '7':
1529915397 case '8':
1530015398 case '9':
15301
- 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
+ }
1530215407 repaint();
1530315408 break;
1530415409 case '!':
....@@ -15861,8 +15966,6 @@
1586115966
1586215967 int width = getBounds().width;
1586315968 int height = getBounds().height;
15864
- ClickInfo info = new ClickInfo();
15865
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1586615969 //Image img = CreateImage(width, height);
1586715970 //System.out.println("width = " + width + "; height = " + height + "\n");
1586815971
....@@ -15939,31 +16042,37 @@
1593916042 }
1594016043 if (object != null && !hasMarquee)
1594116044 {
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
+
1594216051 if (isRenderer)
1594316052 {
15944
- info.flags++;
16053
+ object.clickInfo.flags++;
1594516054 double frameAspect = (double) width / (double) height;
1594616055 if (frameAspect > renderCamera.aspect)
1594716056 {
1594816057 int desired = (int) ((double) height * renderCamera.aspect);
15949
- info.bounds.width -= width - desired;
15950
- info.bounds.x += (width - desired) / 2;
16058
+ object.clickInfo.bounds.width -= width - desired;
16059
+ object.clickInfo.bounds.x += (width - desired) / 2;
1595116060 } else
1595216061 {
1595316062 int desired = (int) ((double) width / renderCamera.aspect);
15954
- info.bounds.height -= height - desired;
15955
- info.bounds.y += (height - desired) / 2;
16063
+ object.clickInfo.bounds.height -= height - desired;
16064
+ object.clickInfo.bounds.y += (height - desired) / 2;
1595616065 }
1595716066 }
1595816067
15959
- info.g = gr;
15960
- info.camera = renderCamera;
16068
+ object.clickInfo.g = gr;
16069
+ object.clickInfo.camera = renderCamera;
1596116070 /*
1596216071 // Memory intensive (brep.verticescopy)
1596316072 if (!(object instanceof Composite))
1596416073 object.draw(info, 0, false); // SLOW :
1596516074 */
15966
- if (!isRenderer)
16075
+ if (!isRenderer) // && drag)
1596716076 {
1596816077 Grafreed.Assert(object != null);
1596916078 Grafreed.Assert(object.selection != null);
....@@ -15971,9 +16080,9 @@
1597116080 {
1597216081 int hitSomething = object.selection.get(0).hitSomething;
1597316082
15974
- info.DX = 0;
15975
- info.DY = 0;
15976
- info.W = 1;
16083
+ object.clickInfo.DX = 0;
16084
+ object.clickInfo.DY = 0;
16085
+ object.clickInfo.W = 1;
1597716086 if (hitSomething == Object3D.hitCenter)
1597816087 {
1597916088 info.DX = X;
....@@ -15985,7 +16094,8 @@
1598516094 info.DY -= info.bounds.height/2;
1598616095 }
1598716096
15988
- object.drawEditHandles(info, 0);
16097
+ object.drawEditHandles(//info,
16098
+ 0);
1598916099
1599016100 if (drag && (X != 0 || Y != 0))
1599116101 {
....@@ -16484,6 +16594,8 @@
1648416594 private /*static*/ boolean firstime;
1648516595 private /*static*/ cVector newView = new cVector();
1648616596 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"};
1648716599 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1648816600 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1648916601 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16496,29 +16608,66 @@
1649616608 {
1649716609 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1649816610
16611
+ int usedsuf = 0;
16612
+
1649916613 for (int i = 0; i < suffixes.length; i++)
1650016614 {
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)
16615
+ String[] suffixe = suffixes;
16616
+ String[] fallback = suffixes2;
16617
+ String[] fallfallback = suffixes3;
16618
+
16619
+ for (int c=usedsuf; --c>=0;)
1650616620 {
16507
- throw new IOException("Unable to load texture " + resourceName);
16621
+// String[] temp = suffixe;
16622
+// suffixe = fallback;
16623
+// fallback = fallfallback;
16624
+// fallfallback = temp;
1650816625 }
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
+
1650916654 //System.out.println("Target = " + targets[i]);
1651016655 cubemap.updateImage(data, targets[i]);
1651116656 }
1651216657
1651316658 return cubemap;
1651416659 }
16660
+
1651516661 int bigsphere = -1;
1651616662
1651716663 float BGcolor = 0.5f;
1651816664
16519
- private void DrawSkyBox(GL gl)
16665
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16666
+
16667
+ private void DrawSkyBox(GL gl, float ratio)
1652016668 {
16521
- if (envyoff || cubemap == null)
16669
+ if (//envyoff ||
16670
+ cubemap == null)
1652216671 {
1652316672 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1652416673 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16533,7 +16682,17 @@
1653316682 // Compensates for ExaminerViewer's modification of modelview matrix
1653416683 gl.glMatrixMode(GL.GL_MODELVIEW);
1653516684 gl.glLoadIdentity();
16685
+ gl.glScalef(1,ratio,1);
1653616686
16687
+// colorV[0] = 2;
16688
+// colorV[1] = 2;
16689
+// colorV[2] = 2;
16690
+// colorV[3] = 1;
16691
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16692
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16693
+//
16694
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16695
+
1653716696 //gl.glActiveTexture(GL.GL_TEXTURE1);
1653816697 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1653916698
....@@ -16565,6 +16724,7 @@
1656516724 {
1656616725 gl.glScalef(1.0f, -1.0f, 1.0f);
1656716726 }
16727
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1656816728 gl.glMultMatrixd(viewrot_1, 0);
1656916729 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1657016730 //viewer.updateInverseRotation(gl);
....@@ -16823,7 +16983,7 @@
1682316983 //new Exception().printStackTrace();
1682416984 System.out.println("select buffer init");
1682516985 // Use debug pipeline
16826
- drawable.setGL(new DebugGL(drawable.getGL()));
16986
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1682716987
1682816988 GL gl = drawable.getGL();
1682916989