From 91106535bc5aa5e67cbb02a67cf6de1519cba0e4 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 22 Apr 2019 13:27:24 -0400 Subject: [PATCH] iCameraPane refactoring phase 1. --- CameraPane.java | 1017 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 877 insertions(+), 140 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index c50eebc..36fbe8d 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -31,8 +31,12 @@ import gleem.linalg.Mat4f; -class CameraPane extends GLCanvas implements Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener +class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener { + static cMaterial[] materialstack = new cMaterial[65536]; + static boolean[] selectedstack = new boolean[65536]; + static int materialdepth = 0; + static boolean DEBUG = false; static boolean FRUSTUM = false; // still bogus true; // frustum culling @@ -42,25 +46,7 @@ static int STEP = 1; - static boolean ONESTEP = false; // do LIVE once - - /** - * @return the LIVE - */ - public static boolean isLIVE() - { - return LIVE || ONESTEP; - } - - /** - * @param aLIVE the LIVE to set - */ - public static void setLIVE(boolean aLIVE) - { - LIVE = aLIVE; - } - - /*static*/ boolean CULLFACE = false; // true; + /*static*/ private boolean CULLFACE = false; // true; /*static*/ boolean NEAREST = false; // true; /*static*/ boolean WIREFRAME = false; // true; @@ -97,10 +83,8 @@ static boolean textureon = true; static boolean LOCALTRANSFORM = false; -private static boolean LIVE = false; static boolean FULLSCREEN = false; static boolean SUPPORT = true; -static boolean CROWD = false; static boolean INERTIA = true; static boolean FAST = false; static boolean SLOWPOSE = false; @@ -206,12 +190,14 @@ return CURRENTANTIALIAS > 0; } - void ClearDepth() + /// INTERFACE + + public void ClearDepth() { GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT); } - void DepthTest(boolean depthtest) + public void DepthTest(boolean depthtest) { if (depthtest) GetGL().glDepthFunc(GL.GL_LEQUAL); @@ -219,7 +205,7 @@ GetGL().glDepthFunc(GL.GL_ALWAYS); } - void DepthWrite(boolean depthwrite) + public void DepthWrite(boolean depthwrite) { if (depthwrite) GetGL().glDepthMask(true); @@ -227,12 +213,776 @@ GetGL().glDepthMask(false); } - void BackFaceCull(boolean bfc) + public void BackFaceCull(boolean bfc) { if (bfc) GetGL().glEnable(GetGL().GL_CULL_FACE); else GetGL().glDisable(GetGL().GL_CULL_FACE); + } + + public boolean BackFaceCullMode() + { + return this.CULLFACE; + } + + public boolean IsAmbientOcclusionOn() + { + return this.ambientOcclusion; + } + + public boolean IsFrozen() + { + boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; + + return !selectmode && cameracount == 0; // != 0; + } + + // Currently in Globals + public int DrawMode() + { + return Globals.DrawMode(); + } + + public Camera EyeCamera() + { + return eyeCamera; + } + + public Camera LightCamera() + { + return lightCamera; + } + + public Camera RenderCamera() + { + return renderCamera; + } + + public void PushMaterial(Object3D obj, boolean selected) + { + CameraPane display = this; + javax.media.opengl.GL gl = display.GetGL(); + cMaterial material = obj.material; + + if (material != null) + { + materialstack[materialdepth] = material; + selectedstack[materialdepth] = selected; + cStatic.objectstack[materialdepth++] = obj; + //System.out.println("material " + material); + //Applet3D.tracein(this, selected); + display.vector2buffer = obj.projectedVertices; + if (obj instanceof Camera) + { + display.options1[0] = material.shift; + //System.out.println("shift " + material.shift); + display.options1[1] = material.lightarea; + display.options1[2] = material.shadowbias; + display.options1[3] = material.aniso; + display.options1[4] = material.anisoV; + display.options2[0] = material.opacity; + display.options2[1] = material.diffuse; + display.options2[2] = material.factor; + + cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); + display.options4[0] = material.cameralight/0.2f; + display.options4[1] = material.subsurface; + display.options4[2] = material.sheen; + + // if (display.CURRENTANTIALIAS > 0) + // display.options3[3] /= 4; + + /* + System.out.println("Focus = " + display.options1[0]); + System.out.println("Aperture = " + display.options1[1]); + System.out.println("ShadowBlur = " + display.options1[2]); + System.out.println("Antialiasing = " + display.options1[3]); + System.out.println("Fog = " + display.options2[0]); + System.out.println("Intensity = " + display.options2[1]); + System.out.println("Elevation = " + display.options2[2]); + /**/ + } else + { + DrawMaterial(material, selected); + } + } else + { + if (selected && CameraPane.flash) + { + display.modelParams4[1] = 100; + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); + } + } + } + + public void PushMaterial2(Object3D obj, boolean selected) + { + CameraPane display = this; + cMaterial material = obj.material; + + if (material != null) + { + materialstack[materialdepth] = material; + selectedstack[materialdepth] = selected; + cStatic.objectstack[materialdepth++] = obj; + //System.out.println("material " + material); + //Applet3D.tracein("selected ", selected); + display.vector2buffer = obj.projectedVertices; + display.DrawMaterial(material, selected); + } + } + + public void PopMaterial(Object3D obj, boolean selected) + { + CameraPane display = this; + javax.media.opengl.GL gl = display.GetGL(); + cMaterial material = obj.material; + + //if (parent != null && parent.GetMaterial() != null) + // parent.GetMaterial().Draw(display, parent.IsSelected(this)); + if (material != null) + { + materialdepth -= 1; + if (materialdepth > 0) + { + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); + } + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); + } else if (selected && CameraPane.flash && obj.GetMaterial() != null) + { + display.modelParams4[1] = obj.GetMaterial().cameralight; + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); + } + } + + public void PopMaterial2(Object3D obj) + { + CameraPane display = this; + cMaterial material = obj.material; + + if (material != null) + { + materialdepth -= 1; + if (materialdepth > 0) + { + display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); + } + //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); + //else + //material.Draw(display, false); + } + } + + public void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face) + { + CameraPane display = this; + + if (pv.y == -10000 || + qv.y == -10000 || + rv.y == -10000) + return; + +// float b = f.nbiterations & 1; +// float g = (f.nbiterations>>1) & 1; +// float r = (f.nbiterations>>2) & 1; +// +// //if (f.weight == 10000) +// //{ +// // r = 1; g = b = 0; +// //} +// //else +// //{ +// // assert(f.weight < 10000); +// r = g = b = (float)bRep.FaceWeight(f)*100; +// if (r<0) +// assert(r>=0); +// //} + + javax.media.opengl.GL gl = display.GetGL(); + + boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; + + //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); + if (!hasnorm) + { + // System.out.println("FUCK!!"); + LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); + LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); + LA.vecCross(obj.v0, obj.v1, obj.v2); + LA.vecNormalize(obj.v2); + gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); + } + + // P + float x = (float)pv.x; + float y = (float)pv.y; + float z = (float)pv.z; + + if (hasnorm) + { +// if (!pv.norm.normalized()) +// assert(pv.norm.normalized()); + + //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); + float nx = (float)pv.norm.x; + float ny = (float)pv.norm.y; + float nz = (float)pv.norm.z; + + x += nx * obj.NORMALPUSH; + y += ny * obj.NORMALPUSH; + z += nz * obj.NORMALPUSH; + + gl.glNormal3f(nx, ny, nz); + } + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); + SetColor(obj, pv); + //gl.glColor4f(r, g, b, 1); + //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); + if (obj.flipV) + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); + else + gl.glTexCoord2f((float) pv.s, (float) pv.t); + //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); + + gl.glVertex3f(x, y, z); + + // Q + x = (float)qv.x; + y = (float)qv.y; + z = (float)qv.z; + +// Print(pv); + if (hasnorm) + { +// assert(qv.norm.normalized()); + //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); + float nx = (float)qv.norm.x; + float ny = (float)qv.norm.y; + float nz = (float)qv.norm.z; + + x += nx * obj.NORMALPUSH; + y += ny * obj.NORMALPUSH; + z += nz * obj.NORMALPUSH; + + gl.glNormal3f(nx, ny, nz); + } + //System.out.println("vertexq = " + qv.s + ", " + qv.t); + // boolean locked = false; + // float eps = 0.1f; + // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice + + // int dot = 0; //*/ (int)f.dot; + + // 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) + if (obj.flipV) + gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); + else + gl.glTexCoord2f((float) qv.s, (float) qv.t); + // else + // { + // locked = true; + // gl.glTexCoord2f((float) pv.s, (float) pv.t); + // } + gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); + SetColor(obj, qv); + + gl.glVertex3f(x, y, z); + //gl.glColor4f(r, g, b, 1); + //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); +// Print(qv); + + // R + x = (float)rv.x; + y = (float)rv.y; + z = (float)rv.z; + + if (hasnorm) + { +// assert(rv.norm.normalized()); + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); + float nx = (float)rv.norm.x; + float ny = (float)rv.norm.y; + float nz = (float)rv.norm.z; + + x += nx * obj.NORMALPUSH; + y += ny * obj.NORMALPUSH; + z += nz * obj.NORMALPUSH; + + gl.glNormal3f(nx, ny, nz); + } + + // 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) + if (obj.flipV) + gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); + else + gl.glTexCoord2f((float) rv.s, (float) rv.t); + // else + // gl.glTexCoord2f((float) pv.s, (float) pv.t); + + // f.dot = dot; + + gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); + SetColor(obj, rv); + //gl.glColor4f(r, g, b, 1); + //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); + //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); + gl.glVertex3f(x, y, z); +// Print(rv); + //gl.glEnd(); + } + else + { + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); + gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); + + } + + if (false) // (attributes & WIREFRAME) != 0) + { + gl.glDisable(gl.GL_LIGHTING); + + gl.glBegin(gl.GL_LINE_LOOP); + gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); + gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); + gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); + gl.glEnd(); + + gl.glEnable(gl.GL_LIGHTING); + } + } + + /// INTERFACE + + void SetColor(Object3D obj, Vertex p0) + { + CameraPane display = this; + BoundaryRep bRep = obj.bRep; + + if (RENDERPROGRAM == 0) + { + float r = 0; + if (bRep != null) + { + if (bRep.stripified) + { + r = 1; + } + } + float g = 0; + if (bRep != null) + { + if (bRep.trimmed) + { + g = 1; + } + } + float b = 0; + if (obj.support != null && obj.link2master) + { + b = 1; + } + display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); + return; + } + + if (display.DrawMode() != CameraPane.SHADOW) + return; + + javax.media.opengl.GL gl = display.GetGL(); +// if (true) return; +// float ao = p.AO; +// +// // if (ao == 0 && !bRep.AOdone) // transient problem! +// // ao = 1; +// +// gl.glColor4f(ao, ao, ao, 1); + +// CameraPane.selectedpoint. +// getAverage(cStatic.point1, true); + if (CameraPane.pointflow == null) // !random) // live) + { + return; + } + + cStatic.point1.set(0,0,0); + LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); + + cStatic.point1.sub(p0); + + +// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? +// { +// return; +// } + + //if (true) + if (cStatic.point1.dot(cStatic.point1) > 0.000001) + { + return; + } + + float[] colorV = new float[3]; + + if (false) // marked) + { + // debug rigging weights + for (int object = 0; object < p0.vertexlinks.length; object++) + { + float weight = p0.weights[object] / p0.totalweight; + + // if (weight < 0.1) + // { + // assert(weight == 0); + // continue; + // } + + if (p0.vertexlinks[object] == -1) + continue; + + Vertex q = obj.support.bRep.GetVertex(p0.vertexlinks[object]); + + int color = //1 << object; // + //p.vertexlinks.length; + obj.support.bRep.supports[p0.closestsupport].links[object]; + colorV[2] += (color & 1) * weight; + colorV[1] += ((color & 2) >> 1) * weight; + colorV[0] += ((color & 4) >> 2) * weight; + } + } + else + { + if (obj.drawingstarted) + { + // find next point + if (bRep.GetVertex(0).faceindices == null) + { + bRep.InitFaceIndices(); + } + + double ymin = p0.y; + + Vertex newp = p0; + + for (int fii = 0; fii < p0.faceindices.length; fii++) + { + int fi = p0.faceindices[fii]; + + if (fi == -1) + break; + + Face f = bRep.GetFace(fi); + + Vertex p = bRep.GetVertex(f.p); + Vertex q = bRep.GetVertex(f.q); + Vertex r = bRep.GetVertex(f.r); + + int swap = (int)(Math.random()*3); + +// for (int s=swap; --s>=0;) +// { +// Vertex t = p; +// p = q; +// q = r; +// r = t; +// } + if (ymin > p.y) + { + ymin = p.y; + newp = p; +// break; + } + if (ymin > q.y) + { + ymin = q.y; + newp = q; +// break; + } + if (ymin > r.y) + { + ymin = r.y; + newp = r; +// break; + } + } + + CameraPane.selectedpoint.toParent[3][0] = newp.x; + CameraPane.selectedpoint.toParent[3][1] = newp.y; + CameraPane.selectedpoint.toParent[3][2] = newp.z; + + obj.drawingstarted = false; + + // return; + } + + if (false) // CameraPane.DRAW + { + p0.AO = colorV[0] = 2; + colorV[1] = 2; + colorV[2] = 2; + } + + CameraPane.pointflow.add(p0); + CameraPane.pointflow.Touch(); + } + +// gl.glColor3f(colorV[0], colorV[1], colorV[2]); +// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); +// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); + } + + void DrawMaterial(cMaterial material, boolean selected) + { + CameraPane display = this; + //new Exception().printStackTrace(); + + if (display.IsFrozen() && !selected || display.IsAmbientOcclusionOn()) // || display.drawMode == display.SHADOW) + { + return; + } + + javax.media.opengl.GL gl = display.GetGL(); + + //Color col = Color.getHSBColor(color,modulation,1); + //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); + if (!material.multiply) + { + display.color = color; + display.saturation = material.modulation; + } + else + { + display.color *= color*2; + display.saturation *= material.modulation*2; + } + + cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); + + float[] colorV = GrafreeD.colorV; + + /**/ + if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) + { + 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; + + gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); + //System.out.println("Opacity = " + opacity); + + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); + //color[0] /= 2; color[1] /= 2; color[2] /= 2; + gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); + + float amb = material.ambient; + if (amb < material.cameralight) + { + amb = material.cameralight; + } + colorV[0] = display.modelParams0[0] * material.diffuse * amb; + colorV[1] = display.modelParams0[1] * material.diffuse * amb; + colorV[2] = display.modelParams0[2] * material.diffuse * amb; + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, colorV, 0); + //color[0] /= 2; color[1] /= 2; color[2] /= 2; + gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT, colorV, 0); + + /**/ + colorV[0] = ((1 - material.metalness) + display.modelParams0[0] * material.metalness) * material.specular; + colorV[1] = ((1 - material.metalness) + display.modelParams0[1] * material.metalness) * material.specular; + colorV[2] = ((1 - material.metalness) + display.modelParams0[2] * material.metalness) * material.specular; + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, colorV, 0); + //color[0] /= 2; color[1] /= 2; color[2] /= 2; + gl.glMaterialfv(gl.GL_BACK, gl.GL_SPECULAR, colorV, 0); + colorV[0] = 10 / material.shininess; // 1/0.005f; + //System.out.println("shininess = " + colorV[0]); + if (colorV[0] > 128) + { + colorV[0] = 128; + } + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, colorV, 0); + gl.glMaterialfv(gl.GL_BACK, gl.GL_SHININESS, colorV, 0); + /**/ + } + /**/ + + //selected = false; + selected = selected && display.flash; + + //display.modelParams0[0] = 0; // pigment.r; + //display.modelParams0[1] = 0; // pigment.g; + //display.modelParams0[2] = 0; // pigment.b; + if (!material.multiply) + { + display.modelParams0[3] = material.metalness; + display.modelParams1[0] = material.diffuse; + display.modelParams1[1] = material.specular; + display.modelParams1[2] = 1 / material.shininess; + display.modelParams1[3] = material.shift; + display.modelParams2[0] = material.ambient; + display.modelParams2[1] = material.lightarea; + //System.out.println("light area = " + lightarea); + display.modelParams2[2] = 1 / material.factor; // diffuseness + display.modelParams2[3] = material.velvet; + display.modelParams3[0] = material.sheen; + display.modelParams3[1] = material.subsurface; + display.modelParams3[2] = material.bump; // backlit + display.modelParams3[3] = material.aniso; + display.modelParams4[0] = material.anisoV; + display.modelParams4[1] = selected ? 100 : material.cameralight; + //System.out.println("selected = " + selected); + display.modelParams4[2] = material.diffuseness; + display.modelParams4[3] = material.shadow; + display.modelParams5[0] = material.texture; + display.modelParams5[1] = material.opacity; + display.modelParams5[2] = material.fakedepth; + display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (material.shadowbias - 0.005f) / 10; + } + else + { + display.modelParams0[3] *= material.metalness*2; + display.modelParams1[0] *= material.diffuse*2; + display.modelParams1[1] *= material.specular*2; + display.modelParams1[2] *= material.shininess*2; + display.modelParams1[3] *= material.shift*2; + display.modelParams2[0] *= material.ambient*2; + display.modelParams2[1] *= material.lightarea*2; + display.modelParams2[2] *= material.factor*2; + display.modelParams2[3] *= material.velvet*2; + display.modelParams3[0] *= material.sheen*2; + display.modelParams3[1] *= material.subsurface*2; + display.modelParams3[2] *= material.bump*2; + display.modelParams3[3] *= material.aniso*2; + display.modelParams4[0] *= material.anisoV*2; + display.modelParams4[1] *= material.cameralight*2; + //System.out.println("selected = " + selected); + display.modelParams4[2] *= material.diffuseness*2; + display.modelParams4[3] *= material.shadow*2; + display.modelParams5[0] *= material.texture*2; + display.modelParams5[1] *= material.opacity*2; + display.modelParams5[2] *= material.fakedepth*2; + display.modelParams5[3] *= material.shadowbias*2; + } + + display.modelParams6[0] = 0; + display.modelParams6[1] = 0; + display.modelParams6[2] = 0; + display.modelParams6[3] = 0; + + display.modelParams7[0] = 0; + display.modelParams7[1] = 1000; + display.modelParams7[2] = 0; + display.modelParams7[3] = 0; + + display.modelParams6[0] = 100; // criss de bug de bump + + Object3D.cVector2[] extparams = display.vector2buffer; + if (extparams != null && extparams.length > 0 && extparams[0] != null) + { + display.modelParams6[0] = extparams[0].x / 1000.0f; // bump + display.modelParams6[1] = extparams[0].y / 1000.0f; // noise + if (extparams.length > 1) + { + display.modelParams6[2] = extparams[1].x / 1000.0f; // borderfade + display.modelParams6[3] = extparams[1].y / 1000.0f; // (float)Math.exp(-extparams[1].y / 1000.0f); // fog punchthrough + if (extparams.length > 2) + { + display.modelParams7[0] = extparams[2].x / 1000.0f; // noise power + float x = extparams[2].y / 1000.0f; + //if (x == 0) + // x = 1f; + display.modelParams7[1] = 1 / x / x / x / x / x / x / x / x / x / x / x / x / x; // (float)Math.pow(-Math.log((extparams[2].y+0.00) / 1000.0f), 1); // opacity power + if (extparams[2].y > 0) + { + //System.out.println("extparams[1].y = " + extparams[1].y); + //System.out.println("extparams[2].y = " + extparams[2].y); + //System.out.println("opacity power = " + display.modelParams7[1]); + } + } + } + } + + //if (display.modelParams6[2] != 0) + /* + System.out.println("modelParams0[0] = " + display.modelParams0[0]); + System.out.println("modelParams0[1] = " + display.modelParams0[1]); + System.out.println("modelParams0[2] = " + display.modelParams0[2]); + System.out.println("modelParams0[3] = " + display.modelParams0[3]); + System.out.println("modelParams1[0] = " + display.modelParams1[0]); + System.out.println("modelParams1[1] = " + display.modelParams1[1]); + System.out.println("modelParams1[2] = " + display.modelParams1[2]); + System.out.println("modelParams1[3] = " + display.modelParams1[3]); + System.out.println("modelParams2[0] = " + display.modelParams2[0]); + System.out.println("modelParams2[1] = " + display.modelParams2[1]); + System.out.println("modelParams2[2] = " + display.modelParams2[2]); + System.out.println("modelParams2[3] = " + display.modelParams2[3]); + System.out.println("modelParams3[0] = " + display.modelParams3[0]); + System.out.println("modelParams3[1] = " + display.modelParams3[1]); + System.out.println("modelParams3[2] = " + display.modelParams3[2]); + System.out.println("modelParams3[3] = " + display.modelParams3[3]); + System.out.println("modelParams4[0] = " + display.modelParams4[0]); + System.out.println("modelParams4[1] = " + display.modelParams4[1]); + System.out.println("modelParams4[2] = " + display.modelParams4[2]); + System.out.println("modelParams4[3] = " + display.modelParams4[3]); + System.out.println("modelParams5[0] = " + display.modelParams5[0]); + System.out.println("modelParams5[1] = " + display.modelParams5[1]); + System.out.println("modelParams5[2] = " + display.modelParams5[2]); + System.out.println("modelParams5[3] = " + display.modelParams5[3]); + System.out.println("modelParams6[0] = " + display.modelParams6[0]); + System.out.println("modelParams6[1] = " + display.modelParams6[1]); + System.out.println("modelParams6[2] = " + display.modelParams6[2]); + System.out.println("modelParams6[3] = " + display.modelParams6[3]); + System.out.println("modelParams7[0] = " + display.modelParams7[0]); + System.out.println("modelParams7[1] = " + display.modelParams7[1]); + System.out.println("modelParams7[2] = " + display.modelParams7[2]); + System.out.println("modelParams7[3] = " + display.modelParams7[3]); + /**/ + //assert (display.modelParams6[2] == 0); + + //System.out.println("noise power = " + display.modelParams7[0]); + //System.out.println("shadowbias = " + shadowbias); + + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 1, display.modelParams1, 0); + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 2, display.modelParams2, 0); + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 3, display.modelParams3, 0); + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 6, display.modelParams6, 0); + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 7, display.modelParams7, 0); + + int mode = display.FP_SHADER; + + if (material.aniso != material.anisoV || material.aniso > 0.002) + { + mode |= display.FP_ANISO; + } + + display.EnableProgram(mode); + + //System.out.println("opacity power = " + display.modelParams7[1]); + + if (!material.multiply) + { + if (Globals.drawMode == CameraPane.SHADOW) + gl.glDepthMask(material.opacity >= 0.9 && display.modelParams7[1] > 0.1); + else + gl.glDepthMask(material.opacity >= 0.99); + } } int matrixdepth = 0; // 10000; // CONFLICT WITH cMESH... WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!!!!!!! 0; @@ -253,7 +1003,7 @@ currentGL.glMultMatrixd(model, 0); } - void PushMatrix(double[][] matrix, int count) + public void PushMatrix(double[][] matrix, int count) // INTERFACE { matrixdepth++; // GrafreeD.tracein(matrix); @@ -298,7 +1048,7 @@ double[][] tmpmat = new double[4][4]; - void PopMatrix(double[][] inverse) + public void PopMatrix(double[][] inverse) // INTERFACE { --matrixdepth; @@ -338,7 +1088,7 @@ PushTextureMatrix(matrix, 1); } - void PushTextureMatrix(double[][] matrix, int count) + public void PushTextureMatrix(double[][] matrix, int count) // INTERFACE { currentGL.glActiveTexture(GetGL().GL_TEXTURE0); @@ -352,7 +1102,7 @@ currentGL.glMatrixMode(GetGL().GL_MODELVIEW); } - void PopTextureMatrix(double[][] inverse) + public void PopTextureMatrix(double[][] inverse) // INTERFACE { currentGL.glActiveTexture(GetGL().GL_TEXTURE0); currentGL.glMatrixMode(GetGL().GL_TEXTURE); @@ -384,10 +1134,10 @@ // may 2014 if (cam == cameras[0] || cam == cameras[1]) // return false; - if (REFUSEMODE && isLIVE() && camerachangeframe != 0 && camerachangeframe != framecount) + if (REFUSEMODE && Globals.isLIVE() && camerachangeframe != 0 && camerachangeframe != Globals.framecount) { // check for last change - if (framecount < camerachangeframe + 400) // 120 == 1 second + if (Globals.framecount < camerachangeframe + 400) // 120 == 1 second { // refuse the camera change System.err.println("Camera " + cam + " REFUSED"); @@ -395,7 +1145,7 @@ } } - camerachangeframe = framecount; + camerachangeframe = Globals.framecount; cam.hAspect = -1; // Read only @@ -426,7 +1176,7 @@ { //System.err.println("Oeil on"); TRACK = true; -// JUNE 2014 if (TRACK && trackedobject != null && drawMode == SHADOW) // && !lightMode) +// JUNE 2014 if (TRACK && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) // object.editWindow.ScreenFit(trackedobject); //pingthread.StepToTarget(true); } @@ -435,7 +1185,7 @@ { //System.err.println("Oeil on"); OEIL = true; - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); //pingthread.StepToTarget(true); } @@ -499,7 +1249,7 @@ { frozen ^= true; // Weird... - lighttouched = true; + Globals.lighttouched = true; } void ToggleDL() @@ -514,11 +1264,11 @@ void ToggleLive() { - setLIVE(isLIVE() ^ true); + Globals.setLIVE(Globals.isLIVE() ^ true); - System.err.println("LIVE = " + isLIVE()); + System.err.println("LIVE = " + Globals.isLIVE()); - if (!isLIVE()) // save sound + if (!Globals.isLIVE()) // save sound GrafreeD.savesound = true; // wav.save(); // else repaint(); // start loop // may 2013 @@ -541,7 +1291,7 @@ void ToggleCrowd() { - CROWD ^= true; + Globals.CROWD ^= true; } void ToggleInertia() @@ -759,7 +1509,7 @@ GL currentGL; - GL GetGL() + public GL GetGL() // INTERFACE { return currentGL; } @@ -6271,7 +7021,7 @@ return null; } - void ReleaseTextures(cTexture tex) + public void ReleaseTextures(cTexture tex) // INTERFACE { if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) { @@ -6309,7 +7059,7 @@ void ReleaseTexture(String tex, boolean bump) { - if (// drawMode != 0 || /*tex == null ||*/ + if (// DrawMode() != 0 || /*tex == null ||*/ ambientOcclusion ) // || !textureon) { return; @@ -6410,9 +7160,9 @@ } } - /*boolean*/ void BindTextures(cTexture tex, int resolution) + /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE { - if (// drawMode != 0 || /*tex == null ||*/ + if (// DrawMode() != 0 || /*tex == null ||*/ ambientOcclusion ) // || !textureon) { return; // false; @@ -7312,9 +8062,9 @@ static boolean occlusionInitialized = false; boolean selection = false; boolean pointselection = false; - /*static*/ boolean lighttouched = true; + ///*static*/ boolean lighttouched = true; boolean deselect; - boolean ambientOcclusion = false; + private boolean ambientOcclusion = false; static boolean flash = false; /*static*/ boolean wait = false; boolean displaydone = false; // after repaint() calls @@ -7603,8 +8353,6 @@ boolean restartframe = false; - static int framecount = 0; // general-purpose global count - void displayAntiAliased(javax.media.opengl.GL gl) { //gl.glGetIntegerv(gl.GL_ACCUM_RED_BITS, viewport, 0); @@ -7635,7 +8383,7 @@ gl.glClear(gl.GL_ACCUM_BUFFER_BIT); for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0) { - framecount++; + Globals.framecount++; if (CameraPane.tickcount > 0) CameraPane.tickcount--; @@ -7673,7 +8421,7 @@ gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, pos, 0); */ - lighttouched = true; + Globals.lighttouched = true; //System.err.println(" shadowbuffer: " + jitter); shadowbuffer.display(); @@ -8620,13 +9368,6 @@ } } - boolean IsFrozen() - { - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; - - return !selectmode && cameracount == 0; // != 0; - } - boolean niceon = false; javax.swing.Timer AAtimer = new javax.swing.Timer(750, this); boolean currentlydrawing = false; @@ -8644,8 +9385,8 @@ } // if (DEBUG_SELECTION) // { -// if (drawMode != SELECTION) -// drawMode = SELECTION; +// if (DrawMode() != SELECTION) +// DrawMode() = SELECTION; // } if (!isRenderer) @@ -8701,9 +9442,9 @@ //ANTIALIAS = 0; - if (drawMode == DEFAULT) // && CURRENTANTIALIAS > 0) + if (DrawMode() == DEFAULT) // && CURRENTANTIALIAS > 0) { - if (niceon || isLIVE()) + if (niceon || Globals.isLIVE()) { //if(active == 0) // antialiaser = null; @@ -8728,7 +9469,7 @@ assert eyeCamera.shaper_zFar == 1E5f; // 500.0f; */ - if (drawMode == DEFAULT) + if (DrawMode() == DEFAULT) { currentlydrawing = true; } @@ -8759,12 +9500,12 @@ // if(Applet3D.clipboard != null) // System.out.println("Clipboard = " + Applet3D.clipboard); //.get(0).parent); -//drawMode = SELECTION; +//DrawMode() = SELECTION; indexcount = 0; - if (drawMode == OCCLUSION) + if (DrawMode() == OCCLUSION) { - drawMode = DEFAULT; + Globals.drawMode = DEFAULT; // WARNING ambientOcclusion = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); Object3D theobject = object; @@ -8783,19 +9524,19 @@ ambientOcclusion = false; } - if (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 && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) { - framecount++; + Globals.framecount++; shadowbuffer.display(); } } - lighttouched = false; // ?? + Globals.lighttouched = false; // ?? //drawing = true; //lighttouched = true; } @@ -8816,9 +9557,9 @@ //eyeCamera.shaper_fovy = 1; } - if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && drawMode == DEFAULT) // SELECTION) + if ((RENDERPROGRAM != 0 || ambientOcclusion || spherical) && DrawMode() == DEFAULT) // SELECTION) { - //System.out.println("drawMode = " + drawMode); + //System.out.println("DrawMode() = " + DrawMode()); vertexMode |= VP_PASS; //vertexMode |= VP_PROJECTION; if (!ambientOcclusion) @@ -8878,7 +9619,7 @@ Camera cam = renderCamera; // lightMode?lightCamera:eyeCamera; //Camera lightcam = new Camera(light0); - if (drawMode == SHADOW) + if (DrawMode() == SHADOW) { /* gl.glMatrixMode(GL.GL_MODELVIEW); @@ -8968,7 +9709,7 @@ gl.glClear(gl.GL_DEPTH_BUFFER_BIT); } else { - if (drawMode != DEFAULT) + if (DrawMode() != DEFAULT) { gl.glClearColor(1, 1, 1, 0); } // 1); @@ -9033,7 +9774,7 @@ fast &= !ambientOcclusion; - if (drawMode == DEFAULT) + if (DrawMode() == DEFAULT) { //gl.glEnable(gl.GL_ALPHA_TEST); //gl.glActiveTexture(GL.GL_TEXTURE0); @@ -9231,7 +9972,7 @@ gl.glMatrixMode(gl.GL_PROJECTION); gl.glLoadIdentity(); - if (drawMode == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) + if (DrawMode() == SHADOW || cam == lightCamera) // || (vertexMode&VP_PROJECTION) != 0) { //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); double scale = lightCamera.SCALE / lightCamera.Distance(); @@ -9289,7 +10030,7 @@ //gl.glPushMatrix(); gl.glLoadIdentity(); - if (!ambientOcclusion) // drawMode != OCCLUSION) + if (!ambientOcclusion) // DrawMode() != OCCLUSION) { //LA.xformPos(light0, lightCamera.fromScreen, light); LA.xformDir(dirlight, lightCamera.fromScreen, lightposition); @@ -9376,7 +10117,7 @@ } /**/ - if (true) // drawMode == SELECTION) // != DEFAULT) + if (true) // DrawMode() == SELECTION) // != DEFAULT) gl.glDisable(gl.GL_LIGHTING); else gl.glEnable(gl.GL_LIGHTING); @@ -9394,7 +10135,7 @@ lightslot = 64; - if (!frozen && !ambientOcclusion && isRenderer && drawMode == DEFAULT) + if (!frozen && !ambientOcclusion && isRenderer && DrawMode() == DEFAULT) { DrawLights(object); } @@ -9405,7 +10146,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 || DEBUG_SELECTION) { /* if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) @@ -9438,7 +10179,7 @@ } } - if (drawMode == DEFAULT) + if (DrawMode() == DEFAULT) { if (WIREFRAME && !ambientOcclusion) { @@ -9456,7 +10197,7 @@ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); - if (!fast/*RENDERPROGRAM != 0*/ && (drawMode == DEFAULT || drawMode == SHADOW)) // && !WIREFRAME) // + if (!fast/*RENDERPROGRAM != 0*/ && (DrawMode() == DEFAULT || DrawMode() == SHADOW)) // && !WIREFRAME) // { if (vertexMode != 0) // && !fast) { @@ -9476,7 +10217,7 @@ } } - if (false) // fast && !IsFreezed() && drawMode != SELECTION && !ambientOcclusion) + if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) { //gl.glDepthFunc(GL.GL_LEQUAL); //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); @@ -9504,7 +10245,7 @@ //gl.glDepthMask(false); } - if (false) // drawMode == SHADOW) + if (false) // DrawMode() == SHADOW) { //SetColumnMajorData(cameraInverseTransform, view_1); //System.out.println("light = " + cameraInverseTransform); @@ -9518,16 +10259,16 @@ //System.out.println("object = " + object); if (!frozen && !imageLocked) { - if (!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0) + if (!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0) { displayAntiAliased(gl); } else { programcount = 0; - int keepmode = drawMode; + int keepmode = DrawMode(); // if (DEBUG_SELECTION) // { -// drawMode = SELECTION; +// DrawMode() = SELECTION; // } // for point selection // gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, tempmat, 0); @@ -9537,10 +10278,10 @@ DrawObject(gl); // jan 2013 System.err.println("RESET ABORT (display)"); - // if (drawMode == DEFAULT) + // if (DrawMode() == DEFAULT) // ABORTED = false; fullreset = false; - drawMode = keepmode; + Globals.drawMode = keepmode; // WARNING //System.out.println("PROGRAM SWITCH " + programcount); } } @@ -9548,11 +10289,11 @@ gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); - if (drawMode == DEFAULT) + if (DrawMode() == DEFAULT) { ReleaseTexture(NOISE_TEXTURE, false); } - //if (drawMode == DEFAULT) + //if (DrawMode() == DEFAULT) { gl.glActiveTexture(GL.GL_TEXTURE1); @@ -9564,7 +10305,7 @@ //else //gl.glDisable(gl.GL_TEXTURE_2D); //gl.glPopMatrix(); - if (imageCompleted && ANTIALIAS > 0 && drawMode == DEFAULT && cam != lightCamera && !ambientOcclusion) + if (imageCompleted && ANTIALIAS > 0 && DrawMode() == DEFAULT && cam != lightCamera && !ambientOcclusion) { //new Exception().printStackTrace(); //System.out.println("Draw image " + width + ", " + height); @@ -9606,7 +10347,7 @@ //gl.glFlush(); } - if (flash && drawMode == DEFAULT) + if (flash && DrawMode() == DEFAULT) { flash = false; wait = true; @@ -9614,9 +10355,9 @@ } //drawing = false; - //if(drawMode == DEFAULT) + //if(DrawMode() == DEFAULT) // niceon = false; - if (drawMode == DEFAULT) + if (DrawMode() == DEFAULT) { currentlydrawing = false; } @@ -9636,7 +10377,7 @@ repaint(); } - if (isLIVE() && drawMode == DEFAULT) // may 2013 + if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 repaint(); displaydone = true; @@ -9673,7 +10414,7 @@ if (GrafreeD.RENDERME > 0) GrafreeD.RENDERME--; // mechante magouille - ONESTEP = false; + Globals.ONESTEP = false; } static boolean zoomonce = false; @@ -9681,11 +10422,11 @@ void DrawObject(GL gl, boolean draw) { //System.out.println("DRAW OBJECT " + mouseDown); -// drawMode = SELECTION; +// DrawMode() = SELECTION; //GL gl = getGL(); if ((TRACK || SHADOWTRACK) || zoomonce) { - if ((TRACK || SHADOWTRACK) && trackedobject != null && drawMode == SHADOW) // && !lightMode) + if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); pingthread.StepToTarget(true); // true); // zoomonce = false; @@ -9706,9 +10447,9 @@ callist = gl.glGenLists(1); } - boolean selectmode = drawMode == SELECTION || CameraPane.DEBUG_SELECTION; + boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; - boolean active = !selectmode; // drawMode != SELECTION; // mouseDown; + boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; if (!mainDL || !active || touched) { @@ -9735,7 +10476,7 @@ PushMatrix(ClickInfo.matbuffer); } - if (drawMode == 0) + if (DrawMode() == 0) { // System.out.println("CLEAR +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++"); @@ -9749,7 +10490,7 @@ // DRAW object.draw(this, /*(Composite)*/ object, false, false); - if (drawMode == DEFAULT) + if (DrawMode() == DEFAULT) { if (DEBUG) { @@ -9801,7 +10542,7 @@ } // GrafreeD.traceoff(); //System.out.println(stackdepth); - if (drawMode == 0) + if (DrawMode() == 0) { ReleaseTextures(DEFAULT_TEXTURES); @@ -9826,10 +10567,10 @@ checker = null; - if (!ambientOcclusion && !IsFrozen() && drawMode == DEFAULT) + if (!ambientOcclusion && !IsFrozen() && DrawMode() == DEFAULT) FindChecker(object); - if (checker != null && drawMode == DEFAULT) + if (checker != null && DrawMode() == DEFAULT) { //BindTexture(IMMORTAL_TEXTURE); BindTextures(checker.GetTextures(), checker.texres); @@ -9851,7 +10592,7 @@ //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); //gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); - if (DISPLAYTEXT && drawMode == DEFAULT) + if (DISPLAYTEXT && DrawMode() == DEFAULT) { // Draw it once, then use the raster Balloon(gl, balloon.createGraphics()); @@ -9907,9 +10648,9 @@ int[] xs = new int[3]; int[] ys = new int[3]; - void DrawString(Object3D obj) // String string) + public void DrawString(Object3D obj) // String string) // INTERFACE { - if (!DISPLAYTEXT || drawMode != DEFAULT) + if (!DISPLAYTEXT || DrawMode() != DEFAULT) { return; } @@ -12068,7 +12809,7 @@ // ObjEditor.tweenManager.update(1f / 60f); // fev 2014??? - if ((TRACK || SHADOWTRACK) && trackedobject != null) // && drawMode == SHADOW) // && !lightMode) + if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); pingthread.StepToTarget(true); // true); } @@ -12319,7 +13060,7 @@ //System.out.println("---------------- ---------- Paint " + tmp.length2()); if (lightMode) { - lighttouched = true; + Globals.lighttouched = true; } if (OEILONCE && OEIL) @@ -12377,7 +13118,7 @@ mouseDown = false; if (lightMode) { - lighttouched = true; + Globals.lighttouched = true; } repaint(); alreadypainted = true; @@ -12385,7 +13126,7 @@ isMoving = false; } //?? - if (isLIVE() && !alreadypainted) + if (Globals.isLIVE() && !alreadypainted) { // FOR DEBUG BREAKPOINT USING PAUSE: while (true) repaint(); @@ -12397,7 +13138,7 @@ { if (lightMode) { - lighttouched = true; + Globals.lighttouched = true; } drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); } @@ -12651,7 +13392,7 @@ if (manipCamera == lightCamera) { - lighttouched = true; + Globals.lighttouched = true; } /* switch (mode) @@ -13039,7 +13780,7 @@ case 'B': BRISMOOTH ^= true; SHADOWCULLFACE ^= true; - lighttouched = true; + Globals.lighttouched = true; repaint(); break; case 'b': @@ -13139,7 +13880,7 @@ repaint(); break; case 'O': - drawMode = OCCLUSION; + Globals.drawMode = OCCLUSION; // WARNING repaint(); break; case 'o': @@ -13230,7 +13971,7 @@ break; case ' ': lightMode ^= true; - lighttouched = true; + Globals.lighttouched = true; manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; targetLookAt.set(manipCamera.lookAt); repaint(); @@ -13246,7 +13987,7 @@ //break; case 'z': RENDERSHADOW ^= true; - lighttouched = true; + Globals.lighttouched = true; repaint(); break; //case UP: @@ -13848,6 +14589,7 @@ //if (g != gr) g.drawImage(img, 0, 0, width, height, null); } + // To avoid clear. public void update(Graphics g) { paint(g); @@ -14510,20 +15252,21 @@ /**/ //checker.GetMaterial().opacity = 1.1f; ////checker.GetMaterial().ambient = 0.99f; - Object3D.materialstack[Object3D.materialdepth] = checker.material; - Object3D.selectedstack[Object3D.materialdepth] = false; - cStatic.objectstack[Object3D.materialdepth++] = checker; + materialstack[materialdepth] = checker.material; + selectedstack[materialdepth] = false; + cStatic.objectstack[materialdepth++] = checker; //System.out.println("material " + material); //Applet3D.tracein(this, selected); vector2buffer = checker.projectedVertices; - checker.GetMaterial().Draw(this, false); // true); + //checker.GetMaterial().Draw(this, false); // true); + DrawMaterial(checker.GetMaterial(), false); // true); - Object3D.materialdepth -= 1; - if (Object3D.materialdepth > 0) + materialdepth -= 1; + if (materialdepth > 0) { - vector2buffer = cStatic.objectstack[Object3D.materialdepth - 1].projectedVertices; - Object3D.materialstack[Object3D.materialdepth - 1].Draw(this, Object3D.selectedstack[Object3D.materialdepth - 1]); + vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); } //checker.GetMaterial().opacity = 1f; ////checker.GetMaterial().ambient = 1f; @@ -14689,14 +15432,14 @@ //int tmp = selection_view; //selection_view = -1; - int temp = drawMode; - drawMode = SELECTION; + int temp = DrawMode(); + Globals.drawMode = SELECTION; // WARNING indexcount = 0; parent.display(drawable); //selection_view = tmp; //if (temp == SELECTION) // temp = DEFAULT; // patch for selection debug - drawMode = temp; + Globals.drawMode = temp; // WARNING //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); @@ -14969,14 +15712,14 @@ //gl.glColorMask(false, false, false, false); //render_scene_from_light_view(gl, drawable, 0, 0); - if (RENDERSHADOW && lighttouched && !movingcamera) // && !parent.IsFreezed()) + if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - int temp = drawMode; - drawMode = SHADOW; + int temp = DrawMode(); + Globals.drawMode = SHADOW; // WARNING parent.display(drawable); - drawMode = temp; + Globals.drawMode = temp; // WARNING } gl.glCullFace(gl.GL_BACK); @@ -15374,12 +16117,6 @@ GLUT glut = new GLUT(); - static final public int DEFAULT = 0; - static final public int SELECTION = 1; - static final public int SHADOW = 2; - static final public int OCCLUSION = 3; - static - public int drawMode = DEFAULT; public boolean spherical = false; static boolean DEBUG_OCCLUSION = false; static boolean DEBUG_SELECTION = false; -- Gitblit v1.6.2