Normand Briere
2019-08-12 8f1afe25ea8fc8801aab66331c32a50859a758c2
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 }
....@@ -8755,10 +8778,12 @@
87558778
87568779 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
87578780 MAXSTACK = temp[0];
8758
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8781
+ if (Globals.DEBUG)
8782
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
87598783 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
87608784 MAXSTACK = temp[0];
8761
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8785
+ if (Globals.DEBUG)
8786
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
87628787
87638788 // Use debug pipeline
87648789 //drawable.setGL(new DebugGL(gl)); //
....@@ -8766,7 +8791,8 @@
87668791 gl = drawable.getGL(); //
87678792
87688793 GL gl3 = getGL();
8769
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8794
+ if (Globals.DEBUG)
8795
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
87708796
87718797
87728798 //float pos[] = { 100, 100, 100, 0 };
....@@ -8931,7 +8957,7 @@
89318957
89328958 if (cubemap == null)
89338959 {
8934
- LoadEnvy(5);
8960
+ //LoadEnvy(1);
89358961 }
89368962
89378963 //cubemap.enable();
....@@ -9218,37 +9244,58 @@
92189244 cubemap = null;
92199245 return;
92209246 case 1:
9221
- name = "cubemaps/box_";
9222
- ext = "png";
9247
+ name = "cubemaps/rgb/";
9248
+ ext = "jpg";
92239249 reverseUP = false;
92249250 break;
92259251 case 2:
9226
- name = "cubemaps/uffizi_";
9227
- ext = "png";
9228
- break; // reverseUP = true; break;
9252
+ name = "cubemaps/uffizi/";
9253
+ ext = "jpg";
9254
+ reverseUP = false;
9255
+ break;
92299256 case 3:
9230
- name = "cubemaps/CloudyHills_";
9231
- ext = "tga";
9257
+ name = "cubemaps/CloudyHills/";
9258
+ ext = "jpg";
92329259 reverseUP = false;
92339260 break;
92349261 case 4:
9235
- name = "cubemaps/cornell_";
9262
+ name = "cubemaps/cornell/";
92369263 ext = "png";
92379264 reverseUP = false;
92389265 break;
9266
+ case 5:
9267
+ name = "cubemaps/skycube/";
9268
+ ext = "jpg";
9269
+ reverseUP = false;
9270
+ break;
9271
+ case 6:
9272
+ name = "cubemaps/SaintLazarusChurch3/";
9273
+ ext = "jpg";
9274
+ reverseUP = false;
9275
+ break;
9276
+ case 7:
9277
+ name = "cubemaps/Sodermalmsallen/";
9278
+ ext = "jpg";
9279
+ reverseUP = false;
9280
+ break;
9281
+ case 8:
9282
+ name = "cubemaps/Sodermalmsallen2/";
9283
+ ext = "jpg";
9284
+ reverseUP = false;
9285
+ break;
9286
+ case 9:
9287
+ name = "cubemaps/UnionSquare/";
9288
+ ext = "jpg";
9289
+ reverseUP = false;
9290
+ break;
92399291 default:
9240
- name = "cubemaps/rgb_";
9241
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9292
+ name = "cubemaps/box/";
9293
+ ext = "png"; /*mipmap = true;*/
9294
+ reverseUP = false;
92429295 break;
92439296 }
9244
-
9245
- try
9246
- {
9247
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
9248
- } catch (IOException e)
9249
- {
9250
- throw new RuntimeException(e);
9251
- }
9297
+
9298
+ LoadSkybox(name, ext, mipmap);
92529299 }
92539300
92549301 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -9280,8 +9327,12 @@
92809327 static double[] model = new double[16];
92819328 double[] camera2light = new double[16];
92829329 double[] light2camera = new double[16];
9283
- int newenvy = -1;
9284
- boolean envyoff = true; // false;
9330
+
9331
+ //int newenvy = -1;
9332
+ //boolean envyoff = false;
9333
+
9334
+ String loadedskyboxname;
9335
+
92859336 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
92869337 //float[] light0 = { 0,0,0 };
92879338 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9699,7 +9750,7 @@
96999750
97009751 if (renderCamera != lightCamera)
97019752 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9702
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
9753
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
97039754
97049755 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
97059756
....@@ -9715,7 +9766,7 @@
97159766
97169767 if (renderCamera != lightCamera)
97179768 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9718
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
9769
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
97199770
97209771 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
97219772
....@@ -9761,10 +9812,12 @@
97619812 rati = 1 / rati;
97629813 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
97639814 }
9764
- assert (newenvy == -1);
9815
+
9816
+ //assert (newenvy == -1);
9817
+
97659818 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
97669819 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9767
- DrawSkyBox(gl);
9820
+ DrawSkyBox(gl, (float)rati);
97689821 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
97699822 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
97709823 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -10801,7 +10854,7 @@
1080110854
1080210855 if (wait)
1080310856 {
10804
- Sleep(500);
10857
+ Sleep(200); // blocks everything
1080510858
1080610859 wait = false;
1080710860 }
....@@ -10916,7 +10969,7 @@
1091610969 // if (parentcam != renderCamera) // not a light
1091710970 if (cam != lightCamera)
1091810971 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10919
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
10972
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1092010973
1092110974 for (int j = 0; j < 4; j++)
1092210975 {
....@@ -10931,7 +10984,7 @@
1093110984 // if (parentcam != renderCamera) // not a light
1093210985 if (cam != lightCamera)
1093310986 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
10987
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1093510988
1093610989 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1093710990
....@@ -11017,13 +11070,27 @@
1101711070 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1101811071 }
1101911072
11020
- if (newenvy > -1)
11073
+// if (newenvy > -1)
11074
+// {
11075
+// LoadEnvy(newenvy);
11076
+// }
11077
+//
11078
+// newenvy = -1;
11079
+
11080
+ if (object.skyboxname != null)
1102111081 {
11022
- LoadEnvy(newenvy);
11082
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11083
+ {
11084
+ LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11085
+ loadedskyboxname = object.skyboxname;
11086
+ }
1102311087 }
11024
-
11025
- newenvy = -1;
11026
-
11088
+ else
11089
+ {
11090
+ cubemap = null;
11091
+ loadedskyboxname = null;
11092
+ }
11093
+
1102711094 ratio = ((double) getWidth()) / getHeight();
1102811095 //System.out.println("ratio = " + ratio);
1102911096
....@@ -11039,7 +11106,7 @@
1103911106
1104011107 if (!IsFrozen() && !ambientOcclusion)
1104111108 {
11042
- DrawSkyBox(gl);
11109
+ DrawSkyBox(gl, (float)ratio);
1104311110 }
1104411111
1104511112 //if (selection_view == -1)
....@@ -11325,7 +11392,7 @@
1132511392
1132611393 // if (cam != lightCamera)
1132711394 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11328
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11395
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1132911396 }
1133011397
1133111398 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12399,8 +12466,76 @@
1239912466
1240012467 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240112468
12402
- String program =
12469
+ String programmin =
12470
+ // Min shader
1240312471 "!!ARBfp1.0\n" +
12472
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12473
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12474
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12475
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12476
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12477
+ "PARAM light2cam0 = program.env[10];" +
12478
+ "PARAM light2cam1 = program.env[11];" +
12479
+ "PARAM light2cam2 = program.env[12];" +
12480
+ "TEMP temp;" +
12481
+ "TEMP light;" +
12482
+ "TEMP ndotl;" +
12483
+ "TEMP normal;" +
12484
+ "TEMP depth;" +
12485
+ "TEMP eye;" +
12486
+ "TEMP pos;" +
12487
+
12488
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12489
+ Normalize("normal") +
12490
+ "MOV light, state.light[0].position;" +
12491
+ "DP3 ndotl.x, light, normal;" +
12492
+
12493
+ // shadow
12494
+ "MOV pos, fragment.texcoord[1];" +
12495
+ "MOV temp, pos;" +
12496
+ ShadowTextureFetch("depth", "temp", "1") +
12497
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12498
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
12499
+
12500
+ // No shadow when out of frustum
12501
+ //"SGE temp.y, depth.z, zero123.y;" +
12502
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12503
+
12504
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
12505
+
12506
+ // Backlit
12507
+ "MOV pos.w, zero123.y;" +
12508
+ "DP4 eye.x, pos, light2cam0;" +
12509
+ "DP4 eye.y, pos, light2cam1;" +
12510
+ "DP4 eye.z, pos, light2cam2;" +
12511
+ Normalize("eye") +
12512
+
12513
+ "DP3 ndotl.y, -eye, normal;" +
12514
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12515
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12516
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12517
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12518
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12519
+
12520
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12521
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12522
+
12523
+ // Pigment
12524
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12525
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12526
+ "MUL temp, temp, ndotl.x;" +
12527
+
12528
+ "MUL temp, temp, zero123.z;" +
12529
+
12530
+ //"MUL temp, temp, ndotl.y;" +
12531
+
12532
+ "MOV temp.w, zero123.y;" + // reset alpha
12533
+ "MOV result.color, temp;" +
12534
+ "END";
12535
+
12536
+ String programmax =
12537
+ "!!ARBfp1.0\n" +
12538
+
1240412539 //"OPTION ARB_fragment_program_shadow;" +
1240512540 "PARAM light2cam0 = program.env[10];" +
1240612541 "PARAM light2cam1 = program.env[11];" +
....@@ -12515,8 +12650,7 @@
1251512650 "TEMP shininess;" +
1251612651 "\n" +
1251712652 "MOV texSamp, one;" +
12518
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12519
-
12653
+
1252012654 "MOV mapgrid.x, one2048th.x;" +
1252112655 "MOV temp, fragment.texcoord[1];" +
1252212656 /*
....@@ -12537,20 +12671,20 @@
1253712671 "MUL temp, floor, mapgrid.x;" +
1253812672 //"TEX depth0, temp, texture[1], 2D;" +
1253912673 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12540
- TextureFetch("depth0", "temp", "1") +
12674
+ ShadowTextureFetch("depth0", "temp", "1") +
1254112675 "") +
1254212676 "ADD temp.x, temp.x, mapgrid.x;" +
1254312677 //"TEX depth1, temp, texture[1], 2D;" +
1254412678 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12545
- TextureFetch("depth1", "temp", "1") +
12679
+ ShadowTextureFetch("depth1", "temp", "1") +
1254612680 "") +
1254712681 "ADD temp.y, temp.y, mapgrid.x;" +
1254812682 //"TEX depth2, temp, texture[1], 2D;" +
12549
- TextureFetch("depth2", "temp", "1") +
12683
+ ShadowTextureFetch("depth2", "temp", "1") +
1255012684 "SUB temp.x, temp.x, mapgrid.x;" +
1255112685 //"TEX depth3, temp, texture[1], 2D;" +
1255212686 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12553
- TextureFetch("depth3", "temp", "1") +
12687
+ ShadowTextureFetch("depth3", "temp", "1") +
1255412688 "") +
1255512689 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1255612690 //"MOV params, material;" +
....@@ -12921,10 +13055,10 @@
1292113055 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1292213056 "") +
1292313057
12924
- // display shadow only (bump == 0)
13058
+ // display shadow only (fakedepth == 0)
1292513059 "SUB temp.x, half.x, shadow.x;" +
1292613060 "MOV temp.y, -params5.z;" + // params6.x;" +
12927
- "SLT temp.z, temp.y, -one2048th.x;" +
13061
+ "SLT temp.z, temp.y, -c256i.x;" +
1292813062 "SUB temp.y, one.x, temp.z;" +
1292913063 "MUL temp.x, temp.x, temp.y;" +
1293013064 "KIL temp.x;" +
....@@ -13255,6 +13389,13 @@
1325513389 //once = true;
1325613390 }
1325713391
13392
+ String program = programmax;
13393
+
13394
+ if (Globals.MINSHADER)
13395
+ {
13396
+ program = programmin;
13397
+ }
13398
+
1325813399 System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1325913400 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1326013401 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
....@@ -13348,25 +13489,26 @@
1334813489 return out;
1334913490 }
1335013491
13351
- String TextureFetch(String dest, String src, String unit)
13492
+ // Also does frustum culling
13493
+ String ShadowTextureFetch(String dest, String src, String unit)
1335213494 {
1335313495 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1335413496 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1335513497 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13498
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13499
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1335613500 "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;" +
13501
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13502
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1336113503 //"SWZ buffer, temp, w,w,w,w;";
13362
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13504
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1336313505 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1336413506 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1336513507 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13366
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13508
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1336713509
13368
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13369
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13510
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13511
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1337013512 }
1337113513
1337213514 String Shadow(String depth, String shadow)
....@@ -13413,7 +13555,7 @@
1341313555 "SLT temp.x, temp.x, zero.x;" + // shadoweps
1341413556 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1341513557
13416
- // No shadow when out of frustrum
13558
+ // No shadow when out of frustum
1341713559 "SGE temp.x, " + depth + ".z, one.z;" +
1341813560 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1341913561 "";
....@@ -14211,14 +14353,15 @@
1421114353 drag = false;
1421214354 //System.out.println("Mouse DOWN");
1421314355 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);
14356
+ //ClickInfo info = new ClickInfo();
14357
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14358
+ object.clickInfo.pane = this;
14359
+ object.clickInfo.camera = renderCamera;
14360
+ object.clickInfo.x = x;
14361
+ object.clickInfo.y = y;
14362
+ object.clickInfo.modifiers = modifiersex;
14363
+ editObj = object.doEditClick(//info,
14364
+ 0);
1422214365 if (!editObj)
1422314366 {
1422414367 hasMarquee = true;
....@@ -14502,9 +14645,9 @@
1450214645 MODIFIERS |= COMMAND;
1450314646 /**/
1450414647 if((mod&SHIFT) == SHIFT)
14505
- manipCamera.RotatePosition(0, -speed);
14506
- else
1450714648 manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14649
+ else
14650
+ manipCamera.RotatePosition(0, -speed);
1450814651 /**/
1450914652 if ((mod & SHIFT) == SHIFT)
1451014653 {
....@@ -14523,9 +14666,9 @@
1452314666 MODIFIERS |= COMMAND;
1452414667 /**/
1452514668 if((mod&SHIFT) == SHIFT)
14526
- manipCamera.RotatePosition(0, speed);
14527
- else
1452814669 manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14670
+ else
14671
+ manipCamera.RotatePosition(0, speed);
1452914672 /**/
1453014673 if ((mod & SHIFT) == SHIFT)
1453114674 {
....@@ -14618,15 +14761,16 @@
1461814761 if (editObj)
1461914762 {
1462014763 drag = true;
14621
- ClickInfo info = new ClickInfo();
14622
- info.bounds.setBounds(0, 0,
14764
+ //ClickInfo info = new ClickInfo();
14765
+ object.clickInfo.bounds.setBounds(0, 0,
1462314766 (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);
14767
+ object.clickInfo.pane = this;
14768
+ object.clickInfo.camera = renderCamera;
14769
+ object.clickInfo.x = x;
14770
+ object.clickInfo.y = y;
14771
+ object //.GetWindow().copy
14772
+ .doEditDrag(//info,
14773
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1463014774 } else
1463114775 {
1463214776 if (x < startX)
....@@ -14775,24 +14919,27 @@
1477514919 }
1477614920 }
1477714921
14922
+// ClickInfo clickInfo = new ClickInfo();
14923
+
1477814924 public void mouseMoved(MouseEvent e)
1477914925 {
1478014926 //System.out.println("mouseMoved: " + e);
1478114927 if (isRenderer)
1478214928 return;
1478314929
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;
14930
+ // Mouse cursor feedback
14931
+ object.clickInfo.x = e.getX();
14932
+ object.clickInfo.y = e.getY();
14933
+ object.clickInfo.modifiers = e.getModifiersEx();
14934
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14935
+ object.clickInfo.pane = this;
14936
+ object.clickInfo.camera = renderCamera;
1479114937 if (!isRenderer)
1479214938 {
1479314939 //ObjEditor editWindow = object.editWindow;
1479414940 //Object3D copy = editWindow.copy;
14795
- if (object.doEditClick(ci, 0))
14941
+ if (object.doEditClick(//clickInfo,
14942
+ 0))
1479614943 {
1479714944 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1479814945 } else
....@@ -15242,20 +15389,24 @@
1524215389 OCCLUSION_CULLING ^= true;
1524315390 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1524415391 break;
15245
- case '0': envyoff ^= true; repaint(); break;
15392
+ //case '0': envyoff ^= true; repaint(); break;
1524615393 case '1':
1524715394 case '2':
1524815395 case '3':
1524915396 case '4':
1525015397 case '5':
15251
- newenvy = Character.getNumericValue(key);
15252
- repaint();
15253
- break;
1525415398 case '6':
1525515399 case '7':
1525615400 case '8':
1525715401 case '9':
15258
- BGcolor = (key - '6')/3.f;
15402
+ if (true) // envyoff)
15403
+ {
15404
+ BGcolor = (key - '1')/8.f;
15405
+ }
15406
+ else
15407
+ {
15408
+ //newenvy = Character.getNumericValue(key);
15409
+ }
1525915410 repaint();
1526015411 break;
1526115412 case '!':
....@@ -15818,8 +15969,6 @@
1581815969
1581915970 int width = getBounds().width;
1582015971 int height = getBounds().height;
15821
- ClickInfo info = new ClickInfo();
15822
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1582315972 //Image img = CreateImage(width, height);
1582415973 //System.out.println("width = " + width + "; height = " + height + "\n");
1582515974
....@@ -15896,31 +16045,37 @@
1589616045 }
1589716046 if (object != null && !hasMarquee)
1589816047 {
16048
+ if (object.clickInfo == null)
16049
+ object.clickInfo = new ClickInfo();
16050
+ ClickInfo info = object.clickInfo;
16051
+ //ClickInfo info = new ClickInfo();
16052
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
16053
+
1589916054 if (isRenderer)
1590016055 {
15901
- info.flags++;
16056
+ object.clickInfo.flags++;
1590216057 double frameAspect = (double) width / (double) height;
1590316058 if (frameAspect > renderCamera.aspect)
1590416059 {
1590516060 int desired = (int) ((double) height * renderCamera.aspect);
15906
- info.bounds.width -= width - desired;
15907
- info.bounds.x += (width - desired) / 2;
16061
+ object.clickInfo.bounds.width -= width - desired;
16062
+ object.clickInfo.bounds.x += (width - desired) / 2;
1590816063 } else
1590916064 {
1591016065 int desired = (int) ((double) width / renderCamera.aspect);
15911
- info.bounds.height -= height - desired;
15912
- info.bounds.y += (height - desired) / 2;
16066
+ object.clickInfo.bounds.height -= height - desired;
16067
+ object.clickInfo.bounds.y += (height - desired) / 2;
1591316068 }
1591416069 }
1591516070
15916
- info.g = gr;
15917
- info.camera = renderCamera;
16071
+ object.clickInfo.g = gr;
16072
+ object.clickInfo.camera = renderCamera;
1591816073 /*
1591916074 // Memory intensive (brep.verticescopy)
1592016075 if (!(object instanceof Composite))
1592116076 object.draw(info, 0, false); // SLOW :
1592216077 */
15923
- if (!isRenderer)
16078
+ if (!isRenderer) // && drag)
1592416079 {
1592516080 Grafreed.Assert(object != null);
1592616081 Grafreed.Assert(object.selection != null);
....@@ -15928,9 +16083,9 @@
1592816083 {
1592916084 int hitSomething = object.selection.get(0).hitSomething;
1593016085
15931
- info.DX = 0;
15932
- info.DY = 0;
15933
- info.W = 1;
16086
+ object.clickInfo.DX = 0;
16087
+ object.clickInfo.DY = 0;
16088
+ object.clickInfo.W = 1;
1593416089 if (hitSomething == Object3D.hitCenter)
1593516090 {
1593616091 info.DX = X;
....@@ -15942,7 +16097,8 @@
1594216097 info.DY -= info.bounds.height/2;
1594316098 }
1594416099
15945
- object.drawEditHandles(info, 0);
16100
+ object.drawEditHandles(//info,
16101
+ 0);
1594616102
1594716103 if (drag && (X != 0 || Y != 0))
1594816104 {
....@@ -16441,6 +16597,8 @@
1644116597 private /*static*/ boolean firstime;
1644216598 private /*static*/ cVector newView = new cVector();
1644316599 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16600
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16601
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1644416602 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1644516603 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1644616604 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16453,29 +16611,67 @@
1645316611 {
1645416612 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1645516613
16614
+ int usedsuf = 0;
16615
+
1645616616 for (int i = 0; i < suffixes.length; i++)
1645716617 {
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)
16618
+ String[] suffixe = suffixes;
16619
+ String[] fallback = suffixes2;
16620
+ String[] fallfallback = suffixes3;
16621
+
16622
+ for (int c=usedsuf; --c>=0;)
1646316623 {
16464
- throw new IOException("Unable to load texture " + resourceName);
16624
+// String[] temp = suffixe;
16625
+// suffixe = fallback;
16626
+// fallback = fallfallback;
16627
+// fallfallback = temp;
1646516628 }
16629
+
16630
+ String resourceName = basename + suffixe[i] + "." + suffix;
16631
+ TextureData data;
16632
+
16633
+ try
16634
+ {
16635
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16636
+ mipmapped,
16637
+ FileUtil.getFileSuffix(resourceName));
16638
+ }
16639
+ catch (Exception e)
16640
+ {
16641
+ try
16642
+ {
16643
+ resourceName = basename + fallback[i] + "." + suffix;
16644
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16645
+ mipmapped,
16646
+ FileUtil.getFileSuffix(resourceName));
16647
+ }
16648
+ catch (Exception e2)
16649
+ {
16650
+ resourceName = basename + fallfallback[i] + "." + suffix;
16651
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16652
+ mipmapped,
16653
+ FileUtil.getFileSuffix(resourceName));
16654
+ }
16655
+ }
16656
+
1646616657 //System.out.println("Target = " + targets[i]);
1646716658 cubemap.updateImage(data, targets[i]);
1646816659 }
1646916660
1647016661 return cubemap;
1647116662 }
16663
+
1647216664 int bigsphere = -1;
1647316665
1647416666 float BGcolor = 0.5f;
1647516667
16476
- private void DrawSkyBox(GL gl)
16668
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16669
+
16670
+ private void DrawSkyBox(GL gl, float ratio)
1647716671 {
16478
- if (envyoff || cubemap == null)
16672
+ if (//envyoff ||
16673
+ WIREFRAME ||
16674
+ cubemap == null)
1647916675 {
1648016676 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1648116677 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16490,7 +16686,17 @@
1649016686 // Compensates for ExaminerViewer's modification of modelview matrix
1649116687 gl.glMatrixMode(GL.GL_MODELVIEW);
1649216688 gl.glLoadIdentity();
16689
+ gl.glScalef(1,ratio,1);
1649316690
16691
+// colorV[0] = 2;
16692
+// colorV[1] = 2;
16693
+// colorV[2] = 2;
16694
+// colorV[3] = 1;
16695
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16696
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16697
+//
16698
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16699
+
1649416700 //gl.glActiveTexture(GL.GL_TEXTURE1);
1649516701 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1649616702
....@@ -16522,6 +16728,7 @@
1652216728 {
1652316729 gl.glScalef(1.0f, -1.0f, 1.0f);
1652416730 }
16731
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1652516732 gl.glMultMatrixd(viewrot_1, 0);
1652616733 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1652716734 //viewer.updateInverseRotation(gl);
....@@ -16780,7 +16987,7 @@
1678016987 //new Exception().printStackTrace();
1678116988 System.out.println("select buffer init");
1678216989 // Use debug pipeline
16783
- drawable.setGL(new DebugGL(drawable.getGL()));
16990
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1678416991
1678516992 GL gl = drawable.getGL();
1678616993