From 07750666120cf38c7ad4f3a3a583a8c4d582bb0e Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Tue, 23 Apr 2019 22:30:47 -0400 Subject: [PATCH] Cross-platform main. --- BoundaryRep.java | 112 +++++++++---------------------------------------------- 1 files changed, 19 insertions(+), 93 deletions(-) diff --git a/BoundaryRep.java b/BoundaryRep.java index d786a91..cbdb1a9 100644 --- a/BoundaryRep.java +++ b/BoundaryRep.java @@ -15,7 +15,7 @@ { this(0, 0); } - + void SaveSupports() { transientsupport = support; @@ -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); @@ -2661,18 +2661,18 @@ if (false) // slow && stepout && onein) { // sound - cVector eye = CameraPane.theRenderer.eyeCamera.location; + cVector eye = Globals.theRenderer.EyeCamera().location; Vertex v = GetVertex(0); 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; @@ -4428,7 +4428,7 @@ } } - void CullVertex(javax.media.opengl.GL gl, boolean shadow) + void CullVertex(javax.media.opengl.GL glNOTUSED, boolean shadowNOTUSED) { CameraPane.glu.gluProject(vect5.x,vect5.y,vect5.z, CameraPane.tempmat,0, CameraPane.tempmat2,0, @@ -4460,14 +4460,14 @@ // june 2014 // Camera parentcam = cam; // -// if (cam == CameraPane.theRenderer.cameras[0]) +// if (cam == Globals.theRenderer.cameras[0]) // { -// parentcam = CameraPane.theRenderer.cameras[1]; +// parentcam = Globals.theRenderer.cameras[1]; // } // -// if (cam == CameraPane.theRenderer.cameras[1]) +// if (cam == Globals.theRenderer.cameras[1]) // { -// parentcam = CameraPane.theRenderer.cameras[0]; +// parentcam = Globals.theRenderer.cameras[0]; // } gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, CameraPane.tempmat, 0); @@ -4893,7 +4893,7 @@ return verticesCopy; } - void PreprocessOcclusion(CameraPane cp, double[][] transform) + void PreprocessOcclusion(iCameraPane cp, double[][] transform) { if (//!trimmed || AOdone) @@ -4902,80 +4902,7 @@ return; } - Camera keep = cp.renderCamera; - cp.renderCamera = localcamera; - - if (trimmed) - { - float[] colors = new float[positions.length / 3]; - - int i3 = 0; - for (int i = 0; i < positions.length / 3; i++, i3 += 3) - { - if (normals[i3] == 0 && normals[i3+1] == 0 && normals[i3+2] == 0) - continue; - - from.set(positions[i3], positions[i3 + 1], positions[i3 + 2]); - to.set(positions[i3] + normals[i3], - positions[i3 + 1] + normals[i3 + 1], - positions[i3 + 2] + normals[i3 + 2]); - LA.xformPos(from, transform, from); - LA.xformPos(to, transform, to); // RIGID ONLY - localcamera.setAim(from, to); - - CameraPane.occlusionbuffer.display(); - - if (CameraPane.DEBUG_OCCLUSION) - cp.display(); // debug - - colors[i] = cp.vertexOcclusion.r; - //colors[i3 + 1] = cp.vertexOcclusion.g; - //colors[i3 + 2] = cp.vertexOcclusion.b; - - if ((i % 100) == 0 && i != 0) - { - CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); - //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); - System.out.println((int) (100.0 * i / (positions.length / 3)) + "% (" + i + " of " + (positions.length / 3) + ")"); - } - } - - this.colors = colors; - } - else - { - for (int i = 0; i < VertexCount(); i++) - { - Vertex v = GetVertex(i); - - if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) - continue; - - from.set(v.x, v.y, v.z); - to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); - LA.xformPos(from, transform, from); - LA.xformPos(to, transform, to); // RIGID ONLY - localcamera.setAim(from, to); - - CameraPane.occlusionbuffer.display(); - - if (CameraPane.DEBUG_OCCLUSION) - cp.display(); // debug - - v.AO = cp.vertexOcclusion.r; - - if ((i % 100) == 0 && i != 0) - { - CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); - //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); - System.out.println((int) (100.0 * i / VertexCount()) + "% (" + i + " of " + VertexCount() + ")"); - } - } - } - - //System.out.println("done."); - - cp.renderCamera = keep; + cp.PrepOcclusion(this, transform); AOdone = true; } @@ -7633,7 +7560,7 @@ s3 = new cVector(); } - CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); try { @@ -7728,7 +7655,7 @@ { if (i++%100 == 0) { - CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); System.out.println("#faces = " + faces.size()); // if (i != 1) // break; @@ -7772,7 +7699,7 @@ //Trim(true,cJME.gennormals,true,false); // doesn't work Trim(true,false,false,false,false); - CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR)); + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR)); } void UpdateIndices(Face face, Face minface) @@ -8354,9 +8281,6 @@ return "trim = " + trimmed + "; stripped = " + stripified + "; colors = " + colors + "; faces = " + (faces!=null?faces.size():null) + "; triangles = " + (triangles!=null?triangles.length:null) + "; indices = " + indices; } - static Camera localcamera = new Camera(); - static cVector from = new cVector(); - static cVector to = new cVector(); boolean trimmed = false; boolean stripified = false; transient boolean AOdone = false; @@ -8364,8 +8288,10 @@ /*transient*/ int maxIndexV = 0; /*transient*/ int bufV, bufF; // Raw version - private float[] positions; - private float[] normals; + //private + float[] positions; + //private + float[] normals; float[] colors; private float[] uvmap; private int[] triangles; -- Gitblit v1.6.2