Normand Briere
2019-07-29 c6c3f0948bd31603547ef8ce47a7784a9a4d55c2
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,13 @@
92809314 static double[] model = new double[16];
92819315 double[] camera2light = new double[16];
92829316 double[] light2camera = new double[16];
9283
- int newenvy = -1;
9317
+
9318
+ //int newenvy = -1;
92849319 boolean envyoff = true; // false;
9320
+ String skyboxname = "";
9321
+ String skyboxext;
9322
+ String loadedskyboxname = "";
9323
+
92859324 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
92869325 //float[] light0 = { 0,0,0 };
92879326 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9699,7 +9738,7 @@
96999738
97009739 if (renderCamera != lightCamera)
97019740 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9702
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
9741
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
97039742
97049743 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
97059744
....@@ -9715,7 +9754,7 @@
97159754
97169755 if (renderCamera != lightCamera)
97179756 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9718
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
9757
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
97199758
97209759 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
97219760
....@@ -9761,10 +9800,12 @@
97619800 rati = 1 / rati;
97629801 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
97639802 }
9764
- assert (newenvy == -1);
9803
+
9804
+ //assert (newenvy == -1);
9805
+
97659806 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
97669807 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9767
- DrawSkyBox(gl);
9808
+ DrawSkyBox(gl, (float)rati);
97689809 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
97699810 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
97709811 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -10916,7 +10957,7 @@
1091610957 // if (parentcam != renderCamera) // not a light
1091710958 if (cam != lightCamera)
1091810959 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10919
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
10960
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1092010961
1092110962 for (int j = 0; j < 4; j++)
1092210963 {
....@@ -10931,7 +10972,7 @@
1093110972 // if (parentcam != renderCamera) // not a light
1093210973 if (cam != lightCamera)
1093310974 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
10975
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1093510976
1093610977 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1093710978
....@@ -11017,13 +11058,19 @@
1101711058 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1101811059 }
1101911060
11020
- if (newenvy > -1)
11061
+// if (newenvy > -1)
11062
+// {
11063
+// LoadEnvy(newenvy);
11064
+// }
11065
+//
11066
+// newenvy = -1;
11067
+
11068
+ if (!skyboxname.equals(this.loadedskyboxname))
1102111069 {
11022
- LoadEnvy(newenvy);
11070
+ LoadSkybox(skyboxname + "/", skyboxext, false);
11071
+ loadedskyboxname = skyboxname;
1102311072 }
11024
-
11025
- newenvy = -1;
11026
-
11073
+
1102711074 ratio = ((double) getWidth()) / getHeight();
1102811075 //System.out.println("ratio = " + ratio);
1102911076
....@@ -11039,7 +11086,7 @@
1103911086
1104011087 if (!IsFrozen() && !ambientOcclusion)
1104111088 {
11042
- DrawSkyBox(gl);
11089
+ DrawSkyBox(gl, (float)ratio);
1104311090 }
1104411091
1104511092 //if (selection_view == -1)
....@@ -12399,50 +12446,74 @@
1239912446
1240012447 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240112448
12402
- String program =
12449
+ String program0 =
1240312450 // Min shader
1240412451 "!!ARBfp1.0\n" +
12405
- "PARAM zero123 = { 0.0, 1.0, 2.0, 3.0 };" +
12452
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
1240612453 "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
1240712454 "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1240812455 "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
1240912456 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12457
+ "PARAM light2cam0 = program.env[10];" +
12458
+ "PARAM light2cam1 = program.env[11];" +
12459
+ "PARAM light2cam2 = program.env[12];" +
1241012460 "TEMP temp;" +
1241112461 "TEMP light;" +
1241212462 "TEMP ndotl;" +
1241312463 "TEMP normal;" +
1241412464 "TEMP depth;" +
12465
+ "TEMP eye;" +
12466
+ "TEMP pos;" +
1241512467
1241612468 "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12417
-
12469
+ Normalize("normal") +
1241812470 "MOV light, state.light[0].position;" +
1241912471 "DP3 ndotl.x, light, normal;" +
1242012472
1242112473 // shadow
12422
- "MOV temp, fragment.texcoord[1];" +
12423
- TextureFetch("depth", "temp", "1") +
12474
+ "MOV pos, fragment.texcoord[1];" +
12475
+ "MOV temp, pos;" +
12476
+ ShadowTextureFetch("depth", "temp", "1") +
1242412477 //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12425
- "SLT temp.x, fragment.texcoord[1].z, depth.z;" +
12426
-
12478
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
1242712479
1242812480 // No shadow when out of frustum
1242912481 //"SGE temp.y, depth.z, zero123.y;" +
1243012482 //"LRP temp.x, temp.y, zero123.y, temp.x;" +
1243112483
12432
- "MUL ndotl.x, ndotl.x, temp.x;" +
12433
- "MAX ndotl.x, ndotl.x, pow2.y;" +
12484
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
1243412485
12486
+ // Backlit
12487
+ "MOV pos.w, zero123.y;" +
12488
+ "DP4 eye.x, pos, light2cam0;" +
12489
+ "DP4 eye.y, pos, light2cam1;" +
12490
+ "DP4 eye.z, pos, light2cam2;" +
12491
+ Normalize("eye") +
12492
+
12493
+ "DP3 ndotl.y, -eye, normal;" +
12494
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12495
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12496
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12497
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12498
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12499
+
12500
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12501
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12502
+
12503
+ // Pigment
1243512504 "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12505
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
1243612506 "MUL temp, temp, ndotl.x;" +
1243712507
1243812508 "MUL temp, temp, zero123.z;" +
1243912509
12440
- "MOV temp.w, zero123.y;" + // reset alpha
12510
+ //"MUL temp, temp, ndotl.y;" +
1244112511
12512
+ "MOV temp.w, zero123.y;" + // reset alpha
1244212513 "MOV result.color, temp;" +
1244312514 "END";
1244412515
12445
- String program2 =
12516
+ String program =
1244612517 "!!ARBfp1.0\n" +
1244712518
1244812519 //"OPTION ARB_fragment_program_shadow;" +
....@@ -12580,20 +12651,20 @@
1258012651 "MUL temp, floor, mapgrid.x;" +
1258112652 //"TEX depth0, temp, texture[1], 2D;" +
1258212653 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12583
- TextureFetch("depth0", "temp", "1") +
12654
+ ShadowTextureFetch("depth0", "temp", "1") +
1258412655 "") +
1258512656 "ADD temp.x, temp.x, mapgrid.x;" +
1258612657 //"TEX depth1, temp, texture[1], 2D;" +
1258712658 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12588
- TextureFetch("depth1", "temp", "1") +
12659
+ ShadowTextureFetch("depth1", "temp", "1") +
1258912660 "") +
1259012661 "ADD temp.y, temp.y, mapgrid.x;" +
1259112662 //"TEX depth2, temp, texture[1], 2D;" +
12592
- TextureFetch("depth2", "temp", "1") +
12663
+ ShadowTextureFetch("depth2", "temp", "1") +
1259312664 "SUB temp.x, temp.x, mapgrid.x;" +
1259412665 //"TEX depth3, temp, texture[1], 2D;" +
1259512666 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12596
- TextureFetch("depth3", "temp", "1") +
12667
+ ShadowTextureFetch("depth3", "temp", "1") +
1259712668 "") +
1259812669 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1259912670 //"MOV params, material;" +
....@@ -12967,7 +13038,7 @@
1296713038 // display shadow only (fakedepth == 0)
1296813039 "SUB temp.x, half.x, shadow.x;" +
1296913040 "MOV temp.y, -params5.z;" + // params6.x;" +
12970
- "SLT temp.z, temp.y, -one2048th.x;" +
13041
+ "SLT temp.z, temp.y, -c256i.x;" +
1297113042 "SUB temp.y, one.x, temp.z;" +
1297213043 "MUL temp.x, temp.x, temp.y;" +
1297313044 "KIL temp.x;" +
....@@ -13391,25 +13462,26 @@
1339113462 return out;
1339213463 }
1339313464
13394
- String TextureFetch(String dest, String src, String unit)
13465
+ // Also does frustum culling
13466
+ String ShadowTextureFetch(String dest, String src, String unit)
1339513467 {
1339613468 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1339713469 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1339813470 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13471
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13472
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1339913473 "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;" +
13474
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13475
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1340413476 //"SWZ buffer, temp, w,w,w,w;";
13405
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13477
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1340613478 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1340713479 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1340813480 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13409
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13481
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1341013482
13411
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13412
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13483
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13484
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1341313485 }
1341413486
1341513487 String Shadow(String depth, String shadow)
....@@ -14254,14 +14326,15 @@
1425414326 drag = false;
1425514327 //System.out.println("Mouse DOWN");
1425614328 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);
14329
+ //ClickInfo info = new ClickInfo();
14330
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14331
+ object.clickInfo.pane = this;
14332
+ object.clickInfo.camera = renderCamera;
14333
+ object.clickInfo.x = x;
14334
+ object.clickInfo.y = y;
14335
+ object.clickInfo.modifiers = modifiersex;
14336
+ editObj = object.doEditClick(//info,
14337
+ 0);
1426514338 if (!editObj)
1426614339 {
1426714340 hasMarquee = true;
....@@ -14661,15 +14734,16 @@
1466114734 if (editObj)
1466214735 {
1466314736 drag = true;
14664
- ClickInfo info = new ClickInfo();
14665
- info.bounds.setBounds(0, 0,
14737
+ //ClickInfo info = new ClickInfo();
14738
+ object.clickInfo.bounds.setBounds(0, 0,
1466614739 (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);
14740
+ object.clickInfo.pane = this;
14741
+ object.clickInfo.camera = renderCamera;
14742
+ object.clickInfo.x = x;
14743
+ object.clickInfo.y = y;
14744
+ object //.GetWindow().copy
14745
+ .doEditDrag(//info,
14746
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1467314747 } else
1467414748 {
1467514749 if (x < startX)
....@@ -14818,24 +14892,27 @@
1481814892 }
1481914893 }
1482014894
14895
+// ClickInfo clickInfo = new ClickInfo();
14896
+
1482114897 public void mouseMoved(MouseEvent e)
1482214898 {
1482314899 //System.out.println("mouseMoved: " + e);
1482414900 if (isRenderer)
1482514901 return;
1482614902
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;
14903
+ // Mouse cursor feedback
14904
+ object.clickInfo.x = e.getX();
14905
+ object.clickInfo.y = e.getY();
14906
+ object.clickInfo.modifiers = e.getModifiersEx();
14907
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14908
+ object.clickInfo.pane = this;
14909
+ object.clickInfo.camera = renderCamera;
1483414910 if (!isRenderer)
1483514911 {
1483614912 //ObjEditor editWindow = object.editWindow;
1483714913 //Object3D copy = editWindow.copy;
14838
- if (object.doEditClick(ci, 0))
14914
+ if (object.doEditClick(//clickInfo,
14915
+ 0))
1483914916 {
1484014917 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1484114918 } else
....@@ -15291,14 +15368,18 @@
1529115368 case '3':
1529215369 case '4':
1529315370 case '5':
15294
- newenvy = Character.getNumericValue(key);
15295
- repaint();
15296
- break;
1529715371 case '6':
1529815372 case '7':
1529915373 case '8':
1530015374 case '9':
15301
- BGcolor = (key - '6')/3.f;
15375
+ if (envyoff)
15376
+ {
15377
+ BGcolor = (key - '1')/8.f;
15378
+ }
15379
+ else
15380
+ {
15381
+ //newenvy = Character.getNumericValue(key);
15382
+ }
1530215383 repaint();
1530315384 break;
1530415385 case '!':
....@@ -15861,8 +15942,6 @@
1586115942
1586215943 int width = getBounds().width;
1586315944 int height = getBounds().height;
15864
- ClickInfo info = new ClickInfo();
15865
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1586615945 //Image img = CreateImage(width, height);
1586715946 //System.out.println("width = " + width + "; height = " + height + "\n");
1586815947
....@@ -15939,31 +16018,37 @@
1593916018 }
1594016019 if (object != null && !hasMarquee)
1594116020 {
16021
+ if (object.clickInfo == null)
16022
+ object.clickInfo = new ClickInfo();
16023
+ ClickInfo info = object.clickInfo;
16024
+ //ClickInfo info = new ClickInfo();
16025
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
16026
+
1594216027 if (isRenderer)
1594316028 {
15944
- info.flags++;
16029
+ object.clickInfo.flags++;
1594516030 double frameAspect = (double) width / (double) height;
1594616031 if (frameAspect > renderCamera.aspect)
1594716032 {
1594816033 int desired = (int) ((double) height * renderCamera.aspect);
15949
- info.bounds.width -= width - desired;
15950
- info.bounds.x += (width - desired) / 2;
16034
+ object.clickInfo.bounds.width -= width - desired;
16035
+ object.clickInfo.bounds.x += (width - desired) / 2;
1595116036 } else
1595216037 {
1595316038 int desired = (int) ((double) width / renderCamera.aspect);
15954
- info.bounds.height -= height - desired;
15955
- info.bounds.y += (height - desired) / 2;
16039
+ object.clickInfo.bounds.height -= height - desired;
16040
+ object.clickInfo.bounds.y += (height - desired) / 2;
1595616041 }
1595716042 }
1595816043
15959
- info.g = gr;
15960
- info.camera = renderCamera;
16044
+ object.clickInfo.g = gr;
16045
+ object.clickInfo.camera = renderCamera;
1596116046 /*
1596216047 // Memory intensive (brep.verticescopy)
1596316048 if (!(object instanceof Composite))
1596416049 object.draw(info, 0, false); // SLOW :
1596516050 */
15966
- if (!isRenderer)
16051
+ if (!isRenderer) // && drag)
1596716052 {
1596816053 Grafreed.Assert(object != null);
1596916054 Grafreed.Assert(object.selection != null);
....@@ -15971,9 +16056,9 @@
1597116056 {
1597216057 int hitSomething = object.selection.get(0).hitSomething;
1597316058
15974
- info.DX = 0;
15975
- info.DY = 0;
15976
- info.W = 1;
16059
+ object.clickInfo.DX = 0;
16060
+ object.clickInfo.DY = 0;
16061
+ object.clickInfo.W = 1;
1597716062 if (hitSomething == Object3D.hitCenter)
1597816063 {
1597916064 info.DX = X;
....@@ -15985,7 +16070,8 @@
1598516070 info.DY -= info.bounds.height/2;
1598616071 }
1598716072
15988
- object.drawEditHandles(info, 0);
16073
+ object.drawEditHandles(//info,
16074
+ 0);
1598916075
1599016076 if (drag && (X != 0 || Y != 0))
1599116077 {
....@@ -15998,7 +16084,7 @@
1599816084 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1599916085 break;
1600016086 case Object3D.hitScale: gr.setColor(Color.cyan);
16001
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16087
+ gr.drawLine(X, Y, 0, 0);
1600216088 break;
1600316089 }
1600416090
....@@ -16484,6 +16570,8 @@
1648416570 private /*static*/ boolean firstime;
1648516571 private /*static*/ cVector newView = new cVector();
1648616572 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16573
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16574
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1648716575 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1648816576 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1648916577 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16496,16 +16584,49 @@
1649616584 {
1649716585 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1649816586
16587
+ int usedsuf = 0;
16588
+
1649916589 for (int i = 0; i < suffixes.length; i++)
1650016590 {
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)
16591
+ String[] suffixe = suffixes;
16592
+ String[] fallback = suffixes2;
16593
+ String[] fallfallback = suffixes3;
16594
+
16595
+ for (int c=usedsuf; --c>=0;)
1650616596 {
16507
- throw new IOException("Unable to load texture " + resourceName);
16597
+// String[] temp = suffixe;
16598
+// suffixe = fallback;
16599
+// fallback = fallfallback;
16600
+// fallfallback = temp;
1650816601 }
16602
+
16603
+ String resourceName = basename + suffixe[i] + "." + suffix;
16604
+ TextureData data;
16605
+
16606
+ try
16607
+ {
16608
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16609
+ mipmapped,
16610
+ FileUtil.getFileSuffix(resourceName));
16611
+ }
16612
+ catch (Exception e)
16613
+ {
16614
+ try
16615
+ {
16616
+ resourceName = basename + fallback[i] + "." + suffix;
16617
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16618
+ mipmapped,
16619
+ FileUtil.getFileSuffix(resourceName));
16620
+ }
16621
+ catch (Exception e2)
16622
+ {
16623
+ resourceName = basename + fallfallback[i] + "." + suffix;
16624
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16625
+ mipmapped,
16626
+ FileUtil.getFileSuffix(resourceName));
16627
+ }
16628
+ }
16629
+
1650916630 //System.out.println("Target = " + targets[i]);
1651016631 cubemap.updateImage(data, targets[i]);
1651116632 }
....@@ -16516,7 +16637,9 @@
1651616637
1651716638 float BGcolor = 0.5f;
1651816639
16519
- private void DrawSkyBox(GL gl)
16640
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16641
+
16642
+ private void DrawSkyBox(GL gl, float ratio)
1652016643 {
1652116644 if (envyoff || cubemap == null)
1652216645 {
....@@ -16533,7 +16656,17 @@
1653316656 // Compensates for ExaminerViewer's modification of modelview matrix
1653416657 gl.glMatrixMode(GL.GL_MODELVIEW);
1653516658 gl.glLoadIdentity();
16659
+ gl.glScalef(1,ratio,1);
1653616660
16661
+ colorV[0] = 2;
16662
+ colorV[1] = 2;
16663
+ colorV[2] = 2;
16664
+ colorV[3] = 1;
16665
+ gl.glDisable(gl.GL_COLOR_MATERIAL);
16666
+ gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16667
+
16668
+ gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16669
+
1653716670 //gl.glActiveTexture(GL.GL_TEXTURE1);
1653816671 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1653916672
....@@ -16546,7 +16679,7 @@
1654616679 // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting
1654716680 // causes the normals to be sent down. Thanks to Ken Dyke.
1654816681 //gl.glEnable(GL.GL_LIGHTING);
16549
- gl.glDisable(GL.GL_LIGHTING);
16682
+ gl.glEnable(GL.GL_LIGHTING);
1655016683
1655116684 gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
1655216685 gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
....@@ -16565,6 +16698,7 @@
1656516698 {
1656616699 gl.glScalef(1.0f, -1.0f, 1.0f);
1656716700 }
16701
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1656816702 gl.glMultMatrixd(viewrot_1, 0);
1656916703 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1657016704 //viewer.updateInverseRotation(gl);
....@@ -16823,7 +16957,7 @@
1682316957 //new Exception().printStackTrace();
1682416958 System.out.println("select buffer init");
1682516959 // Use debug pipeline
16826
- drawable.setGL(new DebugGL(drawable.getGL()));
16960
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1682716961
1682816962 GL gl = drawable.getGL();
1682916963