.. | .. |
---|
8022 | 8022 | } |
---|
8023 | 8023 | } |
---|
8024 | 8024 | |
---|
8025 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8025 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8026 | 8026 | { |
---|
8027 | 8027 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8028 | 8028 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8067 | 8067 | return; // true; |
---|
8068 | 8068 | } |
---|
8069 | 8069 | |
---|
8070 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8070 | + CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8071 | 8071 | { |
---|
8072 | 8072 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
8073 | 8073 | |
---|
.. | .. |
---|
8184 | 8184 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
8185 | 8185 | |
---|
8186 | 8186 | |
---|
8187 | | - if (texturedata != null) |
---|
| 8187 | + if (texturedata == null) |
---|
| 8188 | + throw new Exception(); |
---|
| 8189 | + |
---|
8188 | 8190 | texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
8189 | 8191 | //texture = GetTexture(tex, bump); |
---|
8190 | 8192 | } |
---|
.. | .. |
---|
8306 | 8308 | return texture; |
---|
8307 | 8309 | } |
---|
8308 | 8310 | |
---|
8309 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8311 | + com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8310 | 8312 | { |
---|
8311 | 8313 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8312 | 8314 | |
---|
.. | .. |
---|
8324 | 8326 | return texture!=null?texture.texture:null; |
---|
8325 | 8327 | } |
---|
8326 | 8328 | |
---|
8327 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8329 | + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
8328 | 8330 | { |
---|
8329 | 8331 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8330 | 8332 | |
---|
8331 | 8333 | return texture!=null?texture.texturedata:null; |
---|
8332 | 8334 | } |
---|
8333 | 8335 | |
---|
8334 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8336 | + boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8335 | 8337 | { |
---|
8336 | 8338 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8337 | 8339 | { |
---|
.. | .. |
---|
10798 | 10800 | // Bump noise |
---|
10799 | 10801 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10800 | 10802 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10801 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 10803 | + |
---|
| 10804 | + try |
---|
| 10805 | + { |
---|
| 10806 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 10807 | + } |
---|
| 10808 | + catch (Exception e) |
---|
| 10809 | + { |
---|
| 10810 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 10811 | + } |
---|
| 10812 | + |
---|
10802 | 10813 | |
---|
10803 | 10814 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10804 | 10815 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
11354 | 11365 | |
---|
11355 | 11366 | usedtextures.clear(); |
---|
11356 | 11367 | |
---|
11357 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11368 | + try |
---|
| 11369 | + { |
---|
| 11370 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11371 | + } |
---|
| 11372 | + catch (Exception e) |
---|
| 11373 | + { |
---|
| 11374 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11375 | + } |
---|
11358 | 11376 | } |
---|
11359 | 11377 | //System.out.println("--> " + stackdepth); |
---|
11360 | 11378 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
11445 | 11463 | if (checker != null && DrawMode() == DEFAULT) |
---|
11446 | 11464 | { |
---|
11447 | 11465 | //BindTexture(IMMORTAL_TEXTURE); |
---|
11448 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11466 | + try |
---|
| 11467 | + { |
---|
| 11468 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11469 | + } |
---|
| 11470 | + catch (Exception e) |
---|
| 11471 | + { |
---|
| 11472 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11473 | + } |
---|
11449 | 11474 | // NEAREST |
---|
11450 | 11475 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
11451 | 11476 | DrawChecker(gl); |
---|
.. | .. |
---|
12477 | 12502 | |
---|
12478 | 12503 | // display shadow only (bump == 0) |
---|
12479 | 12504 | "SUB temp.x, half.x, shadow.x;" + |
---|
12480 | | - "MOV temp.y, -params6.x;" + |
---|
12481 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12505 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12506 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
12482 | 12507 | "SUB temp.y, one.x, temp.z;" + |
---|
12483 | 12508 | "MUL temp.x, temp.x, temp.y;" + |
---|
12484 | 12509 | "KIL temp.x;" + |
---|
.. | .. |
---|
12809 | 12834 | //once = true; |
---|
12810 | 12835 | } |
---|
12811 | 12836 | |
---|
12812 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 12837 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12813 | 12838 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12814 | 12839 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12815 | 12840 | |
---|
.. | .. |
---|
12942 | 12967 | |
---|
12943 | 12968 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12944 | 12969 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 12970 | + |
---|
| 12971 | + // Compare fragment depth in light space with shadowmap. |
---|
12945 | 12972 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12946 | 12973 | "SGE temp.y, temp.x, zero.x;" + |
---|
12947 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 12974 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 12975 | + |
---|
| 12976 | + // Reverse comparison |
---|
12948 | 12977 | "SUB temp.x, one.x, temp.x;" + |
---|
12949 | 12978 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12950 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 12979 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12951 | 12980 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12952 | 12981 | |
---|
12953 | 12982 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12961 | 12990 | // No shadow for backface |
---|
12962 | 12991 | "DP3 temp.x, normal, lightd;" + |
---|
12963 | 12992 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 12993 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 12994 | + |
---|
| 12995 | + // No shadow when out of frustrum |
---|
| 12996 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12964 | 12997 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12965 | 12998 | ""; |
---|
12966 | 12999 | } |
---|
.. | .. |
---|
14341 | 14374 | public void mouseReleased(MouseEvent e) |
---|
14342 | 14375 | { |
---|
14343 | 14376 | movingcamera = false; |
---|
| 14377 | + X = Y = 0; |
---|
14344 | 14378 | //System.out.println("mouseReleased: " + e); |
---|
14345 | 14379 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14346 | 14380 | } |
---|
.. | .. |
---|
14870 | 14904 | //RESIZETEXTURE ^= true; |
---|
14871 | 14905 | //break; |
---|
14872 | 14906 | case 'z': |
---|
14873 | | - RENDERSHADOW ^= true; |
---|
| 14907 | + Globals.RENDERSHADOW ^= true; |
---|
14874 | 14908 | Globals.lighttouched = true; |
---|
14875 | 14909 | repaint(); |
---|
14876 | 14910 | break; |
---|
.. | .. |
---|
15349 | 15383 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15350 | 15384 | //Image img = CreateImage(width, height); |
---|
15351 | 15385 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15386 | + |
---|
15352 | 15387 | Graphics gr = g; // img.getGraphics(); |
---|
| 15388 | + |
---|
15353 | 15389 | if (!hasMarquee) |
---|
15354 | 15390 | { |
---|
15355 | 15391 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
15447 | 15483 | if (!isRenderer) |
---|
15448 | 15484 | { |
---|
15449 | 15485 | object.drawEditHandles(info, 0); |
---|
| 15486 | + |
---|
| 15487 | + if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15488 | + { |
---|
| 15489 | + switch (object.selection.get(0).hitSomething) |
---|
| 15490 | + { |
---|
| 15491 | + case Object3D.hitCenter: gr.setColor(Color.pink); break; |
---|
| 15492 | + case Object3D.hitRotate: gr.setColor(Color.green); break; |
---|
| 15493 | + case Object3D.hitScale: gr.setColor(Color.cyan); break; |
---|
| 15494 | + } |
---|
| 15495 | + |
---|
| 15496 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15497 | + } |
---|
15450 | 15498 | } |
---|
15451 | 15499 | } |
---|
| 15500 | + |
---|
15452 | 15501 | if (isRenderer) |
---|
15453 | 15502 | { |
---|
15454 | 15503 | //gr.setColor(Color.black); |
---|
15455 | 15504 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
15456 | 15505 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
15457 | 15506 | } |
---|
| 15507 | + |
---|
15458 | 15508 | if (hasMarquee) |
---|
15459 | 15509 | { |
---|
15460 | 15510 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
16592 | 16642 | gl.glDisable(gl.GL_CULL_FACE); |
---|
16593 | 16643 | } |
---|
16594 | 16644 | |
---|
16595 | | - if (!RENDERSHADOW) |
---|
| 16645 | + if (!Globals.RENDERSHADOW) |
---|
16596 | 16646 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16597 | 16647 | |
---|
16598 | 16648 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
16602 | 16652 | //gl.glColorMask(false, false, false, false); |
---|
16603 | 16653 | |
---|
16604 | 16654 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
16605 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 16655 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
16606 | 16656 | { |
---|
16607 | 16657 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16608 | 16658 | |
---|