From 40f408aaee14abd85d391008b4d22977dc586b50 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 21 Jul 2019 16:45:10 -0400 Subject: [PATCH] Prepare bimtexture. --- CameraPane.java | 507 ++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 331 insertions(+), 176 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index c1f5c9b..1364b89 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -60,7 +60,7 @@ //boolean REDUCETEXTURE = true; boolean CACHETEXTURE = true; boolean CLEANCACHE = false; // true; - boolean MIPMAP = false; // true; + boolean MIPMAP = true; // false; // true; boolean COMPRESSTEXTURE = false; boolean KOMPACTTEXTURE = false; // true; boolean RESIZETEXTURE = false; @@ -335,14 +335,28 @@ display.options1[2] = material.shadowbias; display.options1[3] = material.aniso; display.options1[4] = material.anisoV; +// System.out.println("display.options1[0] " + display.options1[0]); +// System.out.println("display.options1[1] " + display.options1[1]); +// System.out.println("display.options1[2] " + display.options1[2]); +// System.out.println("display.options1[3] " + display.options1[3]); +// System.out.println("display.options1[4] " + display.options1[4]); display.options2[0] = material.opacity; display.options2[1] = material.diffuse; display.options2[2] = material.factor; +// System.out.println("display.options2[0] " + display.options2[0]); +// System.out.println("display.options2[1] " + display.options2[1]); +// System.out.println("display.options2[2] " + display.options2[2]); cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); +// System.out.println("display.options3[0] " + display.options3[0]); +// System.out.println("display.options3[1] " + display.options3[1]); +// System.out.println("display.options3[2] " + display.options3[2]); display.options4[0] = material.cameralight/0.2f; display.options4[1] = material.subsurface; display.options4[2] = material.sheen; +// System.out.println("display.options4[0] " + display.options4[0]); +// System.out.println("display.options4[1] " + display.options4[1]); +// System.out.println("display.options4[2] " + display.options4[2]); // if (display.CURRENTANTIALIAS > 0) // display.options3[3] /= 4; @@ -2051,7 +2065,7 @@ //System.err.println("Oeil on"); OEIL = true; if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); //pingthread.StepToTarget(true); } @@ -2284,10 +2298,17 @@ HANDLES ^= true; } + Object3D paintFolder; + void TogglePaint() { PAINTMODE ^= true; paintcount = 0; + + if (PAINTMODE) + { + paintFolder = GetFolder(); + } } void SwapCamera(int a, int b) @@ -2401,9 +2422,10 @@ /**/ // TEXTURE static Texture texture; - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); + static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>(); + static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>(); + static public java.util.HashSet<String> usedtextures = new java.util.HashSet<String>(); + int pigmentdepth = 0; public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; int bumpdepth = 0; @@ -2425,6 +2447,33 @@ true, com.sun.opengl.util.texture.TextureIO.PNG); } catch (java.io.IOException e) + { + throw new javax.media.opengl.GLException(e); + } + + if (bump) + texturedata = ConvertBump(texturedata, false); + + com.sun.opengl.util.texture.Texture texture = + com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); + + texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); + texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); + + return texture; + } + + com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump) + { + TextureData texturedata = null; + + try + { + texturedata = + com.sun.opengl.util.texture.TextureIO.newTextureData( + name, + true); + } catch (Exception e) { throw new javax.media.opengl.GLException(e); } @@ -3511,6 +3560,8 @@ System.out.println("LOADING TEXTURE : " + name); + Object x = texturedata.getMipmapData(); // .getBuffer(); + // if (false) // compressbit > 0) { @@ -7909,7 +7960,7 @@ String pigment = Object3D.GetPigment(tex); String bump = Object3D.GetBump(tex); - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) { // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); // System.out.println("; bump = " + bump); @@ -7943,7 +7994,7 @@ String pigment = Object3D.GetPigment(tex); - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) { // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); // System.out.println("; bump = " + bump); @@ -7972,7 +8023,7 @@ String bump = Object3D.GetBump(tex); - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) { // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); // System.out.println("; bump = " + bump); @@ -8091,47 +8142,50 @@ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE { - if (// DrawMode() != 0 || /*tex == null ||*/ - ambientOcclusion ) // || !textureon) - { - return; // false; - } - - if (tex == null) - { - BindTexture(null,false,resolution); - BindTexture(null,true,resolution); - return; - } +// if (// DrawMode() != 0 || /*tex == null ||*/ +// ambientOcclusion ) // || !textureon) +// { +// return; // false; +// } +// +// if (tex == null) +// { +// BindTexture(null,false,resolution); +// BindTexture(null,true,resolution); +// return; +// } +// +// String pigment = Object3D.GetPigment(tex); +// String bump = Object3D.GetBump(tex); +// +// usedtextures.add(pigment); +// usedtextures.add(bump); +// +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) +// { +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); +// // System.out.println("; bump = " + bump); +// } +// +// if (bump.equals("")) +// { +// bump = null; +// } +// if (pigment.equals("")) +// { +// pigment = null; +// } +// +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); +// BindTexture(pigment, false, resolution); +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); +// BindTexture(bump, true, resolution); +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); +// +// return; // true; - String pigment = Object3D.GetPigment(tex); - String bump = Object3D.GetBump(tex); - - usedtextures.put(pigment, pigment); - 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; - } - if (pigment.equals("")) - { - pigment = null; - } - - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); - BindTexture(pigment, false, resolution); - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); - BindTexture(bump, true, resolution); - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); - - return; // true; + BindPigmentTexture(tex, resolution); + BindBumpTexture(tex, resolution); } /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE @@ -8144,15 +8198,15 @@ if (tex == null) { - BindTexture(null,false,resolution); + BindTexture(null, null,false,resolution); return; } String pigment = Object3D.GetPigment(tex); - usedtextures.put(pigment, pigment); + usedtextures.add(pigment); - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) { // System.out.print("BIND +++++++++++++++ pigment = " + pigment); // System.out.println("; bump = " + bump); @@ -8164,7 +8218,7 @@ } GetGL().glActiveTexture(GetGL().GL_TEXTURE0); - BindTexture(pigment, false, resolution); + BindTexture(tex.pigmenttexture, pigment, false, resolution); } /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE @@ -8177,15 +8231,15 @@ if (tex == null) { - BindTexture(null,true,resolution); + BindTexture(null, null,true,resolution); return; } String bump = Object3D.GetBump(tex); - usedtextures.put(bump, bump); + usedtextures.add(bump); - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) { // System.out.print("BIND +++++++++++++++ pigment = " + pigment); // System.out.println("; bump = " + bump); @@ -8197,7 +8251,7 @@ } GetGL().glActiveTexture(GetGL().GL_TEXTURE2); - BindTexture(bump, true, resolution); + BindTexture(tex.bumptexture, bump, true, resolution); GetGL().glActiveTexture(GetGL().GL_TEXTURE0); } @@ -8221,9 +8275,9 @@ return fileExists; } - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception + CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception { - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; + CacheTexture texturecache = null; if (tex != null) { @@ -8243,12 +8297,22 @@ } if (CACHETEXTURE) - texture = textures.get(texname); // TEXTURE CACHE - - TextureData texturedata = null; - - if (texture == null || texture.resolution < resolution) { + if (bim == null) + texturecache = textures.get(texname); // TEXTURE CACHE + else + texturecache = bimtextures.get(bim); // TEXTURE CACHE + } + + if (texturecache == null || texturecache.resolution < resolution) + { + TextureData texturedata = null; + + if (bim == null) + { + + } + else if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) { assert(!bump); @@ -8260,19 +8324,19 @@ // } // else // { - texture = textures.get(tex); - if (texture == null) + texturecache = textures.get(tex); + if (texturecache == null) { - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); } // } } else if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) { assert(bump); - texture = textures.get(tex); - if (texture == null) - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); + texturecache = textures.get(tex); + if (texturecache == null) + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); } else { //if (tex.equals("IMMORTAL")) @@ -8282,9 +8346,9 @@ //{ if (tex.equals("WHITE_NOISE")) { - texture = textures.get(tex); - if (texture == null) - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); + texturecache = textures.get(tex); + if (texturecache == null) + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); } else { if (textureon) @@ -8343,19 +8407,19 @@ if (texturedata == null) throw new Exception(); - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); + texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); //texture = GetTexture(tex, bump); } } //} } - if (/*CACHETEXTURE &&*/ texture != null && textureon) + if (/*CACHETEXTURE &&*/ texturecache != null && textureon) { //return false; // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) { // String ext = "_highres"; // if (REDUCETEXTURE) @@ -8444,8 +8508,8 @@ textures.remove(texname); } - texture.texturedata = texturedata; - textures.put(texname, texture); + //texture.texturedata = texturedata; + textures.put(texname, texturecache); // newtex = true; } @@ -8461,12 +8525,12 @@ } } - return texture; + return texturecache; } - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception + com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception { - CacheTexture texture = GetCacheTexture(tex, bump, resolution); + CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); if (bump) { @@ -8482,23 +8546,23 @@ return texture!=null?texture.texture:null; } - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception + public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception { - CacheTexture texture = GetCacheTexture(tex, bump, resolution); + CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); return texture!=null?texture.texturedata:null; } - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception + boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception { if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) { return false; } - boolean newtex = false; + //boolean newtex = false; - com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); + com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution); if (texture == null) return false; @@ -8528,7 +8592,7 @@ texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); - return newtex; + return true; // Warning: not used. } ShadowBuffer shadowPBuf; @@ -9366,11 +9430,35 @@ jy8[3] = 0.5f; } - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV + float[] options1 = new float[]{100, 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, 0}; // fog color float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen + void ResetOptions() + { + options1[0] = 100; + options1[1] = 0.025f; + options1[2] = 0.01f; + options1[3] = 0; + options1[4] = 0; + + options2[0] = 0; + options2[1] = 0.75f; + options2[2] = 0; + options2[3] = 0; + + options3[0] = 1; + options3[1] = 1; + options3[2] = 1; + options3[3] = 0; + + options4[0] = 1; + options4[1] = 0; + options4[2] = 1; + options4[3] = 0; + } + static int imagecount = 0; // movie generation static int jitter = 0; @@ -10481,6 +10569,7 @@ ANTIALIAS = 0; //System.out.println("RESTART"); AAtimer.restart(); + Globals.TIMERRUNNING = true; } } } @@ -10960,7 +11049,7 @@ try { - BindTexture(NOISE_TEXTURE, false, 2); + BindTexture(null, NOISE_TEXTURE, false, 2); } catch (Exception e) { @@ -10989,9 +11078,9 @@ gl.glMatrixMode(GL.GL_MODELVIEW); -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); -//gl.glEnable(gl.GL_POLYGON_SMOOTH); -//gl.glEnable(gl.GL_MULTISAMPLE); +gl.glEnable(gl.GL_POLYGON_SMOOTH); +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); +gl.glEnable(gl.GL_MULTISAMPLE); } else { //gl.glDisable(GL.GL_TEXTURE_2D); @@ -11002,7 +11091,7 @@ //System.out.println("BLENDING ON"); gl.glEnable(GL.GL_BLEND); gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); - +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); gl.glMatrixMode(gl.GL_PROJECTION); gl.glLoadIdentity(); @@ -11479,13 +11568,16 @@ void DrawObject(GL gl, boolean draw) { + // To clear camera values + ResetOptions(); + //System.out.println("DRAW OBJECT " + mouseDown); // DrawMode() = SELECTION; //GL gl = getGL(); if ((TRACK || SHADOWTRACK) || zoomonce) { if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); pingthread.StepToTarget(true); // true); // zoomonce = false; } @@ -11622,7 +11714,7 @@ if (tex.equals("WHITE_NOISE")) continue; - if (!usedtextures.containsKey(tex)) + if (!usedtextures.contains(tex)) { // System.out.println("DISPOSE +++++++++++++++ " + tex); textures.get(tex).texture.dispose(); @@ -12046,7 +12138,7 @@ for (int i = tp.size(); --i >= 0;) { //for (int count = tp.get(i).GetTransformCount(); --count>=0;) - LA.xformPos(light, tp.get(i).GlobalTransform(), light); + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); } @@ -13333,9 +13425,10 @@ "DP3 " + dest + ".z," + "normals," + "eye;" + "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + //"MOV " + dest + ".w," + "normal.z;" + - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + - //"MOV " + dest + ".z," + "params2.w;" + +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + + + "MOV " + dest + ".z," + "params2.w;" + // EXACT "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + "RCP " + dest + ".w," + dest + ".w;" + //"RSQ " + dest + ".w," + dest + ".w;" + @@ -13840,6 +13933,7 @@ else if (evt.getSource() == AAtimer) { + Globals.TIMERRUNNING = false; if (mouseDown) { //new Exception().printStackTrace(); @@ -13899,7 +13993,7 @@ // fev 2014??? if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); pingthread.StepToTarget(true); // true); } // if (!LIVE) @@ -13914,6 +14008,7 @@ return; AAtimer.restart(); // + Globals.TIMERRUNNING = true; // waslive = LIVE; // LIVE = false; @@ -14252,12 +14347,12 @@ void GoDown(int mod) { MODIFIERS |= COMMAND; - /* + /**/ if((mod&SHIFT) == SHIFT) manipCamera.RotatePosition(0, -speed); else - manipCamera.BackForth(0, -speed*delta, getWidth()); - */ + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); + /**/ if ((mod & SHIFT) == SHIFT) { mouseMode = mouseMode; // VR?? @@ -14273,12 +14368,12 @@ void GoUp(int mod) { MODIFIERS |= COMMAND; - /* + /**/ if((mod&SHIFT) == SHIFT) manipCamera.RotatePosition(0, speed); else - manipCamera.BackForth(0, speed*delta, getWidth()); - */ + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); + /**/ if ((mod & SHIFT) == SHIFT) { mouseMode = mouseMode; @@ -14294,12 +14389,12 @@ void GoLeft(int mod) { MODIFIERS |= COMMAND; - /* + /**/ if((mod&SHIFT) == SHIFT) - manipCamera.RotatePosition(speed, 0); - else manipCamera.Translate(speed*delta, 0, getWidth()); - */ + else + manipCamera.RotatePosition(speed, 0); + /**/ if ((mod & SHIFT) == SHIFT) { mouseMode = mouseMode; @@ -14315,12 +14410,12 @@ void GoRight(int mod) { MODIFIERS |= COMMAND; - /* + /**/ if((mod&SHIFT) == SHIFT) - manipCamera.RotatePosition(-speed, 0); - else manipCamera.Translate(-speed*delta, 0, getWidth()); - */ + else + manipCamera.RotatePosition(-speed, 0); + /**/ if ((mod & SHIFT) == SHIFT) { mouseMode = mouseMode; @@ -14377,7 +14472,7 @@ info.camera = renderCamera; info.x = x; info.y = y; - object.manipWindow.copy + object.GetWindow().copy .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); } else { @@ -14559,7 +14654,8 @@ Globals.MOUSEDRAGGED = false; movingcamera = false; - X = Y = 0; + X = 0; // getBounds().width/2; + Y = 0; // getBounds().height/2; //System.out.println("mouseReleased: " + e); clickEnd(e.getX(), e.getY(), e.getModifiersEx()); } @@ -14900,7 +14996,9 @@ case 'E' : COMPACT ^= true; repaint(); break; - case 'W' : DEBUGHSB ^= true; + case 'W' : // Wide Window (fullscreen) + //DEBUGHSB ^= true; + ObjEditor.theFrame.ToggleFullScreen(); repaint(); break; case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; @@ -14926,13 +15024,7 @@ repaint(); break; case 'l': - lightMode ^= true; - Globals.lighttouched = true; - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; - targetLookAt.set(manipCamera.lookAt); - repaint(); - break; - case 'L': + //case 'L': if (lightMode) { lightMode = false; @@ -15075,11 +15167,14 @@ case '_': kompactbit = 5; break; - case '+': - kompactbit = 6; - break; +// case '+': +// kompactbit = 6; +// break; case ' ': - ObjEditor.theFrame.ToggleFullScreen(); + lightMode ^= true; + Globals.lighttouched = true; + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; + targetLookAt.set(manipCamera.lookAt); repaint(); break; //case '`' : @@ -15126,8 +15221,9 @@ case DELETE: ClearSelection(); break; - /* case '+': + + /* //fontsize += 1; bbzoom *= 2; repaint(); @@ -15144,17 +15240,17 @@ case '=': IncDepth(); //fontsize += 1; - object.editWindow.refreshContents(true); + object.GetWindow().refreshContents(true); maskbit = 6; break; case '-': //if (PixelThreshold>1) PixelThreshold /= 2; DecDepth(); maskbit = 5; //if(fontsize > 1) fontsize -= 1; - if (object.editWindow == null) - new Exception().printStackTrace(); - else - object.editWindow.refreshContents(true); +// if (object.editWindow == null) +// new Exception().printStackTrace(); +// else + object.GetWindow().refreshContents(true); break; case '{': manipCamera.shaper_fovy /= 1.1; @@ -15378,7 +15474,7 @@ } */ - object.editWindow.EditSelection(); + object.GetWindow().EditSelection(false); } void SelectParent() @@ -15395,10 +15491,10 @@ { //selectees.remove(i); System.out.println("select parent of " + elem); - group.editWindow.Select(elem.parent.GetTreePath(), first, true); + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); } else { - group.editWindow.Select(elem.GetTreePath(), first, true); + group.GetWindow().Select(elem.GetTreePath(), first, true); } first = false; @@ -15440,12 +15536,12 @@ for (int j = 0; j < group.children.size(); j++) { elem = (Object3D) group.children.elementAt(j); - object.editWindow.Select(elem.GetTreePath(), first, true); + object.GetWindow().Select(elem.GetTreePath(), first, true); first = false; } } else { - object.editWindow.Select(elem.GetTreePath(), first, true); + object.GetWindow().Select(elem.GetTreePath(), first, true); } first = false; @@ -15456,21 +15552,21 @@ { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.loadClipboard(true); // ClearSelection(false); + group.GetWindow().loadClipboard(true); // ClearSelection(false); } void ResetTransform(int mask) { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.ResetTransform(mask); + group.GetWindow().ResetTransform(mask); } void FlipTransform() { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.FlipTransform(); + group.GetWindow().FlipTransform(); // group.editWindow.ReduceMesh(true); } @@ -15478,7 +15574,7 @@ { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.PrintMemory(); + group.GetWindow().PrintMemory(); // group.editWindow.ReduceMesh(true); } @@ -15486,7 +15582,7 @@ { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.ResetCentroid(); + group.GetWindow().ResetCentroid(); } void IncDepth() @@ -15662,6 +15758,7 @@ info.bounds.y += (height - desired) / 2; } } + info.g = gr; info.camera = renderCamera; /* @@ -15671,23 +15768,44 @@ */ if (!isRenderer) { - object.drawEditHandles(info, 0); - - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) + Grafreed.Assert(object != null); + Grafreed.Assert(object.selection != null); + if (object.selection.Size() > 0) { - switch (object.selection.get(0).hitSomething) + int hitSomething = object.selection.get(0).hitSomething; + + info.DX = 0; + info.DY = 0; + info.W = 1; + if (hitSomething == Object3D.hitCenter) { - 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; + info.DX = X; + if (X != 0) + info.DX -= info.bounds.width/2; + + info.DY = Y; + if (Y != 0) + info.DY -= info.bounds.height/2; } - + + object.drawEditHandles(info, 0); + + if (drag && (X != 0 || Y != 0)) + { + switch (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; + } + + } } } } @@ -16485,6 +16603,14 @@ } } + private Object3D GetFolder() + { + Object3D folder = object.GetWindow().copy; + if (object.GetWindow().copy.selection.Size() > 0) + folder = object.GetWindow().copy.selection.elementAt(0); + return folder; + } + class SelectBuffer implements GLEventListener { @@ -16564,6 +16690,17 @@ //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); + if (PAINTMODE) + { + if (object.GetWindow().copy.selection.Size() > 0) + { + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); + + // Make what you paint not selectable. + paintobj.ResetSelectable(); + } + } + //int tmp = selection_view; //selection_view = -1; int temp = DrawMode(); @@ -16575,6 +16712,17 @@ // temp = DEFAULT; // patch for selection debug Globals.drawMode = temp; // WARNING + if (PAINTMODE) + { + if (object.GetWindow().copy.selection.Size() > 0) + { + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); + + // Revert. + paintobj.RestoreSelectable(); + } + } + //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); // trying different ways of getting the depth info over @@ -16678,29 +16826,31 @@ } if (!movingcamera && !PAINTMODE) - object.editWindow.ScreenFitPoint(); // fev 2014 + object.GetWindow().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++); + if (object.GetWindow().copy.selection.Size() > 0) + { + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); - group.CreateMaterial(); // use a void leaf to select instances - - group.add(paintobj); // link - - object.editWindow.SnapObject(group); - - Object3D folder = object.editWindow.copy; - - if (object.editWindow.copy.selection.Size() > 0) - folder = object.editWindow.copy.selection.elementAt(0); - - folder.add(group); - - object.editWindow.ResetModel(); - object.editWindow.refreshContents(); + Object3D inst = new Object3D("inst" + paintcount++); + + inst.CreateMaterial(); // use a void leaf to select instances + + inst.add(paintobj); // link + + object.GetWindow().SnapObject(inst); + + Object3D folder = paintFolder; // GetFolder(); + + folder.add(inst); + + object.GetWindow().ResetModel(); + object.GetWindow().refreshContents(); + } } else paintcount = 0; @@ -16739,6 +16889,11 @@ //System.out.println("objects[color] = " + objects[color]); //objects[color].Select(); indexcount = 0; + ObjEditor window = object.GetWindow(); + if (window != null && deselect) + { + window.Select(null, deselect, true); + } object.Select(color, deselect); } -- Gitblit v1.6.2