From cb37a129d1adb403019c96e798e86e2da9667f15 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 17 Nov 2019 17:56:04 -0500 Subject: [PATCH] Maze --- cMesh.java | 130 ++++++------------------------------------ 1 files changed, 20 insertions(+), 110 deletions(-) diff --git a/cMesh.java b/cMesh.java index 24ad433..e79623b 100644 --- a/cMesh.java +++ b/cMesh.java @@ -1,6 +1,6 @@ import java.util.Hashtable; -import javax.media.opengl.GL; +//import javax.media.opengl.GL; public class cMesh extends cSpring { @@ -49,7 +49,7 @@ cMesh(Object3D bRep) { - this("Me:" + bRep.name, bRep); + this("Mesh:" + bRep.name, bRep); } cMesh(String name, Object3D bRep) @@ -78,7 +78,7 @@ live = true; } - + Object3D deepCopy() { /* @@ -355,7 +355,9 @@ // DynamicNode handle = new DynamicNode(center.x, center.y, center.z, 0 /*0 , 1 or Float.MAX_VALUE*/, 0); // Phys.addHandle(handle); - for (int k=Phys.allNodes.size(); --k>=0;) // warning: "add handle" adds a node + int size = Phys.allNodes.size(); + + for (int k=0; k < size; k++) // warning: "add handle" adds a node { DynamicNode dn = Phys.allNodes.get(k); DynamicNode handle = new DynamicNode(dn.position.x, dn.position.y, dn.position.z, 0 /*0 , 1 or Float.MAX_VALUE*/, 0); @@ -402,8 +404,8 @@ if (ref == null) return; - GraphreeD.epsequal = IsEpsEqual(); - GraphreeD.linkUV = IsLinkUV(); + Grafreed.epsequal = IsEpsEqual(); + Grafreed.linkUV = IsLinkUV(); // BoundaryRep oldrep = transientrep; @@ -415,19 +417,21 @@ ref.count = 1; Object3D obj = ref.GetObject(); + Object3D par = obj.parent; + obj.parent = null; // may 2014: side-effect with UVs!! - obj = (Object3D) GraphreeD.clone(obj); - - merge(obj); + merge((Object3D) Grafreed.clone(obj)); + obj.parent = par; + ref.count = keepcount; System.out.println("RESULT " + ref + "; #vertices = " + bRep.VertexCount() + "; #faces = " + bRep.FaceCount()); bRep.Trim(false, false,false,false,false); System.out.println("------> TRIM " + ref + "; #vertices = " + bRep.VertexCount() + "; #faces = " + bRep.FaceCount()); - GraphreeD.epsequal = false; + Grafreed.epsequal = false; if (transientrep != null && bRep.VertexCount() == transientrep.VertexCount()) { @@ -468,7 +472,7 @@ } else // geometry is merged... - refcopy = (BoundaryRep) GraphreeD.clone(transientrep); + refcopy = (BoundaryRep) Grafreed.clone(transientrep); } transient cVector minima = new cVector(); @@ -482,7 +486,7 @@ } - void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected) // ?? + void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) // ?? { // ?????? if (size() > 0) // { @@ -543,106 +547,10 @@ if(/*showsprings &&*/ Phys != null) { - GL gl = display.GetGL(); // getGL(); - - gl.glDisable(gl.GL_LIGHTING); - - gl.glLineWidth(1); - gl.glColor3f(1,1,1); - gl.glBegin(gl.GL_LINES); - double scale = 0; - int count = 0; - for (int s=0; s<Phys.allSprings.size(); s++) - { - Spring spring = Phys.allSprings.get(s); - if(s == 0) - { - //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); - } - if (showsprings) - { - temp.set(spring.a.position); - temp.add(spring.b.position); - temp.mul(0.5); - temp2.set(spring.a.position); - temp2.sub(spring.b.position); - temp2.mul(spring.restLength/2); - temp.sub(temp2); - gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); - temp.add(temp2); - temp.add(temp2); - gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); - } - - if (spring.isHandle) - continue; - - //if (scale < spring.restLength) - scale += spring.restLength; - count++; - } - gl.glEnd(); - - if (count == 0) - scale = 0.01; - else - scale /= count * 3; - - //scale = 0.25; - - if (ShowInfo()) - { - gl.glLineWidth(4); - for (int s=0; s<Phys.allNodes.size(); s++) - { - DynamicNode node = Phys.allNodes.get(s); - if (node.mass == 0) - continue; - - int i = node.springs==null?-1:node.springs.size(); - gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); - //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); - //temp.normalize(); - //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); - gl.glBegin(gl.GL_LINES); - gl.glVertex3d(node.position.x, node.position.y, node.position.z); - //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); - gl.glVertex3d(node.position.x + bRep.GetVertex(s).norm.x*scale, - node.position.y + bRep.GetVertex(s).norm.y*scale, - node.position.z + bRep.GetVertex(s).norm.z*scale); - gl.glEnd(); - } - - gl.glLineWidth(8); - for (int s=0; s<Phys.allNodes.size(); s++) - { - DynamicNode node = Phys.allNodes.get(s); - - if (node.springs != null) - { - for (int i=0; i<node.springs.size(); i+=1) - { - DynamicNode f = node.springs.get(i).GetOther(node); - - int c = i+1; - // c = node.springs.get(i).nbcopies; - - gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); - gl.glBegin(gl.GL_LINES); - gl.glVertex3d(node.position.x, node.position.y, node.position.z); - gl.glVertex3d(f.position.x/3+node.position.x*2/3, f.position.y/3+node.position.y*2/3, f.position.z/3+node.position.z*2/3); - gl.glEnd(); - } - } - } - - gl.glLineWidth(1); - } - - gl.glEnable(gl.GL_LIGHTING); + display.DrawDynamicMesh(this); } - if (live && display.isLIVE() && display.drawMode == CameraPane.DEFAULT) + if (live && Globals.isLIVE() && display.DrawMode() == CameraPane.DEFAULT) { //System.out.println("UPDATE"); if (Phys == null) @@ -654,6 +562,8 @@ maxima = new cVector(); } + CameraPane.CreateSelectedPoint(); + // ref.getBounds(minima, maxima, true); // Phys.reference.set((maxima.x+minima.x)/2,(maxima.y+minima.y)/2,(maxima.z+minima.z)/2); //ref. -- Gitblit v1.6.2