From 914255f70cf047897212839cbf3a6722703f4457 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 24 Jun 2019 13:19:16 -0400 Subject: [PATCH] Fix manip window + new icons. --- CameraPane.java | 523 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 386 insertions(+), 137 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index 15994b6..c1f5c9b 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -37,7 +37,6 @@ static boolean[] selectedstack = new boolean[65536]; static int materialdepth = 0; - static boolean DEBUG = false; static boolean FRUSTUM = false; // still bogus true; // frustum culling // camera change fix @@ -106,7 +105,7 @@ static boolean OEIL = true; static boolean OEILONCE = false; // do oeilon then oeiloff static boolean LOOKAT = true; -static boolean RANDOM = true; // false; +static boolean SWITCH = true; // false; static boolean HANDLES = false; // selection doesn't work!! static boolean PAINTMODE = false; @@ -149,6 +148,8 @@ defaultcaps.setAccumBlueBits(16); defaultcaps.setAccumAlphaBits(16); } + + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); void SetAsGLRenderer(boolean b) { @@ -325,7 +326,7 @@ cStatic.objectstack[materialdepth++] = obj; //System.out.println("material " + material); //Applet3D.tracein(this, selected); - display.vector2buffer = obj.projectedVertices; + //display.vector2buffer = obj.projectedVertices; if (obj instanceof Camera) { display.options1[0] = material.shift; @@ -357,7 +358,7 @@ /**/ } else { - DrawMaterial(material, selected); + DrawMaterial(material, selected, obj.projectedVertices); } } else { @@ -381,8 +382,8 @@ cStatic.objectstack[materialdepth++] = obj; //System.out.println("material " + material); //Applet3D.tracein("selected ", selected); - display.vector2buffer = obj.projectedVertices; - display.DrawMaterial(material, selected); + //display.vector2buffer = obj.projectedVertices; + display.DrawMaterial(material, selected, obj.projectedVertices); } } @@ -399,8 +400,8 @@ materialdepth -= 1; if (materialdepth > 0) { - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); } //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); } else if (selected && CameraPane.flash && obj.GetMaterial() != null) @@ -420,8 +421,8 @@ materialdepth -= 1; if (materialdepth > 0) { - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); } //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); //else @@ -462,10 +463,12 @@ 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) + // TEST LIVE NORMALS && !obj.dontselect + ; if (!hasnorm) { - // System.out.println("FUCK!!"); + // System.out.println("Mesh normal"); LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); LA.vecCross(obj.v0, obj.v1, obj.v2); @@ -1190,10 +1193,12 @@ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); } } + if (flipV) gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); else gl.glTexCoord2f(uv[count2], uv[count2 + 1]); + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); @@ -1213,10 +1218,12 @@ gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); } } + if (flipV) gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); else gl.glTexCoord2f(uv[count2], uv[count2 + 1]); + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); @@ -1244,8 +1251,10 @@ gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); else gl.glTexCoord2f(uv[count2], uv[count2 + 1]); + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); + count2 += 2; count3 += 3; } @@ -1601,7 +1610,7 @@ // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); } - void DrawMaterial(cMaterial material, boolean selected) + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) { CameraPane display = this; //new Exception().printStackTrace(); @@ -1628,7 +1637,7 @@ cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); - float[] colorV = GrafreeD.colorV; + float[] colorV = Grafreed.colorV; /**/ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) @@ -1636,7 +1645,7 @@ colorV[0] = display.modelParams0[0] * material.diffuse; colorV[1] = display.modelParams0[1] * material.diffuse; colorV[2] = display.modelParams0[2] * material.diffuse; - colorV[3] = material.opacity; + colorV[3] = 1; // material.opacity; gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); //System.out.println("Opacity = " + opacity); @@ -1744,9 +1753,9 @@ display.modelParams7[2] = 0; display.modelParams7[3] = 0; - display.modelParams6[0] = 100; // criss de bug de bump + //display.modelParams6[0] = 100; // criss de bug de bump - Object3D.cVector2[] extparams = display.vector2buffer; + Object3D.cVector2[] extparams = others; // display.vector2buffer; if (extparams != null && extparams.length > 0 && extparams[0] != null) { display.modelParams6[0] = extparams[0].x / 1000.0f; // bump @@ -1888,7 +1897,7 @@ void PushMatrix(double[][] matrix) { // GrafreeD.tracein(matrix); - PushMatrix(matrix,1); + PushMatrix(matrix, 1); } void PushMatrix() @@ -2140,7 +2149,7 @@ System.err.println("LIVE = " + Globals.isLIVE()); if (!Globals.isLIVE()) // save sound - GrafreeD.savesound = true; // wav.save(); + Grafreed.savesound = true; // wav.save(); // else repaint(); // start loop // may 2013 } @@ -2257,7 +2266,7 @@ void ToggleDebug() { - DEBUG ^= true; + Globals.DEBUG ^= true; } void ToggleLookAt() @@ -2265,9 +2274,9 @@ LOOKAT ^= true; } - void ToggleRandom() + void ToggleSwitch() { - RANDOM ^= true; + SWITCH ^= true; } void ToggleHandles() @@ -2374,7 +2383,7 @@ { return currentGL; } - + /**/ class CacheTexture { @@ -7919,6 +7928,64 @@ ReleaseTexture(pigment, false); } + public void ReleasePigmentTexture(cTexture tex) // INTERFACE + { + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) + { + return; + } + + if (tex == null) + { + ReleaseTexture(null, false); + return; + } + + String pigment = Object3D.GetPigment(tex); + + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) + { + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); + // System.out.println("; bump = " + bump); + } + + if (pigment.equals("")) + { + pigment = null; + } + + ReleaseTexture(pigment, false); + } + + public void ReleaseBumpTexture(cTexture tex) // INTERFACE + { + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) + { + return; + } + + if (tex == null) + { + ReleaseTexture(null, true); + return; + } + + String bump = Object3D.GetBump(tex); + + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) + { + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); + // System.out.println("; bump = " + bump); + } + + if (bump.equals("")) + { + bump = null; + } + + ReleaseTexture(bump, true); + } + void ReleaseTexture(String tex, boolean bump) { if (// DrawMode() != 0 || /*tex == null ||*/ @@ -8022,7 +8089,7 @@ } } - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE { if (// DrawMode() != 0 || /*tex == null ||*/ ambientOcclusion ) // || !textureon) @@ -8067,7 +8134,94 @@ return; // true; } - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE + { + if (// DrawMode() != 0 || /*tex == null ||*/ + ambientOcclusion ) // || !textureon) + { + return; // false; + } + + if (tex == null) + { + BindTexture(null,false,resolution); + return; + } + + String pigment = Object3D.GetPigment(tex); + + usedtextures.put(pigment, pigment); + + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) + { + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); + // System.out.println("; bump = " + bump); + } + + if (pigment.equals("")) + { + pigment = null; + } + + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); + BindTexture(pigment, false, resolution); + } + + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE + { + if (// DrawMode() != 0 || /*tex == null ||*/ + ambientOcclusion ) // || !textureon) + { + return; // false; + } + + if (tex == null) + { + BindTexture(null,true,resolution); + return; + } + + String bump = Object3D.GetBump(tex); + + usedtextures.put(bump, bump); + + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) + { + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); + // System.out.println("; bump = " + bump); + } + + if (bump.equals("")) + { + bump = null; + } + + GetGL().glActiveTexture(GetGL().GL_TEXTURE2); + BindTexture(bump, true, resolution); + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); + } + + 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,12 +8229,18 @@ { String texname = tex; - 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; + 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 (!FileExists(tex)) + { + texname = fallbackTextureName; + } if (CACHETEXTURE) texture = textures.get(texname); // TEXTURE CACHE @@ -8149,7 +8309,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 @@ -8171,7 +8331,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 @@ -8180,7 +8340,9 @@ texturedata = GetFileTexture(cachename, processbump, resolution); - if (texturedata != null) + if (texturedata == null) + throw new Exception(); + texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); //texture = GetTexture(tex, bump); } @@ -8302,7 +8464,7 @@ return texture; } - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) + com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception { CacheTexture texture = GetCacheTexture(tex, bump, resolution); @@ -8320,14 +8482,14 @@ return texture!=null?texture.texture:null; } - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception { CacheTexture texture = GetCacheTexture(tex, bump, resolution); return texture!=null?texture.texturedata:null; } - boolean BindTexture(String tex, boolean bump, int resolution) + boolean BindTexture(String tex, boolean bump, int resolution) throws Exception { if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) { @@ -9304,8 +9466,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); @@ -9320,8 +9482,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); @@ -9538,7 +9700,7 @@ if (!BOXMODE) { - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); } if (!BOXMODE) @@ -9576,7 +9738,7 @@ ABORTED = false; } else - GrafreeD.wav.cursor += 735 * ACSIZE; + Grafreed.wav.cursor += 735 * ACSIZE; if (false) { @@ -10239,11 +10401,11 @@ public void display(GLAutoDrawable drawable) { - if (GrafreeD.savesound && GrafreeD.hassound) + if (Grafreed.savesound && Grafreed.hassound) { - GrafreeD.wav.save(); - GrafreeD.savesound = false; - GrafreeD.hassound = false; + Grafreed.wav.save(); + Grafreed.savesound = false; + Grafreed.hassound = false; } // if (DEBUG_SELECTION) // { @@ -10373,7 +10535,7 @@ Object3D theobject = object; Object3D theparent = object.parent; object.parent = null; - object = (Object3D)GrafreeD.clone(object); + object = (Object3D)Grafreed.clone(object); object.Stripify(); if (theobject.selection == null || theobject.selection.Size() == 0) theobject.PreprocessOcclusion(this); @@ -10386,13 +10548,14 @@ ambientOcclusion = false; } - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) + if (//Globals.lighttouched && + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) { //if (RENDERSHADOW) // ? if (!IsFrozen()) { // dec 2012 - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) { Globals.framecount++; shadowbuffer.display(); @@ -10519,8 +10682,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++) { @@ -10534,8 +10697,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); @@ -10794,7 +10957,16 @@ // Bump noise gl.glActiveTexture(GL.GL_TEXTURE6); //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); - BindTexture(NOISE_TEXTURE, false, 2); + + try + { + BindTexture(NOISE_TEXTURE, false, 2); + } + catch (Exception e) + { + System.err.println("FAILED: " + NOISE_TEXTURE); + } + gl.glActiveTexture(GL.GL_TEXTURE0); gl.glEnable(GL.GL_TEXTURE_2D); @@ -10919,8 +11091,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); @@ -10941,8 +11113,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); @@ -11279,13 +11451,31 @@ e.printStackTrace(); } - if (GrafreeD.RENDERME > 0) - GrafreeD.RENDERME--; // mechante magouille + if (Grafreed.RENDERME > 0) + Grafreed.RENDERME--; // mechante magouille Globals.ONESTEP = false; } static boolean zoomonce = false; + + static void CreateSelectedPoint() + { + if (selectedpoint == null) + { + debugpointG = new Sphere(); + debugpointP = new Sphere(); + debugpointC = new Sphere(); + debugpointR = new Sphere(); + + selectedpoint = new Superellipsoid(); + + for (int i=0; i<8; i++) + { + debugpoints[i] = new Sphere(); + } + } + } void DrawObject(GL gl, boolean draw) { @@ -11350,7 +11540,14 @@ usedtextures.clear(); - BindTextures(DEFAULT_TEXTURES, 2); + try + { + BindTextures(DEFAULT_TEXTURES, 2); + } + catch (Exception e) + { + System.err.println("FAILED: " + DEFAULT_TEXTURES); + } } //System.out.println("--> " + stackdepth); // GrafreeD.traceon(); @@ -11360,8 +11557,9 @@ if (DrawMode() == DEFAULT) { - if (DEBUG) + if (Globals.DEBUG) { + CreateSelectedPoint(); float radius = 0.05f; if (selectedpoint.radius != radius) { @@ -11441,7 +11639,14 @@ if (checker != null && DrawMode() == DEFAULT) { //BindTexture(IMMORTAL_TEXTURE); - BindTextures(checker.GetTextures(), checker.texres); + try + { + BindTextures(checker.GetTextures(), checker.texres); + } + catch (Exception e) + { + System.err.println("FAILED: " + checker.GetTextures()); + } // NEAREST GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); DrawChecker(gl); @@ -11523,7 +11728,7 @@ return; } - String string = obj.GetToolTip(); + String string = obj.toString(); //.GetToolTip(); GL gl = GetGL(); @@ -11840,8 +12045,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); } @@ -11858,8 +12063,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); @@ -12473,8 +12678,8 @@ // display shadow only (bump == 0) "SUB temp.x, half.x, shadow.x;" + - "MOV temp.y, -params6.x;" + - "SLT temp.z, temp.y, zero.x;" + + "MOV temp.y, -params5.z;" + // params6.x;" + + "SLT temp.z, temp.y, -one2048th.x;" + "SUB temp.y, one.x, temp.z;" + "MUL temp.x, temp.x, temp.y;" + "KIL temp.x;" + @@ -12603,8 +12808,10 @@ "MAX ndotl.x, ndotl.x, -ndotl.x;" + "SUB temp.x, one.x, ndotl.x;" + - "ADD temp.x, temp.x, options2.z;" + // lightsheen - "ADD temp.y, one.y, options2.y;" + // sursurface + // Tuning for default skin + //"ADD temp.x, temp.x, options2.z;" + // lightsheen + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen + "ADD temp.y, one.y, options2.y;" + // subsurface "MUL temp.x, temp.x, temp.y;" + "MUL saturation, saturation, temp.xxxx;" + @@ -12752,7 +12959,7 @@ "MUL final.y, fragment.texcoord[0].x, c256;" + "FLR final.x, final.y;" + "SUB final.y, final.y, final.x;" + - //"MUL final.x, final.x, c256i;" + + "MUL final.x, final.x, c256i;" + "MOV final.z, zero.x;" + "MOV final.a, one.w;":"" ) + @@ -12760,7 +12967,7 @@ "MUL final.y, fragment.texcoord[0].y, c256;" + "FLR final.x, final.y;" + "SUB final.y, final.y, final.x;" + - //"MUL final.x, final.x, c256i;" + + "MUL final.x, final.x, c256i;" + "MOV final.z, zero.x;" + "MOV final.a, one.w;":"" ) + @@ -12803,7 +13010,7 @@ //once = true; } - System.out.print("Program #" + mode + "; length = " + program.length()); + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); @@ -12936,12 +13143,16 @@ "ADD " + depth + ".z, " + depth + ".z, temp.x;" + //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! + + // Compare fragment depth in light space with shadowmap. "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + "SGE temp.y, temp.x, zero.x;" + - "SUB " + shadow + ".y, one.x, temp.y;" + + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded + + // Reverse comparison "SUB temp.x, one.x, temp.x;" + "MUL " + shadow + ".x, temp.x, temp.y;" + - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + @@ -12955,6 +13166,10 @@ // No shadow for backface "DP3 temp.x, normal, lightd;" + "SLT temp.x, temp.x, zero.x;" + // shadoweps + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + + + // No shadow when out of frustrum + "SGE temp.x, " + depth + ".z, one.z;" + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + ""; } @@ -13101,7 +13316,8 @@ /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power - Object3D.cVector2[] vector2buffer; + + //Object3D.cVector2[] vector2buffer; // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea // OUT : diff, spec @@ -13513,7 +13729,7 @@ public void mousePressed(MouseEvent e) { //System.out.println("mousePressed: " + e); - clickStart(e.getX(), e.getY(), e.getModifiersEx()); + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); } static long prevtime = 0; @@ -13589,8 +13805,8 @@ // mode |= META; //} - SetMouseMode(WHEEL | e.getModifiersEx()); - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); anchorX = ax; anchorY = ay; prevX = px; @@ -13650,6 +13866,10 @@ // wasliveok = true; // waslive = false; + // May 2019 Forget it: + if (true) + return; + // source == timer if (mouseDown) { @@ -13688,7 +13908,7 @@ javax.swing.Timer timer = new javax.swing.Timer(350, this); - void clickStart(int x, int y, int modifiers) + void clickStart(int x, int y, int modifiers, int modifiersex) { if (!wasliveok) return; @@ -13705,7 +13925,7 @@ // touched = true; // main DL if (isRenderer) { - SetMouseMode(modifiers); + SetMouseMode(modifiers, modifiersex); } selectX = anchorX = x; @@ -13718,7 +13938,7 @@ clicked = true; hold = false; - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection { // System.out.println("RESTART II " + modifiers); @@ -13749,7 +13969,7 @@ info.camera = renderCamera; info.x = x; info.y = y; - info.modifiers = modifiers; + info.modifiers = modifiersex; editObj = object.doEditClick(info, 0); if (!editObj) { @@ -13766,9 +13986,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 @@ -13778,7 +14001,7 @@ clickEnd(e.getX(), e.getY(), e.getModifiersEx()); } else - drag(e.getX(), e.getY(), e.getModifiersEx()); + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); //try { Thread.sleep(1); } catch (Exception ex) {} } @@ -14015,7 +14238,7 @@ { Globals.lighttouched = true; } - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); } //else } @@ -14115,7 +14338,7 @@ int X, Y; boolean SX, SY; - void drag(int x, int y, int modifiers) + void drag(int x, int y, int modifiers, int modifiersex) { if (IsFrozen()) { @@ -14124,17 +14347,17 @@ drag = true; // NEW - boolean continuous = (modifiers & COMMAND) == COMMAND; + boolean continuous = (modifiersex & COMMAND) == COMMAND; X = x; Y = y; // floating state for animation - MODIFIERS = modifiers; - modifiers &= ~1024; + MODIFIERS = modifiersex; + modifiersex &= ~1024; if (false) // modifiers != 0) { //new Exception().printStackTrace(); - System.out.println("mouseDragged: " + modifiers); + System.out.println("mouseDragged: " + modifiersex); System.out.println("SHIFT = " + SHIFT); System.out.println("CONTROL = " + COMMAND); System.out.println("META = " + META); @@ -14154,7 +14377,8 @@ info.camera = renderCamera; info.x = x; info.y = y; - object.editWindow.copy.doEditDrag(info); + object.manipWindow.copy + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); } else { if (x < startX) @@ -14318,7 +14542,9 @@ ci.camera = renderCamera; if (!isRenderer) { - if (object.editWindow.copy.doEditClick(ci, 0)) + //ObjEditor editWindow = object.editWindow; + //Object3D copy = editWindow.copy; + if (object.doEditClick(ci, 0)) { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else @@ -14330,7 +14556,10 @@ public void mouseReleased(MouseEvent e) { + Globals.MOUSEDRAGGED = false; + movingcamera = false; + X = Y = 0; //System.out.println("mouseReleased: " + e); clickEnd(e.getX(), e.getY(), e.getModifiersEx()); } @@ -14353,9 +14582,9 @@ boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection - if (control || command || IsFrozen()) +// No delay if (control || command || IsFrozen()) timeout = true; - else +// ?? May 2019 else // timer.setDelay((modifiers & 128) != 0?0:350); mouseDown = false; if (!control && !command) // june 2013 @@ -14465,7 +14694,7 @@ System.out.println("keyReleased: " + e); } - void SetMouseMode(int modifiers) + void SetMouseMode(int modifiers, int modifiersex) { //System.out.println("SetMouseMode = " + modifiers); //modifiers &= ~1024; @@ -14477,25 +14706,25 @@ //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) // return; //System.out.println("SetMode = " + modifiers); - if ((modifiers & WHEEL) == WHEEL) + if ((modifiersex & WHEEL) == WHEEL) { mouseMode |= ZOOM; } boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); - if (capsLocked || (modifiers & META) == META) + if (capsLocked) // || (modifiers & META) == META) { mouseMode |= VR; // BACKFORTH; } - if ((modifiers & CTRLCLICK) == CTRLCLICK) + if ((modifiersex & CTRLCLICK) == CTRLCLICK) { mouseMode |= SELECT; } - if ((modifiers & COMMAND) == COMMAND) + if ((modifiersex & COMMAND) == COMMAND) { mouseMode |= SELECT; } - if ((modifiers & SHIFT) == SHIFT || forcetranslate) + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) { mouseMode &= ~VR; mouseMode |= TRANSLATE; @@ -14524,7 +14753,7 @@ if (isRenderer) // { - SetMouseMode(modifiers); + SetMouseMode(0, modifiers); } Globals.theRenderer.keyPressed(key); @@ -14696,8 +14925,14 @@ RevertCamera(); repaint(); break; - case 'L': case 'l': + lightMode ^= true; + Globals.lighttouched = true; + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; + targetLookAt.set(manipCamera.lookAt); + repaint(); + break; + case 'L': if (lightMode) { lightMode = false; @@ -14844,23 +15079,21 @@ kompactbit = 6; break; case ' ': - lightMode ^= true; - Globals.lighttouched = true; - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; - targetLookAt.set(manipCamera.lookAt); + ObjEditor.theFrame.ToggleFullScreen(); repaint(); break; //case '`' : case ESC: RENDERPROGRAM += 1; RENDERPROGRAM %= 3; + repaint(); break; case 'Z': //RESIZETEXTURE ^= true; //break; case 'z': - RENDERSHADOW ^= true; + Globals.RENDERSHADOW ^= true; Globals.lighttouched = true; repaint(); break; @@ -14984,7 +15217,7 @@ //mode = ROTATE; if ((MODIFIERS & COMMAND) == 0) // VR?? { - SetMouseMode(modifiers); + SetMouseMode(0, modifiers); } } @@ -15120,7 +15353,7 @@ { //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) - if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0) + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) { mouseMoved(e); } else @@ -15339,7 +15572,9 @@ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); //Image img = CreateImage(width, height); //System.out.println("width = " + width + "; height = " + height + "\n"); + Graphics gr = g; // img.getGraphics(); + if (!hasMarquee) { if (Xmin < Xmax) // !locked) @@ -15437,14 +15672,33 @@ if (!isRenderer) { object.drawEditHandles(info, 0); + + if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) + { + switch (object.selection.get(0).hitSomething) + { + 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; + } + + } } } + if (isRenderer) { //gr.setColor(Color.black); //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); } + if (hasMarquee) { gr.setXORMode(Color.white); @@ -15557,6 +15811,7 @@ public boolean mouseDown(Event evt, int x, int y) { System.out.println("mouseDown: " + evt); + System.exit(0); /* locked = true; drag = false; @@ -15600,7 +15855,7 @@ { keyPressed(0, modifiers); } - clickStart(x, y, modifiers); + // clickStart(x, y, modifiers); return true; } @@ -15718,7 +15973,7 @@ { keyReleased(0, 0); } - drag(x, y, modifiers); + drag(x, y, 0, modifiers); return true; } @@ -15850,7 +16105,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; @@ -16135,16 +16390,16 @@ cStatic.objectstack[materialdepth++] = checker; //System.out.println("material " + material); //Applet3D.tracein(this, selected); - vector2buffer = checker.projectedVertices; + //vector2buffer = checker.projectedVertices; //checker.GetMaterial().Draw(this, false); // true); - DrawMaterial(checker.GetMaterial(), false); // true); + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); materialdepth -= 1; if (materialdepth > 0) { - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); } //checker.GetMaterial().opacity = 1f; ////checker.GetMaterial().ambient = 1f; @@ -16368,6 +16623,8 @@ // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); + CreateSelectedPoint(); + // Will fit the mesh !!! selectedpoint.toParent[0][0] = 0.0001; selectedpoint.toParent[1][1] = 0.0001; @@ -16416,16 +16673,16 @@ System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2])); } - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); } } if (!movingcamera && !PAINTMODE) object.editWindow.ScreenFitPoint(); // fev 2014 - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) + if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) { - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); + Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); Object3D group = new Object3D("inst" + paintcount++); @@ -16581,7 +16838,7 @@ gl.glDisable(gl.GL_CULL_FACE); } - if (!RENDERSHADOW) + if (!Globals.RENDERSHADOW) gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // SB gl.glPolygonOffset(2.5f, 10); @@ -16591,7 +16848,7 @@ //gl.glColorMask(false, false, false, false); //render_scene_from_light_view(gl, drawable, 0, 0); - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); @@ -17007,23 +17264,15 @@ int AAbuffersize = 0; //double[] selectedpoint = new double[3]; - static Superellipsoid selectedpoint = new Superellipsoid(); + static Superellipsoid selectedpoint; static Sphere previousselectedpoint = null; - static Sphere debugpointG = new Sphere(); - static Sphere debugpointP = new Sphere(); - static Sphere debugpointC = new Sphere(); - static Sphere debugpointR = new Sphere(); + static Sphere debugpointG; + static Sphere debugpointP; + static Sphere debugpointC; + static Sphere debugpointR; static Sphere debugpoints[] = new Sphere[8]; - static - { - for (int i=0; i<8; i++) - { - debugpoints[i] = new Sphere(); - } - } - static void InitPoints(float radius) { for (int i=0; i<8; i++) -- Gitblit v1.6.2