.. | .. |
---|
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 ||*/ |
---|
.. | .. |
---|
8067 | 8127 | return; // true; |
---|
8068 | 8128 | } |
---|
8069 | 8129 | |
---|
| 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 | + |
---|
8070 | 8217 | CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8071 | 8218 | { |
---|
8072 | 8219 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
.. | .. |
---|
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 |
---|
.. | .. |
---|
9310 | 9459 | assert (parentcam != renderCamera); |
---|
9311 | 9460 | |
---|
9312 | 9461 | if (renderCamera != lightCamera) |
---|
9313 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9314 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9462 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9463 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9315 | 9464 | |
---|
9316 | 9465 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9317 | 9466 | |
---|
.. | .. |
---|
9326 | 9475 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9327 | 9476 | |
---|
9328 | 9477 | if (renderCamera != lightCamera) |
---|
9329 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9330 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9478 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9479 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9331 | 9480 | |
---|
9332 | 9481 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9333 | 9482 | |
---|
.. | .. |
---|
10392 | 10541 | ambientOcclusion = false; |
---|
10393 | 10542 | } |
---|
10394 | 10543 | |
---|
10395 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10544 | + if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10396 | 10545 | { |
---|
10397 | 10546 | //if (RENDERSHADOW) // ? |
---|
10398 | 10547 | if (!IsFrozen()) |
---|
10399 | 10548 | { |
---|
10400 | 10549 | // dec 2012 |
---|
10401 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10550 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10402 | 10551 | { |
---|
10403 | 10552 | Globals.framecount++; |
---|
10404 | 10553 | shadowbuffer.display(); |
---|
.. | .. |
---|
10525 | 10674 | |
---|
10526 | 10675 | // if (parentcam != renderCamera) // not a light |
---|
10527 | 10676 | if (cam != lightCamera) |
---|
10528 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10529 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10677 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10678 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10530 | 10679 | |
---|
10531 | 10680 | for (int j = 0; j < 4; j++) |
---|
10532 | 10681 | { |
---|
.. | .. |
---|
10540 | 10689 | |
---|
10541 | 10690 | // if (parentcam != renderCamera) // not a light |
---|
10542 | 10691 | if (cam != lightCamera) |
---|
10543 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10544 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10692 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10693 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10545 | 10694 | |
---|
10546 | 10695 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10547 | 10696 | |
---|
.. | .. |
---|
10934 | 11083 | System.err.println("parentcam != renderCamera"); |
---|
10935 | 11084 | |
---|
10936 | 11085 | // if (cam != lightCamera) |
---|
10937 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10938 | | - 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 |
---|
10939 | 11088 | } |
---|
10940 | 11089 | |
---|
10941 | 11090 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10956 | 11105 | if (true) // TODO |
---|
10957 | 11106 | { |
---|
10958 | 11107 | if (cam != lightCamera) |
---|
10959 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10960 | | - 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 |
---|
10961 | 11110 | } |
---|
10962 | 11111 | |
---|
10963 | 11112 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11552 | 11701 | return; |
---|
11553 | 11702 | } |
---|
11554 | 11703 | |
---|
11555 | | - String string = obj.GetToolTip(); |
---|
| 11704 | + String string = obj.toString(); //.GetToolTip(); |
---|
11556 | 11705 | |
---|
11557 | 11706 | GL gl = GetGL(); |
---|
11558 | 11707 | |
---|
.. | .. |
---|
11869 | 12018 | //obj.TransformToWorld(light, light); |
---|
11870 | 12019 | for (int i = tp.size(); --i >= 0;) |
---|
11871 | 12020 | { |
---|
11872 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11873 | | - 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); |
---|
11874 | 12023 | } |
---|
11875 | 12024 | |
---|
11876 | 12025 | |
---|
.. | .. |
---|
11887 | 12036 | parentcam = cameras[0]; |
---|
11888 | 12037 | } |
---|
11889 | 12038 | |
---|
11890 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11891 | | - 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 |
---|
11892 | 12041 | |
---|
11893 | 12042 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11894 | 12043 | |
---|
.. | .. |
---|
13809 | 13958 | |
---|
13810 | 13959 | public void mouseDragged(MouseEvent e) |
---|
13811 | 13960 | { |
---|
| 13961 | + Globals.MOUSEDRAGGED = true; |
---|
| 13962 | + |
---|
13812 | 13963 | //System.out.println("mouseDragged: " + e); |
---|
13813 | 13964 | if (isRenderer) |
---|
13814 | 13965 | movingcamera = true; |
---|
| 13966 | + |
---|
13815 | 13967 | //if (drawing) |
---|
13816 | 13968 | //return; |
---|
13817 | 13969 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
.. | .. |
---|
14373 | 14525 | |
---|
14374 | 14526 | public void mouseReleased(MouseEvent e) |
---|
14375 | 14527 | { |
---|
| 14528 | + Globals.MOUSEDRAGGED = false; |
---|
| 14529 | + |
---|
14376 | 14530 | movingcamera = false; |
---|
14377 | 14531 | X = Y = 0; |
---|
14378 | 14532 | //System.out.println("mouseReleased: " + e); |
---|
.. | .. |
---|
15488 | 15642 | { |
---|
15489 | 15643 | switch (object.selection.get(0).hitSomething) |
---|
15490 | 15644 | { |
---|
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; |
---|
| 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; |
---|
15494 | 15654 | } |
---|
15495 | 15655 | |
---|
15496 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15497 | 15656 | } |
---|
15498 | 15657 | } |
---|
15499 | 15658 | } |
---|
.. | .. |
---|
15911 | 16070 | Object3D object; |
---|
15912 | 16071 | static Object3D trackedobject; |
---|
15913 | 16072 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15914 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16073 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15915 | 16074 | /*static*/ Camera eyeCamera; |
---|
15916 | 16075 | /*static*/ Camera lightCamera; |
---|
15917 | 16076 | int cameracount; |
---|