.. | .. |
---|
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) |
---|
| 468 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 469 | + ; |
---|
466 | 470 | if (!hasnorm) |
---|
467 | 471 | { |
---|
468 | | - // System.out.println("FUCK!!"); |
---|
| 472 | + // System.out.println("Mesh normal"); |
---|
469 | 473 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
470 | 474 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
471 | 475 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1190 | 1194 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1191 | 1195 | } |
---|
1192 | 1196 | } |
---|
| 1197 | + |
---|
1193 | 1198 | if (flipV) |
---|
1194 | 1199 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1195 | 1200 | else |
---|
1196 | 1201 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1202 | + |
---|
1197 | 1203 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1198 | 1204 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1199 | 1205 | |
---|
.. | .. |
---|
1213 | 1219 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1214 | 1220 | } |
---|
1215 | 1221 | } |
---|
| 1222 | + |
---|
1216 | 1223 | if (flipV) |
---|
1217 | 1224 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1218 | 1225 | else |
---|
1219 | 1226 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1227 | + |
---|
1220 | 1228 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1221 | 1229 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1222 | 1230 | |
---|
.. | .. |
---|
1244 | 1252 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1245 | 1253 | else |
---|
1246 | 1254 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1255 | + |
---|
1247 | 1256 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1248 | 1257 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1258 | + |
---|
1249 | 1259 | count2 += 2; |
---|
1250 | 1260 | count3 += 3; |
---|
1251 | 1261 | } |
---|
.. | .. |
---|
1888 | 1898 | void PushMatrix(double[][] matrix) |
---|
1889 | 1899 | { |
---|
1890 | 1900 | // GrafreeD.tracein(matrix); |
---|
1891 | | - PushMatrix(matrix,1); |
---|
| 1901 | + PushMatrix(matrix, 1); |
---|
1892 | 1902 | } |
---|
1893 | 1903 | |
---|
1894 | 1904 | void PushMatrix() |
---|
.. | .. |
---|
2265 | 2275 | LOOKAT ^= true; |
---|
2266 | 2276 | } |
---|
2267 | 2277 | |
---|
2268 | | - void ToggleRandom() |
---|
| 2278 | + void ToggleSwitch() |
---|
2269 | 2279 | { |
---|
2270 | 2280 | SWITCH ^= true; |
---|
2271 | 2281 | } |
---|
.. | .. |
---|
2374 | 2384 | { |
---|
2375 | 2385 | return currentGL; |
---|
2376 | 2386 | } |
---|
2377 | | - |
---|
| 2387 | + |
---|
2378 | 2388 | /**/ |
---|
2379 | 2389 | class CacheTexture |
---|
2380 | 2390 | { |
---|
.. | .. |
---|
7919 | 7929 | ReleaseTexture(pigment, false); |
---|
7920 | 7930 | } |
---|
7921 | 7931 | |
---|
| 7932 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 7933 | + { |
---|
| 7934 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 7935 | + { |
---|
| 7936 | + return; |
---|
| 7937 | + } |
---|
| 7938 | + |
---|
| 7939 | + if (tex == null) |
---|
| 7940 | + { |
---|
| 7941 | + ReleaseTexture(null, false); |
---|
| 7942 | + return; |
---|
| 7943 | + } |
---|
| 7944 | + |
---|
| 7945 | + String pigment = Object3D.GetPigment(tex); |
---|
| 7946 | + |
---|
| 7947 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 7948 | + { |
---|
| 7949 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 7950 | + // System.out.println("; bump = " + bump); |
---|
| 7951 | + } |
---|
| 7952 | + |
---|
| 7953 | + if (pigment.equals("")) |
---|
| 7954 | + { |
---|
| 7955 | + pigment = null; |
---|
| 7956 | + } |
---|
| 7957 | + |
---|
| 7958 | + ReleaseTexture(pigment, false); |
---|
| 7959 | + } |
---|
| 7960 | + |
---|
| 7961 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 7962 | + { |
---|
| 7963 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 7964 | + { |
---|
| 7965 | + return; |
---|
| 7966 | + } |
---|
| 7967 | + |
---|
| 7968 | + if (tex == null) |
---|
| 7969 | + { |
---|
| 7970 | + ReleaseTexture(null, true); |
---|
| 7971 | + return; |
---|
| 7972 | + } |
---|
| 7973 | + |
---|
| 7974 | + String bump = Object3D.GetBump(tex); |
---|
| 7975 | + |
---|
| 7976 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 7977 | + { |
---|
| 7978 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 7979 | + // System.out.println("; bump = " + bump); |
---|
| 7980 | + } |
---|
| 7981 | + |
---|
| 7982 | + if (bump.equals("")) |
---|
| 7983 | + { |
---|
| 7984 | + bump = null; |
---|
| 7985 | + } |
---|
| 7986 | + |
---|
| 7987 | + ReleaseTexture(bump, true); |
---|
| 7988 | + } |
---|
| 7989 | + |
---|
7922 | 7990 | void ReleaseTexture(String tex, boolean bump) |
---|
7923 | 7991 | { |
---|
7924 | 7992 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
.. | .. |
---|
8022 | 8090 | } |
---|
8023 | 8091 | } |
---|
8024 | 8092 | |
---|
8025 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8093 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8026 | 8094 | { |
---|
8027 | 8095 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8028 | 8096 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8067 | 8135 | return; // true; |
---|
8068 | 8136 | } |
---|
8069 | 8137 | |
---|
8070 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8138 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8139 | + { |
---|
| 8140 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8141 | + ambientOcclusion ) // || !textureon) |
---|
| 8142 | + { |
---|
| 8143 | + return; // false; |
---|
| 8144 | + } |
---|
| 8145 | + |
---|
| 8146 | + if (tex == null) |
---|
| 8147 | + { |
---|
| 8148 | + BindTexture(null,false,resolution); |
---|
| 8149 | + return; |
---|
| 8150 | + } |
---|
| 8151 | + |
---|
| 8152 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8153 | + |
---|
| 8154 | + usedtextures.put(pigment, pigment); |
---|
| 8155 | + |
---|
| 8156 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8157 | + { |
---|
| 8158 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8159 | + // System.out.println("; bump = " + bump); |
---|
| 8160 | + } |
---|
| 8161 | + |
---|
| 8162 | + if (pigment.equals("")) |
---|
| 8163 | + { |
---|
| 8164 | + pigment = null; |
---|
| 8165 | + } |
---|
| 8166 | + |
---|
| 8167 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8168 | + BindTexture(pigment, false, resolution); |
---|
| 8169 | + } |
---|
| 8170 | + |
---|
| 8171 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8172 | + { |
---|
| 8173 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8174 | + ambientOcclusion ) // || !textureon) |
---|
| 8175 | + { |
---|
| 8176 | + return; // false; |
---|
| 8177 | + } |
---|
| 8178 | + |
---|
| 8179 | + if (tex == null) |
---|
| 8180 | + { |
---|
| 8181 | + BindTexture(null,true,resolution); |
---|
| 8182 | + return; |
---|
| 8183 | + } |
---|
| 8184 | + |
---|
| 8185 | + String bump = Object3D.GetBump(tex); |
---|
| 8186 | + |
---|
| 8187 | + usedtextures.put(bump, bump); |
---|
| 8188 | + |
---|
| 8189 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8190 | + { |
---|
| 8191 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8192 | + // System.out.println("; bump = " + bump); |
---|
| 8193 | + } |
---|
| 8194 | + |
---|
| 8195 | + if (bump.equals("")) |
---|
| 8196 | + { |
---|
| 8197 | + bump = null; |
---|
| 8198 | + } |
---|
| 8199 | + |
---|
| 8200 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8201 | + BindTexture(bump, true, resolution); |
---|
| 8202 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8203 | + } |
---|
| 8204 | + |
---|
| 8205 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8206 | + |
---|
| 8207 | + private boolean FileExists(String tex) |
---|
| 8208 | + { |
---|
| 8209 | + if (missingTextures.contains(tex)) |
---|
| 8210 | + { |
---|
| 8211 | + return false; |
---|
| 8212 | + } |
---|
| 8213 | + |
---|
| 8214 | + boolean fileExists = new File(tex).exists(); |
---|
| 8215 | + |
---|
| 8216 | + if (!fileExists) |
---|
| 8217 | + { |
---|
| 8218 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8219 | + missingTextures.add(tex); |
---|
| 8220 | + } |
---|
| 8221 | + |
---|
| 8222 | + return fileExists; |
---|
| 8223 | + } |
---|
| 8224 | + |
---|
| 8225 | + CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8071 | 8226 | { |
---|
8072 | 8227 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
8073 | 8228 | |
---|
.. | .. |
---|
8075 | 8230 | { |
---|
8076 | 8231 | String texname = tex; |
---|
8077 | 8232 | |
---|
| 8233 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8234 | + |
---|
8078 | 8235 | // String[] split = tex.split("Textures"); |
---|
8079 | 8236 | // if (split.length > 1) |
---|
8080 | 8237 | // texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
8081 | 8238 | // else |
---|
8082 | 8239 | // if (!texname.startsWith("/")) |
---|
8083 | 8240 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8084 | | - if (!new File(tex).exists()) |
---|
| 8241 | + if (!FileExists(tex)) |
---|
8085 | 8242 | { |
---|
8086 | | - texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname; |
---|
| 8243 | + texname = fallbackTextureName; |
---|
8087 | 8244 | } |
---|
8088 | 8245 | |
---|
8089 | 8246 | if (CACHETEXTURE) |
---|
.. | .. |
---|
8153 | 8310 | } |
---|
8154 | 8311 | |
---|
8155 | 8312 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
8156 | | - if (!new File(cachename).exists()) |
---|
| 8313 | + if (!FileExists(cachename)) |
---|
8157 | 8314 | cachename = texname; |
---|
8158 | 8315 | else |
---|
8159 | 8316 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8175 | 8332 | } |
---|
8176 | 8333 | |
---|
8177 | 8334 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
8178 | | - if (!new File(cachename).exists()) |
---|
| 8335 | + if (!FileExists(cachename)) |
---|
8179 | 8336 | cachename = texname; |
---|
8180 | 8337 | else |
---|
8181 | 8338 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8184 | 8341 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
8185 | 8342 | |
---|
8186 | 8343 | |
---|
8187 | | - if (texturedata != null) |
---|
| 8344 | + if (texturedata == null) |
---|
| 8345 | + throw new Exception(); |
---|
| 8346 | + |
---|
8188 | 8347 | texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
8189 | 8348 | //texture = GetTexture(tex, bump); |
---|
8190 | 8349 | } |
---|
.. | .. |
---|
8306 | 8465 | return texture; |
---|
8307 | 8466 | } |
---|
8308 | 8467 | |
---|
8309 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8468 | + com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8310 | 8469 | { |
---|
8311 | 8470 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8312 | 8471 | |
---|
.. | .. |
---|
8324 | 8483 | return texture!=null?texture.texture:null; |
---|
8325 | 8484 | } |
---|
8326 | 8485 | |
---|
8327 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8486 | + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
8328 | 8487 | { |
---|
8329 | 8488 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8330 | 8489 | |
---|
8331 | 8490 | return texture!=null?texture.texturedata:null; |
---|
8332 | 8491 | } |
---|
8333 | 8492 | |
---|
8334 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8493 | + boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8335 | 8494 | { |
---|
8336 | 8495 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8337 | 8496 | { |
---|
.. | .. |
---|
9308 | 9467 | assert (parentcam != renderCamera); |
---|
9309 | 9468 | |
---|
9310 | 9469 | if (renderCamera != lightCamera) |
---|
9311 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9312 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9470 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9471 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9313 | 9472 | |
---|
9314 | 9473 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9315 | 9474 | |
---|
.. | .. |
---|
9324 | 9483 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9325 | 9484 | |
---|
9326 | 9485 | if (renderCamera != lightCamera) |
---|
9327 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9328 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9486 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9487 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9329 | 9488 | |
---|
9330 | 9489 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9331 | 9490 | |
---|
.. | .. |
---|
10390 | 10549 | ambientOcclusion = false; |
---|
10391 | 10550 | } |
---|
10392 | 10551 | |
---|
10393 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10552 | + if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10394 | 10553 | { |
---|
10395 | 10554 | //if (RENDERSHADOW) // ? |
---|
10396 | 10555 | if (!IsFrozen()) |
---|
10397 | 10556 | { |
---|
10398 | 10557 | // dec 2012 |
---|
10399 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10558 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10400 | 10559 | { |
---|
10401 | 10560 | Globals.framecount++; |
---|
10402 | 10561 | shadowbuffer.display(); |
---|
.. | .. |
---|
10523 | 10682 | |
---|
10524 | 10683 | // if (parentcam != renderCamera) // not a light |
---|
10525 | 10684 | if (cam != lightCamera) |
---|
10526 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10527 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10685 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10686 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10528 | 10687 | |
---|
10529 | 10688 | for (int j = 0; j < 4; j++) |
---|
10530 | 10689 | { |
---|
.. | .. |
---|
10538 | 10697 | |
---|
10539 | 10698 | // if (parentcam != renderCamera) // not a light |
---|
10540 | 10699 | if (cam != lightCamera) |
---|
10541 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10542 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10700 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10701 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10543 | 10702 | |
---|
10544 | 10703 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10545 | 10704 | |
---|
.. | .. |
---|
10798 | 10957 | // Bump noise |
---|
10799 | 10958 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10800 | 10959 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10801 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 10960 | + |
---|
| 10961 | + try |
---|
| 10962 | + { |
---|
| 10963 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 10964 | + } |
---|
| 10965 | + catch (Exception e) |
---|
| 10966 | + { |
---|
| 10967 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 10968 | + } |
---|
| 10969 | + |
---|
10802 | 10970 | |
---|
10803 | 10971 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10804 | 10972 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10923 | 11091 | System.err.println("parentcam != renderCamera"); |
---|
10924 | 11092 | |
---|
10925 | 11093 | // if (cam != lightCamera) |
---|
10926 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10927 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11094 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11095 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10928 | 11096 | } |
---|
10929 | 11097 | |
---|
10930 | 11098 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10945 | 11113 | if (true) // TODO |
---|
10946 | 11114 | { |
---|
10947 | 11115 | if (cam != lightCamera) |
---|
10948 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10949 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11116 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11117 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10950 | 11118 | } |
---|
10951 | 11119 | |
---|
10952 | 11120 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11354 | 11522 | |
---|
11355 | 11523 | usedtextures.clear(); |
---|
11356 | 11524 | |
---|
11357 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11525 | + try |
---|
| 11526 | + { |
---|
| 11527 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11528 | + } |
---|
| 11529 | + catch (Exception e) |
---|
| 11530 | + { |
---|
| 11531 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11532 | + } |
---|
11358 | 11533 | } |
---|
11359 | 11534 | //System.out.println("--> " + stackdepth); |
---|
11360 | 11535 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
11445 | 11620 | if (checker != null && DrawMode() == DEFAULT) |
---|
11446 | 11621 | { |
---|
11447 | 11622 | //BindTexture(IMMORTAL_TEXTURE); |
---|
11448 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11623 | + try |
---|
| 11624 | + { |
---|
| 11625 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11626 | + } |
---|
| 11627 | + catch (Exception e) |
---|
| 11628 | + { |
---|
| 11629 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11630 | + } |
---|
11449 | 11631 | // NEAREST |
---|
11450 | 11632 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
11451 | 11633 | DrawChecker(gl); |
---|
.. | .. |
---|
11527 | 11709 | return; |
---|
11528 | 11710 | } |
---|
11529 | 11711 | |
---|
11530 | | - String string = obj.GetToolTip(); |
---|
| 11712 | + String string = obj.toString(); //.GetToolTip(); |
---|
11531 | 11713 | |
---|
11532 | 11714 | GL gl = GetGL(); |
---|
11533 | 11715 | |
---|
.. | .. |
---|
11844 | 12026 | //obj.TransformToWorld(light, light); |
---|
11845 | 12027 | for (int i = tp.size(); --i >= 0;) |
---|
11846 | 12028 | { |
---|
11847 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11848 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12029 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12030 | + LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
11849 | 12031 | } |
---|
11850 | 12032 | |
---|
11851 | 12033 | |
---|
.. | .. |
---|
11862 | 12044 | parentcam = cameras[0]; |
---|
11863 | 12045 | } |
---|
11864 | 12046 | |
---|
11865 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11866 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12047 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12048 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11867 | 12049 | |
---|
11868 | 12050 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11869 | 12051 | |
---|
.. | .. |
---|
12477 | 12659 | |
---|
12478 | 12660 | // display shadow only (bump == 0) |
---|
12479 | 12661 | "SUB temp.x, half.x, shadow.x;" + |
---|
12480 | | - "MOV temp.y, -params6.x;" + |
---|
12481 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12662 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12663 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
12482 | 12664 | "SUB temp.y, one.x, temp.z;" + |
---|
12483 | 12665 | "MUL temp.x, temp.x, temp.y;" + |
---|
12484 | 12666 | "KIL temp.x;" + |
---|
.. | .. |
---|
12809 | 12991 | //once = true; |
---|
12810 | 12992 | } |
---|
12811 | 12993 | |
---|
12812 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 12994 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12813 | 12995 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12814 | 12996 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12815 | 12997 | |
---|
.. | .. |
---|
12942 | 13124 | |
---|
12943 | 13125 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12944 | 13126 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13127 | + |
---|
| 13128 | + // Compare fragment depth in light space with shadowmap. |
---|
12945 | 13129 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12946 | 13130 | "SGE temp.y, temp.x, zero.x;" + |
---|
12947 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13131 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13132 | + |
---|
| 13133 | + // Reverse comparison |
---|
12948 | 13134 | "SUB temp.x, one.x, temp.x;" + |
---|
12949 | 13135 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12950 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13136 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12951 | 13137 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12952 | 13138 | |
---|
12953 | 13139 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12961 | 13147 | // No shadow for backface |
---|
12962 | 13148 | "DP3 temp.x, normal, lightd;" + |
---|
12963 | 13149 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13150 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13151 | + |
---|
| 13152 | + // No shadow when out of frustrum |
---|
| 13153 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12964 | 13154 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12965 | 13155 | ""; |
---|
12966 | 13156 | } |
---|
.. | .. |
---|
13776 | 13966 | |
---|
13777 | 13967 | public void mouseDragged(MouseEvent e) |
---|
13778 | 13968 | { |
---|
| 13969 | + Globals.MOUSEDRAGGED = true; |
---|
| 13970 | + |
---|
13779 | 13971 | //System.out.println("mouseDragged: " + e); |
---|
13780 | 13972 | if (isRenderer) |
---|
13781 | 13973 | movingcamera = true; |
---|
| 13974 | + |
---|
13782 | 13975 | //if (drawing) |
---|
13783 | 13976 | //return; |
---|
13784 | 13977 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
.. | .. |
---|
14340 | 14533 | |
---|
14341 | 14534 | public void mouseReleased(MouseEvent e) |
---|
14342 | 14535 | { |
---|
| 14536 | + Globals.MOUSEDRAGGED = false; |
---|
| 14537 | + |
---|
14343 | 14538 | movingcamera = false; |
---|
| 14539 | + X = Y = 0; |
---|
14344 | 14540 | //System.out.println("mouseReleased: " + e); |
---|
14345 | 14541 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14346 | 14542 | } |
---|
.. | .. |
---|
14870 | 15066 | //RESIZETEXTURE ^= true; |
---|
14871 | 15067 | //break; |
---|
14872 | 15068 | case 'z': |
---|
14873 | | - RENDERSHADOW ^= true; |
---|
| 15069 | + Globals.RENDERSHADOW ^= true; |
---|
14874 | 15070 | Globals.lighttouched = true; |
---|
14875 | 15071 | repaint(); |
---|
14876 | 15072 | break; |
---|
.. | .. |
---|
15349 | 15545 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15350 | 15546 | //Image img = CreateImage(width, height); |
---|
15351 | 15547 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15548 | + |
---|
15352 | 15549 | Graphics gr = g; // img.getGraphics(); |
---|
| 15550 | + |
---|
15353 | 15551 | if (!hasMarquee) |
---|
15354 | 15552 | { |
---|
15355 | 15553 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
15447 | 15645 | if (!isRenderer) |
---|
15448 | 15646 | { |
---|
15449 | 15647 | object.drawEditHandles(info, 0); |
---|
| 15648 | + |
---|
| 15649 | + if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15650 | + { |
---|
| 15651 | + switch (object.selection.get(0).hitSomething) |
---|
| 15652 | + { |
---|
| 15653 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15654 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15655 | + break; |
---|
| 15656 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15657 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15658 | + break; |
---|
| 15659 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15660 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15661 | + break; |
---|
| 15662 | + } |
---|
| 15663 | + |
---|
| 15664 | + } |
---|
15450 | 15665 | } |
---|
15451 | 15666 | } |
---|
| 15667 | + |
---|
15452 | 15668 | if (isRenderer) |
---|
15453 | 15669 | { |
---|
15454 | 15670 | //gr.setColor(Color.black); |
---|
15455 | 15671 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
15456 | 15672 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
15457 | 15673 | } |
---|
| 15674 | + |
---|
15458 | 15675 | if (hasMarquee) |
---|
15459 | 15676 | { |
---|
15460 | 15677 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
15861 | 16078 | Object3D object; |
---|
15862 | 16079 | static Object3D trackedobject; |
---|
15863 | 16080 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15864 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16081 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15865 | 16082 | /*static*/ Camera eyeCamera; |
---|
15866 | 16083 | /*static*/ Camera lightCamera; |
---|
15867 | 16084 | int cameracount; |
---|
.. | .. |
---|
16592 | 16809 | gl.glDisable(gl.GL_CULL_FACE); |
---|
16593 | 16810 | } |
---|
16594 | 16811 | |
---|
16595 | | - if (!RENDERSHADOW) |
---|
| 16812 | + if (!Globals.RENDERSHADOW) |
---|
16596 | 16813 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16597 | 16814 | |
---|
16598 | 16815 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
16602 | 16819 | //gl.glColorMask(false, false, false, false); |
---|
16603 | 16820 | |
---|
16604 | 16821 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
16605 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 16822 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
16606 | 16823 | { |
---|
16607 | 16824 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16608 | 16825 | |
---|