From 372b7fd481a476cd659713a4a01bf28bf6760cbe Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 16 Jun 2019 12:09:54 -0400 Subject: [PATCH] Fix info panel. --- CameraPane.java | 90 +++++++++++++++++++++++++++++++-------------- 1 files changed, 62 insertions(+), 28 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index 16d28d9..cfdc3d3 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -150,6 +150,8 @@ defaultcaps.setAccumAlphaBits(16); } + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); + void SetAsGLRenderer(boolean b) { isRenderer = b; @@ -462,7 +464,7 @@ if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) { //gl.glBegin(gl.GL_TRIANGLES); - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); if (!hasnorm) { // System.out.println("FUCK!!"); @@ -1888,7 +1890,7 @@ void PushMatrix(double[][] matrix) { // GrafreeD.tracein(matrix); - PushMatrix(matrix,1); + PushMatrix(matrix, 1); } void PushMatrix() @@ -2374,7 +2376,7 @@ { return currentGL; } - + /**/ class CacheTexture { @@ -8067,6 +8069,26 @@ return; // true; } + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); + + private boolean FileExists(String tex) + { + if (missingTextures.contains(tex)) + { + return false; + } + + boolean fileExists = new File(tex).exists(); + + if (!fileExists) + { + // If file exists, the "new File()" is not executed sgain + missingTextures.add(tex); + } + + return fileExists; + } + CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception { CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; @@ -8075,15 +8097,17 @@ { String texname = tex; + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; + // String[] split = tex.split("Textures"); // if (split.length > 1) // texname = "/Users/nbriere/Textures" + split[split.length-1]; // else // if (!texname.startsWith("/")) // texname = "/Users/nbriere/Textures/" + texname; - if (!new File(tex).exists()) + if (!FileExists(tex)) { - texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname; + texname = fallbackTextureName; } if (CACHETEXTURE) @@ -8153,7 +8177,7 @@ } cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; - if (!new File(cachename).exists()) + if (!FileExists(cachename)) cachename = texname; else processbump = false; // don't process bump map again @@ -8175,7 +8199,7 @@ } cachename = texname.substring(0, texname.length()-4)+ext+".png"; - if (!new File(cachename).exists()) + if (!FileExists(cachename)) cachename = texname; else processbump = false; // don't process bump map again @@ -9310,8 +9334,8 @@ assert (parentcam != renderCamera); if (renderCamera != lightCamera) - for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.matConcat(matrix, parentcam.toParent, matrix); + //for (int count = parentcam.GetTransformCount(); --count>=0;) + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); @@ -9326,8 +9350,8 @@ LA.matCopy(renderCamera.fromScreen, matrix); if (renderCamera != lightCamera) - for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.matConcat(parentcam.fromParent, matrix, matrix); + //for (int count = parentcam.GetTransformCount(); --count>=0;) + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); @@ -10525,8 +10549,8 @@ // if (parentcam != renderCamera) // not a light if (cam != lightCamera) - for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.matConcat(matrix, parentcam.toParent, matrix); + //for (int count = parentcam.GetTransformCount(); --count>=0;) + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); for (int j = 0; j < 4; j++) { @@ -10540,8 +10564,8 @@ // if (parentcam != renderCamera) // not a light if (cam != lightCamera) - for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.matConcat(parentcam.fromParent, matrix, matrix); + //for (int count = parentcam.GetTransformCount(); --count>=0;) + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); @@ -10934,8 +10958,8 @@ System.err.println("parentcam != renderCamera"); // if (cam != lightCamera) - for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 + //for (int count = parentcam.GetTransformCount(); --count>=0;) + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 } LA.xformDir(lightposition, cam.toScreen, lightposition); @@ -10956,8 +10980,8 @@ if (true) // TODO { if (cam != lightCamera) - for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 + //for (int count = parentcam.GetTransformCount(); --count>=0;) + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 } LA.xformPos(light0, cam.toScreen, light0); @@ -11869,8 +11893,8 @@ //obj.TransformToWorld(light, light); for (int i = tp.size(); --i >= 0;) { - for (int count = tp.get(i).GetTransformCount(); --count>=0;) - LA.xformPos(light, tp.get(i).toParent, light); + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) + LA.xformPos(light, tp.get(i).GlobalTransform(), light); } @@ -11887,8 +11911,8 @@ parentcam = cameras[0]; } - for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.xformPos(light, parentcam.toParent, light); // may 2013 + //for (int count = parentcam.GetTransformCount(); --count>=0;) + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 LA.xformPos(light, renderCamera.toScreen, light); @@ -13809,9 +13833,12 @@ public void mouseDragged(MouseEvent e) { + Globals.MOUSEDRAGGED = true; + //System.out.println("mouseDragged: " + e); if (isRenderer) movingcamera = true; + //if (drawing) //return; if ((e.getModifiersEx() & CTRL) != 0 @@ -14373,6 +14400,8 @@ public void mouseReleased(MouseEvent e) { + Globals.MOUSEDRAGGED = false; + movingcamera = false; X = Y = 0; //System.out.println("mouseReleased: " + e); @@ -15488,12 +15517,17 @@ { switch (object.selection.get(0).hitSomething) { - case Object3D.hitCenter: gr.setColor(Color.pink); break; - case Object3D.hitRotate: gr.setColor(Color.green); break; - case Object3D.hitScale: gr.setColor(Color.cyan); break; + case Object3D.hitCenter: gr.setColor(Color.pink); + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); + break; + case Object3D.hitRotate: gr.setColor(Color.yellow); + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); + break; + case Object3D.hitScale: gr.setColor(Color.cyan); + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); + break; } - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); } } } @@ -15911,7 +15945,7 @@ Object3D object; static Object3D trackedobject; Camera renderCamera; // Light or Eye (or Occlusion) - /*static*/ Camera manipCamera; // Light or Eye + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light /*static*/ Camera eyeCamera; /*static*/ Camera lightCamera; int cameracount; -- Gitblit v1.6.2