Normand Briere
2019-07-30 475f8cbdbd96fdbf8f5b216ffebb31a51f25c2f9
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 {
....@@ -8931,7 +8944,7 @@
89318944
89328945 if (cubemap == null)
89338946 {
8934
- LoadEnvy(5);
8947
+ //LoadEnvy(1);
89358948 }
89368949
89378950 //cubemap.enable();
....@@ -9218,37 +9231,58 @@
92189231 cubemap = null;
92199232 return;
92209233 case 1:
9221
- name = "cubemaps/box_";
9222
- ext = "png";
9234
+ name = "cubemaps/rgb/";
9235
+ ext = "jpg";
92239236 reverseUP = false;
92249237 break;
92259238 case 2:
9226
- name = "cubemaps/uffizi_";
9227
- ext = "png";
9228
- break; // reverseUP = true; break;
9239
+ name = "cubemaps/uffizi/";
9240
+ ext = "jpg";
9241
+ reverseUP = false;
9242
+ break;
92299243 case 3:
9230
- name = "cubemaps/CloudyHills_";
9231
- ext = "tga";
9244
+ name = "cubemaps/CloudyHills/";
9245
+ ext = "jpg";
92329246 reverseUP = false;
92339247 break;
92349248 case 4:
9235
- name = "cubemaps/cornell_";
9249
+ name = "cubemaps/cornell/";
92369250 ext = "png";
92379251 reverseUP = false;
92389252 break;
9253
+ case 5:
9254
+ name = "cubemaps/skycube/";
9255
+ ext = "jpg";
9256
+ reverseUP = false;
9257
+ break;
9258
+ case 6:
9259
+ name = "cubemaps/SaintLazarusChurch3/";
9260
+ ext = "jpg";
9261
+ reverseUP = false;
9262
+ break;
9263
+ case 7:
9264
+ name = "cubemaps/Sodermalmsallen/";
9265
+ ext = "jpg";
9266
+ reverseUP = false;
9267
+ break;
9268
+ case 8:
9269
+ name = "cubemaps/Sodermalmsallen2/";
9270
+ ext = "jpg";
9271
+ reverseUP = false;
9272
+ break;
9273
+ case 9:
9274
+ name = "cubemaps/UnionSquare/";
9275
+ ext = "jpg";
9276
+ reverseUP = false;
9277
+ break;
92399278 default:
9240
- name = "cubemaps/rgb_";
9241
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9279
+ name = "cubemaps/box/";
9280
+ ext = "png"; /*mipmap = true;*/
9281
+ reverseUP = false;
92429282 break;
92439283 }
9244
-
9245
- try
9246
- {
9247
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
9248
- } catch (IOException e)
9249
- {
9250
- throw new RuntimeException(e);
9251
- }
9284
+
9285
+ LoadSkybox(name, ext, mipmap);
92529286 }
92539287
92549288 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -9280,8 +9314,12 @@
92809314 static double[] model = new double[16];
92819315 double[] camera2light = new double[16];
92829316 double[] light2camera = new double[16];
9283
- int newenvy = -1;
9284
- boolean envyoff = true; // false;
9317
+
9318
+ //int newenvy = -1;
9319
+ //boolean envyoff = false;
9320
+
9321
+ String loadedskyboxname;
9322
+
92859323 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
92869324 //float[] light0 = { 0,0,0 };
92879325 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9699,7 +9737,7 @@
96999737
97009738 if (renderCamera != lightCamera)
97019739 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9702
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
9740
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
97039741
97049742 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
97059743
....@@ -9715,7 +9753,7 @@
97159753
97169754 if (renderCamera != lightCamera)
97179755 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9718
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
9756
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
97199757
97209758 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
97219759
....@@ -9761,10 +9799,12 @@
97619799 rati = 1 / rati;
97629800 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
97639801 }
9764
- assert (newenvy == -1);
9802
+
9803
+ //assert (newenvy == -1);
9804
+
97659805 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
97669806 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9767
- DrawSkyBox(gl);
9807
+ DrawSkyBox(gl, (float)rati);
97689808 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
97699809 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
97709810 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -10916,7 +10956,7 @@
1091610956 // if (parentcam != renderCamera) // not a light
1091710957 if (cam != lightCamera)
1091810958 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10919
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
10959
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1092010960
1092110961 for (int j = 0; j < 4; j++)
1092210962 {
....@@ -10931,7 +10971,7 @@
1093110971 // if (parentcam != renderCamera) // not a light
1093210972 if (cam != lightCamera)
1093310973 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
10974
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1093510975
1093610976 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1093710977
....@@ -11017,13 +11057,27 @@
1101711057 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1101811058 }
1101911059
11020
- if (newenvy > -1)
11060
+// if (newenvy > -1)
11061
+// {
11062
+// LoadEnvy(newenvy);
11063
+// }
11064
+//
11065
+// newenvy = -1;
11066
+
11067
+ if (object.skyboxname != null)
1102111068 {
11022
- LoadEnvy(newenvy);
11069
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11070
+ {
11071
+ LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11072
+ loadedskyboxname = object.skyboxname;
11073
+ }
1102311074 }
11024
-
11025
- newenvy = -1;
11026
-
11075
+ else
11076
+ {
11077
+ cubemap = null;
11078
+ loadedskyboxname = null;
11079
+ }
11080
+
1102711081 ratio = ((double) getWidth()) / getHeight();
1102811082 //System.out.println("ratio = " + ratio);
1102911083
....@@ -11039,7 +11093,7 @@
1103911093
1104011094 if (!IsFrozen() && !ambientOcclusion)
1104111095 {
11042
- DrawSkyBox(gl);
11096
+ DrawSkyBox(gl, (float)ratio);
1104311097 }
1104411098
1104511099 //if (selection_view == -1)
....@@ -12399,8 +12453,76 @@
1239912453
1240012454 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240112455
12456
+ String program0 =
12457
+ // Min shader
12458
+ "!!ARBfp1.0\n" +
12459
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12460
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12461
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12462
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12463
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12464
+ "PARAM light2cam0 = program.env[10];" +
12465
+ "PARAM light2cam1 = program.env[11];" +
12466
+ "PARAM light2cam2 = program.env[12];" +
12467
+ "TEMP temp;" +
12468
+ "TEMP light;" +
12469
+ "TEMP ndotl;" +
12470
+ "TEMP normal;" +
12471
+ "TEMP depth;" +
12472
+ "TEMP eye;" +
12473
+ "TEMP pos;" +
12474
+
12475
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12476
+ Normalize("normal") +
12477
+ "MOV light, state.light[0].position;" +
12478
+ "DP3 ndotl.x, light, normal;" +
12479
+
12480
+ // shadow
12481
+ "MOV pos, fragment.texcoord[1];" +
12482
+ "MOV temp, pos;" +
12483
+ ShadowTextureFetch("depth", "temp", "1") +
12484
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12485
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
12486
+
12487
+ // No shadow when out of frustum
12488
+ //"SGE temp.y, depth.z, zero123.y;" +
12489
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12490
+
12491
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
12492
+
12493
+ // Backlit
12494
+ "MOV pos.w, zero123.y;" +
12495
+ "DP4 eye.x, pos, light2cam0;" +
12496
+ "DP4 eye.y, pos, light2cam1;" +
12497
+ "DP4 eye.z, pos, light2cam2;" +
12498
+ Normalize("eye") +
12499
+
12500
+ "DP3 ndotl.y, -eye, normal;" +
12501
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12502
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12503
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12504
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12505
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12506
+
12507
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12508
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12509
+
12510
+ // Pigment
12511
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12512
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12513
+ "MUL temp, temp, ndotl.x;" +
12514
+
12515
+ "MUL temp, temp, zero123.z;" +
12516
+
12517
+ //"MUL temp, temp, ndotl.y;" +
12518
+
12519
+ "MOV temp.w, zero123.y;" + // reset alpha
12520
+ "MOV result.color, temp;" +
12521
+ "END";
12522
+
1240212523 String program =
1240312524 "!!ARBfp1.0\n" +
12525
+
1240412526 //"OPTION ARB_fragment_program_shadow;" +
1240512527 "PARAM light2cam0 = program.env[10];" +
1240612528 "PARAM light2cam1 = program.env[11];" +
....@@ -12515,8 +12637,7 @@
1251512637 "TEMP shininess;" +
1251612638 "\n" +
1251712639 "MOV texSamp, one;" +
12518
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12519
-
12640
+
1252012641 "MOV mapgrid.x, one2048th.x;" +
1252112642 "MOV temp, fragment.texcoord[1];" +
1252212643 /*
....@@ -12537,20 +12658,20 @@
1253712658 "MUL temp, floor, mapgrid.x;" +
1253812659 //"TEX depth0, temp, texture[1], 2D;" +
1253912660 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12540
- TextureFetch("depth0", "temp", "1") +
12661
+ ShadowTextureFetch("depth0", "temp", "1") +
1254112662 "") +
1254212663 "ADD temp.x, temp.x, mapgrid.x;" +
1254312664 //"TEX depth1, temp, texture[1], 2D;" +
1254412665 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12545
- TextureFetch("depth1", "temp", "1") +
12666
+ ShadowTextureFetch("depth1", "temp", "1") +
1254612667 "") +
1254712668 "ADD temp.y, temp.y, mapgrid.x;" +
1254812669 //"TEX depth2, temp, texture[1], 2D;" +
12549
- TextureFetch("depth2", "temp", "1") +
12670
+ ShadowTextureFetch("depth2", "temp", "1") +
1255012671 "SUB temp.x, temp.x, mapgrid.x;" +
1255112672 //"TEX depth3, temp, texture[1], 2D;" +
1255212673 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12553
- TextureFetch("depth3", "temp", "1") +
12674
+ ShadowTextureFetch("depth3", "temp", "1") +
1255412675 "") +
1255512676 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1255612677 //"MOV params, material;" +
....@@ -12921,10 +13042,10 @@
1292113042 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1292213043 "") +
1292313044
12924
- // display shadow only (bump == 0)
13045
+ // display shadow only (fakedepth == 0)
1292513046 "SUB temp.x, half.x, shadow.x;" +
1292613047 "MOV temp.y, -params5.z;" + // params6.x;" +
12927
- "SLT temp.z, temp.y, -one2048th.x;" +
13048
+ "SLT temp.z, temp.y, -c256i.x;" +
1292813049 "SUB temp.y, one.x, temp.z;" +
1292913050 "MUL temp.x, temp.x, temp.y;" +
1293013051 "KIL temp.x;" +
....@@ -13348,25 +13469,26 @@
1334813469 return out;
1334913470 }
1335013471
13351
- String TextureFetch(String dest, String src, String unit)
13472
+ // Also does frustum culling
13473
+ String ShadowTextureFetch(String dest, String src, String unit)
1335213474 {
1335313475 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1335413476 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1335513477 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13478
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13479
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1335613480 "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;" +
13481
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13482
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1336113483 //"SWZ buffer, temp, w,w,w,w;";
13362
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13484
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1336313485 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1336413486 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1336513487 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13366
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13488
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1336713489
13368
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13369
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13490
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13491
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1337013492 }
1337113493
1337213494 String Shadow(String depth, String shadow)
....@@ -13413,7 +13535,7 @@
1341313535 "SLT temp.x, temp.x, zero.x;" + // shadoweps
1341413536 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1341513537
13416
- // No shadow when out of frustrum
13538
+ // No shadow when out of frustum
1341713539 "SGE temp.x, " + depth + ".z, one.z;" +
1341813540 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1341913541 "";
....@@ -14211,14 +14333,15 @@
1421114333 drag = false;
1421214334 //System.out.println("Mouse DOWN");
1421314335 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);
14336
+ //ClickInfo info = new ClickInfo();
14337
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14338
+ object.clickInfo.pane = this;
14339
+ object.clickInfo.camera = renderCamera;
14340
+ object.clickInfo.x = x;
14341
+ object.clickInfo.y = y;
14342
+ object.clickInfo.modifiers = modifiersex;
14343
+ editObj = object.doEditClick(//info,
14344
+ 0);
1422214345 if (!editObj)
1422314346 {
1422414347 hasMarquee = true;
....@@ -14618,15 +14741,16 @@
1461814741 if (editObj)
1461914742 {
1462014743 drag = true;
14621
- ClickInfo info = new ClickInfo();
14622
- info.bounds.setBounds(0, 0,
14744
+ //ClickInfo info = new ClickInfo();
14745
+ object.clickInfo.bounds.setBounds(0, 0,
1462314746 (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);
14747
+ object.clickInfo.pane = this;
14748
+ object.clickInfo.camera = renderCamera;
14749
+ object.clickInfo.x = x;
14750
+ object.clickInfo.y = y;
14751
+ object //.GetWindow().copy
14752
+ .doEditDrag(//info,
14753
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1463014754 } else
1463114755 {
1463214756 if (x < startX)
....@@ -14775,24 +14899,27 @@
1477514899 }
1477614900 }
1477714901
14902
+// ClickInfo clickInfo = new ClickInfo();
14903
+
1477814904 public void mouseMoved(MouseEvent e)
1477914905 {
1478014906 //System.out.println("mouseMoved: " + e);
1478114907 if (isRenderer)
1478214908 return;
1478314909
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;
14910
+ // Mouse cursor feedback
14911
+ object.clickInfo.x = e.getX();
14912
+ object.clickInfo.y = e.getY();
14913
+ object.clickInfo.modifiers = e.getModifiersEx();
14914
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14915
+ object.clickInfo.pane = this;
14916
+ object.clickInfo.camera = renderCamera;
1479114917 if (!isRenderer)
1479214918 {
1479314919 //ObjEditor editWindow = object.editWindow;
1479414920 //Object3D copy = editWindow.copy;
14795
- if (object.doEditClick(ci, 0))
14921
+ if (object.doEditClick(//clickInfo,
14922
+ 0))
1479614923 {
1479714924 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1479814925 } else
....@@ -15242,20 +15369,24 @@
1524215369 OCCLUSION_CULLING ^= true;
1524315370 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1524415371 break;
15245
- case '0': envyoff ^= true; repaint(); break;
15372
+ //case '0': envyoff ^= true; repaint(); break;
1524615373 case '1':
1524715374 case '2':
1524815375 case '3':
1524915376 case '4':
1525015377 case '5':
15251
- newenvy = Character.getNumericValue(key);
15252
- repaint();
15253
- break;
1525415378 case '6':
1525515379 case '7':
1525615380 case '8':
1525715381 case '9':
15258
- BGcolor = (key - '6')/3.f;
15382
+ if (true) // envyoff)
15383
+ {
15384
+ BGcolor = (key - '1')/8.f;
15385
+ }
15386
+ else
15387
+ {
15388
+ //newenvy = Character.getNumericValue(key);
15389
+ }
1525915390 repaint();
1526015391 break;
1526115392 case '!':
....@@ -15818,8 +15949,6 @@
1581815949
1581915950 int width = getBounds().width;
1582015951 int height = getBounds().height;
15821
- ClickInfo info = new ClickInfo();
15822
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1582315952 //Image img = CreateImage(width, height);
1582415953 //System.out.println("width = " + width + "; height = " + height + "\n");
1582515954
....@@ -15896,31 +16025,37 @@
1589616025 }
1589716026 if (object != null && !hasMarquee)
1589816027 {
16028
+ if (object.clickInfo == null)
16029
+ object.clickInfo = new ClickInfo();
16030
+ ClickInfo info = object.clickInfo;
16031
+ //ClickInfo info = new ClickInfo();
16032
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
16033
+
1589916034 if (isRenderer)
1590016035 {
15901
- info.flags++;
16036
+ object.clickInfo.flags++;
1590216037 double frameAspect = (double) width / (double) height;
1590316038 if (frameAspect > renderCamera.aspect)
1590416039 {
1590516040 int desired = (int) ((double) height * renderCamera.aspect);
15906
- info.bounds.width -= width - desired;
15907
- info.bounds.x += (width - desired) / 2;
16041
+ object.clickInfo.bounds.width -= width - desired;
16042
+ object.clickInfo.bounds.x += (width - desired) / 2;
1590816043 } else
1590916044 {
1591016045 int desired = (int) ((double) width / renderCamera.aspect);
15911
- info.bounds.height -= height - desired;
15912
- info.bounds.y += (height - desired) / 2;
16046
+ object.clickInfo.bounds.height -= height - desired;
16047
+ object.clickInfo.bounds.y += (height - desired) / 2;
1591316048 }
1591416049 }
1591516050
15916
- info.g = gr;
15917
- info.camera = renderCamera;
16051
+ object.clickInfo.g = gr;
16052
+ object.clickInfo.camera = renderCamera;
1591816053 /*
1591916054 // Memory intensive (brep.verticescopy)
1592016055 if (!(object instanceof Composite))
1592116056 object.draw(info, 0, false); // SLOW :
1592216057 */
15923
- if (!isRenderer)
16058
+ if (!isRenderer) // && drag)
1592416059 {
1592516060 Grafreed.Assert(object != null);
1592616061 Grafreed.Assert(object.selection != null);
....@@ -15928,9 +16063,9 @@
1592816063 {
1592916064 int hitSomething = object.selection.get(0).hitSomething;
1593016065
15931
- info.DX = 0;
15932
- info.DY = 0;
15933
- info.W = 1;
16066
+ object.clickInfo.DX = 0;
16067
+ object.clickInfo.DY = 0;
16068
+ object.clickInfo.W = 1;
1593416069 if (hitSomething == Object3D.hitCenter)
1593516070 {
1593616071 info.DX = X;
....@@ -15942,7 +16077,8 @@
1594216077 info.DY -= info.bounds.height/2;
1594316078 }
1594416079
15945
- object.drawEditHandles(info, 0);
16080
+ object.drawEditHandles(//info,
16081
+ 0);
1594616082
1594716083 if (drag && (X != 0 || Y != 0))
1594816084 {
....@@ -15955,7 +16091,7 @@
1595516091 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1595616092 break;
1595716093 case Object3D.hitScale: gr.setColor(Color.cyan);
15958
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16094
+ gr.drawLine(X, Y, 0, 0);
1595916095 break;
1596016096 }
1596116097
....@@ -16441,6 +16577,8 @@
1644116577 private /*static*/ boolean firstime;
1644216578 private /*static*/ cVector newView = new cVector();
1644316579 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16580
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16581
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1644416582 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1644516583 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1644616584 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16453,29 +16591,66 @@
1645316591 {
1645416592 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1645516593
16594
+ int usedsuf = 0;
16595
+
1645616596 for (int i = 0; i < suffixes.length; i++)
1645716597 {
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)
16598
+ String[] suffixe = suffixes;
16599
+ String[] fallback = suffixes2;
16600
+ String[] fallfallback = suffixes3;
16601
+
16602
+ for (int c=usedsuf; --c>=0;)
1646316603 {
16464
- throw new IOException("Unable to load texture " + resourceName);
16604
+// String[] temp = suffixe;
16605
+// suffixe = fallback;
16606
+// fallback = fallfallback;
16607
+// fallfallback = temp;
1646516608 }
16609
+
16610
+ String resourceName = basename + suffixe[i] + "." + suffix;
16611
+ TextureData data;
16612
+
16613
+ try
16614
+ {
16615
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16616
+ mipmapped,
16617
+ FileUtil.getFileSuffix(resourceName));
16618
+ }
16619
+ catch (Exception e)
16620
+ {
16621
+ try
16622
+ {
16623
+ resourceName = basename + fallback[i] + "." + suffix;
16624
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16625
+ mipmapped,
16626
+ FileUtil.getFileSuffix(resourceName));
16627
+ }
16628
+ catch (Exception e2)
16629
+ {
16630
+ resourceName = basename + fallfallback[i] + "." + suffix;
16631
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16632
+ mipmapped,
16633
+ FileUtil.getFileSuffix(resourceName));
16634
+ }
16635
+ }
16636
+
1646616637 //System.out.println("Target = " + targets[i]);
1646716638 cubemap.updateImage(data, targets[i]);
1646816639 }
1646916640
1647016641 return cubemap;
1647116642 }
16643
+
1647216644 int bigsphere = -1;
1647316645
1647416646 float BGcolor = 0.5f;
1647516647
16476
- private void DrawSkyBox(GL gl)
16648
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16649
+
16650
+ private void DrawSkyBox(GL gl, float ratio)
1647716651 {
16478
- if (envyoff || cubemap == null)
16652
+ if (//envyoff ||
16653
+ cubemap == null)
1647916654 {
1648016655 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1648116656 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16490,7 +16665,17 @@
1649016665 // Compensates for ExaminerViewer's modification of modelview matrix
1649116666 gl.glMatrixMode(GL.GL_MODELVIEW);
1649216667 gl.glLoadIdentity();
16668
+ gl.glScalef(1,ratio,1);
1649316669
16670
+ colorV[0] = 2;
16671
+ colorV[1] = 2;
16672
+ colorV[2] = 2;
16673
+ colorV[3] = 1;
16674
+ gl.glDisable(gl.GL_COLOR_MATERIAL);
16675
+ gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16676
+
16677
+ gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16678
+
1649416679 //gl.glActiveTexture(GL.GL_TEXTURE1);
1649516680 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1649616681
....@@ -16503,7 +16688,7 @@
1650316688 // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting
1650416689 // causes the normals to be sent down. Thanks to Ken Dyke.
1650516690 //gl.glEnable(GL.GL_LIGHTING);
16506
- gl.glDisable(GL.GL_LIGHTING);
16691
+ gl.glEnable(GL.GL_LIGHTING);
1650716692
1650816693 gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
1650916694 gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
....@@ -16522,6 +16707,7 @@
1652216707 {
1652316708 gl.glScalef(1.0f, -1.0f, 1.0f);
1652416709 }
16710
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1652516711 gl.glMultMatrixd(viewrot_1, 0);
1652616712 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1652716713 //viewer.updateInverseRotation(gl);
....@@ -16780,7 +16966,7 @@
1678016966 //new Exception().printStackTrace();
1678116967 System.out.println("select buffer init");
1678216968 // Use debug pipeline
16783
- drawable.setGL(new DebugGL(drawable.getGL()));
16969
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1678416970
1678516971 GL gl = drawable.getGL();
1678616972