Normand Briere
2019-11-17 cb37a129d1adb403019c96e798e86e2da9667f15
cMesh.java
....@@ -1,6 +1,6 @@
11 import java.util.Hashtable;
22
3
-import javax.media.opengl.GL;
3
+//import javax.media.opengl.GL;
44
55 public class cMesh extends cSpring
66 {
....@@ -49,7 +49,7 @@
4949
5050 cMesh(Object3D bRep)
5151 {
52
- this("Me:" + bRep.name, bRep);
52
+ this("Mesh:" + bRep.name, bRep);
5353 }
5454
5555 cMesh(String name, Object3D bRep)
....@@ -78,7 +78,7 @@
7878
7979 live = true;
8080 }
81
-
81
+
8282 Object3D deepCopy()
8383 {
8484 /*
....@@ -355,7 +355,9 @@
355355 // DynamicNode handle = new DynamicNode(center.x, center.y, center.z, 0 /*0 , 1 or Float.MAX_VALUE*/, 0);
356356 // Phys.addHandle(handle);
357357
358
- for (int k=Phys.allNodes.size(); --k>=0;) // warning: "add handle" adds a node
358
+ int size = Phys.allNodes.size();
359
+
360
+ for (int k=0; k < size; k++) // warning: "add handle" adds a node
359361 {
360362 DynamicNode dn = Phys.allNodes.get(k);
361363 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 @@
402404 if (ref == null)
403405 return;
404406
405
- GrafreeD.epsequal = IsEpsEqual();
406
- GrafreeD.linkUV = IsLinkUV();
407
+ Grafreed.epsequal = IsEpsEqual();
408
+ Grafreed.linkUV = IsLinkUV();
407409
408410 // BoundaryRep oldrep = transientrep;
409411
....@@ -415,19 +417,21 @@
415417 ref.count = 1;
416418
417419 Object3D obj = ref.GetObject();
420
+ Object3D par = obj.parent;
421
+ obj.parent = null;
418422
419423 // may 2014: side-effect with UVs!!
420
- obj = (Object3D) GrafreeD.clone(obj);
421
-
422
- merge(obj);
424
+ merge((Object3D) Grafreed.clone(obj));
423425
426
+ obj.parent = par;
427
+
424428 ref.count = keepcount;
425429
426430 System.out.println("RESULT " + ref + "; #vertices = " + bRep.VertexCount() + "; #faces = " + bRep.FaceCount());
427431 bRep.Trim(false, false,false,false,false);
428432 System.out.println("------> TRIM " + ref + "; #vertices = " + bRep.VertexCount() + "; #faces = " + bRep.FaceCount());
429433
430
- GrafreeD.epsequal = false;
434
+ Grafreed.epsequal = false;
431435
432436 if (transientrep != null && bRep.VertexCount() == transientrep.VertexCount())
433437 {
....@@ -468,7 +472,7 @@
468472 }
469473 else
470474 // geometry is merged...
471
- refcopy = (BoundaryRep) GrafreeD.clone(transientrep);
475
+ refcopy = (BoundaryRep) Grafreed.clone(transientrep);
472476 }
473477
474478 transient cVector minima = new cVector();
....@@ -482,7 +486,7 @@
482486 }
483487
484488
485
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected) // ??
489
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) // ??
486490 {
487491 // ?????? if (size() > 0)
488492 // {
....@@ -543,106 +547,10 @@
543547
544548 if(/*showsprings &&*/ Phys != null)
545549 {
546
- GL gl = display.GetGL(); // getGL();
547
-
548
- gl.glDisable(gl.GL_LIGHTING);
549
-
550
- gl.glLineWidth(1);
551
- gl.glColor3f(1,1,1);
552
- gl.glBegin(gl.GL_LINES);
553
- double scale = 0;
554
- int count = 0;
555
- for (int s=0; s<Phys.allSprings.size(); s++)
556
- {
557
- Spring spring = Phys.allSprings.get(s);
558
- if(s == 0)
559
- {
560
- //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
561
- }
562
- if (showsprings)
563
- {
564
- temp.set(spring.a.position);
565
- temp.add(spring.b.position);
566
- temp.mul(0.5);
567
- temp2.set(spring.a.position);
568
- temp2.sub(spring.b.position);
569
- temp2.mul(spring.restLength/2);
570
- temp.sub(temp2);
571
- gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
572
- temp.add(temp2);
573
- temp.add(temp2);
574
- gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
575
- }
576
-
577
- if (spring.isHandle)
578
- continue;
579
-
580
- //if (scale < spring.restLength)
581
- scale += spring.restLength;
582
- count++;
583
- }
584
- gl.glEnd();
585
-
586
- if (count == 0)
587
- scale = 0.01;
588
- else
589
- scale /= count * 3;
590
-
591
- //scale = 0.25;
592
-
593
- if (ShowInfo())
594
- {
595
- gl.glLineWidth(4);
596
- for (int s=0; s<Phys.allNodes.size(); s++)
597
- {
598
- DynamicNode node = Phys.allNodes.get(s);
599
- if (node.mass == 0)
600
- continue;
601
-
602
- int i = node.springs==null?-1:node.springs.size();
603
- gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
604
- //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
605
- //temp.normalize();
606
- //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
607
- gl.glBegin(gl.GL_LINES);
608
- gl.glVertex3d(node.position.x, node.position.y, node.position.z);
609
- //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
610
- gl.glVertex3d(node.position.x + bRep.GetVertex(s).norm.x*scale,
611
- node.position.y + bRep.GetVertex(s).norm.y*scale,
612
- node.position.z + bRep.GetVertex(s).norm.z*scale);
613
- gl.glEnd();
614
- }
615
-
616
- gl.glLineWidth(8);
617
- for (int s=0; s<Phys.allNodes.size(); s++)
618
- {
619
- DynamicNode node = Phys.allNodes.get(s);
620
-
621
- if (node.springs != null)
622
- {
623
- for (int i=0; i<node.springs.size(); i+=1)
624
- {
625
- DynamicNode f = node.springs.get(i).GetOther(node);
626
-
627
- int c = i+1;
628
- // c = node.springs.get(i).nbcopies;
629
-
630
- gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
631
- gl.glBegin(gl.GL_LINES);
632
- gl.glVertex3d(node.position.x, node.position.y, node.position.z);
633
- 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);
634
- gl.glEnd();
635
- }
636
- }
637
- }
638
-
639
- gl.glLineWidth(1);
640
- }
641
-
642
- gl.glEnable(gl.GL_LIGHTING);
550
+ display.DrawDynamicMesh(this);
643551 }
644552
645
- if (live && display.isLIVE() && display.drawMode == CameraPane.DEFAULT)
553
+ if (live && Globals.isLIVE() && display.DrawMode() == CameraPane.DEFAULT)
646554 {
647555 //System.out.println("UPDATE");
648556 if (Phys == null)
....@@ -654,6 +562,8 @@
654562 maxima = new cVector();
655563 }
656564
565
+ CameraPane.CreateSelectedPoint();
566
+
657567 // ref.getBounds(minima, maxima, true);
658568 // Phys.reference.set((maxima.x+minima.x)/2,(maxima.y+minima.y)/2,(maxima.z+minima.z)/2);
659569 //ref.