.. | .. |
---|
110 | 110 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
111 | 111 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
112 | 112 | 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; |
---|
114 | 116 | boolean reverseUP = false; |
---|
115 | 117 | static boolean frozen = false; |
---|
116 | 118 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
173 | 175 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
174 | 176 | boolean anisotropy = true; |
---|
175 | 177 | boolean softshadow = true; // slower but better false; |
---|
176 | | - boolean opacityhalo = false; |
---|
| 178 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
177 | 179 | |
---|
178 | 180 | boolean macromode = false; |
---|
179 | 181 | |
---|
.. | .. |
---|
187 | 189 | } |
---|
188 | 190 | |
---|
189 | 191 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 192 | + |
---|
| 193 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 194 | + { |
---|
| 195 | + try |
---|
| 196 | + { |
---|
| 197 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 198 | + } catch (IOException e) |
---|
| 199 | + { |
---|
| 200 | + System.out.println("NAME = " + name); |
---|
| 201 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 202 | + return null; |
---|
| 203 | + } |
---|
| 204 | + } |
---|
190 | 205 | |
---|
191 | 206 | void SetAsGLRenderer(boolean b) |
---|
192 | 207 | { |
---|
.. | .. |
---|
1485 | 1500 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1486 | 1501 | } |
---|
1487 | 1502 | |
---|
| 1503 | + float[] colorV = new float[4]; |
---|
| 1504 | + |
---|
1488 | 1505 | void SetColor(Object3D obj, Vertex p0) |
---|
1489 | 1506 | { |
---|
1490 | 1507 | CameraPane display = this; |
---|
.. | .. |
---|
1552 | 1569 | { |
---|
1553 | 1570 | return; |
---|
1554 | 1571 | } |
---|
1555 | | - |
---|
1556 | | - float[] colorV = new float[3]; |
---|
1557 | 1572 | |
---|
1558 | 1573 | if (false) // marked) |
---|
1559 | 1574 | { |
---|
.. | .. |
---|
8346 | 8361 | // else |
---|
8347 | 8362 | // if (!texname.startsWith("/")) |
---|
8348 | 8363 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8349 | | - if (!FileExists(texname)) |
---|
| 8364 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8350 | 8365 | { |
---|
8351 | 8366 | texname = fallbackTextureName; |
---|
8352 | 8367 | } |
---|
.. | .. |
---|
8429 | 8444 | new Exception().printStackTrace(); |
---|
8430 | 8445 | } else |
---|
8431 | 8446 | { |
---|
| 8447 | + if (texname.startsWith("@")) |
---|
| 8448 | + { |
---|
| 8449 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8450 | + if (texturecache == null) |
---|
| 8451 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8452 | + else |
---|
| 8453 | + new Exception().printStackTrace(); |
---|
| 8454 | + } else |
---|
| 8455 | + { |
---|
8432 | 8456 | if (textureon) |
---|
8433 | 8457 | { |
---|
8434 | 8458 | String cachename = texname; |
---|
.. | .. |
---|
8488 | 8512 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8489 | 8513 | //texture = GetTexture(tex, bump); |
---|
8490 | 8514 | } |
---|
| 8515 | + } |
---|
8491 | 8516 | } |
---|
8492 | 8517 | //} |
---|
8493 | 8518 | } |
---|
.. | .. |
---|
8756 | 8781 | |
---|
8757 | 8782 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8758 | 8783 | MAXSTACK = temp[0]; |
---|
8759 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8784 | + if (Globals.DEBUG) |
---|
| 8785 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8760 | 8786 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8761 | 8787 | MAXSTACK = temp[0]; |
---|
8762 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8788 | + if (Globals.DEBUG) |
---|
| 8789 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8763 | 8790 | |
---|
8764 | 8791 | // Use debug pipeline |
---|
8765 | 8792 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8767 | 8794 | gl = drawable.getGL(); // |
---|
8768 | 8795 | |
---|
8769 | 8796 | GL gl3 = getGL(); |
---|
8770 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8797 | + if (Globals.DEBUG) |
---|
| 8798 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8771 | 8799 | |
---|
8772 | 8800 | |
---|
8773 | 8801 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8932 | 8960 | |
---|
8933 | 8961 | if (cubemap == null) |
---|
8934 | 8962 | { |
---|
8935 | | - LoadEnvy(5); |
---|
| 8963 | + //LoadEnvy(1); |
---|
8936 | 8964 | } |
---|
8937 | 8965 | |
---|
8938 | 8966 | //cubemap.enable(); |
---|
.. | .. |
---|
9208 | 9236 | |
---|
9209 | 9237 | void LoadEnvy(int which) |
---|
9210 | 9238 | { |
---|
| 9239 | + assert(false); |
---|
| 9240 | + |
---|
9211 | 9241 | String name; |
---|
9212 | 9242 | String ext; |
---|
9213 | 9243 | |
---|
.. | .. |
---|
9219 | 9249 | cubemap = null; |
---|
9220 | 9250 | return; |
---|
9221 | 9251 | case 1: |
---|
9222 | | - name = "cubemaps/box_"; |
---|
9223 | | - ext = "png"; |
---|
| 9252 | + name = "cubemaps/rgb/"; |
---|
| 9253 | + ext = "jpg"; |
---|
9224 | 9254 | reverseUP = false; |
---|
9225 | 9255 | break; |
---|
9226 | 9256 | case 2: |
---|
9227 | | - name = "cubemaps/uffizi_"; |
---|
9228 | | - ext = "png"; |
---|
9229 | | - break; // reverseUP = true; break; |
---|
| 9257 | + name = "cubemaps/uffizi/"; |
---|
| 9258 | + ext = "jpg"; |
---|
| 9259 | + reverseUP = false; |
---|
| 9260 | + break; |
---|
9230 | 9261 | case 3: |
---|
9231 | | - name = "cubemaps/CloudyHills_"; |
---|
9232 | | - ext = "tga"; |
---|
| 9262 | + name = "cubemaps/CloudyHills/"; |
---|
| 9263 | + ext = "jpg"; |
---|
9233 | 9264 | reverseUP = false; |
---|
9234 | 9265 | break; |
---|
9235 | 9266 | case 4: |
---|
9236 | | - name = "cubemaps/cornell_"; |
---|
| 9267 | + name = "cubemaps/cornell/"; |
---|
9237 | 9268 | ext = "png"; |
---|
9238 | 9269 | reverseUP = false; |
---|
9239 | 9270 | break; |
---|
| 9271 | + case 5: |
---|
| 9272 | + name = "cubemaps/skycube/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
| 9276 | + case 6: |
---|
| 9277 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9278 | + ext = "jpg"; |
---|
| 9279 | + reverseUP = false; |
---|
| 9280 | + break; |
---|
| 9281 | + case 7: |
---|
| 9282 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9283 | + ext = "jpg"; |
---|
| 9284 | + reverseUP = false; |
---|
| 9285 | + break; |
---|
| 9286 | + case 8: |
---|
| 9287 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9288 | + ext = "jpg"; |
---|
| 9289 | + reverseUP = false; |
---|
| 9290 | + break; |
---|
| 9291 | + case 9: |
---|
| 9292 | + name = "cubemaps/UnionSquare/"; |
---|
| 9293 | + ext = "jpg"; |
---|
| 9294 | + reverseUP = false; |
---|
| 9295 | + break; |
---|
9240 | 9296 | default: |
---|
9241 | | - name = "cubemaps/rgb_"; |
---|
9242 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9297 | + name = "cubemaps/box/"; |
---|
| 9298 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9299 | + reverseUP = false; |
---|
9243 | 9300 | break; |
---|
9244 | 9301 | } |
---|
9245 | | - |
---|
9246 | | - try |
---|
9247 | | - { |
---|
9248 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9249 | | - } catch (IOException e) |
---|
9250 | | - { |
---|
9251 | | - throw new RuntimeException(e); |
---|
9252 | | - } |
---|
| 9302 | + |
---|
| 9303 | + LoadSkybox(name, ext, mipmap); |
---|
9253 | 9304 | } |
---|
9254 | 9305 | |
---|
9255 | 9306 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9281 | 9332 | static double[] model = new double[16]; |
---|
9282 | 9333 | double[] camera2light = new double[16]; |
---|
9283 | 9334 | double[] light2camera = new double[16]; |
---|
9284 | | - int newenvy = -1; |
---|
9285 | | - boolean envyoff = true; // false; |
---|
| 9335 | + |
---|
| 9336 | + //int newenvy = -1; |
---|
| 9337 | + //boolean envyoff = false; |
---|
| 9338 | + |
---|
| 9339 | + String loadedskyboxname; |
---|
| 9340 | + |
---|
9286 | 9341 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9287 | 9342 | //float[] light0 = { 0,0,0 }; |
---|
9288 | 9343 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9762 | 9817 | rati = 1 / rati; |
---|
9763 | 9818 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9764 | 9819 | } |
---|
9765 | | - assert (newenvy == -1); |
---|
| 9820 | + |
---|
| 9821 | + //assert (newenvy == -1); |
---|
| 9822 | + |
---|
9766 | 9823 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9767 | 9824 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9768 | | - DrawSkyBox(gl); |
---|
| 9825 | + DrawSkyBox(gl, (float)rati); |
---|
9769 | 9826 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9770 | 9827 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9771 | 9828 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10802 | 10859 | |
---|
10803 | 10860 | if (wait) |
---|
10804 | 10861 | { |
---|
10805 | | - Sleep(500); |
---|
| 10862 | + Sleep(200); // blocks everything |
---|
10806 | 10863 | |
---|
10807 | 10864 | wait = false; |
---|
10808 | 10865 | } |
---|
.. | .. |
---|
11018 | 11075 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
11019 | 11076 | } |
---|
11020 | 11077 | |
---|
11021 | | - if (newenvy > -1) |
---|
| 11078 | +// if (newenvy > -1) |
---|
| 11079 | +// { |
---|
| 11080 | +// LoadEnvy(newenvy); |
---|
| 11081 | +// } |
---|
| 11082 | +// |
---|
| 11083 | +// newenvy = -1; |
---|
| 11084 | + |
---|
| 11085 | + if (object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11022 | 11086 | { |
---|
11023 | | - LoadEnvy(newenvy); |
---|
| 11087 | + if (cubemaprgb == null) |
---|
| 11088 | + { |
---|
| 11089 | + cubemaprgb = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11090 | + } |
---|
| 11091 | + |
---|
| 11092 | + cubemap = cubemaprgb; |
---|
11024 | 11093 | } |
---|
11025 | | - |
---|
11026 | | - newenvy = -1; |
---|
11027 | | - |
---|
| 11094 | + else |
---|
| 11095 | + { |
---|
| 11096 | + if (object.skyboxname != null) |
---|
| 11097 | + { |
---|
| 11098 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11099 | + { |
---|
| 11100 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11101 | + loadedskyboxname = object.skyboxname; |
---|
| 11102 | + } |
---|
| 11103 | + } |
---|
| 11104 | + else |
---|
| 11105 | + { |
---|
| 11106 | + cubemapcustom = null; |
---|
| 11107 | + loadedskyboxname = null; |
---|
| 11108 | + } |
---|
| 11109 | + |
---|
| 11110 | + cubemap = cubemapcustom; |
---|
| 11111 | + } |
---|
| 11112 | + |
---|
11028 | 11113 | ratio = ((double) getWidth()) / getHeight(); |
---|
11029 | 11114 | //System.out.println("ratio = " + ratio); |
---|
11030 | 11115 | |
---|
.. | .. |
---|
11040 | 11125 | |
---|
11041 | 11126 | if (!IsFrozen() && !ambientOcclusion) |
---|
11042 | 11127 | { |
---|
11043 | | - DrawSkyBox(gl); |
---|
| 11128 | + DrawSkyBox(gl, (float)ratio); |
---|
11044 | 11129 | } |
---|
11045 | 11130 | |
---|
11046 | 11131 | //if (selection_view == -1) |
---|
.. | .. |
---|
11326 | 11411 | |
---|
11327 | 11412 | // if (cam != lightCamera) |
---|
11328 | 11413 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11329 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11414 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11330 | 11415 | } |
---|
11331 | 11416 | |
---|
11332 | 11417 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12400 | 12485 | |
---|
12401 | 12486 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12402 | 12487 | |
---|
12403 | | - String program = |
---|
| 12488 | + String programmin = |
---|
12404 | 12489 | // Min shader |
---|
12405 | 12490 | "!!ARBfp1.0\n" + |
---|
12406 | 12491 | "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
.. | .. |
---|
12451 | 12536 | //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
12452 | 12537 | //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
12453 | 12538 | |
---|
12454 | | - "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12539 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12540 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
12455 | 12541 | |
---|
12456 | 12542 | // Pigment |
---|
12457 | 12543 | "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
.. | .. |
---|
12466 | 12552 | "MOV result.color, temp;" + |
---|
12467 | 12553 | "END"; |
---|
12468 | 12554 | |
---|
12469 | | - String program2 = |
---|
| 12555 | + String programmax = |
---|
12470 | 12556 | "!!ARBfp1.0\n" + |
---|
12471 | 12557 | |
---|
12472 | 12558 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
12991 | 13077 | // display shadow only (fakedepth == 0) |
---|
12992 | 13078 | "SUB temp.x, half.x, shadow.x;" + |
---|
12993 | 13079 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12994 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13080 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12995 | 13081 | "SUB temp.y, one.x, temp.z;" + |
---|
12996 | 13082 | "MUL temp.x, temp.x, temp.y;" + |
---|
12997 | 13083 | "KIL temp.x;" + |
---|
.. | .. |
---|
13322 | 13408 | //once = true; |
---|
13323 | 13409 | } |
---|
13324 | 13410 | |
---|
| 13411 | + String program = programmax; |
---|
| 13412 | + |
---|
| 13413 | + if (Globals.MINSHADER) |
---|
| 13414 | + { |
---|
| 13415 | + program = programmin; |
---|
| 13416 | + } |
---|
| 13417 | + |
---|
13325 | 13418 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13326 | 13419 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13327 | 13420 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
14571 | 14664 | MODIFIERS |= COMMAND; |
---|
14572 | 14665 | /**/ |
---|
14573 | 14666 | if((mod&SHIFT) == SHIFT) |
---|
14574 | | - manipCamera.RotatePosition(0, -speed); |
---|
14575 | | - else |
---|
14576 | 14667 | manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14668 | + else |
---|
| 14669 | + manipCamera.RotatePosition(0, -speed); |
---|
14577 | 14670 | /**/ |
---|
14578 | 14671 | if ((mod & SHIFT) == SHIFT) |
---|
14579 | 14672 | { |
---|
.. | .. |
---|
14592 | 14685 | MODIFIERS |= COMMAND; |
---|
14593 | 14686 | /**/ |
---|
14594 | 14687 | if((mod&SHIFT) == SHIFT) |
---|
14595 | | - manipCamera.RotatePosition(0, speed); |
---|
14596 | | - else |
---|
14597 | 14688 | manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14689 | + else |
---|
| 14690 | + manipCamera.RotatePosition(0, speed); |
---|
14598 | 14691 | /**/ |
---|
14599 | 14692 | if ((mod & SHIFT) == SHIFT) |
---|
14600 | 14693 | { |
---|
.. | .. |
---|
15315 | 15408 | OCCLUSION_CULLING ^= true; |
---|
15316 | 15409 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15317 | 15410 | break; |
---|
15318 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15411 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15319 | 15412 | case '1': |
---|
15320 | 15413 | case '2': |
---|
15321 | 15414 | case '3': |
---|
15322 | 15415 | case '4': |
---|
15323 | 15416 | case '5': |
---|
15324 | | - newenvy = Character.getNumericValue(key); |
---|
15325 | | - repaint(); |
---|
15326 | | - break; |
---|
15327 | 15417 | case '6': |
---|
15328 | 15418 | case '7': |
---|
15329 | 15419 | case '8': |
---|
15330 | 15420 | case '9': |
---|
15331 | | - BGcolor = (key - '6')/3.f; |
---|
| 15421 | + if (true) // envyoff) |
---|
| 15422 | + { |
---|
| 15423 | + BGcolor = (key - '1')/8.f; |
---|
| 15424 | + } |
---|
| 15425 | + else |
---|
| 15426 | + { |
---|
| 15427 | + //newenvy = Character.getNumericValue(key); |
---|
| 15428 | + } |
---|
15332 | 15429 | repaint(); |
---|
15333 | 15430 | break; |
---|
15334 | 15431 | case '!': |
---|
.. | .. |
---|
16033 | 16130 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16034 | 16131 | break; |
---|
16035 | 16132 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16036 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16133 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16037 | 16134 | break; |
---|
16038 | 16135 | } |
---|
16039 | 16136 | |
---|
.. | .. |
---|
16519 | 16616 | private /*static*/ boolean firstime; |
---|
16520 | 16617 | private /*static*/ cVector newView = new cVector(); |
---|
16521 | 16618 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16619 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16620 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16522 | 16621 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16523 | 16622 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16524 | 16623 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16531 | 16630 | { |
---|
16532 | 16631 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16533 | 16632 | |
---|
| 16633 | + int usedsuf = 0; |
---|
| 16634 | + |
---|
16534 | 16635 | for (int i = 0; i < suffixes.length; i++) |
---|
16535 | 16636 | { |
---|
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) |
---|
| 16637 | + String[] suffixe = suffixes; |
---|
| 16638 | + String[] fallback = suffixes2; |
---|
| 16639 | + String[] fallfallback = suffixes3; |
---|
| 16640 | + |
---|
| 16641 | + for (int c=usedsuf; --c>=0;) |
---|
16541 | 16642 | { |
---|
16542 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16643 | +// String[] temp = suffixe; |
---|
| 16644 | +// suffixe = fallback; |
---|
| 16645 | +// fallback = fallfallback; |
---|
| 16646 | +// fallfallback = temp; |
---|
16543 | 16647 | } |
---|
| 16648 | + |
---|
| 16649 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16650 | + TextureData data; |
---|
| 16651 | + |
---|
| 16652 | + try |
---|
| 16653 | + { |
---|
| 16654 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16655 | + mipmapped, |
---|
| 16656 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16657 | + } |
---|
| 16658 | + catch (Exception e) |
---|
| 16659 | + { |
---|
| 16660 | + try |
---|
| 16661 | + { |
---|
| 16662 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16663 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16664 | + mipmapped, |
---|
| 16665 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16666 | + } |
---|
| 16667 | + catch (Exception e2) |
---|
| 16668 | + { |
---|
| 16669 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16670 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16671 | + mipmapped, |
---|
| 16672 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16673 | + } |
---|
| 16674 | + } |
---|
| 16675 | + |
---|
16544 | 16676 | //System.out.println("Target = " + targets[i]); |
---|
16545 | 16677 | cubemap.updateImage(data, targets[i]); |
---|
16546 | 16678 | } |
---|
16547 | 16679 | |
---|
16548 | 16680 | return cubemap; |
---|
16549 | 16681 | } |
---|
| 16682 | + |
---|
16550 | 16683 | int bigsphere = -1; |
---|
16551 | 16684 | |
---|
16552 | 16685 | float BGcolor = 0.5f; |
---|
16553 | 16686 | |
---|
16554 | | - private void DrawSkyBox(GL gl) |
---|
| 16687 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16688 | + |
---|
| 16689 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16555 | 16690 | { |
---|
16556 | | - if (envyoff || cubemap == null) |
---|
| 16691 | + if (//envyoff || |
---|
| 16692 | + WIREFRAME || |
---|
| 16693 | + cubemap == null) |
---|
16557 | 16694 | { |
---|
16558 | 16695 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16559 | 16696 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16568 | 16705 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16569 | 16706 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16570 | 16707 | gl.glLoadIdentity(); |
---|
| 16708 | + gl.glScalef(1,ratio,1); |
---|
16571 | 16709 | |
---|
| 16710 | +// colorV[0] = 2; |
---|
| 16711 | +// colorV[1] = 2; |
---|
| 16712 | +// colorV[2] = 2; |
---|
| 16713 | +// colorV[3] = 1; |
---|
| 16714 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16715 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16716 | +// |
---|
| 16717 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16718 | + |
---|
16572 | 16719 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16573 | 16720 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16574 | 16721 | |
---|
.. | .. |
---|
16600 | 16747 | { |
---|
16601 | 16748 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16602 | 16749 | } |
---|
| 16750 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16603 | 16751 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16604 | 16752 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16605 | 16753 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16858 | 17006 | //new Exception().printStackTrace(); |
---|
16859 | 17007 | System.out.println("select buffer init"); |
---|
16860 | 17008 | // Use debug pipeline |
---|
16861 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17009 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16862 | 17010 | |
---|
16863 | 17011 | GL gl = drawable.getGL(); |
---|
16864 | 17012 | |
---|
.. | .. |
---|
17404 | 17552 | gl.glFlush(); |
---|
17405 | 17553 | |
---|
17406 | 17554 | /**/ |
---|
17407 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17555 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17408 | 17556 | |
---|
17409 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17557 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17410 | 17558 | |
---|
| 17559 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17560 | + |
---|
| 17561 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17562 | + |
---|
17411 | 17563 | double r = 0, g = 0, b = 0; |
---|
17412 | 17564 | |
---|
17413 | 17565 | double count = 0; |
---|
.. | .. |
---|
17418 | 17570 | |
---|
17419 | 17571 | double FACTOR = 1; |
---|
17420 | 17572 | |
---|
17421 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17573 | + for (int i = 0; i < depths.length; i++) |
---|
17422 | 17574 | { |
---|
17423 | 17575 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17424 | 17576 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17501 | 17653 | |
---|
17502 | 17654 | double scale = ray.z; // 1; // cos |
---|
17503 | 17655 | |
---|
17504 | | - float depth = pixels[newindex]; |
---|
| 17656 | + float depth = depths[newindex]; |
---|
17505 | 17657 | |
---|
17506 | 17658 | /* |
---|
17507 | 17659 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17698 | 17850 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17699 | 17851 | static IntBuffer bigAAbuffer; |
---|
17700 | 17852 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17701 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17853 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17702 | 17854 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17703 | 17855 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17704 | 17856 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17705 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17857 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17858 | + |
---|
| 17859 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17860 | + |
---|
17706 | 17861 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17707 | 17862 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17708 | 17863 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|