From 1af7d3700724834e40ad8636bc9a56cdc3b19b15 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sat, 27 Jul 2019 11:52:38 -0400 Subject: [PATCH] New layout icons --- CameraPane.java | 2401 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 1,958 insertions(+), 443 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index 36fbe8d..fdb5f77 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -18,7 +18,10 @@ import javax.imageio.ImageIO; import javax.imageio.ImageWriteParam; import javax.imageio.ImageWriter; +import javax.imageio.ImageReadParam; +import javax.imageio.ImageReader; import javax.imageio.plugins.jpeg.JPEGImageWriteParam; +import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.ImageOutputStream; import javax.imageio.ImageWriteParam; @@ -30,6 +33,7 @@ import java.nio.*; import gleem.linalg.Mat4f; +import javax.imageio.ImageTypeSpecifier; class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener { @@ -37,7 +41,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 @@ -45,6 +48,39 @@ static boolean ABORTED = false; static int STEP = 1; + + private static BufferedImage CreateBim(byte[] bytes, int width, int height) + { + int[] pixels = new int[bytes.length/3]; + for (int i=pixels.length; --i>=0;) + { + int i3 = i*3; + pixels[i] = 0xFF; + pixels[i] <<= 8; + pixels[i] |= bytes[i3+2] & 0xFF; + pixels[i] <<= 8; + pixels[i] |= bytes[i3+1] & 0xFF; + pixels[i] <<= 8; + pixels[i] |= bytes[i3] & 0xFF; + } + /* + int r=0,g=0,b=0,a=0; + for (int i=0; i<width; i++) + for (int j=0; j<height; j++) + { + int index = j*width+i; + int p = pixels[index]; + a = ((p>>24) & 0xFF); + r = ((p>>16) & 0xFF); + g = ((p>>8) & 0xFF); + b = (p & 0xFF); + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; + } + /**/ + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); + return rendImage; + } /*static*/ private boolean CULLFACE = false; // true; /*static*/ boolean NEAREST = false; // true; @@ -56,14 +92,12 @@ static int CURRENTANTIALIAS = 0; // 1; /*static*/ boolean RENDERSHADOW = true; /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal - static boolean ANIMATION = false; - static String filename; boolean DISPLAYTEXT = false; //boolean REDUCETEXTURE = true; boolean CACHETEXTURE = true; boolean CLEANCACHE = false; // true; - boolean MIPMAP = false; // true; + boolean MIPMAP = false; // true; // never works... boolean COMPRESSTEXTURE = false; boolean KOMPACTTEXTURE = false; // true; boolean RESIZETEXTURE = false; @@ -92,6 +126,8 @@ static int tickcount = 0; // slow pose issue +static boolean BUTTONLESSWHEEL = false; +static boolean ZOOMBOXMODE = false; static boolean BOXMODE = false; static boolean IMAGEFLIP = false; static boolean SMOOTHFOCUS = false; @@ -106,7 +142,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,12 +185,13 @@ defaultcaps.setAccumBlueBits(16); defaultcaps.setAccumAlphaBits(16); } - static CameraPane theRenderer; - + + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); + void SetAsGLRenderer(boolean b) { isRenderer = b; - theRenderer = this; + Globals.theRenderer = this; } CameraPane(Object3D o, Camera cam, boolean withcontext) @@ -169,7 +206,8 @@ SetCamera(cam); - SetLight(new Camera(new cVector(10, 10, -20))); + // Warning: not used. + SetLight(new Camera(new cVector(15, 10, -20))); object = o; @@ -191,6 +229,45 @@ } /// INTERFACE + + public javax.media.opengl.GL GetGL0() + { + return null; + } + + public int GenList() + { + javax.media.opengl.GL gl = GetGL(); + return gl.glGenLists(1); + } + + public void NewList(int id) + { + javax.media.opengl.GL gl = GetGL(); + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); + } + + public void CallList(int id) + { + javax.media.opengl.GL gl = GetGL(); + gl.glCallList(id); + } + + public void EndList() + { + javax.media.opengl.GL gl = GetGL(); + gl.glEndList(); + } + + public boolean IsBoxMode() + { + return BOXMODE; + } + + public boolean IsZoomBoxMode() + { + return ZOOMBOXMODE; + } public void ClearDepth() { @@ -231,9 +308,14 @@ return this.ambientOcclusion; } + public boolean IsDebugSelection() + { + return DEBUG_SELECTION; + } + public boolean IsFrozen() { - boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); return !selectmode && cameracount == 0; // != 0; } @@ -254,9 +336,19 @@ return lightCamera; } + public Camera ManipCamera() + { + return manipCamera; + } + public Camera RenderCamera() { return renderCamera; + } + + public Camera[] Cameras() + { + return cameras; } public void PushMaterial(Object3D obj, boolean selected) @@ -272,7 +364,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; @@ -281,14 +373,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; @@ -304,7 +410,7 @@ /**/ } else { - DrawMaterial(material, selected); + DrawMaterial(material, selected, obj.projectedVertices); } } else { @@ -328,8 +434,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); } } @@ -346,8 +452,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) @@ -367,8 +473,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 @@ -403,16 +509,18 @@ javax.media.opengl.GL gl = display.GetGL(); - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); 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); @@ -566,7 +674,816 @@ } } + /** + * <code>draw</code> renders a <code>TriMesh</code> object including + * it's normals, colors, textures and vertices. + * + * @see Renderer#draw(TriMesh) + * @param tris + * the mesh to render. + */ + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) + { + CameraPane display = this; + + float r = display.modelParams0[0]; + float g = display.modelParams0[1]; + float b = display.modelParams0[2]; + float opacity = display.modelParams5[1]; + + //final GL gl = GLU.getCurrentGL(); + GL gl = display.GetGL(); // getGL(); + + FloatBuffer vertBuf = geo.vertBuf; + + int v = vertBuf.capacity(); + + int count = 0; + + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); + gl.glEnable(gl.GL_CULL_FACE); + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); + for (int i=0; i<v/3; i++) + { + int index3 = i*3; + + if (geo.sizeBuf.get(index3+1) == 0) + continue; + + count++; + + int index4 = i*4; + + float tx = vertBuf.get(index3); + float ty = vertBuf.get(index3+1); + float tz = vertBuf.get(index3+2); + + // if (tx == 0 && ty == 0 && tz == 0) + // continue; + + gl.glMatrixMode(gl.GL_TEXTURE); + gl.glPushMatrix(); + + float[] texmat = geo.texmat; + texmat[12] = texmat[13] = texmat[14] = i; + + gl.glMultMatrixf(texmat, 0); + + gl.glMatrixMode(gl.GL_MODELVIEW); + gl.glPushMatrix(); + + gl.glTranslatef(tx,ty,tz); + + if (rotate) + gl.glRotatef(i, 0, 1, 0); + + float size = geo.sizeBuf.get(index3) / 100; + gl.glScalef(size,size,size); + + float cr = geo.colorBuf.get(index4); + float cg = geo.colorBuf.get(index4+1); + float cb = geo.colorBuf.get(index4+2); + float ca = geo.colorBuf.get(index4+3); + + display.modelParams0[0] = r * cr; + display.modelParams0[1] = g * cg; + display.modelParams0[2] = b * cb; + + display.modelParams5[1] = opacity * ca; + + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); + + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; + RandomNode.globalseed2 = RandomNode.globalseed; + +// gl.glColor4f(cr,cg,cb,ca); + // gl.glScalef(1024/16,1024/16,1024/16); + shape.Draw/*Node*/(display,null,selected,false); // blocked + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); + //gl.glTranslatef(-tx,-ty,-tz); + gl.glPopMatrix(); + + gl.glMatrixMode(gl.GL_TEXTURE); + gl.glPopMatrix(); + } + // gl.glScalef(1024,1024,1024); + if (!cf) + gl.glDisable(gl.GL_CULL_FACE); + + display.modelParams0[0] = r; + display.modelParams0[1] = g; + display.modelParams0[2] = b; + + display.modelParams5[1] = opacity; + + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); + + gl.glMatrixMode(gl.GL_MODELVIEW); + +// System.err.println("total = " + v/3 + "; displayed = " + count); + if (true) + return; + +//// if (!tris.predraw(this)) +//// { +//// return; +//// } +//// if (Debug.stats) +//// { +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); +//// } +//// +//// if (tris.getDisplayListID() != -1) +//// { +//// renderDisplayList(tris); +//// return; +//// } +//// +//// if (!generatingDisplayList) +//// { +//// applyStates(tris.states, tris); +//// } +//// if (Debug.stats) +//// { +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); +//// } +//// boolean transformed = doTransforms(tris); +// +// int glMode = GL.GL_TRIANGLES; +// switch (getMode()) +// { +// case Triangles: +// glMode = GL.GL_TRIANGLES; +// break; +// case Strip: +// glMode = GL.GL_TRIANGLE_STRIP; +// break; +// case Fan: +// glMode = GL.GL_TRIANGLE_FAN; +// break; +// } +// +// if (!predrawGeometry(gl)) +// { +// // make sure only the necessary indices are sent through on old +// // cards. +// IntBuffer indices = this.getIndexBuffer(); +// if (indices == null) +// { +// logger.severe("missing indices on geometry object: " + this.toString()); +// } else +// { +// indices.rewind(); +// indices.limit(this.getMaxIndex()); +// +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT +// +// indices.clear(); +// } +// } else +// { +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), +// GL.GL_UNSIGNED_INT, 0); +// } +// +//// postdrawGeometry(tris); +//// if (transformed) +//// { +//// undoTransforms(tris); +//// } +//// +//// if (Debug.stats) +//// { +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); +//// } +//// tris.postdraw(this); + } + + static Camera localcamera = new Camera(); + static cVector from = new cVector(); + static cVector to = new cVector(); + + public void PrepOcclusion(BoundaryRep br, double[][] transform) + { + CameraPane cp = this; + + Camera keep = cp.RenderCamera(); + cp.renderCamera = localcamera; + + if (br.trimmed) + { + float[] colors = new float[br.positions.length / 3]; + + int i3 = 0; + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) + { + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) + continue; + + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); + to.set(br.positions[i3] + br.normals[i3], + br.positions[i3 + 1] + br.normals[i3 + 1], + br.positions[i3 + 2] + br.normals[i3 + 2]); + LA.xformPos(from, transform, from); + LA.xformPos(to, transform, to); // RIGID ONLY + localcamera.setAim(from, to); + + CameraPane.occlusionbuffer.display(); + + if (CameraPane.DEBUG_OCCLUSION) + cp.display(); // debug + + colors[i] = cp.vertexOcclusion.r; + //colors[i3 + 1] = cp.vertexOcclusion.g; + //colors[i3 + 2] = cp.vertexOcclusion.b; + + if ((i % 100) == 0 && i != 0) + { + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); + } + } + + br.colors = colors; + } + else + { + for (int i = 0; i < br.VertexCount(); i++) + { + Vertex v = br.GetVertex(i); + + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) + continue; + + from.set(v.x, v.y, v.z); + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); + LA.xformPos(from, transform, from); + LA.xformPos(to, transform, to); // RIGID ONLY + localcamera.setAim(from, to); + + CameraPane.occlusionbuffer.display(); + + if (CameraPane.DEBUG_OCCLUSION) + cp.display(); // debug + + v.AO = cp.vertexOcclusion.r; + + if ((i % 100) == 0 && i != 0) + { + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); + } + } + } + + //System.out.println("done."); + + cp.renderCamera = keep; + } + + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) + { + CameraPane display = this; + pointFlow.CreateHT(); + + float r = display.modelParams0[0]; + float g = display.modelParams0[1]; + float b = display.modelParams0[2]; + float opacity = display.modelParams5[1]; + + //final GL gl = GLU.getCurrentGL(); + GL gl = display.GetGL(); // getGL(); + + int s = pointFlow.points.size(); + + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); + gl.glEnable(gl.GL_CULL_FACE); + + for (int i=s; --i>=0;) + //for (int i=0; i<s; i++) + { + cVector v = pointFlow.points.get(i); + + double mindist = Double.MAX_VALUE; + + double size = pointFlow.minimumSize; + + double distancenext = 0; + + if (i > 0) + { + cVector w = pointFlow.points.get(i-1); + + double dist = w.distance(v); + + distancenext = dist; + + if (mindist > dist) + { + mindist = dist; + size = mindist*pointFlow.resizefactor; + } + } + + if (i < s-1) + { + cVector w = pointFlow.points.get(i+1); + + double dist = w.distance(v); + + if (mindist > dist) + { + mindist = dist; + size = mindist*pointFlow.resizefactor; + } + } + + if (size < pointFlow.minimumSize) + size = pointFlow.minimumSize; + if (size > pointFlow.maximumSize) + size = pointFlow.maximumSize; + + double tx = v.x; + double ty = v.y; + double tz = v.z; + + // if (tx == 0 && ty == 0 && tz == 0) + // continue; + + gl.glMatrixMode(gl.GL_TEXTURE); + gl.glPushMatrix(); + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; + + gl.glMultMatrixf(pointFlow.texmat, 0); + + gl.glMatrixMode(gl.GL_MODELVIEW); + gl.glPushMatrix(); + + gl.glTranslated(tx,ty,tz); + + gl.glScaled(size,size,size); + +// float cr = colorBuf.get(index4); +// float cg = colorBuf.get(index4+1); +// float cb = colorBuf.get(index4+2); +// float ca = colorBuf.get(index4+3); +// +// display.modelParams0[0] = r * cr; +// display.modelParams0[1] = g * cg; +// display.modelParams0[2] = b * cb; +// +// display.modelParams5[1] = opacity * ca; +// +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); +// +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; +// RandomNode.globalseed2 = RandomNode.globalseed; +// +//// gl.glColor4f(cr,cg,cb,ca); +// // gl.glScalef(1024/16,1024/16,1024/16); + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); + + gl.glPopMatrix(); + + double step = size/4; // + + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) + continue; + + int nbsteps = (int)(distancenext/step); + + step = distancenext/nbsteps; + + cVector next = pointFlow.points.get(i-1); + + tmp.set(next); + tmp.sub(v); + tmp.normalize(); + tmp.mul(step); + + // calculate next size + mindist = Double.MAX_VALUE; + + double nextsize = pointFlow.minimumSize; + + if (i > 1) + { + cVector w = pointFlow.points.get(i-2); + + double dist = w.distance(next); + + if (mindist > dist) + { + mindist = dist; + nextsize = mindist*pointFlow.resizefactor; + } + } + + double dist = v.distance(next); + + if (mindist > dist) + { + mindist = dist; + nextsize = mindist*pointFlow.resizefactor; + } + + if (nextsize < pointFlow.minimumSize) + nextsize = pointFlow.minimumSize; + if (nextsize > pointFlow.maximumSize) + nextsize = pointFlow.maximumSize; + // + + double count = 0; + + while (distancenext > 0.000000001) // step + { + gl.glPushMatrix(); + + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); + + double K = count/nbsteps; + + double intersize = K*nextsize + (1-K)*size; + + gl.glScaled(intersize,intersize,intersize); + + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); + + count++; + + distancenext -= step; + + gl.glPopMatrix(); + } + + if (count != nbsteps) + assert(count == nbsteps); + + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); + //gl.glTranslatef(-tx,-ty,-tz); + + gl.glMatrixMode(gl.GL_TEXTURE); + gl.glPopMatrix(); + } + + if (!cf) + gl.glDisable(gl.GL_CULL_FACE); + +// display.modelParams0[0] = r; +// display.modelParams0[1] = g; +// display.modelParams0[2] = b; +// +// display.modelParams5[1] = opacity; +// +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); + + gl.glMatrixMode(gl.GL_MODELVIEW); + } + + public void DrawBox(cVector min, cVector max) + { + javax.media.opengl.GL gl = GetGL(); + gl.glBegin(gl.GL_LINES); + + gl.glVertex3d(min.x, min.y, min.z); + gl.glVertex3d(min.x, min.y, max.z); + gl.glVertex3d(min.x, min.y, min.z); + gl.glVertex3d(min.x, max.y, min.z); + gl.glVertex3d(min.x, min.y, min.z); + gl.glVertex3d(max.x, min.y, min.z); + + gl.glVertex3d(max.x, max.y, max.z); + gl.glVertex3d(min.x, max.y, max.z); + gl.glVertex3d(max.x, max.y, max.z); + gl.glVertex3d(max.x, min.y, max.z); + gl.glVertex3d(max.x, max.y, max.z); + gl.glVertex3d(max.x, max.y, min.z); + + gl.glEnd(); + } + + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) + { + int[] strips = bRep.getRawIndices(); + + javax.media.opengl.GL gl = GetGL(); + + // TRIANGLE STRIP ARRAY + if (bRep.trimmed) + { + float[] v = bRep.getRawVertices(); + float[] n = bRep.getRawNormals(); + float[] c = bRep.getRawColors(); + float[] uv = bRep.getRawUVMap(); + + int count2 = 0; + int count3 = 0; + + if (n.length > 0) + { + for (int i = 0; i < strips.length; i++) + { + gl.glBegin(gl.GL_TRIANGLE_STRIP); + + /* + boolean locked = false; + float eps = 0.1f; + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice + + int dot = 0; + + if ((dot&1) == 0) + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; + + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) + gl.glTexCoord2f((float) qv.s, (float) qv.t); + else + { + locked = true; + gl.glTexCoord2f((float) pv.s, (float) pv.t); + } + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); + if (hasnorm) + { + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); + } + + if ((dot&4) == 0) + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; + + if (wrap || !locked && (dot&8) != 0) + gl.glTexCoord2f((float) rv.s, (float) rv.t); + else + gl.glTexCoord2f((float) pv.s, (float) pv.t); + + f.dot = dot; + */ + + if (!selectmode) + { + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) + { + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); + } else + { + gl.glNormal3f(0, 0, 1); + } + + if (c != null) + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); + { + 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]); + + count2 += 2; + count3 += 3; + if (!selectmode) + { + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) + { + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); + } else + { + gl.glNormal3f(0, 0, 1); + } + if (c != null) + { + 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]); + + count2 += 2; + count3 += 3; + for (int j = 0; j < strips[i] - 2; j++) + { + //gl.glTexCoord2d(...); + if (!selectmode) + { + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) + { + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); + } else + { + gl.glNormal3f(0, 0, 1); + } + if (c != null) + { + 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("coord3 = " + uv[count2] + ", " + uv[count2+1]); + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); + + count2 += 2; + count3 += 3; + } + + gl.glEnd(); + } + } + + assert count3 == v.length; + } + else // !trimmed + { + int count = 0; + for (int i = 0; i < strips.length; i++) + { + gl.glBegin(gl.GL_TRIANGLE_STRIP); + + Vertex p = bRep.GetVertex(bRep.indices[count++]); + Vertex q = bRep.GetVertex(bRep.indices[count++]); + + drawVertex(gl, p, flipV, selectmode); + drawVertex(gl, q, flipV, selectmode); + + for (int j = 0; j < strips[i] - 2; j++) + { + Vertex r = bRep.GetVertex(bRep.indices[count++]); + + // if (j%2 == 0) + // drawFace(p, q, r, display, null); + // else + // drawFace(p, r, q, display, null); + + // p = q; + // q = r; + drawVertex(gl, r, flipV, selectmode); + } + + gl.glEnd(); + } + } + } + + static cSpring.Point3D temp = new cSpring.Point3D(); + static cSpring.Point3D temp2 = new cSpring.Point3D(); + static cSpring.Point3D temp3 = new cSpring.Point3D(); + + public void DrawDynamicMesh(cMesh mesh) + { + GL gl = GetGL(); // getGL(); + + cSpring.PhysicsController3D Phys = mesh.Phys; + + gl.glDisable(gl.GL_LIGHTING); + + gl.glLineWidth(1); + gl.glColor3f(1,1,1); + gl.glBegin(gl.GL_LINES); + double scale = 0; + int count = 0; + for (int s=0; s<Phys.allSprings.size(); s++) + { + cSpring.Spring spring = Phys.allSprings.get(s); + if(s == 0) + { + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); + } + if (mesh.showsprings) + { + temp.set(spring.a.position); + temp.add(spring.b.position); + temp.mul(0.5); + temp2.set(spring.a.position); + temp2.sub(spring.b.position); + temp2.mul(spring.restLength/2); + temp.sub(temp2); + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); + temp.add(temp2); + temp.add(temp2); + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); + } + + if (spring.isHandle) + continue; + + //if (scale < spring.restLength) + scale += spring.restLength; + count++; + } + gl.glEnd(); + + if (count == 0) + scale = 0.01; + else + scale /= count * 3; + + //scale = 0.25; + + if (mesh.ShowInfo()) + { + gl.glLineWidth(4); + for (int s=0; s<Phys.allNodes.size(); s++) + { + cSpring.DynamicNode node = Phys.allNodes.get(s); + if (node.mass == 0) + continue; + + int i = node.springs==null?-1:node.springs.size(); + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); + //temp.normalize(); + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); + gl.glBegin(gl.GL_LINES); + gl.glVertex3d(node.position.x, node.position.y, node.position.z); + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); + gl.glEnd(); + } + + gl.glLineWidth(8); + for (int s=0; s<Phys.allNodes.size(); s++) + { + cSpring.DynamicNode node = Phys.allNodes.get(s); + + if (node.springs != null) + { + for (int i=0; i<node.springs.size(); i+=1) + { + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); + + int c = i+1; + // c = node.springs.get(i).nbcopies; + + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); + gl.glBegin(gl.GL_LINES); + gl.glVertex3d(node.position.x, node.position.y, node.position.z); + gl.glVertex3d(f.position.x/3+node.position.x*2/3, f.position.y/3+node.position.y*2/3, f.position.z/3+node.position.z*2/3); + gl.glEnd(); + } + } + } + + gl.glLineWidth(1); + } + + gl.glEnable(gl.GL_LIGHTING); + } + /// INTERFACE + + public void StartTriangles() + { + javax.media.opengl.GL gl = GetGL(); + gl.glBegin(gl.GL_TRIANGLES); + } + + public void EndTriangles() + { + GetGL().glEnd(); + } + + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) + { + if (!selectmode) + { + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); + + if (flipV) + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); + else + gl.glTexCoord2f((float) pv.s, (float) pv.t); + } + + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); + } void SetColor(Object3D obj, Vertex p0) { @@ -745,7 +1662,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(); @@ -761,18 +1678,18 @@ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); if (!material.multiply) { - display.color = color; + display.color = material.color; display.saturation = material.modulation; } else { - display.color *= color*2; + display.color *= material.color*2; display.saturation *= material.modulation*2; } 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) @@ -780,7 +1697,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); @@ -888,9 +1805,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 @@ -1032,7 +1949,7 @@ void PushMatrix(double[][] matrix) { // GrafreeD.tracein(matrix); - PushMatrix(matrix,1); + PushMatrix(matrix, 1); } void PushMatrix() @@ -1129,7 +2046,7 @@ static int camerachangeframe; - boolean SetCamera(Camera cam) + public boolean SetCamera(Camera cam) { // may 2014 if (cam == cameras[0] || cam == cameras[1]) // return false; @@ -1186,7 +2103,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); } @@ -1257,33 +2174,6 @@ mainDL ^= true; } - void ToggleTexture() - { - textureon ^= true; - } - - void ToggleLive() - { - Globals.setLIVE(Globals.isLIVE() ^ true); - - System.err.println("LIVE = " + Globals.isLIVE()); - - if (!Globals.isLIVE()) // save sound - GrafreeD.savesound = true; // wav.save(); - // else - repaint(); // start loop // may 2013 - } - - void ToggleSupport() - { - SUPPORT ^= true; - } - - void ToggleAbort() - { - ABORTMODE ^= true; - } - void ToggleFullScreen() { FULLSCREEN ^= true; @@ -1294,72 +2184,94 @@ Globals.CROWD ^= true; } - void ToggleInertia() - { - INERTIA ^= true; - } - void ToggleLocal() { LOCALTRANSFORM ^= true; } - void ToggleFast() + public void ToggleTexture() + { + textureon ^= true; + } + + public void ToggleLive() + { + Globals.setLIVE(Globals.isLIVE() ^ true); + + System.err.println("LIVE = " + Globals.isLIVE()); + + if (!Globals.isLIVE()) // save sound + Grafreed.savesound = true; // wav.save(); + // else + repaint(); // start loop // may 2013 + } + + public void ToggleSupport() + { + SUPPORT ^= true; + } + + public void ToggleAbort() + { + ABORTMODE ^= true; + } + + public void ToggleInertia() + { + INERTIA ^= true; + } + + public void ToggleFast() { FAST ^= true; } - void ToggleSlowPose() + public void ToggleSlowPose() { SLOWPOSE ^= true; } - void ToggleFootContact() - { - FOOTCONTACT ^= true; - } - - void ToggleBoxMode() + public void ToggleBoxMode() { BOXMODE ^= true; } - void ToggleSmoothFocus() + public void ToggleZoomBoxMode() + { + ZOOMBOXMODE ^= true; + } + + public void ToggleSmoothFocus() { SMOOTHFOCUS ^= true; } - void ToggleImageFlip() + public void ToggleImageFlip() { IMAGEFLIP ^= true; } - void ToggleSpeakerMocap() + public void ToggleSpeakerMocap() { SPEAKERMOCAP ^= true; } - void ToggleSpeakerCamera() + public void ToggleSpeakerCamera() { SPEAKERCAMERA ^= true; } - void ToggleSpeakerFocus() + public void ToggleSpeakerFocus() { SPEAKERFOCUS ^= true; } - void ToggleDebug() - { - DEBUG ^= true; - } - - void ToggleFrustum() + public void ToggleFrustum() { FRUSTUM ^= true; } - void ToggleTrack() + public void ToggleTrack() { TRACK ^= true; if (TRACK) @@ -1378,25 +2290,35 @@ repaint(); } - void ToggleTrackOnce() + public void ToggleTrackOnce() { TRACKONCE ^= true; } - void ToggleShadowTrack() + public void ToggleShadowTrack() { SHADOWTRACK ^= true; repaint(); } - void ToggleOeil() + public void ToggleOeil() { OEIL ^= true; } - void ToggleOeilOnce() + public void ToggleOeilOnce() { OEILONCE ^= true; + } + + void ToggleFootContact() + { + FOOTCONTACT ^= true; + } + + void ToggleDebug() + { + Globals.DEBUG ^= true; } void ToggleLookAt() @@ -1404,9 +2326,9 @@ LOOKAT ^= true; } - void ToggleRandom() + void ToggleSwitch() { - RANDOM ^= true; + SWITCH ^= true; } void ToggleHandles() @@ -1414,10 +2336,17 @@ HANDLES ^= true; } + Object3D paintFolder; + void TogglePaint() { PAINTMODE ^= true; paintcount = 0; + + if (PAINTMODE) + { + paintFolder = GetFolder(); + } } void SwapCamera(int a, int b) @@ -1513,7 +2442,22 @@ { return currentGL; } - + + static private BufferedImage CreateBim(TextureData texturedata) + { + Grafreed.Assert(texturedata != null); + + int width = texturedata.getWidth(); + int height = texturedata.getHeight(); + + Buffer buffer = texturedata.getBuffer(); + ByteBuffer bytebuf = (ByteBuffer)buffer; + + byte[] bytes = bytebuf.array(); + + return CreateBim(bytes, width, height); + } + /**/ class CacheTexture { @@ -1522,28 +2466,31 @@ int resolution; - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) { - texture = tex; + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); + texturedata = texdata; resolution = res; } } /**/ // 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 Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); + int pigmentdepth = 0; public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; int bumpdepth = 0; public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); - public static String NOISE_TEXTURE = "WHITE_NOISE"; + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) { TextureData texturedata = null; @@ -1562,13 +2509,34 @@ if (bump) texturedata = ConvertBump(texturedata, false); - com.sun.opengl.util.texture.Texture texture = - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); +// 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); + //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; + return texturedata; + } + + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) + { + TextureData texturedata = null; + + try + { + texturedata = + com.sun.opengl.util.texture.TextureIO.newTextureData( + bim, + true); + } catch (Exception e) + { + throw new javax.media.opengl.GLException(e); + } + + if (bump) + texturedata = ConvertBump(texturedata, false); + + return texturedata; } boolean HUESMOOTH = true; // wrap around bug... true; @@ -2641,6 +3609,8 @@ System.out.println("LOADING TEXTURE : " + name); + Object x = texturedata.getMipmapData(); // .getBuffer(); + // if (false) // compressbit > 0) { @@ -3345,6 +4315,7 @@ com.sun.opengl.util.texture.Texture CompressTexture2(String name) { + new Exception().printStackTrace(); System.exit(0); com.sun.opengl.util.texture.Texture texture = null; @@ -7038,7 +8009,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); @@ -7053,11 +8024,69 @@ pigment = null; } - ReleaseTexture(bump, true); - ReleaseTexture(pigment, false); + ReleaseTexture(tex, true); + ReleaseTexture(tex, false); } - void ReleaseTexture(String tex, boolean bump) + 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(tex, 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(tex, true); + } + + void ReleaseTexture(cTexture tex, boolean bump) { if (// DrawMode() != 0 || /*tex == null ||*/ ambientOcclusion ) // || !textureon) @@ -7068,7 +8097,7 @@ CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; if (tex != null) - texture = textures.get(tex); + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); // //assert( texture != null ); // if (texture == null) @@ -7160,7 +8189,55 @@ } } - /*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) +// { +// 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; + + BindPigmentTexture(tex, resolution); + BindBumpTexture(tex, resolution); + } + + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE { if (// DrawMode() != 0 || /*tex == null ||*/ ambientOcclusion ) // || !textureon) @@ -7171,17 +8248,47 @@ if (tex == null) { BindTexture(null,false,resolution); - BindTexture(null,true,resolution); return; } String pigment = Object3D.GetPigment(tex); + + usedtextures.add(tex); + + //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(tex, 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(pigment, pigment); - usedtextures.put(bump, bump); + usedtextures.add(tex); - 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); @@ -7191,43 +8298,94 @@ { 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); + BindTexture(tex, true, resolution); GetGL().glActiveTexture(GetGL().GL_TEXTURE0); - - return; // true; } - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); + + private boolean FileExists(String tex) { - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; + 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(cTexture tex, boolean bump, int resolution) throws Exception + { + CacheTexture texturecache = null; if (tex != null) { - String texname = tex; + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; - 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 (texname.equals("") && texdata == null) + { + return null; + } + + 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(texname)) + { + texname = fallbackTextureName; + } if (CACHETEXTURE) - texture = textures.get(texname); // TEXTURE CACHE - - TextureData texturedata = null; - - if (texture == null || texture.resolution < resolution) { - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) + if (texdata == null) + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); + else + texturecache = bimtextures.get(texdata); + } + + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) + { + TextureData texturedata = null; + + if (texdata != null && textureon) + { + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); + + try + { + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); + } + catch (Exception e) + { + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); + } + + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); + bimtextures.put(texdata, texturecache); + + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); + + //Object bim2 = CreateBim(texturecache.texturedata); + //bim2 = bim; + } + else + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) { assert(!bump); // if (bump) @@ -7238,19 +8396,23 @@ // } // else // { - texture = textures.get(tex); - if (texture == null) + // texturecache = textures.get(texname); // suspicious + if (texturecache == null) { - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); } + else + new Exception().printStackTrace(); // } } else - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) + if (texname.endsWith("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(texname); // suspicious + if (texturecache == null) + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); + else + new Exception().printStackTrace(); } else { //if (tex.equals("IMMORTAL")) @@ -7258,11 +8420,13 @@ // texture = GetResourceTexture("default.png"); //} else //{ - if (tex.equals("WHITE_NOISE")) + if (texname.endsWith("WHITE_NOISE")) { - texture = textures.get(tex); - if (texture == null) - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); + // texturecache = textures.get(texname); // suspicious + if (texturecache == null) + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); + else + new Exception().printStackTrace(); } else { if (textureon) @@ -7287,7 +8451,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 @@ -7309,7 +8473,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 @@ -7318,20 +8482,22 @@ texturedata = GetFileTexture(cachename, processbump, resolution); - if (texturedata != null) - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); + if (texturedata == null) + throw new Exception(); + + texturecache = new CacheTexture(texturedata,resolution); //texture = GetTexture(tex, bump); } } //} } - if (/*CACHETEXTURE &&*/ texture != null && textureon) + if (texdata == null && /*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) @@ -7348,52 +8514,17 @@ File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); if (!cachefile.exists()) { - // cache to disk - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); - //buffers[0]. - - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); - int[] pixels = new int[bytebuf.capacity()/3]; - - // squared size heuristic... - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) + //if (texturedata.getWidth() == texturedata.getHeight()) { - for (int i=pixels.length; --i>=0;) - { - int i3 = i*3; - pixels[i] = 0xFF; - pixels[i] <<= 8; - pixels[i] |= bytebuf.get(i3+2) & 0xFF; - pixels[i] <<= 8; - pixels[i] |= bytebuf.get(i3+1) & 0xFF; - pixels[i] <<= 8; - pixels[i] |= bytebuf.get(i3) & 0xFF; - } - - /* - int r=0,g=0,b=0,a=0; - for (int i=0; i<width; i++) - for (int j=0; j<height; j++) - { - int index = j*width+i; - int p = pixels[index]; - a = ((p>>24) & 0xFF); - r = ((p>>16) & 0xFF); - g = ((p>>8) & 0xFF); - b = (p & 0xFF); - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; - } - /**/ - int width = (int)Math.sqrt(pixels.length); // squared - int height = width; - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); + BufferedImage rendImage = CreateBim(texturedata); + ImageWriter writer = null; Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); if (iter.hasNext()) { writer = (ImageWriter)iter.next(); } - float compressionQuality = 0.9f; + + float compressionQuality = 0.85f; try { ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); @@ -7410,18 +8541,20 @@ } } } - + + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; + //System.out.println("Texture = " + tex); - if (textures.containsKey(texname)) + if (textures.containsKey(tex)) { - CacheTexture thetex = textures.get(texname); + CacheTexture thetex = textures.get(tex); thetex.texture.disable(); thetex.texture.dispose(); - textures.remove(texname); + textures.remove(tex); } - texture.texturedata = texturedata; - textures.put(texname, texture); + //texture.texturedata = texturedata; + textures.put(tex, texturecache); // newtex = true; } @@ -7437,10 +8570,44 @@ } } - return texture; + return texturecache; } - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) + static void EmbedTextures(cTexture tex) + { + if (tex.pigmentdata == null) + { + //String texname = Object3D.GetPigment(tex); + + CacheTexture texturecache = texturepigment.get(tex); + + if (texturecache != null) + { + tex.pw = texturecache.texturedata.getWidth(); + tex.ph = texturecache.texturedata.getHeight(); + tex.pigmentdata = //CompressJPEG(CreateBim + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() + ; + //, tex.pw, tex.ph), 0.5f); + } + } + + if (tex.bumpdata == null) + { + //String texname = Object3D.GetBump(tex); + + CacheTexture texturecache = texturebump.get(tex); + + if (texturecache != null) + { + tex.bw = texturecache.texturedata.getWidth(); + tex.bh = texturecache.texturedata.getHeight(); + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); + } + } + } + + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception { CacheTexture texture = GetCacheTexture(tex, bump, resolution); @@ -7458,21 +8625,21 @@ return texture!=null?texture.texture:null; } - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture 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(cTexture 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); @@ -7504,9 +8671,75 @@ 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. } + public static byte[] CompressJPEG(BufferedImage image, float quality) + { + try + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); + ImageWriter writer = writers.next(); + + ImageWriteParam param = writer.getDefaultWriteParam(); + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); + param.setCompressionQuality(quality); + + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); + writer.setOutput(ios); + writer.write(null, new IIOImage(image, null, null), param); + + byte[] data = baos.toByteArray(); + writer.dispose(); + return data; + } + catch (Exception e) + { + e.printStackTrace(); + return null; + } + } + + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException + { + ByteArrayInputStream baos = new ByteArrayInputStream(image); + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); + ImageReader reader = writers.next(); + + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + + ImageReadParam param = reader.getDefaultReadParam(); + param.setDestination(bim); + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); + + ImageInputStream ios = ImageIO.createImageInputStream(baos); + reader.setInput(ios); + BufferedImage bim2 = reader.read(0, param); + reader.dispose(); + +// WritableRaster raster = bim2.getRaster(); +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); +// byte[] bytes = data.getData(); +// +// int[] pixels = new int[bytes.length/3]; +// for (int i=pixels.length; --i>=0;) +// { +// int i3 = i*3; +// pixels[i] = 0xFF; +// pixels[i] <<= 8; +// pixels[i] |= bytes[i3+2] & 0xFF; +// pixels[i] <<= 8; +// pixels[i] |= bytes[i3+1] & 0xFF; +// pixels[i] <<= 8; +// pixels[i] |= bytes[i3] & 0xFF; +// } +// +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); + + return bim; + } + ShadowBuffer shadowPBuf; AntialiasBuffer antialiasPBuf; int MAXSTACK; @@ -8342,11 +9575,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; @@ -8442,8 +9699,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.GlobalTransformInv(), matrix); // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); @@ -8458,8 +9715,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.GlobalTransform(), matrix, matrix); // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); @@ -8531,7 +9788,7 @@ //gl.glFlush(); gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); - if (ANIMATION && ABORTED) + if (Globals.ANIMATION && ABORTED) { System.err.println(" ABORTED FRAME"); break; @@ -8561,7 +9818,7 @@ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); // save image - if (ANIMATION && !ABORTED) + if (Globals.ANIMATION && !ABORTED) { VPwidth = viewport[2]; VPheight = viewport[3]; @@ -8672,11 +9929,11 @@ // imagecount++; - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; 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) @@ -8714,7 +9971,7 @@ ABORTED = false; } else - GrafreeD.wav.cursor += 735 * ACSIZE; + Grafreed.wav.cursor += 735 * ACSIZE; if (false) { @@ -9377,11 +10634,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) // { @@ -9457,6 +10714,7 @@ ANTIALIAS = 0; //System.out.println("RESTART"); AAtimer.restart(); + Globals.TIMERRUNNING = true; } } } @@ -9511,7 +10769,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); @@ -9524,13 +10782,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(); @@ -9657,8 +10916,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.GlobalTransformInv(), matrix); for (int j = 0; j < 4; j++) { @@ -9672,8 +10931,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.GlobalTransform(), matrix, matrix); //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); @@ -9932,7 +11191,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); @@ -9955,9 +11223,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); @@ -9968,7 +11236,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(); @@ -10057,8 +11325,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); @@ -10079,8 +11347,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); @@ -10146,7 +11414,7 @@ fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso //System.out.println("fragmentMode = " + fragmentMode); - if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION) + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) { /* if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) @@ -10217,7 +11485,7 @@ } } - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) { //gl.glDepthFunc(GL.GL_LEQUAL); //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); @@ -10225,24 +11493,21 @@ boolean texon = textureon; - if (RENDERPROGRAM > 0) - { - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); - textureon = false; - } + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); + textureon = false; + //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); //System.out.println("ALLO"); gl.glColorMask(false, false, false, false); DrawObject(gl); - if (RENDERPROGRAM > 0) - { - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); - textureon = texon; - } + + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); + textureon = texon; + gl.glColorMask(true, true, true, true); gl.glDepthFunc(GL.GL_EQUAL); - //gl.glDepthMask(false); + gl.glDepthMask(false); } if (false) // DrawMode() == SHADOW) @@ -10396,8 +11661,14 @@ { renderpass++; // System.out.println("Draw object... "); + STEP = 1; if (FAST) // in case there is no script - STEP = 16; + STEP = 8; + + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) + { + STEP *= 4; + } //object.FullInvariants(); @@ -10411,23 +11682,44 @@ 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) { + // 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; } @@ -10447,7 +11739,7 @@ callist = gl.glGenLists(1); } - boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; @@ -10482,7 +11774,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(); @@ -10492,8 +11791,9 @@ if (DrawMode() == DEFAULT) { - if (DEBUG) + if (Globals.DEBUG) { + CreateSelectedPoint(); float radius = 0.05f; if (selectedpoint.radius != radius) { @@ -10547,20 +11847,32 @@ ReleaseTextures(DEFAULT_TEXTURES); if (CLEANCACHE) - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) { - String tex = e.nextElement(); + cTexture tex = e.nextElement(); // System.out.println("Texture --------- " + tex); - if (tex.equals("WHITE_NOISE")) + if (tex.equals("WHITE_NOISE:")) continue; - if (!usedtextures.containsKey(tex)) + if (!usedtextures.contains(tex)) { + CacheTexture gettex = texturepigment.get(tex); // System.out.println("DISPOSE +++++++++++++++ " + tex); - textures.get(tex).texture.dispose(); - textures.remove(tex); + if (gettex != null) + { + gettex.texture.dispose(); + texturepigment.remove(tex); + } + + gettex = texturebump.get(tex); + // System.out.println("DISPOSE +++++++++++++++ " + tex); + if (gettex != null) + { + gettex.texture.dispose(); + texturebump.remove(tex); + } } } } @@ -10573,7 +11885,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); @@ -10655,7 +11974,7 @@ return; } - String string = obj.GetToolTip(); + String string = obj.toString(); //.GetToolTip(); GL gl = GetGL(); @@ -10972,8 +12291,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).GlobalTransformInv(), light); } @@ -10990,8 +12309,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); @@ -11082,7 +12401,74 @@ //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); String program = + // Min shader "!!ARBfp1.0\n" + + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + + "PARAM light2cam0 = program.env[10];" + + "PARAM light2cam1 = program.env[11];" + + "PARAM light2cam2 = program.env[12];" + + "TEMP temp;" + + "TEMP light;" + + "TEMP ndotl;" + + "TEMP normal;" + + "TEMP depth;" + + "TEMP eye;" + + "TEMP pos;" + + + "MAD normal, fragment.color, zero123.z, -zero123.y;" + + Normalize("normal") + + "MOV light, state.light[0].position;" + + "DP3 ndotl.x, light, normal;" + + + // shadow + "MOV pos, fragment.texcoord[1];" + + "MOV temp, pos;" + + ShadowTextureFetch("depth", "temp", "1") + + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + + + // No shadow when out of frustum + //"SGE temp.y, depth.z, zero123.y;" + + //"LRP temp.x, temp.y, zero123.y, temp.x;" + + + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow + + // Backlit + "MOV pos.w, zero123.y;" + + "DP4 eye.x, pos, light2cam0;" + + "DP4 eye.y, pos, light2cam1;" + + "DP4 eye.z, pos, light2cam2;" + + Normalize("eye") + + + "DP3 ndotl.y, -eye, normal;" + + //"MUL ndotl.y, ndotl.y, pow2.x;" + + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit + "SUB ndotl.y, zero123.y, ndotl.y;" + + //"SUB ndotl.y, zero123.y, ndotl.y;" + + //"MUL ndotl.y, ndotl.y, pow2.z;" + + + "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient + + // Pigment + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + + "LRP temp, zero123.w, temp, one;" + // texture proportion + "MUL temp, temp, ndotl.x;" + + + "MUL temp, temp, zero123.z;" + + + //"MUL temp, temp, ndotl.y;" + + + "MOV temp.w, zero123.y;" + // reset alpha + "MOV result.color, temp;" + + "END"; + + String program2 = + "!!ARBfp1.0\n" + + //"OPTION ARB_fragment_program_shadow;" + "PARAM light2cam0 = program.env[10];" + "PARAM light2cam1 = program.env[11];" + @@ -11197,8 +12583,7 @@ "TEMP shininess;" + "\n" + "MOV texSamp, one;" + - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + - + "MOV mapgrid.x, one2048th.x;" + "MOV temp, fragment.texcoord[1];" + /* @@ -11219,20 +12604,20 @@ "MUL temp, floor, mapgrid.x;" + //"TEX depth0, temp, texture[1], 2D;" + (((mode & FP_SOFTSHADOW) == 0) ? "" : - TextureFetch("depth0", "temp", "1") + + ShadowTextureFetch("depth0", "temp", "1") + "") + "ADD temp.x, temp.x, mapgrid.x;" + //"TEX depth1, temp, texture[1], 2D;" + (((mode & FP_SOFTSHADOW) == 0) ? "" : - TextureFetch("depth1", "temp", "1") + + ShadowTextureFetch("depth1", "temp", "1") + "") + "ADD temp.y, temp.y, mapgrid.x;" + //"TEX depth2, temp, texture[1], 2D;" + - TextureFetch("depth2", "temp", "1") + + ShadowTextureFetch("depth2", "temp", "1") + "SUB temp.x, temp.x, mapgrid.x;" + //"TEX depth3, temp, texture[1], 2D;" + (((mode & FP_SOFTSHADOW) == 0) ? "" : - TextureFetch("depth3", "temp", "1") + + ShadowTextureFetch("depth3", "temp", "1") + "") + //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + //"MOV params, material;" + @@ -11603,10 +12988,10 @@ "MAD shadow.x, buffer.x, frac.y, shadow.x;" + "") + - // display shadow only (bump == 0) + // display shadow only (fakedepth == 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;" + @@ -11735,8 +13120,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;" + @@ -11935,7 +13322,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); @@ -12028,25 +13415,26 @@ return out; } - String TextureFetch(String dest, String src, String unit) + // Also does frustum culling + String ShadowTextureFetch(String dest, String src, String unit) { return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + "SGE " + src + ".w, " + src + ".x, eps.x;" + "SGE " + src + ".z, " + src + ".y, eps.x;" + + "SLT " + dest + ".x, " + src + ".x, one.x;" + + "SLT " + dest + ".y, " + src + ".y, one.x;" + "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + - "SLT " + src + ".z, " + src + ".x, one.x;" + - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + - "SLT " + src + ".z, " + src + ".y, one.x;" + - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + //"SWZ buffer, temp, w,w,w,w;"; - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + "SUB " + src + ".z, " + "one.x, " + src + ".w;" + //"MUL " + src + ".z, " + src + ".z, infinity.x;" + //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; } String Shadow(String depth, String shadow) @@ -12068,12 +13456,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;" + @@ -12087,6 +13479,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 frustum + "SGE temp.x, " + depth + ".z, one.z;" + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + ""; } @@ -12233,7 +13629,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 @@ -12249,9 +13646,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;" + @@ -12645,7 +14043,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; @@ -12672,6 +14070,7 @@ //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); + if (BUTTONLESSWHEEL) if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) { return; @@ -12680,7 +14079,7 @@ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); // TIMER - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR { keepboxmode = BOXMODE; keepsupport = SUPPORT; @@ -12720,8 +14119,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; @@ -12755,6 +14154,7 @@ else if (evt.getSource() == AAtimer) { + Globals.TIMERRUNNING = false; if (mouseDown) { //new Exception().printStackTrace(); @@ -12780,6 +14180,10 @@ // LIVE = waslive; // wasliveok = true; // waslive = false; + + // May 2019 Forget it: + if (true) + return; // source == timer if (mouseDown) @@ -12810,7 +14214,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) @@ -12819,12 +14223,13 @@ 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; AAtimer.restart(); // + Globals.TIMERRUNNING = true; // waslive = LIVE; // LIVE = false; @@ -12836,7 +14241,7 @@ // touched = true; // main DL if (isRenderer) { - SetMouseMode(modifiers); + SetMouseMode(modifiers, modifiersex); } selectX = anchorX = x; @@ -12849,7 +14254,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); @@ -12874,14 +14279,15 @@ drag = false; //System.out.println("Mouse DOWN"); editObj = false; - ClickInfo info = new ClickInfo(); - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); - info.pane = this; - info.camera = renderCamera; - info.x = x; - info.y = y; - info.modifiers = modifiers; - editObj = object.doEditClick(info, 0); + //ClickInfo info = new ClickInfo(); + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); + object.clickInfo.pane = this; + object.clickInfo.camera = renderCamera; + object.clickInfo.x = x; + object.clickInfo.y = y; + object.clickInfo.modifiers = modifiersex; + editObj = object.doEditClick(//info, + 0); if (!editObj) { hasMarquee = true; @@ -12897,11 +14303,14 @@ public void mouseDragged(MouseEvent e) { + Globals.MOUSEDRAGGED = true; + + //System.out.println("mouseDragged: " + e); if (isRenderer) movingcamera = true; + //if (drawing) //return; - //System.out.println("mouseDragged: " + e); if ((e.getModifiersEx() & CTRL) != 0 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) { @@ -12909,7 +14318,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) {} } @@ -12921,6 +14330,11 @@ cVector tmp = new cVector(); cVector tmp2 = new cVector(); boolean isMoving; + + public cVector TargetLookAt() + { + return targetLookAt; + } class PingThread extends Thread { @@ -13077,6 +14491,7 @@ public void run() { + new Exception().printStackTrace(); System.exit(0); for (;;) { @@ -13140,7 +14555,7 @@ { Globals.lighttouched = true; } - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); } //else } @@ -13154,12 +14569,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?? @@ -13175,12 +14590,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; @@ -13196,12 +14611,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; @@ -13217,12 +14632,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; @@ -13240,7 +14655,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()) { @@ -13249,17 +14664,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); @@ -13272,14 +14687,16 @@ if (editObj) { drag = true; - ClickInfo info = new ClickInfo(); - info.bounds.setBounds(0, 0, + //ClickInfo info = new ClickInfo(); + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); - info.pane = this; - info.camera = renderCamera; - info.x = x; - info.y = y; - object.editWindow.copy.doEditDrag(info); + object.clickInfo.pane = this; + object.clickInfo.camera = renderCamera; + object.clickInfo.x = x; + object.clickInfo.y = y; + object //.GetWindow().copy + .doEditDrag(//info, + (modifiers & MouseEvent.BUTTON3_MASK) != 0); } else { if (x < startX) @@ -13428,23 +14845,27 @@ } } +// ClickInfo clickInfo = new ClickInfo(); + public void mouseMoved(MouseEvent e) { //System.out.println("mouseMoved: " + e); - if (isRenderer) return; - ClickInfo ci = new ClickInfo(); - ci.x = e.getX(); - ci.y = e.getY(); - ci.modifiers = e.getModifiersEx(); - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); - ci.pane = this; - ci.camera = renderCamera; + // Mouse cursor feedback + object.clickInfo.x = e.getX(); + object.clickInfo.y = e.getY(); + object.clickInfo.modifiers = e.getModifiersEx(); + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); + object.clickInfo.pane = this; + object.clickInfo.camera = renderCamera; if (!isRenderer) { - if (object.editWindow.copy.doEditClick(ci, 0)) + //ObjEditor editWindow = object.editWindow; + //Object3D copy = editWindow.copy; + if (object.doEditClick(//clickInfo, + 0)) { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else @@ -13456,7 +14877,11 @@ public void mouseReleased(MouseEvent e) { + Globals.MOUSEDRAGGED = false; + movingcamera = false; + X = 0; // getBounds().width/2; + Y = 0; // getBounds().height/2; //System.out.println("mouseReleased: " + e); clickEnd(e.getX(), e.getY(), e.getModifiersEx()); } @@ -13479,9 +14904,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 @@ -13591,7 +15016,7 @@ System.out.println("keyReleased: " + e); } - void SetMouseMode(int modifiers) + void SetMouseMode(int modifiers, int modifiersex) { //System.out.println("SetMouseMode = " + modifiers); //modifiers &= ~1024; @@ -13603,25 +15028,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; @@ -13650,10 +15075,10 @@ if (isRenderer) // { - SetMouseMode(modifiers); + SetMouseMode(0, modifiers); } - theRenderer.keyPressed(key); + Globals.theRenderer.keyPressed(key); } int kompactbit = 4; // power bit @@ -13665,7 +15090,7 @@ float SATPOW = 1; // 2; // 0.5f; float BRIPOW = 1; // 0.5f; // 0.5f; - void keyPressed(int key) + public void keyPressed(int key) { if (key >= '0' && key <= '5') clampbit = (key-'0'); @@ -13712,7 +15137,8 @@ // break; case 'T': CACHETEXTURE ^= true; - textures.clear(); + texturepigment.clear(); + texturebump.clear(); // repaint(); break; case 'Y': @@ -13797,7 +15223,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; @@ -13822,8 +15250,8 @@ RevertCamera(); repaint(); break; - case 'L': case 'l': + //case 'L': if (lightMode) { lightMode = false; @@ -13966,9 +15394,9 @@ case '_': kompactbit = 5; break; - case '+': - kompactbit = 6; - break; +// case '+': +// kompactbit = 6; +// break; case ' ': lightMode ^= true; Globals.lighttouched = true; @@ -13980,13 +15408,14 @@ 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; @@ -14019,8 +15448,9 @@ case DELETE: ClearSelection(); break; - /* case '+': + + /* //fontsize += 1; bbzoom *= 2; repaint(); @@ -14037,17 +15467,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; @@ -14102,6 +15532,7 @@ } //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); } + static double OCCLUSIONBOOST = 1; // 0.5; void keyReleased(int key, int modifiers) @@ -14109,11 +15540,11 @@ //mode = ROTATE; if ((MODIFIERS & COMMAND) == 0) // VR?? { - SetMouseMode(modifiers); + SetMouseMode(0, modifiers); } } - protected void processKeyEvent(KeyEvent e) + public void processKeyEvent(KeyEvent e) { switch (e.getID()) { @@ -14243,8 +15674,9 @@ protected void processMouseMotionEvent(MouseEvent e) { - //System.out.println("processMouseMotionEvent: " + mouseMode); - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) + //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 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) { mouseMoved(e); } else @@ -14269,11 +15701,12 @@ } */ - object.editWindow.EditSelection(); + object.GetWindow().EditSelection(false); } void SelectParent() { + new Exception().printStackTrace(); System.exit(0); Composite group = (Composite) object; java.util.Vector selectees = new java.util.Vector(group.selection); @@ -14285,10 +15718,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; @@ -14297,6 +15730,7 @@ void SelectChildren() { + new Exception().printStackTrace(); System.exit(0); /* Composite group = (Composite) object; @@ -14329,12 +15763,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; @@ -14345,21 +15779,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); } @@ -14367,7 +15801,7 @@ { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.PrintMemory(); + group.GetWindow().PrintMemory(); // group.editWindow.ReduceMesh(true); } @@ -14375,7 +15809,7 @@ { //Composite group = (Composite) object; Object3D group = object; - group.editWindow.ResetCentroid(); + group.GetWindow().ResetCentroid(); } void IncDepth() @@ -14457,11 +15891,11 @@ int width = getBounds().width; int height = getBounds().height; - ClickInfo info = new ClickInfo(); - 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) @@ -14533,40 +15967,88 @@ } if (object != null && !hasMarquee) { + if (object.clickInfo == null) + object.clickInfo = new ClickInfo(); + ClickInfo info = object.clickInfo; + //ClickInfo info = new ClickInfo(); + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); + if (isRenderer) { - info.flags++; + object.clickInfo.flags++; double frameAspect = (double) width / (double) height; if (frameAspect > renderCamera.aspect) { int desired = (int) ((double) height * renderCamera.aspect); - info.bounds.width -= width - desired; - info.bounds.x += (width - desired) / 2; + object.clickInfo.bounds.width -= width - desired; + object.clickInfo.bounds.x += (width - desired) / 2; } else { int desired = (int) ((double) width / renderCamera.aspect); - info.bounds.height -= height - desired; - info.bounds.y += (height - desired) / 2; + object.clickInfo.bounds.height -= height - desired; + object.clickInfo.bounds.y += (height - desired) / 2; } } - info.g = gr; - info.camera = renderCamera; + + object.clickInfo.g = gr; + object.clickInfo.camera = renderCamera; /* // Memory intensive (brep.verticescopy) if (!(object instanceof Composite)) object.draw(info, 0, false); // SLOW : */ - if (!isRenderer) + if (!isRenderer) // && drag) { - object.drawEditHandles(info, 0); + Grafreed.Assert(object != null); + Grafreed.Assert(object.selection != null); + if (object.selection.Size() > 0) + { + int hitSomething = object.selection.get(0).hitSomething; + + object.clickInfo.DX = 0; + object.clickInfo.DY = 0; + object.clickInfo.W = 1; + if (hitSomething == Object3D.hitCenter) + { + 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, 0, 0); + 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); @@ -14679,6 +16161,7 @@ public boolean mouseDown(Event evt, int x, int y) { System.out.println("mouseDown: " + evt); + System.exit(0); /* locked = true; drag = false; @@ -14722,7 +16205,7 @@ { keyPressed(0, modifiers); } - clickStart(x, y, modifiers); + // clickStart(x, y, modifiers); return true; } @@ -14840,7 +16323,7 @@ { keyReleased(0, 0); } - drag(x, y, modifiers); + drag(x, y, 0, modifiers); return true; } @@ -14972,7 +16455,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; @@ -15257,16 +16740,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; @@ -15352,6 +16835,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 { @@ -15410,6 +16901,7 @@ { if (!selection) { + new Exception().printStackTrace(); System.exit(0); return; } @@ -15430,6 +16922,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(); @@ -15441,6 +16944,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 @@ -15488,6 +17002,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; @@ -15537,34 +17053,36 @@ 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 + 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; @@ -15603,6 +17121,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); } @@ -15702,7 +17225,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); @@ -15712,7 +17235,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); @@ -15772,7 +17295,6 @@ class AntialiasBuffer implements GLEventListener { - CameraPane parent = null; AntialiasBuffer(CameraPane p) @@ -16129,23 +17651,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++) @@ -16165,7 +17679,7 @@ } } - static void DrawPoints(CameraPane cpane) + static void DrawPoints(iCameraPane cpane) { for (int i=0; i<8; i++) // first and last are red { @@ -16197,10 +17711,11 @@ static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); // Depth buffer format //private int depth_format; - static public void NextIndex(Object3D o, GL gl) + + public void NextIndex() { indexcount+=16; - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); //objects[indexcount] = o; //System.out.println("indexcount = " + indexcount); } -- Gitblit v1.6.2