From 76522bc3ee92bd50dbd946d7f865666be4ad7bac Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sat, 20 Jul 2019 20:50:56 -0400 Subject: [PATCH] cTexture serial change --- CameraPane.java | 512 +++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 389 insertions(+), 123 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index cfdc3d3..b55d184 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 @@ -327,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; @@ -336,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; @@ -359,7 +372,7 @@ /**/ } else { - DrawMaterial(material, selected); + DrawMaterial(material, selected, obj.projectedVertices); } } else { @@ -383,8 +396,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); } } @@ -401,8 +414,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) @@ -422,8 +435,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 @@ -464,10 +477,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); @@ -1192,10 +1207,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]); @@ -1215,10 +1232,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]); @@ -1246,8 +1265,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; } @@ -1603,7 +1624,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(); @@ -1638,7 +1659,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); @@ -1746,9 +1767,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 @@ -2044,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); } @@ -2259,7 +2280,7 @@ void ToggleDebug() { - DEBUG ^= true; + Globals.DEBUG ^= true; } void ToggleLookAt() @@ -2277,10 +2298,17 @@ HANDLES ^= true; } + Object3D paintFolder; + void TogglePaint() { PAINTMODE ^= true; paintcount = 0; + + if (PAINTMODE) + { + paintFolder = GetFolder(); + } } void SwapCamera(int a, int b) @@ -7902,7 +7930,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); @@ -7919,6 +7947,64 @@ ReleaseTexture(bump, true); 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) @@ -8045,7 +8131,7 @@ usedtextures.put(pigment, pigment); usedtextures.put(bump, 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); @@ -8067,6 +8153,73 @@ GetGL().glActiveTexture(GetGL().GL_TEXTURE0); return; // true; + } + + /*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>(); @@ -8364,7 +8517,7 @@ return false; } - boolean newtex = false; + //boolean newtex = false; com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); @@ -8396,7 +8549,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; @@ -9234,11 +9387,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; @@ -10349,6 +10526,7 @@ ANTIALIAS = 0; //System.out.println("RESTART"); AAtimer.restart(); + Globals.TIMERRUNNING = true; } } } @@ -10416,7 +10594,8 @@ ambientOcclusion = false; } - if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) + if (//Globals.lighttouched && + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) { //if (RENDERSHADOW) // ? if (!IsFrozen()) @@ -10856,9 +11035,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); @@ -10869,7 +11048,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(); @@ -11326,15 +11505,36 @@ 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) { + // 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; } @@ -11406,8 +11606,9 @@ if (DrawMode() == DEFAULT) { - if (DEBUG) + if (Globals.DEBUG) { + CreateSelectedPoint(); float radius = 0.05f; if (selectedpoint.radius != radius) { @@ -11894,7 +12095,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); } @@ -13164,7 +13365,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 @@ -13180,9 +13382,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;" + @@ -13687,6 +13890,7 @@ else if (evt.getSource() == AAtimer) { + Globals.TIMERRUNNING = false; if (mouseDown) { //new Exception().printStackTrace(); @@ -13746,7 +13950,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) @@ -13761,6 +13965,7 @@ return; AAtimer.restart(); // + Globals.TIMERRUNNING = true; // waslive = LIVE; // LIVE = false; @@ -14099,12 +14304,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?? @@ -14120,12 +14325,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; @@ -14141,12 +14346,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; @@ -14162,12 +14367,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; @@ -14224,7 +14429,8 @@ info.camera = renderCamera; info.x = x; info.y = y; - object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); + object.GetWindow().copy + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); } else { if (x < startX) @@ -14388,7 +14594,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 @@ -14403,7 +14611,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()); } @@ -14744,7 +14953,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; @@ -14769,8 +14980,8 @@ RevertCamera(); repaint(); break; - case 'L': case 'l': + //case 'L': if (lightMode) { lightMode = false; @@ -14913,9 +15124,9 @@ case '_': kompactbit = 5; break; - case '+': - kompactbit = 6; - break; +// case '+': +// kompactbit = 6; +// break; case ' ': lightMode ^= true; Globals.lighttouched = true; @@ -14927,6 +15138,7 @@ case ESC: RENDERPROGRAM += 1; RENDERPROGRAM %= 3; + repaint(); break; case 'Z': @@ -14966,8 +15178,9 @@ case DELETE: ClearSelection(); break; - /* case '+': + + /* //fontsize += 1; bbzoom *= 2; repaint(); @@ -14984,17 +15197,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; @@ -15218,7 +15431,7 @@ } */ - object.editWindow.EditSelection(); + object.GetWindow().EditSelection(false); } void SelectParent() @@ -15235,10 +15448,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; @@ -15280,12 +15493,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; @@ -15296,21 +15509,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); } @@ -15318,7 +15531,7 @@ { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.PrintMemory(); + group.GetWindow().PrintMemory(); // group.editWindow.ReduceMesh(true); } @@ -15326,7 +15539,7 @@ { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.ResetCentroid(); + group.GetWindow().ResetCentroid(); } void IncDepth() @@ -15502,6 +15715,7 @@ info.bounds.y += (height - desired) / 2; } } + info.g = gr; info.camera = renderCamera; /* @@ -15511,23 +15725,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; + } + + } } } } @@ -16230,16 +16465,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; @@ -16325,6 +16560,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 { @@ -16404,6 +16647,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(); @@ -16415,6 +16669,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 @@ -16462,6 +16727,8 @@ // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); // 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; @@ -16516,29 +16783,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; @@ -16577,6 +16846,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); } @@ -17102,23 +17376,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