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. --- ObjEditor.java | 5 MorphNode.java | 2 cMaterial.java | 476 ++++++------ BezierPatch.java | 2 BlobComponent.java | 2 ScriptNode.java | 6 cMesh.java | 2 iCameraPane.java | 53 + CameraPane.java | 1017 +++++++++++++++++++++++--- PhysicsNode.java | 2 GroupEditor.java | 15 BillboardNode.java | 4 VehicleDemo.java | 2 BezierSurface.java | 2 SwitchNode.java | 4 Biparam.java | 2 Mocap.java | 8 Composite.java | 6 GenericJoint.java | 2 BoundaryRep.java | 6 cLinker.java | 6 Attribute.java | 6 Globals.java | 26 cSpring.java | 8 cFileSystemPane.java | 2 ParticleNode.java | 4 Object3D.java | 524 +------------- 27 files changed, 1,281 insertions(+), 913 deletions(-) diff --git a/Attribute.java b/Attribute.java index 2988035..670dda4 100644 --- a/Attribute.java +++ b/Attribute.java @@ -45,13 +45,13 @@ editWindow = objectUI.GetEditor(); } - void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) + void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { if (hide) return; // super.draw(display, root, selected); - if (display.ambientOcclusion) + if (display.IsAmbientOcclusionOn()) return; if (cleardepth) @@ -64,7 +64,7 @@ if (backfacecull) display.BackFaceCull(true); else - display.BackFaceCull(display.CULLFACE); + display.BackFaceCull(display.BackFaceCullMode()); } boolean cleardepth; diff --git a/BezierPatch.java b/BezierPatch.java index 246e44e..294bdec 100644 --- a/BezierPatch.java +++ b/BezierPatch.java @@ -60,7 +60,7 @@ } /**/ - void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) + void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { //recalculate(); //System.out.println(); diff --git a/BezierSurface.java b/BezierSurface.java index 2f28e09..7cd1fca 100644 --- a/BezierSurface.java +++ b/BezierSurface.java @@ -67,7 +67,7 @@ return l; } - void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) + void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { // ((BezierSurface)parent.parent).currentHandle = (Sphere)this; // parent.parent.recalculate(); diff --git a/BillboardNode.java b/BillboardNode.java index ea1cb8e..e38d956 100644 --- a/BillboardNode.java +++ b/BillboardNode.java @@ -21,9 +21,9 @@ cVector pos = new cVector(); - void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) + void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { - cVector eye = display.eyeCamera.location; + cVector eye = display.EyeCamera().location; GlobalTransformInv(); diff --git a/Biparam.java b/Biparam.java index b4468b2..67ef12f 100644 --- a/Biparam.java +++ b/Biparam.java @@ -16,7 +16,7 @@ CreateMaterial(); } - void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected) + void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) { //System.out.println("#vertices = " + bRep.VertexCount()); if(false) diff --git a/BlobComponent.java b/BlobComponent.java index 39aae19..dc3a512 100644 --- a/BlobComponent.java +++ b/BlobComponent.java @@ -140,7 +140,7 @@ info.g.drawArc(spot.x + 1, spot.y + 1, spot.width - 2, spot.height - 2, 0, 360); } - void draw(CameraPane display, boolean selected) + void draw(iCameraPane display, boolean selected) { } */ diff --git a/BoundaryRep.java b/BoundaryRep.java index d786a91..655d595 100644 --- a/BoundaryRep.java +++ b/BoundaryRep.java @@ -790,7 +790,7 @@ v.weights[k] = other.ComputeWeight(v, toRoot, k); // (float)(supportsize * normalweight * nz / Math.pow(tx*tx+ty*ty+tz*tz, 1)); v.totalweight += v.weights[k]; - if (CameraPane.CROWD) + if (Globals.CROWD) { // System.out.print("weight = " + v.weights[k]); // System.out.println("; totalweight = " + v.totalweight); @@ -2668,11 +2668,11 @@ tmp.set(v); tmp.sub(eye); - if (CameraPane.framecount - lastsoundtime > 30) // 0.25 secs + if (Globals.framecount - lastsoundtime > 30) // 0.25 secs { GrafreeD.wav.play((Math.random()+0.5)/Math.max(tmp.length2(),0.2)); //, 1); - lastsoundtime = CameraPane.framecount; + lastsoundtime = Globals.framecount; } stepout = false; 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; diff --git a/Composite.java b/Composite.java index 2a20ab9..6156d60 100644 --- a/Composite.java +++ b/Composite.java @@ -822,7 +822,7 @@ } - void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) + void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { if (this instanceof BezierPatch) { @@ -837,7 +837,7 @@ } if ((//display.drawMode == CameraPane.SHADOW || - display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && + display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && //HasTransparency()) // SERIAL PATCH // if (viewCode == -1) @@ -855,7 +855,7 @@ cTexture tex = null; - boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION; + boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; if (//display.drawMode != display.SHADOW && !selectmode // display.drawMode != display.SELECTION diff --git a/GenericJoint.java b/GenericJoint.java index 0e2ebd5..b6d18be 100644 --- a/GenericJoint.java +++ b/GenericJoint.java @@ -339,7 +339,7 @@ // assert(bRep != null); - if (display.isLIVE() && live && display.drawMode == display.SHADOW) // FUCK + if (Globals.isLIVE() && live && display.DrawMode() == display.SHADOW) // FUCK { // float ms = getDeltaTimeMicroseconds(); // float minFPS = 1000000f / 60f; diff --git a/Globals.java b/Globals.java new file mode 100644 index 0000000..0e4465b --- /dev/null +++ b/Globals.java @@ -0,0 +1,26 @@ + +public class Globals +{ +static boolean CROWD = false; + static public int drawMode = iCameraPane.DEFAULT; // WARNING + static public boolean lighttouched = false; // WARNING + + static int framecount = 0; // general-purpose global count + private static boolean LIVE = false; + static boolean ONESTEP = false; // do LIVE once + + public static boolean isLIVE() + { + return LIVE || ONESTEP; + } + + public static void setLIVE(boolean aLIVE) + { + LIVE = aLIVE; + } + + public static int DrawMode() + { + return drawMode; + } +} diff --git a/GroupEditor.java b/GroupEditor.java index da3ecc4..7cc81e0 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -437,7 +437,7 @@ oe.aConstraints.gridwidth = 1; oe.aConstraints.gridx = 0; - oe.toolbarPanel.add(liveCB = new cCheckBox("Live", CameraPane.isLIVE()), oe.aConstraints); + oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE()), oe.aConstraints); liveCB.addItemListener(this); oe.aConstraints.gridx += 1; @@ -449,7 +449,7 @@ // localCB.addItemListener(this); oe.aConstraints.gridx += 1; - oe.toolbarPanel.add(crowdCB = new cCheckBox("Crowd", CameraPane.CROWD), oe.aConstraints); + oe.toolbarPanel.add(crowdCB = new cCheckBox("Crowd", Globals.CROWD), oe.aConstraints); crowdCB.addItemListener(this); oe.aConstraints.gridx += 1; @@ -1782,7 +1782,7 @@ } else if (event.getSource() == computeAOItem) { - CameraPane.drawMode = CameraPane.OCCLUSION; + Globals.drawMode = CameraPane.OCCLUSION; CameraPane.theRenderer.repaint(); } else if (event.getSource() == recompileItem) @@ -2920,7 +2920,8 @@ cameraView.cameras[cameraView.cameracount] = radio.camera; cameraView.targetLookAt.set(radio.camera.lookAt); cameraView.object = group; - cameraView.lighttouched = true; + //cameraView.lighttouched = true; + Globals.lighttouched = true; topView.object = group; frontView.object = group; sideView.object = group; @@ -2956,7 +2957,7 @@ if (useclient) { cameraView.object = client; - cameraView.lighttouched = true; + Globals.lighttouched = true; //topView.object = client; //frontView.object = client; //sideView.object = client; @@ -2964,7 +2965,7 @@ else { cameraView.object = group; - cameraView.lighttouched = true; + Globals.lighttouched = true; //topView.object = group; //frontView.object = group; //sideView.object = group; @@ -4058,7 +4059,7 @@ objEditor.SetText(); // jan 2014 - if (flashIt && !CameraPane.isLIVE() && tps != null && tps.length > 0 && !(((Object3D) tps[0].getLastPathComponent()) instanceof Camera)) + if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(((Object3D) tps[0].getLastPathComponent()) instanceof Camera)) CameraPane.flash = true; if (tps != null && tps.length > 0 && ((Object3D) tps[0].getLastPathComponent()) instanceof Camera) diff --git a/Mocap.java b/Mocap.java index f451172..931d1e6 100644 --- a/Mocap.java +++ b/Mocap.java @@ -1564,7 +1564,7 @@ //GraphreeD. wav.play(volume * usedvolume); //, mywave); - lastsoundtime = CameraPane.framecount; + lastsoundtime = Globals.framecount; GrafreeD.hassound = true; } @@ -3289,7 +3289,7 @@ "; fullname = " + fullname); //int delta = frame - baseframe; - if (CameraPane.CROWD) + if (Globals.CROWD) { baseframe = GetFirstFrame(); // 0 initial point } @@ -3871,7 +3871,7 @@ // return; if (!restarted && /*display.restartframe &&*/ - display.isLIVE() && live && display.drawMode == display.SHADOW) // FUCK + Globals.isLIVE() && live && display.DrawMode() == display.SHADOW) // FUCK { //display.restartframe = false; restarted = true; @@ -3879,7 +3879,7 @@ } else { - if (display.isLIVE() && live && display.drawMode != display.SHADOW) + if (Globals.isLIVE() && live && display.DrawMode() != display.SHADOW) restarted = false; } diff --git a/MorphNode.java b/MorphNode.java index f11562e..c783c97 100644 --- a/MorphNode.java +++ b/MorphNode.java @@ -59,7 +59,7 @@ // bRep = (BoundaryRep) GrafreeD.clone(morphobject.get(0).bRep); // } - if (CameraPane.SUPPORT && display.drawMode == display.SHADOW) + if (CameraPane.SUPPORT && display.DrawMode() == display.SHADOW) { for (int i=0; i<morphobject.Size(); i++) { diff --git a/ObjEditor.java b/ObjEditor.java index 25a20ef..884881a 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -311,7 +311,7 @@ toggleTextureItem.setState(CameraPane.textureon); cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live")); toggleLiveItem.addItemListener(this); - toggleLiveItem.setState(CameraPane.isLIVE()); + toggleLiveItem.setState(Globals.isLIVE()); cameraMenu.add(stepItem = new MenuItem("Step")); stepItem.addActionListener(this); // cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List")); @@ -3139,7 +3139,8 @@ objEditor.refreshContents(); } else if (event.getSource() == stepItem) { - cameraView.ONESTEP = true; + //cameraView.ONESTEP = true; + Globals.ONESTEP = true; cameraView.repaint(); return; } else if (event.getSource() == stepButton) diff --git a/Object3D.java b/Object3D.java index 8a39641..18fd57e 100644 --- a/Object3D.java +++ b/Object3D.java @@ -760,7 +760,7 @@ int GetTransformCount() { - // marde pour serialization de Texture + // patch pour serialization de Texture resetmaxcount(); resettransformcount(); resetstep(); @@ -794,12 +794,12 @@ // factor = CameraPane.STEP; // } - if (marked && CameraPane.isLIVE() && live && + if (marked && Globals.isLIVE() && live && //TEMP21aug2018 - CameraPane.drawMode == CameraPane.SHADOW && - currentframe != CameraPane.framecount) + Globals.DrawMode() == iCameraPane.SHADOW && + currentframe != Globals.framecount) { - currentframe = CameraPane.framecount; + currentframe = Globals.framecount; // System.err.println("transformcount = " + transformcount); // System.err.println("factor = " + factor); @@ -5001,7 +5001,8 @@ } else // if (editWindow != null) { - editWindow.cameraView.lighttouched = true; + //editWindow.cameraView.lighttouched = true; + Globals.lighttouched = true; } } @@ -5313,25 +5314,21 @@ } } - void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) + void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { Draw(display, root, selected, blocked); } - static cMaterial[] materialstack = new cMaterial[65536]; - static boolean[] selectedstack = new boolean[65536]; - static int materialdepth = 0; - boolean NeedSupport() { return CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null // PROBLEM with CROWD!! - && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD); + && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD); } - void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) + void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { Invariants(); // june 2013 @@ -5340,7 +5337,7 @@ // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame); } - if (display.drawMode == CameraPane.SELECTION && + if (display.DrawMode() == iCameraPane.SELECTION && hide) return; @@ -5359,7 +5356,7 @@ if (this instanceof Checker) return; - if (display.drawMode == display.SHADOW && PASSTEST) + if (display.DrawMode() == display.SHADOW && PASSTEST) return; if (count <= 0) @@ -5367,8 +5364,8 @@ return; } - if ((//display.drawMode == CameraPane.SHADOW || - display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency()) + if ((//display.DrawMode() == CameraPane.SHADOW || + display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency()) { return; } @@ -5409,15 +5406,15 @@ boolean compiled = false; - boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION; + boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; - if (!selectmode && //display.drawMode != display.SELECTION && + if (!selectmode && //display.DrawMode() != display.SELECTION && (touched || (bRep != null && bRep.displaylist <= 0))) { - display.lighttouched = true; + Globals.lighttouched = true; } // all panes... - //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW && - if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW && + //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && + if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && (touched || (bRep != null && bRep.displaylist <= 0))) { if (!(this instanceof Composite)) @@ -5448,7 +5445,7 @@ } //gl.glDrawBuffer(gl.GL_BACK); // XXX touched = false; - display.lighttouched = true; // all panes... + Globals.lighttouched = true; // all panes... } touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false; @@ -5487,12 +5484,12 @@ // frustum culling if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid - && display.drawMode != CameraPane.SELECTION) + && display.DrawMode() != CameraPane.SELECTION) { - if (display.drawMode == CameraPane.SHADOW) + if (display.DrawMode() == CameraPane.SHADOW) { if (!link2master // tricky to cull in shadow mode. - && GetBRep().FrustumCull(this, gl, display.lightCamera, true)) + && GetBRep().FrustumCull(this, gl, display.LightCamera(), true)) { //System.out.print("CULLED"); culled = true; @@ -5500,7 +5497,7 @@ } else //GetBRep().getBounds(v0, v1, this); - if (GetBRep().FrustumCull(this, gl, display.renderCamera, false)) + if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false)) culled = true; // LA.xformPos(v0, display.renderCamera.toScreen, v0); @@ -5536,7 +5533,7 @@ if (!culled) - if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION) + if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION) { if (GetBRep() != null) { @@ -5562,55 +5559,7 @@ color[2] /= 2; gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0); */ - if (material != null) - { - materialstack[materialdepth] = material; - selectedstack[materialdepth] = selected; - cStatic.objectstack[materialdepth++] = this; - //System.out.println("material " + material); - //Applet3D.tracein(this, selected); - display.vector2buffer = projectedVertices; - if (this 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 - { - material.Draw(display, selected); - } - } else - { - if (selected && CameraPane.flash) - { - display.modelParams4[1] = 100; - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); - } - } + display.PushMaterial(this, selected); //System.out.println("call list " + list); //System.out.println(); @@ -5652,23 +5601,8 @@ } display.ReleaseTextures(tex); - - //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; - materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]); - } - //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); - } else if (selected && CameraPane.flash && GetMaterial() != null) - { - display.modelParams4[1] = GetMaterial().cameralight; - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); - } + + display.PopMaterial(this, selected); } if (this instanceof Texture || this instanceof TextureNode) @@ -5710,7 +5644,7 @@ // resetMasterNode(); } - void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) + void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { if (GetBRep() == null) { @@ -5793,7 +5727,7 @@ boolean flipV = false; // true; int texres = 0; // 0 = low, 1 = normal, 2 = high res texture - void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) + void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { if (hide) return; @@ -5852,16 +5786,7 @@ // // ??????????????????????????? Touch(); // } - if (material != null) - { - materialstack[materialdepth] = material; - selectedstack[materialdepth] = selected; - cStatic.objectstack[materialdepth++] = this; - //System.out.println("material " + material); - //Applet3D.tracein("selected ", selected); - display.vector2buffer = projectedVertices; - material.Draw(display, selected); - } +display.PushMaterial2(this, selected); Object3D child; boolean sel; @@ -5913,19 +5838,7 @@ */ //depth += 1; - if (material != null) - { - materialdepth -= 1; - if (materialdepth > 0) - { - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; - materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]); - } - //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); - //else - //material.Draw(display, false); - } - +display.PopMaterial2(this); /* display.ReleaseTextures(tex); */ @@ -5936,9 +5849,9 @@ //static cVector min,max; - void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected) + void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) { - if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) + if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) return; // no shadow for transparent objects if (hide) @@ -6060,7 +5973,7 @@ { //throw new Error(); - boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION; + boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; int[] strips = bRep.getRawIndices(); @@ -6304,7 +6217,7 @@ // // r.norm.dot(v3) > -0.5) // // continue; - drawFace(p, q, r, display, face); + display.DrawFace(this, p, q, r, face); } gl.glEnd(); } @@ -6348,7 +6261,7 @@ Vertex q = bRep.GetVertex(face.q); Vertex r = bRep.GetVertex(face.r); - drawFace(p, q, r, display, face); + display.DrawFace(this, p, q, r, face); } gl.glEnd(); } @@ -6488,180 +6401,6 @@ transient FaceCompare[] facescompare = null; - void SetColor(CameraPane display, Vertex p0) - { - if (display.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 (support != null && 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 = support.bRep.GetVertex(p0.vertexlinks[object]); - - int color = //1 << object; // - //p.vertexlinks.length; - 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 (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; - - 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 Print(Vertex v) { //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")"); @@ -6683,195 +6422,6 @@ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); } - void drawFace(Vertex pv, Vertex qv, Vertex rv, - CameraPane display, Face face) - { - 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*/, v0); - LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1); - LA.vecCross(v0, v1, v2); - LA.vecNormalize(v2); - gl.glNormal3f((float) v2.x, (float) v2.y, (float) 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 * NORMALPUSH; - y += ny * NORMALPUSH; - z += nz * NORMALPUSH; - - gl.glNormal3f(nx, ny, nz); - } - gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); - SetColor(display, pv); - //gl.glColor4f(r, g, b, 1); - //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); - if (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 * NORMALPUSH; - y += ny * NORMALPUSH; - z += nz * 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 (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(display, 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 * NORMALPUSH; - y += ny * NORMALPUSH; - z += nz * 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 (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(display, 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); - } - } - void drawSelf(ClickInfo info, int level, boolean select) { if (bRep == null) diff --git a/ParticleNode.java b/ParticleNode.java index 5ed427e..e05819c 100644 --- a/ParticleNode.java +++ b/ParticleNode.java @@ -346,7 +346,7 @@ void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected) // ?? { - if (display.drawMode == display.SELECTION || display.BOXMODE) + if (display.DrawMode() == display.SELECTION || display.BOXMODE) return; // hum... Object3D geo = test; @@ -354,7 +354,7 @@ if (support != null && link2master) geo = support; - if (live && display.isLIVE() && display.drawMode == display.SHADOW) // june 2013 + if (live && Globals.isLIVE() && display.DrawMode() == display.SHADOW) // june 2013 { Step(); } diff --git a/PhysicsNode.java b/PhysicsNode.java index 50d34d6..97369ee 100644 --- a/PhysicsNode.java +++ b/PhysicsNode.java @@ -110,7 +110,7 @@ void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { - if (display.isLIVE() && live && display.drawMode == display.SHADOW) // FUCK + if (Globals.isLIVE() && live && display.DrawMode() == display.SHADOW) // FUCK { float ms = getDeltaTimeMicroseconds(); float minFPS = 1000000f / 60f; diff --git a/ScriptNode.java b/ScriptNode.java index 1315df0..4dbb2ca 100644 --- a/ScriptNode.java +++ b/ScriptNode.java @@ -538,13 +538,13 @@ } if (command.equals("stoplive") || command.equals("liveoff")) { - if (CameraPane.isLIVE()) + if (Globals.isLIVE()) CameraPane.theRenderer.ToggleLive(); return; } if (command.equals("startlive") || command.equals("liveon")) { - if (!CameraPane.isLIVE()) + if (!Globals.isLIVE()) CameraPane.theRenderer.ToggleLive(); return; } @@ -1793,7 +1793,7 @@ return; } - if (isLive() && display.isLIVE() && display.drawMode == display.SHADOW) + if (isLive() && Globals.isLIVE() && Globals.drawMode == display.SHADOW) { if (reader == null) Init(); diff --git a/SwitchNode.java b/SwitchNode.java index fc726c6..0297c96 100644 --- a/SwitchNode.java +++ b/SwitchNode.java @@ -57,7 +57,7 @@ parent = super.parent; } - if (live && display.isLIVE() && display.drawMode == display.SHADOW) + if (live && Globals.isLIVE() && display.DrawMode() == display.SHADOW) { if (countspeed == 0) { @@ -100,7 +100,7 @@ bRep = (BoundaryRep) GrafreeD.clone(switchobject.get(0).bRep); } - if (CameraPane.SUPPORT && display.drawMode == display.SHADOW) + if (CameraPane.SUPPORT && display.DrawMode() == display.SHADOW) { Update(); } diff --git a/VehicleDemo.java b/VehicleDemo.java index 583d8ae..1641446 100755 --- a/VehicleDemo.java +++ b/VehicleDemo.java @@ -490,7 +490,7 @@ renderme(display); - if (display.isLIVE()) // && display.drawMode != display.SHADOW) + if (Globals.isLIVE()) // && display.drawMode != display.SHADOW) { float ms = getDeltaTimeMicroseconds(); float minFPS = 1000000f / 60f; diff --git a/cFileSystemPane.java b/cFileSystemPane.java index 8bd7ccd..ccd740b 100644 --- a/cFileSystemPane.java +++ b/cFileSystemPane.java @@ -235,7 +235,7 @@ System.out.println("drop2 = " + dtde + "; drop : " + target); //assert dropTarget == dtde.getSource(); - if (target instanceof CameraPane) + if (target instanceof iCameraPane) { Object object = null; try diff --git a/cLinker.java b/cLinker.java index ec1d652..5441199 100644 --- a/cLinker.java +++ b/cLinker.java @@ -29,12 +29,12 @@ editWindow = objectUI.GetEditor(); } - void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) + void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { //if(count <= 0) // return; - if(display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION) + if(display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION) { super.draw(display, root, selected, blocked); return; @@ -134,7 +134,7 @@ //System.out.println("point = " + cStatic.point7); LA.matConcat(cStatic.matrix1, cStatic.cone[d].toParent, cStatic.cone[d].toParent); - if (display.matrixdepth >= display.MAXSTACK) + if (false) // TODO display.matrixdepth >= display.MAXSTACK) { LA.matRotate(cStatic.cone[d].fromParent, cStatic.point8, cStatic.point7); LA.matRotate(cStatic.sphere[d].fromParent, cStatic.point8, cStatic.point7); diff --git a/cMaterial.java b/cMaterial.java index 06f35ec..14519fe 100644 --- a/cMaterial.java +++ b/cMaterial.java @@ -118,244 +118,244 @@ return current / anchor; } - void Draw(CameraPane display, boolean selected) - { - //new Exception().printStackTrace(); - - if (display.IsFrozen() && !selected || display.ambientOcclusion) // || 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 (!multiply) - { - display.color = color; - display.saturation = modulation; - } - else - { - display.color *= color*2; - display.saturation *= 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] * diffuse; - colorV[1] = display.modelParams0[1] * diffuse; - colorV[2] = display.modelParams0[2] * diffuse; - colorV[3] = opacity; - - gl.glColor4f(colorV[0], colorV[1], colorV[2], 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 = ambient; - if (amb < cameralight) - { - amb = cameralight; - } - colorV[0] = display.modelParams0[0] * diffuse * amb; - colorV[1] = display.modelParams0[1] * diffuse * amb; - colorV[2] = display.modelParams0[2] * 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 - metalness) + display.modelParams0[0] * metalness) * specular; - colorV[1] = ((1 - metalness) + display.modelParams0[1] * metalness) * specular; - colorV[2] = ((1 - metalness) + display.modelParams0[2] * metalness) * 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 / 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 (!multiply) - { - display.modelParams0[3] = metalness; - display.modelParams1[0] = diffuse; - display.modelParams1[1] = specular; - display.modelParams1[2] = 1 / shininess; - display.modelParams1[3] = shift; - display.modelParams2[0] = ambient; - display.modelParams2[1] = lightarea; - //System.out.println("light area = " + lightarea); - display.modelParams2[2] = 1 / factor; // diffuseness - display.modelParams2[3] = velvet; - display.modelParams3[0] = sheen; - display.modelParams3[1] = subsurface; - display.modelParams3[2] = bump; // backlit - display.modelParams3[3] = aniso; - display.modelParams4[0] = anisoV; - display.modelParams4[1] = selected ? 100 : cameralight; - //System.out.println("selected = " + selected); - display.modelParams4[2] = diffuseness; - display.modelParams4[3] = shadow; - display.modelParams5[0] = texture; - display.modelParams5[1] = opacity; - display.modelParams5[2] = fakedepth; - display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (shadowbias - 0.005f) / 10; - } - else - { - display.modelParams0[3] *= metalness*2; - display.modelParams1[0] *= diffuse*2; - display.modelParams1[1] *= specular*2; - display.modelParams1[2] *= shininess*2; - display.modelParams1[3] *= shift*2; - display.modelParams2[0] *= ambient*2; - display.modelParams2[1] *= lightarea*2; - display.modelParams2[2] *= factor*2; - display.modelParams2[3] *= velvet*2; - display.modelParams3[0] *= sheen*2; - display.modelParams3[1] *= subsurface*2; - display.modelParams3[2] *= bump*2; - display.modelParams3[3] *= aniso*2; - display.modelParams4[0] *= anisoV*2; - display.modelParams4[1] *= cameralight*2; - //System.out.println("selected = " + selected); - display.modelParams4[2] *= diffuseness*2; - display.modelParams4[3] *= shadow*2; - display.modelParams5[0] *= texture*2; - display.modelParams5[1] *= opacity*2; - display.modelParams5[2] *= fakedepth*2; - display.modelParams5[3] *= 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 (aniso != anisoV || aniso > 0.002) - { - mode |= display.FP_ANISO; - } - - display.EnableProgram(mode); - - //System.out.println("opacity power = " + display.modelParams7[1]); - - if (!multiply) - { - if (display.drawMode == CameraPane.SHADOW) - gl.glDepthMask(opacity >= 0.9 && display.modelParams7[1] > 0.1); - else - gl.glDepthMask(opacity >= 0.99); - } - } +// void Draw(iCameraPane display, boolean selected) +// { +// //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 (!multiply) +// { +// display.color = color; +// display.saturation = modulation; +// } +// else +// { +// display.color *= color*2; +// display.saturation *= 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] * diffuse; +// colorV[1] = display.modelParams0[1] * diffuse; +// colorV[2] = display.modelParams0[2] * diffuse; +// colorV[3] = opacity; +// +// gl.glColor4f(colorV[0], colorV[1], colorV[2], 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 = ambient; +// if (amb < cameralight) +// { +// amb = cameralight; +// } +// colorV[0] = display.modelParams0[0] * diffuse * amb; +// colorV[1] = display.modelParams0[1] * diffuse * amb; +// colorV[2] = display.modelParams0[2] * 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 - metalness) + display.modelParams0[0] * metalness) * specular; +// colorV[1] = ((1 - metalness) + display.modelParams0[1] * metalness) * specular; +// colorV[2] = ((1 - metalness) + display.modelParams0[2] * metalness) * 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 / 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 (!multiply) +// { +// display.modelParams0[3] = metalness; +// display.modelParams1[0] = diffuse; +// display.modelParams1[1] = specular; +// display.modelParams1[2] = 1 / shininess; +// display.modelParams1[3] = shift; +// display.modelParams2[0] = ambient; +// display.modelParams2[1] = lightarea; +// //System.out.println("light area = " + lightarea); +// display.modelParams2[2] = 1 / factor; // diffuseness +// display.modelParams2[3] = velvet; +// display.modelParams3[0] = sheen; +// display.modelParams3[1] = subsurface; +// display.modelParams3[2] = bump; // backlit +// display.modelParams3[3] = aniso; +// display.modelParams4[0] = anisoV; +// display.modelParams4[1] = selected ? 100 : cameralight; +// //System.out.println("selected = " + selected); +// display.modelParams4[2] = diffuseness; +// display.modelParams4[3] = shadow; +// display.modelParams5[0] = texture; +// display.modelParams5[1] = opacity; +// display.modelParams5[2] = fakedepth; +// display.modelParams5[3] = CameraPane.SHADOWCULLFACE ? 0f : (shadowbias - 0.005f) / 10; +// } +// else +// { +// display.modelParams0[3] *= metalness*2; +// display.modelParams1[0] *= diffuse*2; +// display.modelParams1[1] *= specular*2; +// display.modelParams1[2] *= shininess*2; +// display.modelParams1[3] *= shift*2; +// display.modelParams2[0] *= ambient*2; +// display.modelParams2[1] *= lightarea*2; +// display.modelParams2[2] *= factor*2; +// display.modelParams2[3] *= velvet*2; +// display.modelParams3[0] *= sheen*2; +// display.modelParams3[1] *= subsurface*2; +// display.modelParams3[2] *= bump*2; +// display.modelParams3[3] *= aniso*2; +// display.modelParams4[0] *= anisoV*2; +// display.modelParams4[1] *= cameralight*2; +// //System.out.println("selected = " + selected); +// display.modelParams4[2] *= diffuseness*2; +// display.modelParams4[3] *= shadow*2; +// display.modelParams5[0] *= texture*2; +// display.modelParams5[1] *= opacity*2; +// display.modelParams5[2] *= fakedepth*2; +// display.modelParams5[3] *= 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 (aniso != anisoV || aniso > 0.002) +// { +// mode |= display.FP_ANISO; +// } +// +// display.EnableProgram(mode); +// +// //System.out.println("opacity power = " + display.modelParams7[1]); +// +// if (!multiply) +// { +// if (display.drawMode == CameraPane.SHADOW) +// gl.glDepthMask(opacity >= 0.9 && display.modelParams7[1] > 0.1); +// else +// gl.glDepthMask(opacity >= 0.99); +// } +// } float color = 0.5f, modulation /*SATURATION*/ = 0.001f, metalness = 0.001f; float diffuse = 0.75f, specular = 0.25f, shininess = 0.75f, shift = 1; diff --git a/cMesh.java b/cMesh.java index 942d155..c2eb4ad 100644 --- a/cMesh.java +++ b/cMesh.java @@ -644,7 +644,7 @@ gl.glEnable(gl.GL_LIGHTING); } - if (live && display.isLIVE() && display.drawMode == CameraPane.DEFAULT) + if (live && Globals.isLIVE() && display.DrawMode() == CameraPane.DEFAULT) { //System.out.println("UPDATE"); if (Phys == null) diff --git a/cSpring.java b/cSpring.java index 445f1ac..fcf1d91 100644 --- a/cSpring.java +++ b/cSpring.java @@ -10,7 +10,7 @@ boolean IsStatic() { - return !(live && (CameraPane.isLIVE() || CameraPane.waslive)); + return !(live && (Globals.isLIVE() || CameraPane.waslive)); } void Revert() @@ -569,7 +569,7 @@ //gl.glDisable(GL.GL_LIGHTING); - if (display.drawMode == display.SHADOW) + if (display.DrawMode() == display.SHADOW) { gl.glDisable(gl.GL_CULL_FACE); } @@ -762,7 +762,7 @@ gl.glEnd(); gl.glEnable(GL.GL_LIGHTING); /**/ - if (display.CULLFACE) + if (display.BackFaceCullMode()) { gl.glEnable(gl.GL_CULL_FACE); } @@ -775,7 +775,7 @@ // displaylist = 0; // june 2013 -1; //System.out.println("DRAW " + display.drawMode); - if (live && display.isLIVE() && display.drawMode == display.DEFAULT) + if (live && Globals.isLIVE() && display.DrawMode() == display.DEFAULT) { //System.out.println("UPDATE"); Phys.update(); diff --git a/iCameraPane.java b/iCameraPane.java new file mode 100644 index 0000000..5fa0b77 --- /dev/null +++ b/iCameraPane.java @@ -0,0 +1,53 @@ + +public interface iCameraPane +{ + static final public int DEFAULT = 0; + static final public int SELECTION = 1; + static final public int SHADOW = 2; + static final public int OCCLUSION = 3; + + void ClearDepth(); + + void DepthTest(boolean depthtest); + + void DepthWrite(boolean depthwrite); + + void BackFaceCull(boolean bfc); + + boolean BackFaceCullMode(); + + boolean IsAmbientOcclusionOn(); + + boolean IsFrozen(); + + javax.media.opengl.GL GetGL(); + + // Currently in Globals + int DrawMode(); + + void PushMatrix(double[][] matrix, int count); + void PopMatrix(double[][] matrix); + + void PushTextureMatrix(double[][] matrix, int count); + void PopTextureMatrix(double[][] matrix); + + Camera EyeCamera(); + + Camera LightCamera(); + + Camera RenderCamera(); + + // Should be cMaterial + void PushMaterial(Object3D obj, boolean selected); + void PushMaterial2(Object3D obj, boolean selected); + + void PopMaterial(Object3D obj, boolean selected); + void PopMaterial2(Object3D obj); + + void DrawString(Object3D obj); + + void BindTextures(cTexture tex, int resolution); + void ReleaseTextures(cTexture tex); + + void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face); +} -- Gitblit v1.6.2