Normand Briere
2019-08-16 83d0c2fa0bd2e96448f776144e1a89cdb1bb6998
CameraPane.java
....@@ -110,7 +110,11 @@
110110 //private Mat4f spotlightTransform = new Mat4f();
111111 //private Mat4f spotlightInverseTransform = new Mat4f();
112112 static GLContext glcontext = null;
113
- /*static*/ com.sun.opengl.util.texture.Texture cubemap;
113
+ /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb
114
+ /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom;
115
+ /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb;
116
+ boolean transformMode;
117
+
114118 boolean reverseUP = false;
115119 static boolean frozen = false;
116120 boolean enablebackspace = false; // patch for back buffer refresh
....@@ -173,7 +177,7 @@
173177 static boolean doublesided = false; // true; // reversed normals are awful for conformance
174178 boolean anisotropy = true;
175179 boolean softshadow = true; // slower but better false;
176
- boolean opacityhalo = false;
180
+ boolean opacityhalo = false; // reverse the halo effect (e.g. glass)
177181
178182 boolean macromode = false;
179183
....@@ -187,6 +191,19 @@
187191 }
188192
189193 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
194
+
195
+ public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
196
+ {
197
+ try
198
+ {
199
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
200
+ } catch (IOException e)
201
+ {
202
+ System.out.println("NAME = " + name);
203
+ e.printStackTrace(); // throw new RuntimeException(e);
204
+ return null;
205
+ }
206
+ }
190207
191208 void SetAsGLRenderer(boolean b)
192209 {
....@@ -1485,6 +1502,8 @@
14851502 gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
14861503 }
14871504
1505
+ float[] colorV = new float[4];
1506
+
14881507 void SetColor(Object3D obj, Vertex p0)
14891508 {
14901509 CameraPane display = this;
....@@ -1552,8 +1571,6 @@
15521571 {
15531572 return;
15541573 }
1555
-
1556
- float[] colorV = new float[3];
15571574
15581575 if (false) // marked)
15591576 {
....@@ -2500,7 +2517,7 @@
25002517 com.sun.opengl.util.texture.TextureIO.newTextureData(
25012518 getClass().getClassLoader().getResourceAsStream(name),
25022519 true,
2503
- com.sun.opengl.util.texture.TextureIO.PNG);
2520
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
25042521 } catch (java.io.IOException e)
25052522 {
25062523 throw new javax.media.opengl.GLException(e);
....@@ -8346,7 +8363,7 @@
83468363 // else
83478364 // if (!texname.startsWith("/"))
83488365 // texname = "/Users/nbriere/Textures/" + texname;
8349
- if (!FileExists(texname))
8366
+ if (!FileExists(texname) && !texname.startsWith("@"))
83508367 {
83518368 texname = fallbackTextureName;
83528369 }
....@@ -8429,6 +8446,15 @@
84298446 new Exception().printStackTrace();
84308447 } else
84318448 {
8449
+ if (texname.startsWith("@"))
8450
+ {
8451
+ // texturecache = textures.get(texname); // suspicious
8452
+ if (texturecache == null)
8453
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8454
+ else
8455
+ new Exception().printStackTrace();
8456
+ } else
8457
+ {
84328458 if (textureon)
84338459 {
84348460 String cachename = texname;
....@@ -8488,6 +8514,7 @@
84888514 texturecache = new CacheTexture(texturedata,resolution);
84898515 //texture = GetTexture(tex, bump);
84908516 }
8517
+ }
84918518 }
84928519 //}
84938520 }
....@@ -8756,10 +8783,12 @@
87568783
87578784 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
87588785 MAXSTACK = temp[0];
8759
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8786
+ if (Globals.DEBUG)
8787
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
87608788 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
87618789 MAXSTACK = temp[0];
8762
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8790
+ if (Globals.DEBUG)
8791
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
87638792
87648793 // Use debug pipeline
87658794 //drawable.setGL(new DebugGL(gl)); //
....@@ -8767,7 +8796,8 @@
87678796 gl = drawable.getGL(); //
87688797
87698798 GL gl3 = getGL();
8770
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8799
+ if (Globals.DEBUG)
8800
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
87718801
87728802
87738803 //float pos[] = { 100, 100, 100, 0 };
....@@ -8932,7 +8962,7 @@
89328962
89338963 if (cubemap == null)
89348964 {
8935
- LoadEnvy(5);
8965
+ //LoadEnvy(1);
89368966 }
89378967
89388968 //cubemap.enable();
....@@ -9208,6 +9238,8 @@
92089238
92099239 void LoadEnvy(int which)
92109240 {
9241
+ assert(false);
9242
+
92119243 String name;
92129244 String ext;
92139245
....@@ -9219,37 +9251,58 @@
92199251 cubemap = null;
92209252 return;
92219253 case 1:
9222
- name = "cubemaps/box_";
9223
- ext = "png";
9254
+ name = "cubemaps/rgb/";
9255
+ ext = "jpg";
92249256 reverseUP = false;
92259257 break;
92269258 case 2:
9227
- name = "cubemaps/uffizi_";
9228
- ext = "png";
9229
- break; // reverseUP = true; break;
9259
+ name = "cubemaps/uffizi/";
9260
+ ext = "jpg";
9261
+ reverseUP = false;
9262
+ break;
92309263 case 3:
9231
- name = "cubemaps/CloudyHills_";
9232
- ext = "tga";
9264
+ name = "cubemaps/CloudyHills/";
9265
+ ext = "jpg";
92339266 reverseUP = false;
92349267 break;
92359268 case 4:
9236
- name = "cubemaps/cornell_";
9269
+ name = "cubemaps/cornell/";
92379270 ext = "png";
92389271 reverseUP = false;
92399272 break;
9273
+ case 5:
9274
+ name = "cubemaps/skycube/";
9275
+ ext = "jpg";
9276
+ reverseUP = false;
9277
+ break;
9278
+ case 6:
9279
+ name = "cubemaps/SaintLazarusChurch3/";
9280
+ ext = "jpg";
9281
+ reverseUP = false;
9282
+ break;
9283
+ case 7:
9284
+ name = "cubemaps/Sodermalmsallen/";
9285
+ ext = "jpg";
9286
+ reverseUP = false;
9287
+ break;
9288
+ case 8:
9289
+ name = "cubemaps/Sodermalmsallen2/";
9290
+ ext = "jpg";
9291
+ reverseUP = false;
9292
+ break;
9293
+ case 9:
9294
+ name = "cubemaps/UnionSquare/";
9295
+ ext = "jpg";
9296
+ reverseUP = false;
9297
+ break;
92409298 default:
9241
- name = "cubemaps/rgb_";
9242
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9299
+ name = "cubemaps/box/";
9300
+ ext = "png"; /*mipmap = true;*/
9301
+ reverseUP = false;
92439302 break;
92449303 }
9245
-
9246
- try
9247
- {
9248
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
9249
- } catch (IOException e)
9250
- {
9251
- throw new RuntimeException(e);
9252
- }
9304
+
9305
+ LoadSkybox(name, ext, mipmap);
92539306 }
92549307
92559308 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -9281,8 +9334,12 @@
92819334 static double[] model = new double[16];
92829335 double[] camera2light = new double[16];
92839336 double[] light2camera = new double[16];
9284
- int newenvy = -1;
9285
- boolean envyoff = true; // false;
9337
+
9338
+ //int newenvy = -1;
9339
+ //boolean envyoff = false;
9340
+
9341
+ String loadedskyboxname;
9342
+
92869343 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
92879344 //float[] light0 = { 0,0,0 };
92889345 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9762,10 +9819,12 @@
97629819 rati = 1 / rati;
97639820 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
97649821 }
9765
- assert (newenvy == -1);
9822
+
9823
+ //assert (newenvy == -1);
9824
+
97669825 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
97679826 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9768
- DrawSkyBox(gl);
9827
+ DrawSkyBox(gl, (float)rati);
97699828 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
97709829 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
97719830 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -10802,7 +10861,7 @@
1080210861
1080310862 if (wait)
1080410863 {
10805
- Sleep(500);
10864
+ Sleep(200); // blocks everything
1080610865
1080710866 wait = false;
1080810867 }
....@@ -11018,13 +11077,43 @@
1101811077 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1101911078 }
1102011079
11021
- if (newenvy > -1)
11080
+// if (newenvy > -1)
11081
+// {
11082
+// LoadEnvy(newenvy);
11083
+// }
11084
+//
11085
+// newenvy = -1;
11086
+
11087
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1102211088 {
11023
- LoadEnvy(newenvy);
11089
+ if (cubemaprgb == null)
11090
+ {
11091
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
11092
+ }
11093
+
11094
+ cubemap = cubemaprgb;
1102411095 }
11025
-
11026
- newenvy = -1;
11027
-
11096
+ else
11097
+ {
11098
+ if (object.skyboxname != null)
11099
+ {
11100
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11101
+ {
11102
+ if (cubemap != null && cubemap != cubemaprgb)
11103
+ cubemap.dispose();
11104
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11105
+ loadedskyboxname = object.skyboxname;
11106
+ }
11107
+ }
11108
+ else
11109
+ {
11110
+ cubemapcustom = null;
11111
+ loadedskyboxname = null;
11112
+ }
11113
+
11114
+ cubemap = cubemapcustom;
11115
+ }
11116
+
1102811117 ratio = ((double) getWidth()) / getHeight();
1102911118 //System.out.println("ratio = " + ratio);
1103011119
....@@ -11040,7 +11129,7 @@
1104011129
1104111130 if (!IsFrozen() && !ambientOcclusion)
1104211131 {
11043
- DrawSkyBox(gl);
11132
+ DrawSkyBox(gl, (float)ratio);
1104411133 }
1104511134
1104611135 //if (selection_view == -1)
....@@ -11326,7 +11415,7 @@
1132611415
1132711416 // if (cam != lightCamera)
1132811417 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11329
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11418
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1133011419 }
1133111420
1133211421 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -12400,7 +12489,7 @@
1240012489
1240112490 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240212491
12403
- String program =
12492
+ String programmin =
1240412493 // Min shader
1240512494 "!!ARBfp1.0\n" +
1240612495 "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
....@@ -12451,7 +12540,8 @@
1245112540 //"SUB ndotl.y, zero123.y, ndotl.y;" +
1245212541 //"MUL ndotl.y, ndotl.y, pow2.z;" +
1245312542
12454
- "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12543
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12544
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
1245512545
1245612546 // Pigment
1245712547 "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
....@@ -12466,7 +12556,7 @@
1246612556 "MOV result.color, temp;" +
1246712557 "END";
1246812558
12469
- String program2 =
12559
+ String programmax =
1247012560 "!!ARBfp1.0\n" +
1247112561
1247212562 //"OPTION ARB_fragment_program_shadow;" +
....@@ -12991,7 +13081,7 @@
1299113081 // display shadow only (fakedepth == 0)
1299213082 "SUB temp.x, half.x, shadow.x;" +
1299313083 "MOV temp.y, -params5.z;" + // params6.x;" +
12994
- "SLT temp.z, temp.y, -one2048th.x;" +
13084
+ "SLT temp.z, temp.y, -c256i.x;" +
1299513085 "SUB temp.y, one.x, temp.z;" +
1299613086 "MUL temp.x, temp.x, temp.y;" +
1299713087 "KIL temp.x;" +
....@@ -13322,8 +13412,19 @@
1332213412 //once = true;
1332313413 }
1332413414
13325
- System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13326
- System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13415
+ String program = programmax;
13416
+
13417
+ if (Globals.MINSHADER)
13418
+ {
13419
+ program = programmin;
13420
+ }
13421
+
13422
+ if (Globals.DEBUG)
13423
+ {
13424
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13425
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13426
+ }
13427
+
1332713428 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1332813429
1332913430 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13370,7 +13471,8 @@
1337013471 "\n" +
1337113472 "END\n";
1337213473
13373
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13474
+ if (Globals.DEBUG)
13475
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1337413476 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1337513477
1337613478 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -14569,11 +14671,17 @@
1456914671 void GoDown(int mod)
1457014672 {
1457114673 MODIFIERS |= COMMAND;
14674
+ boolean isVR = (mouseMode&VR)!=0;
1457214675 /**/
1457314676 if((mod&SHIFT) == SHIFT)
14574
- manipCamera.RotatePosition(0, -speed);
14677
+ {
14678
+ if (isVR)
14679
+ manipCamera.RotateInterest(0, -speed);
14680
+ else
14681
+ manipCamera.RotatePosition(0, -speed);
14682
+ }
1457514683 else
14576
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14684
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1457714685 /**/
1457814686 if ((mod & SHIFT) == SHIFT)
1457914687 {
....@@ -14583,6 +14691,8 @@
1458314691 mouseMode |= BACKFORTH;
1458414692 }
1458514693
14694
+ targetLookAt.set(manipCamera.lookAt);
14695
+
1458614696 //prevX = X = anchorX;
1458714697 prevY = Y = anchorY - (int) (renderCamera.Distance());
1458814698 }
....@@ -14591,10 +14701,17 @@
1459114701 {
1459214702 MODIFIERS |= COMMAND;
1459314703 /**/
14704
+ boolean isVR = (mouseMode&VR)!=0;
14705
+
1459414706 if((mod&SHIFT) == SHIFT)
14595
- manipCamera.RotatePosition(0, speed);
14707
+ {
14708
+ if (isVR)
14709
+ manipCamera.RotateInterest(0, speed);
14710
+ else
14711
+ manipCamera.RotatePosition(0, speed);
14712
+ }
1459614713 else
14597
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14714
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1459814715 /**/
1459914716 if ((mod & SHIFT) == SHIFT)
1460014717 {
....@@ -14604,6 +14721,8 @@
1460414721 mouseMode |= BACKFORTH;
1460514722 }
1460614723
14724
+ targetLookAt.set(manipCamera.lookAt);
14725
+
1460714726 //prevX = X = anchorX;
1460814727 prevY = Y = anchorY + (int) (renderCamera.Distance());
1460914728 }
....@@ -14613,9 +14732,14 @@
1461314732 MODIFIERS |= COMMAND;
1461414733 /**/
1461514734 if((mod&SHIFT) == SHIFT)
14616
- manipCamera.Translate(speed*delta, 0, getWidth());
14735
+ manipCamera.Translate(speed*delta, 0, getWidth());
1461714736 else
14618
- manipCamera.RotatePosition(speed, 0);
14737
+ {
14738
+ if ((mouseMode&VR)!=0)
14739
+ manipCamera.RotateInterest(-speed, 0);
14740
+ else
14741
+ manipCamera.RotatePosition(speed, 0);
14742
+ }
1461914743 /**/
1462014744 if ((mod & SHIFT) == SHIFT)
1462114745 {
....@@ -14625,6 +14749,8 @@
1462514749 mouseMode |= ROTATE;
1462614750 } // TRANSLATE;
1462714751
14752
+ targetLookAt.set(manipCamera.lookAt);
14753
+
1462814754 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1462914755 prevY = Y = anchorY;
1463014756 }
....@@ -14634,9 +14760,15 @@
1463414760 MODIFIERS |= COMMAND;
1463514761 /**/
1463614762 if((mod&SHIFT) == SHIFT)
14637
- manipCamera.Translate(-speed*delta, 0, getWidth());
14763
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1463814764 else
14639
- manipCamera.RotatePosition(-speed, 0);
14765
+ {
14766
+ if ((mouseMode&VR)!=0)
14767
+ manipCamera.RotateInterest(speed, 0);
14768
+ else
14769
+ manipCamera.RotatePosition(-speed, 0);
14770
+ }
14771
+
1464014772 /**/
1464114773 if ((mod & SHIFT) == SHIFT)
1464214774 {
....@@ -14646,6 +14778,8 @@
1464614778 mouseMode |= ROTATE;
1464714779 } // TRANSLATE;
1464814780
14781
+ targetLookAt.set(manipCamera.lookAt);
14782
+
1464914783 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1465014784 prevY = Y = anchorY;
1465114785 }
....@@ -15315,20 +15449,24 @@
1531515449 OCCLUSION_CULLING ^= true;
1531615450 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1531715451 break;
15318
- case '0': envyoff ^= true; repaint(); break;
15452
+ //case '0': envyoff ^= true; repaint(); break;
1531915453 case '1':
1532015454 case '2':
1532115455 case '3':
1532215456 case '4':
1532315457 case '5':
15324
- newenvy = Character.getNumericValue(key);
15325
- repaint();
15326
- break;
1532715458 case '6':
1532815459 case '7':
1532915460 case '8':
1533015461 case '9':
15331
- BGcolor = (key - '6')/3.f;
15462
+ if (true) // envyoff)
15463
+ {
15464
+ BGcolor = (key - '1')/8.f;
15465
+ }
15466
+ else
15467
+ {
15468
+ //newenvy = Character.getNumericValue(key);
15469
+ }
1533215470 repaint();
1533315471 break;
1533415472 case '!':
....@@ -16026,14 +16164,14 @@
1602616164 {
1602716165 switch (hitSomething)
1602816166 {
16029
- case Object3D.hitCenter: gr.setColor(Color.pink);
16167
+ case Object3D.hitCenter: gr.setColor(Color.white);
1603016168 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1603116169 break;
1603216170 case Object3D.hitRotate: gr.setColor(Color.yellow);
1603316171 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1603416172 break;
1603516173 case Object3D.hitScale: gr.setColor(Color.cyan);
16036
- gr.drawLine(X, Y, 0, 0);
16174
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1603716175 break;
1603816176 }
1603916177
....@@ -16052,7 +16190,7 @@
1605216190 if (hasMarquee)
1605316191 {
1605416192 gr.setXORMode(Color.white);
16055
- gr.setColor(Color.red);
16193
+ gr.setColor(Color.white);
1605616194 if (!firstime)
1605716195 {
1605816196 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16519,6 +16657,8 @@
1651916657 private /*static*/ boolean firstime;
1652016658 private /*static*/ cVector newView = new cVector();
1652116659 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16660
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16661
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1652216662 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1652316663 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1652416664 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16531,29 +16671,67 @@
1653116671 {
1653216672 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1653316673
16674
+ int usedsuf = 0;
16675
+
1653416676 for (int i = 0; i < suffixes.length; i++)
1653516677 {
16536
- String resourceName = basename + suffixes[i] + "." + suffix;
16537
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16538
- mipmapped,
16539
- FileUtil.getFileSuffix(resourceName));
16540
- if (data == null)
16678
+ String[] suffixe = suffixes;
16679
+ String[] fallback = suffixes2;
16680
+ String[] fallfallback = suffixes3;
16681
+
16682
+ for (int c=usedsuf; --c>=0;)
1654116683 {
16542
- throw new IOException("Unable to load texture " + resourceName);
16684
+// String[] temp = suffixe;
16685
+// suffixe = fallback;
16686
+// fallback = fallfallback;
16687
+// fallfallback = temp;
1654316688 }
16689
+
16690
+ String resourceName = basename + suffixe[i] + "." + suffix;
16691
+ TextureData data;
16692
+
16693
+ try
16694
+ {
16695
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16696
+ mipmapped,
16697
+ FileUtil.getFileSuffix(resourceName));
16698
+ }
16699
+ catch (Exception e)
16700
+ {
16701
+ try
16702
+ {
16703
+ resourceName = basename + fallback[i] + "." + suffix;
16704
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16705
+ mipmapped,
16706
+ FileUtil.getFileSuffix(resourceName));
16707
+ }
16708
+ catch (Exception e2)
16709
+ {
16710
+ resourceName = basename + fallfallback[i] + "." + suffix;
16711
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16712
+ mipmapped,
16713
+ FileUtil.getFileSuffix(resourceName));
16714
+ }
16715
+ }
16716
+
1654416717 //System.out.println("Target = " + targets[i]);
1654516718 cubemap.updateImage(data, targets[i]);
1654616719 }
1654716720
1654816721 return cubemap;
1654916722 }
16723
+
1655016724 int bigsphere = -1;
1655116725
1655216726 float BGcolor = 0.5f;
1655316727
16554
- private void DrawSkyBox(GL gl)
16728
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16729
+
16730
+ private void DrawSkyBox(GL gl, float ratio)
1655516731 {
16556
- if (envyoff || cubemap == null)
16732
+ if (//envyoff ||
16733
+ WIREFRAME ||
16734
+ cubemap == null)
1655716735 {
1655816736 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1655916737 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16568,7 +16746,17 @@
1656816746 // Compensates for ExaminerViewer's modification of modelview matrix
1656916747 gl.glMatrixMode(GL.GL_MODELVIEW);
1657016748 gl.glLoadIdentity();
16749
+ gl.glScalef(1,ratio,1);
1657116750
16751
+// colorV[0] = 2;
16752
+// colorV[1] = 2;
16753
+// colorV[2] = 2;
16754
+// colorV[3] = 1;
16755
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16756
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16757
+//
16758
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16759
+
1657216760 //gl.glActiveTexture(GL.GL_TEXTURE1);
1657316761 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1657416762
....@@ -16600,6 +16788,7 @@
1660016788 {
1660116789 gl.glScalef(1.0f, -1.0f, 1.0f);
1660216790 }
16791
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1660316792 gl.glMultMatrixd(viewrot_1, 0);
1660416793 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1660516794 //viewer.updateInverseRotation(gl);
....@@ -16640,7 +16829,8 @@
1664016829 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1664116830
1664216831 cubemap.disable();
16643
- ////cubemap.unbind();
16832
+ //cubemap.dispose();
16833
+
1664416834 if (CULLFACE)
1664516835 {
1664616836 gl.glEnable(gl.GL_CULL_FACE);
....@@ -16858,7 +17048,7 @@
1685817048 //new Exception().printStackTrace();
1685917049 System.out.println("select buffer init");
1686017050 // Use debug pipeline
16861
- drawable.setGL(new DebugGL(drawable.getGL()));
17051
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1686217052
1686317053 GL gl = drawable.getGL();
1686417054
....@@ -17176,6 +17366,7 @@
1717617366
1717717367 public void init(GLAutoDrawable drawable)
1717817368 {
17369
+ if (Globals.DEBUG)
1717917370 System.out.println("shadow buffer init");
1718017371
1718117372 GL gl = drawable.getGL();
....@@ -17404,10 +17595,14 @@
1740417595 gl.glFlush();
1740517596
1740617597 /**/
17407
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17598
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1740817599
17409
- float[] pixels = occlusionsizebuffer.array();
17600
+ float[] depths = occlusiondepthbuffer.array();
1741017601
17602
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17603
+
17604
+ int[] pixels = selectsizebuffer.array();
17605
+
1741117606 double r = 0, g = 0, b = 0;
1741217607
1741317608 double count = 0;
....@@ -17418,7 +17613,7 @@
1741817613
1741917614 double FACTOR = 1;
1742017615
17421
- for (int i = 0; i < pixels.length; i++)
17616
+ for (int i = 0; i < depths.length; i++)
1742217617 {
1742317618 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1742417619 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17501,7 +17696,7 @@
1750117696
1750217697 double scale = ray.z; // 1; // cos
1750317698
17504
- float depth = pixels[newindex];
17699
+ float depth = depths[newindex];
1750517700
1750617701 /*
1750717702 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17698,11 +17893,14 @@
1769817893 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1769917894 static IntBuffer bigAAbuffer;
1770017895 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17701
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17896
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1770217897 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1770317898 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1770417899 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17705
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17900
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17901
+
17902
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17903
+
1770617904 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1770717905 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1770817906 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();