From bb87fae3b097ddd5c5039bf1ab48d3718b900b08 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 01 Jul 2018 17:00:29 -0400 Subject: [PATCH] Fix camera and hip height. --- CameraPane.java | 190 +++++++++++++++++++++++++++++++++++------------ 1 files changed, 140 insertions(+), 50 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index b9fb49f..a1b29d7 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -228,7 +228,7 @@ void PushMatrix(double[][] matrix, int count) { matrixdepth++; - // GraphreeD.tracein(matrix); + // GrafreeD.tracein(matrix); if (matrix == null) return; // Identity @@ -253,13 +253,13 @@ void PushMatrix(double[][] matrix) { - // GraphreeD.tracein(matrix); + // GrafreeD.tracein(matrix); PushMatrix(matrix,1); } void PushMatrix() { - // GraphreeD.tracein(null); + // GrafreeD.tracein(null); if (matrixdepth++ < MAXSTACK - 1) { currentGL.glPushMatrix(); @@ -274,7 +274,7 @@ { --matrixdepth; - // GraphreeD.traceout(inverse); + // GrafreeD.traceout(inverse); if (inverse == null) return; // Identity @@ -292,7 +292,7 @@ void PopMatrix() { - // GraphreeD.traceout(null); + // GrafreeD.traceout(null); // inverse == null?? if (--matrixdepth < MAXSTACK - 1) { @@ -491,7 +491,7 @@ System.err.println("LIVE = " + isLIVE()); if (!isLIVE()) // save sound - GraphreeD.savesound = true; // wav.save(); + GrafreeD.savesound = true; // wav.save(); // else repaint(); // start loop // may 2013 } @@ -768,6 +768,8 @@ class CacheTexture { com.sun.opengl.util.texture.Texture texture; + com.sun.opengl.util.texture.TextureData texturedata; + int resolution; CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) @@ -1998,10 +2000,12 @@ */ TextureData ReduceTexture(TextureData texturedata, int resolution) // String name) { + int pixelformat = texturedata.getPixelFormat(); + int stride = 1; - if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) + if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE) stride = 3; - if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) + if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA) stride = 4; int width = texturedata.getWidth(); @@ -6331,7 +6335,7 @@ { bumpdepth--; - // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture); + // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture); if (bumpstack[bumpdepth] != (texture!=null?texture.texture:null)) { // assert (bumpstack[bumpdepth] == texture); @@ -6361,7 +6365,7 @@ { pigmentdepth--; - // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture); + // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture); if (pigmentstack[pigmentdepth] != (texture!=null?texture.texture:null)) { // assert (pigmentstack[pigmentdepth] == texture); @@ -6451,7 +6455,7 @@ return; // true; } - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) + CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) { CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; @@ -6665,6 +6669,8 @@ thetex.texture.dispose(); textures.remove(texname); } + + texture.texturedata = texturedata; textures.put(texname, texture); // newtex = true; @@ -6681,18 +6687,32 @@ } } + return texture; + } + + com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) + { + CacheTexture texture = GetCacheTexture(tex, bump, resolution); + if (bump) { - // GraphreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture); + // GrafreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture); bumpstack[bumpdepth++] = texture!=null?texture.texture:null; } else { - // GraphreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture); + // GrafreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture); pigmentstack[pigmentdepth++] = texture!=null?texture.texture:null; } return texture!=null?texture.texture:null; + } + + com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) + { + CacheTexture texture = GetCacheTexture(tex, bump, resolution); + + return texture!=null?texture.texturedata:null; } boolean BindTexture(String tex, boolean bump, int resolution) @@ -7572,7 +7592,8 @@ float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation - float[] options3 = new float[]{1, 1, 1, 1}; // fog color. image intensity + float[] options3 = new float[]{1, 1, 1, 0}; // fog color + float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen static int imagecount = 0; // movie generation @@ -7610,14 +7631,14 @@ //System.out.println("start frame"); gl.glClear(gl.GL_ACCUM_BUFFER_BIT); - for (jitter = 0; jitter < ACSIZE; jitter++) //, GraphreeD.wav.cursor += LIVE ? 735 : 0) + for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) { framecount++; if (CameraPane.tickcount > 0) CameraPane.tickcount--; -// GraphreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits) +// GrafreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits) // restartframe = true; if (options1[2] > 100 && (jitter%2==0)) { @@ -7672,7 +7693,7 @@ if (renderCamera != lightCamera) for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.matConcat(parentcam.toParent, matrix, matrix); + LA.matConcat(matrix, parentcam.toParent, matrix); // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); @@ -7688,7 +7709,7 @@ if (renderCamera != lightCamera) for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.matConcat(matrix, parentcam.fromParent, matrix); + LA.matConcat(parentcam.fromParent, matrix, matrix); // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); @@ -7905,7 +7926,7 @@ if (!BOXMODE) { - System.out.println("image: " + fullname + " (" + (GraphreeD.wav.cursor / 735 / 4) + ")"); + System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); } if (!BOXMODE) @@ -7933,7 +7954,7 @@ { if (ACSIZE > 1) { - // System.err.println("image #" + (GraphreeD.wav.cursor / 735 / 4)); + // System.err.println("image #" + (GrafreeD.wav.cursor / 735 / 4)); } } @@ -7943,7 +7964,7 @@ ABORTED = false; } else - GraphreeD.wav.cursor += 735 * ACSIZE; + GrafreeD.wav.cursor += 735 * ACSIZE; if (false) { @@ -8613,11 +8634,11 @@ public void display(GLAutoDrawable drawable) { - if (GraphreeD.savesound && GraphreeD.hassound) + if (GrafreeD.savesound && GrafreeD.hassound) { - GraphreeD.wav.save(); - GraphreeD.savesound = false; - GraphreeD.hassound = false; + GrafreeD.wav.save(); + GrafreeD.savesound = false; + GrafreeD.hassound = false; } // if (DEBUG_SELECTION) // { @@ -8747,7 +8768,7 @@ Object3D theobject = object; Object3D theparent = object.parent; object.parent = null; - object = (Object3D)GraphreeD.clone(object); + object = (Object3D)GrafreeD.clone(object); object.Stripify(); if (theobject.selection == null || theobject.selection.Size() == 0) theobject.PreprocessOcclusion(this); @@ -8766,7 +8787,7 @@ if (!IsFrozen()) { // dec 2012 - if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) + if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0)) { framecount++; shadowbuffer.display(); @@ -8894,7 +8915,7 @@ // if (parentcam != renderCamera) // not a light if (cam != lightCamera) for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.matConcat(parentcam.toParent, matrix, matrix); + LA.matConcat(matrix, parentcam.toParent, matrix); for (int j = 0; j < 4; j++) { @@ -8909,7 +8930,7 @@ // if (parentcam != renderCamera) // not a light if (cam != lightCamera) for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.matConcat(matrix, parentcam.fromParent, matrix); + LA.matConcat(parentcam.fromParent, matrix, matrix); //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); @@ -9361,6 +9382,7 @@ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0); gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0); + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0); options2[0] *= renderCamera.Distance(); @@ -9642,8 +9664,8 @@ e.printStackTrace(); } - if (GraphreeD.RENDERME > 0) - GraphreeD.RENDERME--; // mechante magouille + if (GrafreeD.RENDERME > 0) + GrafreeD.RENDERME--; // mechante magouille ONESTEP = false; } @@ -9716,7 +9738,7 @@ BindTextures(DEFAULT_TEXTURES, 2); } //System.out.println("--> " + stackdepth); -// GraphreeD.traceon(); +// GrafreeD.traceon(); // DRAW object.draw(this, /*(Composite)*/ object, false, false); @@ -9732,7 +9754,7 @@ selectedpoint.radius = radius; selectedpoint.recalculate(); selectedpoint.material = new cMaterial(); - selectedpoint.material.color = 0.25f; + selectedpoint.material.color = 0.15f; selectedpoint.material.modulation = 0.75f; debugpoint.radius = radius; @@ -9747,17 +9769,31 @@ debugpoint2.material.color = 0.75f; debugpoint2.material.modulation = 0.75f; + debugpoint3.radius = radius; + debugpoint3.recalculate(); + debugpoint3.material = new cMaterial(); + debugpoint3.material.color = 0.5f; + debugpoint3.material.modulation = 0.75f; + + debugpoint4.radius = radius; + debugpoint4.recalculate(); + debugpoint4.material = new cMaterial(); + debugpoint4.material.color = 0f; + debugpoint4.material.modulation = 0.75f; + InitPoints(radius); } selectedpoint.draw(this, /*(Composite)*/ null, false, false); - //debugpoint.draw(this, /*(Composite)*/ null, false); - //debugpoint2.draw(this, /*(Composite)*/ null, false); - DrawPoints(this); + debugpoint.draw(this, /*(Composite)*/ null, false,false); + debugpoint2.draw(this, /*(Composite)*/ null, false,false); + debugpoint3.draw(this, /*(Composite)*/ null, false,false); + debugpoint4.draw(this, /*(Composite)*/ null, false,false); + // DrawPoints(this); } // debugstuff.draw(this, /*(Composite)*/ null, false); } -// GraphreeD.traceoff(); +// GrafreeD.traceoff(); //System.out.println(stackdepth); if (drawMode == 0) { @@ -10253,7 +10289,7 @@ return; } - if (obj instanceof CheckerIG) + if (obj instanceof Checker) { checker = obj; @@ -10325,11 +10361,13 @@ "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough "PARAM params7 = program.env[7];" + // noise power, opacity power "PARAM options0 = program.env[63];" + // fog density, intensity, elevation - "PARAM options1 = program.env[62];" + // fog rgb color, image intensity + "PARAM options1 = program.env[62];" + // fog rgb color + "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen "PARAM pointlight = program.env[127];" + // ... "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" + "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" + "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + + "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" + "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + "PARAM ten = { 10, 10, 10, 1.0 };" + "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" + @@ -10390,6 +10428,10 @@ "TEMP R1;" + "TEMP R2;" + "TEMP R3;" + + "TEMP min;" + + "TEMP max;" + + "TEMP average;" + + "TEMP saturation;" + "TEMP keep1;" + "TEMP keep2;" + "TEMP keep3;" + @@ -10920,10 +10962,40 @@ // skin? // Saturation for skin - /**/ // c'est ici - (Skinshader? "DP3 temp.x, final,one;" + + /**/ + (Skinshader? + "DP3 average.x, final,one;" + + "MUL average, one3rd.xxxx,average.xxxx;" + + + "MIN min.x, final.x,final.y;" + + "MIN min.x, min.x,final.z;" + + + "MAX max.x, final.x,final.y;" + + "MAX max.x, max.x,final.z;" + + "MOV max, max.xxxx;" + + + "SUB saturation, max, final;" + + + "ADD temp.x, max.x, one10th.x;" + + "RCP temp.x, temp.x;" + + "MUL temp.x, temp.x, half.x;" + + "MUL saturation, saturation, temp.xxxx;" + + + "DP3 ndotl.x, normald, light;" + + "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 + "MUL temp.x, temp.x, temp.y;" + + + "MUL saturation, saturation, temp.xxxx;" + + "SUB_SAT temp, max, saturation;" + +/** + "DP3 temp.x, final,one;" + "MUL R2, one3rd.xxxx,temp.xxxx;" + - "SUB temp, final,R2;" + + "SUB temp, final, R2;" + + // using light angle "DP3 ndotl.x, normald,light;" + //"SLT ndotl.y, ndotl.x, zero.x;" + @@ -10936,7 +11008,6 @@ // using light intensity "MOV ndotl.z, R2.x;" + "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning... - // june 2014 "MAD R1.x, ndotl.z,slope.y,one.x;" + // "SUB ndotl.x, one.x, ndotl.x;" + @@ -10948,6 +11019,7 @@ //"MUL R2.y, shadow.x,R2.y;" + // avril 2014 "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin) +/**/ // "ADD final, R2,temp;" + "MOV final, temp;" @@ -11037,7 +11109,7 @@ /**/ // HDR "MOV temp.z, final.a;" + - "MUL final, final,options1.w;" + + "MUL final, final,options2.x;" + "MOV final.a, temp.z;" + /**/ @@ -11074,10 +11146,17 @@ "MOV final.z, zero.x;" + "MOV final.a, one.w;":"" ) + + /* (NORMALdebug?"MOV final.x, normal.x;" + "MOV final.y, normal.y;" + "MOV final.z, normal.z;" + "MOV final.a, one.w;":"" + ) + + */ + (NORMALdebug?"SUB final.x, one.x, final.x;" + + "SUB final.y, one.x, final.y;" + + "SUB final.z, one.x, final.z;" + + "MOV final.a, final.a;":"" ) + // "MOV final, bumpmap;" + "MOV result.color, final;" + @@ -12775,7 +12854,9 @@ { mouseMode |= ZOOM; } - if ((modifiers & META) == META) + + boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); + if (capsLocked || (modifiers & META) == META) { mouseMode |= VR; // BACKFORTH; } @@ -12789,6 +12870,7 @@ } if ((modifiers & SHIFT) == SHIFT || forcetranslate) { + mouseMode &= ~VR; mouseMode |= TRANSLATE; } // if ((modifiers & SHIFT_META) == SHIFT_META) @@ -13178,7 +13260,8 @@ FlipTransform(); break; case ENTER: - object.editWindow.ScreenFit(); // Edit(); + // object.editWindow.ScreenFit(); // Edit(); + ToggleLive(); break; case DELETE: ClearSelection(); @@ -14639,6 +14722,11 @@ // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); + // Will fit the mesh !!! + selectedpoint.toParent[0][0] = 0.0001; + selectedpoint.toParent[1][1] = 0.0001; + selectedpoint.toParent[2][2] = 0.0001; + glu.gluUnProject(x,y,depth,view,0,tempmat2,0,viewport,0,selectedpoint.toParent[3],0); // if (object.selection != null && object.selection.Size() > 0) @@ -14682,16 +14770,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) GraphreeD.clone(selectedpoint); + previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); } } if (!movingcamera && !PAINTMODE) object.editWindow.ScreenFitPoint(); // fev 2014 - if (PAINTMODE && GraphreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) + if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) { - Object3D paintobj = GraphreeD.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++); @@ -15261,10 +15349,12 @@ int AAbuffersize = 0; //double[] selectedpoint = new double[3]; - static Sphere selectedpoint = new Sphere(); + static Superellipsoid selectedpoint = new Superellipsoid(); static Sphere previousselectedpoint = null; static Sphere debugpoint = new Sphere(); static Sphere debugpoint2 = new Sphere(); + static Sphere debugpoint3 = new Sphere(); + static Sphere debugpoint4 = new Sphere(); static Sphere debugpoints[] = new Sphere[8]; -- Gitblit v1.6.2