.. | .. |
---|
150 | 150 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 151 | } |
---|
152 | 152 | |
---|
| 153 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 154 | + |
---|
153 | 155 | void SetAsGLRenderer(boolean b) |
---|
154 | 156 | { |
---|
155 | 157 | isRenderer = b; |
---|
.. | .. |
---|
462 | 464 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
463 | 465 | { |
---|
464 | 466 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
465 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 467 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
466 | 468 | if (!hasnorm) |
---|
467 | 469 | { |
---|
468 | 470 | // System.out.println("FUCK!!"); |
---|
.. | .. |
---|
1888 | 1890 | void PushMatrix(double[][] matrix) |
---|
1889 | 1891 | { |
---|
1890 | 1892 | // GrafreeD.tracein(matrix); |
---|
1891 | | - PushMatrix(matrix,1); |
---|
| 1893 | + PushMatrix(matrix, 1); |
---|
1892 | 1894 | } |
---|
1893 | 1895 | |
---|
1894 | 1896 | void PushMatrix() |
---|
.. | .. |
---|
2265 | 2267 | LOOKAT ^= true; |
---|
2266 | 2268 | } |
---|
2267 | 2269 | |
---|
2268 | | - void ToggleRandom() |
---|
| 2270 | + void ToggleSwitch() |
---|
2269 | 2271 | { |
---|
2270 | 2272 | SWITCH ^= true; |
---|
2271 | 2273 | } |
---|
.. | .. |
---|
2374 | 2376 | { |
---|
2375 | 2377 | return currentGL; |
---|
2376 | 2378 | } |
---|
2377 | | - |
---|
| 2379 | + |
---|
2378 | 2380 | /**/ |
---|
2379 | 2381 | class CacheTexture |
---|
2380 | 2382 | { |
---|
.. | .. |
---|
7919 | 7921 | ReleaseTexture(pigment, false); |
---|
7920 | 7922 | } |
---|
7921 | 7923 | |
---|
| 7924 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 7925 | + { |
---|
| 7926 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 7927 | + { |
---|
| 7928 | + return; |
---|
| 7929 | + } |
---|
| 7930 | + |
---|
| 7931 | + if (tex == null) |
---|
| 7932 | + { |
---|
| 7933 | + ReleaseTexture(null, false); |
---|
| 7934 | + return; |
---|
| 7935 | + } |
---|
| 7936 | + |
---|
| 7937 | + String pigment = Object3D.GetPigment(tex); |
---|
| 7938 | + |
---|
| 7939 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 7940 | + { |
---|
| 7941 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 7942 | + // System.out.println("; bump = " + bump); |
---|
| 7943 | + } |
---|
| 7944 | + |
---|
| 7945 | + if (pigment.equals("")) |
---|
| 7946 | + { |
---|
| 7947 | + pigment = null; |
---|
| 7948 | + } |
---|
| 7949 | + |
---|
| 7950 | + ReleaseTexture(pigment, false); |
---|
| 7951 | + } |
---|
| 7952 | + |
---|
| 7953 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 7954 | + { |
---|
| 7955 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 7956 | + { |
---|
| 7957 | + return; |
---|
| 7958 | + } |
---|
| 7959 | + |
---|
| 7960 | + if (tex == null) |
---|
| 7961 | + { |
---|
| 7962 | + ReleaseTexture(null, true); |
---|
| 7963 | + return; |
---|
| 7964 | + } |
---|
| 7965 | + |
---|
| 7966 | + String bump = Object3D.GetBump(tex); |
---|
| 7967 | + |
---|
| 7968 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 7969 | + { |
---|
| 7970 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 7971 | + // System.out.println("; bump = " + bump); |
---|
| 7972 | + } |
---|
| 7973 | + |
---|
| 7974 | + if (bump.equals("")) |
---|
| 7975 | + { |
---|
| 7976 | + bump = null; |
---|
| 7977 | + } |
---|
| 7978 | + |
---|
| 7979 | + ReleaseTexture(bump, true); |
---|
| 7980 | + } |
---|
| 7981 | + |
---|
7922 | 7982 | void ReleaseTexture(String tex, boolean bump) |
---|
7923 | 7983 | { |
---|
7924 | 7984 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
.. | .. |
---|
8022 | 8082 | } |
---|
8023 | 8083 | } |
---|
8024 | 8084 | |
---|
8025 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8085 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8026 | 8086 | { |
---|
8027 | 8087 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8028 | 8088 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8067 | 8127 | return; // true; |
---|
8068 | 8128 | } |
---|
8069 | 8129 | |
---|
8070 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8130 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8131 | + { |
---|
| 8132 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8133 | + ambientOcclusion ) // || !textureon) |
---|
| 8134 | + { |
---|
| 8135 | + return; // false; |
---|
| 8136 | + } |
---|
| 8137 | + |
---|
| 8138 | + if (tex == null) |
---|
| 8139 | + { |
---|
| 8140 | + BindTexture(null,false,resolution); |
---|
| 8141 | + return; |
---|
| 8142 | + } |
---|
| 8143 | + |
---|
| 8144 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8145 | + |
---|
| 8146 | + usedtextures.put(pigment, pigment); |
---|
| 8147 | + |
---|
| 8148 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8149 | + { |
---|
| 8150 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8151 | + // System.out.println("; bump = " + bump); |
---|
| 8152 | + } |
---|
| 8153 | + |
---|
| 8154 | + if (pigment.equals("")) |
---|
| 8155 | + { |
---|
| 8156 | + pigment = null; |
---|
| 8157 | + } |
---|
| 8158 | + |
---|
| 8159 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8160 | + BindTexture(pigment, false, resolution); |
---|
| 8161 | + } |
---|
| 8162 | + |
---|
| 8163 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8164 | + { |
---|
| 8165 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8166 | + ambientOcclusion ) // || !textureon) |
---|
| 8167 | + { |
---|
| 8168 | + return; // false; |
---|
| 8169 | + } |
---|
| 8170 | + |
---|
| 8171 | + if (tex == null) |
---|
| 8172 | + { |
---|
| 8173 | + BindTexture(null,true,resolution); |
---|
| 8174 | + return; |
---|
| 8175 | + } |
---|
| 8176 | + |
---|
| 8177 | + String bump = Object3D.GetBump(tex); |
---|
| 8178 | + |
---|
| 8179 | + usedtextures.put(bump, bump); |
---|
| 8180 | + |
---|
| 8181 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8182 | + { |
---|
| 8183 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8184 | + // System.out.println("; bump = " + bump); |
---|
| 8185 | + } |
---|
| 8186 | + |
---|
| 8187 | + if (bump.equals("")) |
---|
| 8188 | + { |
---|
| 8189 | + bump = null; |
---|
| 8190 | + } |
---|
| 8191 | + |
---|
| 8192 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8193 | + BindTexture(bump, true, resolution); |
---|
| 8194 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8195 | + } |
---|
| 8196 | + |
---|
| 8197 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8198 | + |
---|
| 8199 | + private boolean FileExists(String tex) |
---|
| 8200 | + { |
---|
| 8201 | + if (missingTextures.contains(tex)) |
---|
| 8202 | + { |
---|
| 8203 | + return false; |
---|
| 8204 | + } |
---|
| 8205 | + |
---|
| 8206 | + boolean fileExists = new File(tex).exists(); |
---|
| 8207 | + |
---|
| 8208 | + if (!fileExists) |
---|
| 8209 | + { |
---|
| 8210 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8211 | + missingTextures.add(tex); |
---|
| 8212 | + } |
---|
| 8213 | + |
---|
| 8214 | + return fileExists; |
---|
| 8215 | + } |
---|
| 8216 | + |
---|
| 8217 | + CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8071 | 8218 | { |
---|
8072 | 8219 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
8073 | 8220 | |
---|
.. | .. |
---|
8075 | 8222 | { |
---|
8076 | 8223 | String texname = tex; |
---|
8077 | 8224 | |
---|
| 8225 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8226 | + |
---|
8078 | 8227 | // String[] split = tex.split("Textures"); |
---|
8079 | 8228 | // if (split.length > 1) |
---|
8080 | 8229 | // texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
8081 | 8230 | // else |
---|
8082 | 8231 | // if (!texname.startsWith("/")) |
---|
8083 | 8232 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8084 | | - if (!new File(tex).exists()) |
---|
| 8233 | + if (!FileExists(tex)) |
---|
8085 | 8234 | { |
---|
8086 | | - texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname; |
---|
| 8235 | + texname = fallbackTextureName; |
---|
8087 | 8236 | } |
---|
8088 | 8237 | |
---|
8089 | 8238 | if (CACHETEXTURE) |
---|
.. | .. |
---|
8153 | 8302 | } |
---|
8154 | 8303 | |
---|
8155 | 8304 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
8156 | | - if (!new File(cachename).exists()) |
---|
| 8305 | + if (!FileExists(cachename)) |
---|
8157 | 8306 | cachename = texname; |
---|
8158 | 8307 | else |
---|
8159 | 8308 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8175 | 8324 | } |
---|
8176 | 8325 | |
---|
8177 | 8326 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
8178 | | - if (!new File(cachename).exists()) |
---|
| 8327 | + if (!FileExists(cachename)) |
---|
8179 | 8328 | cachename = texname; |
---|
8180 | 8329 | else |
---|
8181 | 8330 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8184 | 8333 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
8185 | 8334 | |
---|
8186 | 8335 | |
---|
8187 | | - if (texturedata != null) |
---|
| 8336 | + if (texturedata == null) |
---|
| 8337 | + throw new Exception(); |
---|
| 8338 | + |
---|
8188 | 8339 | texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
8189 | 8340 | //texture = GetTexture(tex, bump); |
---|
8190 | 8341 | } |
---|
.. | .. |
---|
8306 | 8457 | return texture; |
---|
8307 | 8458 | } |
---|
8308 | 8459 | |
---|
8309 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8460 | + com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8310 | 8461 | { |
---|
8311 | 8462 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8312 | 8463 | |
---|
.. | .. |
---|
8324 | 8475 | return texture!=null?texture.texture:null; |
---|
8325 | 8476 | } |
---|
8326 | 8477 | |
---|
8327 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8478 | + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
8328 | 8479 | { |
---|
8329 | 8480 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8330 | 8481 | |
---|
8331 | 8482 | return texture!=null?texture.texturedata:null; |
---|
8332 | 8483 | } |
---|
8333 | 8484 | |
---|
8334 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8485 | + boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8335 | 8486 | { |
---|
8336 | 8487 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8337 | 8488 | { |
---|
.. | .. |
---|
9308 | 9459 | assert (parentcam != renderCamera); |
---|
9309 | 9460 | |
---|
9310 | 9461 | if (renderCamera != lightCamera) |
---|
9311 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9312 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9462 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9463 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9313 | 9464 | |
---|
9314 | 9465 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9315 | 9466 | |
---|
.. | .. |
---|
9324 | 9475 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9325 | 9476 | |
---|
9326 | 9477 | if (renderCamera != lightCamera) |
---|
9327 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9328 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9478 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9479 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9329 | 9480 | |
---|
9330 | 9481 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9331 | 9482 | |
---|
.. | .. |
---|
10390 | 10541 | ambientOcclusion = false; |
---|
10391 | 10542 | } |
---|
10392 | 10543 | |
---|
10393 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10544 | + if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10394 | 10545 | { |
---|
10395 | 10546 | //if (RENDERSHADOW) // ? |
---|
10396 | 10547 | if (!IsFrozen()) |
---|
10397 | 10548 | { |
---|
10398 | 10549 | // dec 2012 |
---|
10399 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10550 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10400 | 10551 | { |
---|
10401 | 10552 | Globals.framecount++; |
---|
10402 | 10553 | shadowbuffer.display(); |
---|
.. | .. |
---|
10523 | 10674 | |
---|
10524 | 10675 | // if (parentcam != renderCamera) // not a light |
---|
10525 | 10676 | if (cam != lightCamera) |
---|
10526 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10527 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10677 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10678 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10528 | 10679 | |
---|
10529 | 10680 | for (int j = 0; j < 4; j++) |
---|
10530 | 10681 | { |
---|
.. | .. |
---|
10538 | 10689 | |
---|
10539 | 10690 | // if (parentcam != renderCamera) // not a light |
---|
10540 | 10691 | if (cam != lightCamera) |
---|
10541 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10542 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10692 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10693 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10543 | 10694 | |
---|
10544 | 10695 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10545 | 10696 | |
---|
.. | .. |
---|
10798 | 10949 | // Bump noise |
---|
10799 | 10950 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10800 | 10951 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10801 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 10952 | + |
---|
| 10953 | + try |
---|
| 10954 | + { |
---|
| 10955 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 10956 | + } |
---|
| 10957 | + catch (Exception e) |
---|
| 10958 | + { |
---|
| 10959 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 10960 | + } |
---|
| 10961 | + |
---|
10802 | 10962 | |
---|
10803 | 10963 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10804 | 10964 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10923 | 11083 | System.err.println("parentcam != renderCamera"); |
---|
10924 | 11084 | |
---|
10925 | 11085 | // if (cam != lightCamera) |
---|
10926 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10927 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11086 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11087 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10928 | 11088 | } |
---|
10929 | 11089 | |
---|
10930 | 11090 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10945 | 11105 | if (true) // TODO |
---|
10946 | 11106 | { |
---|
10947 | 11107 | if (cam != lightCamera) |
---|
10948 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10949 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11108 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11109 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10950 | 11110 | } |
---|
10951 | 11111 | |
---|
10952 | 11112 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11354 | 11514 | |
---|
11355 | 11515 | usedtextures.clear(); |
---|
11356 | 11516 | |
---|
11357 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11517 | + try |
---|
| 11518 | + { |
---|
| 11519 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11520 | + } |
---|
| 11521 | + catch (Exception e) |
---|
| 11522 | + { |
---|
| 11523 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11524 | + } |
---|
11358 | 11525 | } |
---|
11359 | 11526 | //System.out.println("--> " + stackdepth); |
---|
11360 | 11527 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
11445 | 11612 | if (checker != null && DrawMode() == DEFAULT) |
---|
11446 | 11613 | { |
---|
11447 | 11614 | //BindTexture(IMMORTAL_TEXTURE); |
---|
11448 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11615 | + try |
---|
| 11616 | + { |
---|
| 11617 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11618 | + } |
---|
| 11619 | + catch (Exception e) |
---|
| 11620 | + { |
---|
| 11621 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11622 | + } |
---|
11449 | 11623 | // NEAREST |
---|
11450 | 11624 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
11451 | 11625 | DrawChecker(gl); |
---|
.. | .. |
---|
11527 | 11701 | return; |
---|
11528 | 11702 | } |
---|
11529 | 11703 | |
---|
11530 | | - String string = obj.GetToolTip(); |
---|
| 11704 | + String string = obj.toString(); //.GetToolTip(); |
---|
11531 | 11705 | |
---|
11532 | 11706 | GL gl = GetGL(); |
---|
11533 | 11707 | |
---|
.. | .. |
---|
11844 | 12018 | //obj.TransformToWorld(light, light); |
---|
11845 | 12019 | for (int i = tp.size(); --i >= 0;) |
---|
11846 | 12020 | { |
---|
11847 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11848 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12021 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12022 | + LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
11849 | 12023 | } |
---|
11850 | 12024 | |
---|
11851 | 12025 | |
---|
.. | .. |
---|
11862 | 12036 | parentcam = cameras[0]; |
---|
11863 | 12037 | } |
---|
11864 | 12038 | |
---|
11865 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11866 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12039 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12040 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11867 | 12041 | |
---|
11868 | 12042 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11869 | 12043 | |
---|
.. | .. |
---|
12477 | 12651 | |
---|
12478 | 12652 | // display shadow only (bump == 0) |
---|
12479 | 12653 | "SUB temp.x, half.x, shadow.x;" + |
---|
12480 | | - "MOV temp.y, -params6.x;" + |
---|
12481 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12654 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12655 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
12482 | 12656 | "SUB temp.y, one.x, temp.z;" + |
---|
12483 | 12657 | "MUL temp.x, temp.x, temp.y;" + |
---|
12484 | 12658 | "KIL temp.x;" + |
---|
.. | .. |
---|
12809 | 12983 | //once = true; |
---|
12810 | 12984 | } |
---|
12811 | 12985 | |
---|
12812 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 12986 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12813 | 12987 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12814 | 12988 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12815 | 12989 | |
---|
.. | .. |
---|
12942 | 13116 | |
---|
12943 | 13117 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12944 | 13118 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13119 | + |
---|
| 13120 | + // Compare fragment depth in light space with shadowmap. |
---|
12945 | 13121 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12946 | 13122 | "SGE temp.y, temp.x, zero.x;" + |
---|
12947 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13123 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13124 | + |
---|
| 13125 | + // Reverse comparison |
---|
12948 | 13126 | "SUB temp.x, one.x, temp.x;" + |
---|
12949 | 13127 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12950 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13128 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12951 | 13129 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12952 | 13130 | |
---|
12953 | 13131 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12961 | 13139 | // No shadow for backface |
---|
12962 | 13140 | "DP3 temp.x, normal, lightd;" + |
---|
12963 | 13141 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13142 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13143 | + |
---|
| 13144 | + // No shadow when out of frustrum |
---|
| 13145 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12964 | 13146 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12965 | 13147 | ""; |
---|
12966 | 13148 | } |
---|
.. | .. |
---|
13776 | 13958 | |
---|
13777 | 13959 | public void mouseDragged(MouseEvent e) |
---|
13778 | 13960 | { |
---|
| 13961 | + Globals.MOUSEDRAGGED = true; |
---|
| 13962 | + |
---|
13779 | 13963 | //System.out.println("mouseDragged: " + e); |
---|
13780 | 13964 | if (isRenderer) |
---|
13781 | 13965 | movingcamera = true; |
---|
| 13966 | + |
---|
13782 | 13967 | //if (drawing) |
---|
13783 | 13968 | //return; |
---|
13784 | 13969 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
.. | .. |
---|
14340 | 14525 | |
---|
14341 | 14526 | public void mouseReleased(MouseEvent e) |
---|
14342 | 14527 | { |
---|
| 14528 | + Globals.MOUSEDRAGGED = false; |
---|
| 14529 | + |
---|
14343 | 14530 | movingcamera = false; |
---|
| 14531 | + X = Y = 0; |
---|
14344 | 14532 | //System.out.println("mouseReleased: " + e); |
---|
14345 | 14533 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14346 | 14534 | } |
---|
.. | .. |
---|
14870 | 15058 | //RESIZETEXTURE ^= true; |
---|
14871 | 15059 | //break; |
---|
14872 | 15060 | case 'z': |
---|
14873 | | - RENDERSHADOW ^= true; |
---|
| 15061 | + Globals.RENDERSHADOW ^= true; |
---|
14874 | 15062 | Globals.lighttouched = true; |
---|
14875 | 15063 | repaint(); |
---|
14876 | 15064 | break; |
---|
.. | .. |
---|
15349 | 15537 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15350 | 15538 | //Image img = CreateImage(width, height); |
---|
15351 | 15539 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15540 | + |
---|
15352 | 15541 | Graphics gr = g; // img.getGraphics(); |
---|
| 15542 | + |
---|
15353 | 15543 | if (!hasMarquee) |
---|
15354 | 15544 | { |
---|
15355 | 15545 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
15447 | 15637 | if (!isRenderer) |
---|
15448 | 15638 | { |
---|
15449 | 15639 | object.drawEditHandles(info, 0); |
---|
| 15640 | + |
---|
| 15641 | + if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15642 | + { |
---|
| 15643 | + switch (object.selection.get(0).hitSomething) |
---|
| 15644 | + { |
---|
| 15645 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15646 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15647 | + break; |
---|
| 15648 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15649 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15650 | + break; |
---|
| 15651 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15652 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15653 | + break; |
---|
| 15654 | + } |
---|
| 15655 | + |
---|
| 15656 | + } |
---|
15450 | 15657 | } |
---|
15451 | 15658 | } |
---|
| 15659 | + |
---|
15452 | 15660 | if (isRenderer) |
---|
15453 | 15661 | { |
---|
15454 | 15662 | //gr.setColor(Color.black); |
---|
15455 | 15663 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
15456 | 15664 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
15457 | 15665 | } |
---|
| 15666 | + |
---|
15458 | 15667 | if (hasMarquee) |
---|
15459 | 15668 | { |
---|
15460 | 15669 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
15861 | 16070 | Object3D object; |
---|
15862 | 16071 | static Object3D trackedobject; |
---|
15863 | 16072 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15864 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16073 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15865 | 16074 | /*static*/ Camera eyeCamera; |
---|
15866 | 16075 | /*static*/ Camera lightCamera; |
---|
15867 | 16076 | int cameracount; |
---|
.. | .. |
---|
16592 | 16801 | gl.glDisable(gl.GL_CULL_FACE); |
---|
16593 | 16802 | } |
---|
16594 | 16803 | |
---|
16595 | | - if (!RENDERSHADOW) |
---|
| 16804 | + if (!Globals.RENDERSHADOW) |
---|
16596 | 16805 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16597 | 16806 | |
---|
16598 | 16807 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
16602 | 16811 | //gl.glColorMask(false, false, false, false); |
---|
16603 | 16812 | |
---|
16604 | 16813 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
16605 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 16814 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
16606 | 16815 | { |
---|
16607 | 16816 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16608 | 16817 | |
---|