Normand Briere
2019-09-20 cbe4e90105d07d7d3fecabffaa01342403aa2ae3
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 /*
....@@ -404,8 +404,8 @@
404404 if (ref == null)
405405 return;
406406
407
- GrafreeD.epsequal = IsEpsEqual();
408
- GrafreeD.linkUV = IsLinkUV();
407
+ Grafreed.epsequal = IsEpsEqual();
408
+ Grafreed.linkUV = IsLinkUV();
409409
410410 // BoundaryRep oldrep = transientrep;
411411
....@@ -417,19 +417,21 @@
417417 ref.count = 1;
418418
419419 Object3D obj = ref.GetObject();
420
+ Object3D par = obj.parent;
421
+ obj.parent = null;
420422
421423 // may 2014: side-effect with UVs!!
422
- obj = (Object3D) GrafreeD.clone(obj);
423
-
424
- merge(obj);
424
+ merge((Object3D) Grafreed.clone(obj));
425425
426
+ obj.parent = par;
427
+
426428 ref.count = keepcount;
427429
428430 System.out.println("RESULT " + ref + "; #vertices = " + bRep.VertexCount() + "; #faces = " + bRep.FaceCount());
429431 bRep.Trim(false, false,false,false,false);
430432 System.out.println("------> TRIM " + ref + "; #vertices = " + bRep.VertexCount() + "; #faces = " + bRep.FaceCount());
431433
432
- GrafreeD.epsequal = false;
434
+ Grafreed.epsequal = false;
433435
434436 if (transientrep != null && bRep.VertexCount() == transientrep.VertexCount())
435437 {
....@@ -470,7 +472,7 @@
470472 }
471473 else
472474 // geometry is merged...
473
- refcopy = (BoundaryRep) GrafreeD.clone(transientrep);
475
+ refcopy = (BoundaryRep) Grafreed.clone(transientrep);
474476 }
475477
476478 transient cVector minima = new cVector();
....@@ -484,7 +486,7 @@
484486 }
485487
486488
487
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected) // ??
489
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) // ??
488490 {
489491 // ?????? if (size() > 0)
490492 // {
....@@ -545,103 +547,7 @@
545547
546548 if(/*showsprings &&*/ Phys != null)
547549 {
548
- GL gl = display.GetGL(); // getGL();
549
-
550
- gl.glDisable(gl.GL_LIGHTING);
551
-
552
- gl.glLineWidth(1);
553
- gl.glColor3f(1,1,1);
554
- gl.glBegin(gl.GL_LINES);
555
- double scale = 0;
556
- int count = 0;
557
- for (int s=0; s<Phys.allSprings.size(); s++)
558
- {
559
- Spring spring = Phys.allSprings.get(s);
560
- if(s == 0)
561
- {
562
- //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position);
563
- }
564
- if (showsprings)
565
- {
566
- temp.set(spring.a.position);
567
- temp.add(spring.b.position);
568
- temp.mul(0.5);
569
- temp2.set(spring.a.position);
570
- temp2.sub(spring.b.position);
571
- temp2.mul(spring.restLength/2);
572
- temp.sub(temp2);
573
- gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
574
- temp.add(temp2);
575
- temp.add(temp2);
576
- gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z);
577
- }
578
-
579
- if (spring.isHandle)
580
- continue;
581
-
582
- //if (scale < spring.restLength)
583
- scale += spring.restLength;
584
- count++;
585
- }
586
- gl.glEnd();
587
-
588
- if (count == 0)
589
- scale = 0.01;
590
- else
591
- scale /= count * 3;
592
-
593
- //scale = 0.25;
594
-
595
- if (ShowInfo())
596
- {
597
- gl.glLineWidth(4);
598
- for (int s=0; s<Phys.allNodes.size(); s++)
599
- {
600
- DynamicNode node = Phys.allNodes.get(s);
601
- if (node.mass == 0)
602
- continue;
603
-
604
- int i = node.springs==null?-1:node.springs.size();
605
- gl.glColor3f((i>>2)&1,(i>>1)&1,i&1);
606
- //temp.set(node.springForce.x, node.springForce.y, node.springForce.z);
607
- //temp.normalize();
608
- //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2);
609
- gl.glBegin(gl.GL_LINES);
610
- gl.glVertex3d(node.position.x, node.position.y, node.position.z);
611
- //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale);
612
- gl.glVertex3d(node.position.x + bRep.GetVertex(s).norm.x*scale,
613
- node.position.y + bRep.GetVertex(s).norm.y*scale,
614
- node.position.z + bRep.GetVertex(s).norm.z*scale);
615
- gl.glEnd();
616
- }
617
-
618
- gl.glLineWidth(8);
619
- for (int s=0; s<Phys.allNodes.size(); s++)
620
- {
621
- DynamicNode node = Phys.allNodes.get(s);
622
-
623
- if (node.springs != null)
624
- {
625
- for (int i=0; i<node.springs.size(); i+=1)
626
- {
627
- DynamicNode f = node.springs.get(i).GetOther(node);
628
-
629
- int c = i+1;
630
- // c = node.springs.get(i).nbcopies;
631
-
632
- gl.glColor3f((c>>2)&1,(c>>1)&1,c&1);
633
- gl.glBegin(gl.GL_LINES);
634
- gl.glVertex3d(node.position.x, node.position.y, node.position.z);
635
- 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);
636
- gl.glEnd();
637
- }
638
- }
639
- }
640
-
641
- gl.glLineWidth(1);
642
- }
643
-
644
- gl.glEnable(gl.GL_LIGHTING);
550
+ display.DrawDynamicMesh(this);
645551 }
646552
647553 if (live && Globals.isLIVE() && display.DrawMode() == CameraPane.DEFAULT)
....@@ -656,6 +562,8 @@
656562 maxima = new cVector();
657563 }
658564
565
+ CameraPane.CreateSelectedPoint();
566
+
659567 // ref.getBounds(minima, maxima, true);
660568 // Phys.reference.set((maxima.x+minima.x)/2,(maxima.y+minima.y)/2,(maxima.z+minima.z)/2);
661569 //ref.