.. | .. |
---|
1 | 1 | import java.util.Hashtable; |
---|
2 | 2 | |
---|
3 | | -import javax.media.opengl.GL; |
---|
| 3 | +//import javax.media.opengl.GL; |
---|
4 | 4 | |
---|
5 | 5 | public class cMesh extends cSpring |
---|
6 | 6 | { |
---|
.. | .. |
---|
49 | 49 | |
---|
50 | 50 | cMesh(Object3D bRep) |
---|
51 | 51 | { |
---|
52 | | - this("Me:" + bRep.name, bRep); |
---|
| 52 | + this("Mesh:" + bRep.name, bRep); |
---|
53 | 53 | } |
---|
54 | 54 | |
---|
55 | 55 | cMesh(String name, Object3D bRep) |
---|
.. | .. |
---|
78 | 78 | |
---|
79 | 79 | live = true; |
---|
80 | 80 | } |
---|
81 | | - |
---|
| 81 | + |
---|
82 | 82 | Object3D deepCopy() |
---|
83 | 83 | { |
---|
84 | 84 | /* |
---|
.. | .. |
---|
355 | 355 | // DynamicNode handle = new DynamicNode(center.x, center.y, center.z, 0 /*0 , 1 or Float.MAX_VALUE*/, 0); |
---|
356 | 356 | // Phys.addHandle(handle); |
---|
357 | 357 | |
---|
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 |
---|
359 | 361 | { |
---|
360 | 362 | DynamicNode dn = Phys.allNodes.get(k); |
---|
361 | 363 | DynamicNode handle = new DynamicNode(dn.position.x, dn.position.y, dn.position.z, 0 /*0 , 1 or Float.MAX_VALUE*/, 0); |
---|
.. | .. |
---|
402 | 404 | if (ref == null) |
---|
403 | 405 | return; |
---|
404 | 406 | |
---|
405 | | - GrafreeD.epsequal = IsEpsEqual(); |
---|
406 | | - GrafreeD.linkUV = IsLinkUV(); |
---|
| 407 | + Grafreed.epsequal = IsEpsEqual(); |
---|
| 408 | + Grafreed.linkUV = IsLinkUV(); |
---|
407 | 409 | |
---|
408 | 410 | // BoundaryRep oldrep = transientrep; |
---|
409 | 411 | |
---|
.. | .. |
---|
415 | 417 | ref.count = 1; |
---|
416 | 418 | |
---|
417 | 419 | Object3D obj = ref.GetObject(); |
---|
| 420 | + Object3D par = obj.parent; |
---|
| 421 | + obj.parent = null; |
---|
418 | 422 | |
---|
419 | 423 | // may 2014: side-effect with UVs!! |
---|
420 | | - obj = (Object3D) GrafreeD.clone(obj); |
---|
421 | | - |
---|
422 | | - merge(obj); |
---|
| 424 | + merge((Object3D) Grafreed.clone(obj)); |
---|
423 | 425 | |
---|
| 426 | + obj.parent = par; |
---|
| 427 | + |
---|
424 | 428 | ref.count = keepcount; |
---|
425 | 429 | |
---|
426 | 430 | System.out.println("RESULT " + ref + "; #vertices = " + bRep.VertexCount() + "; #faces = " + bRep.FaceCount()); |
---|
427 | 431 | bRep.Trim(false, false,false,false,false); |
---|
428 | 432 | System.out.println("------> TRIM " + ref + "; #vertices = " + bRep.VertexCount() + "; #faces = " + bRep.FaceCount()); |
---|
429 | 433 | |
---|
430 | | - GrafreeD.epsequal = false; |
---|
| 434 | + Grafreed.epsequal = false; |
---|
431 | 435 | |
---|
432 | 436 | if (transientrep != null && bRep.VertexCount() == transientrep.VertexCount()) |
---|
433 | 437 | { |
---|
.. | .. |
---|
468 | 472 | } |
---|
469 | 473 | else |
---|
470 | 474 | // geometry is merged... |
---|
471 | | - refcopy = (BoundaryRep) GrafreeD.clone(transientrep); |
---|
| 475 | + refcopy = (BoundaryRep) Grafreed.clone(transientrep); |
---|
472 | 476 | } |
---|
473 | 477 | |
---|
474 | 478 | transient cVector minima = new cVector(); |
---|
.. | .. |
---|
482 | 486 | } |
---|
483 | 487 | |
---|
484 | 488 | |
---|
485 | | - void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected) // ?? |
---|
| 489 | + void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) // ?? |
---|
486 | 490 | { |
---|
487 | 491 | // ?????? if (size() > 0) |
---|
488 | 492 | // { |
---|
.. | .. |
---|
543 | 547 | |
---|
544 | 548 | if(/*showsprings &&*/ Phys != null) |
---|
545 | 549 | { |
---|
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); |
---|
643 | 551 | } |
---|
644 | 552 | |
---|
645 | | - if (live && display.isLIVE() && display.drawMode == CameraPane.DEFAULT) |
---|
| 553 | + if (live && Globals.isLIVE() && display.DrawMode() == CameraPane.DEFAULT) |
---|
646 | 554 | { |
---|
647 | 555 | //System.out.println("UPDATE"); |
---|
648 | 556 | if (Phys == null) |
---|
.. | .. |
---|
654 | 562 | maxima = new cVector(); |
---|
655 | 563 | } |
---|
656 | 564 | |
---|
| 565 | + CameraPane.CreateSelectedPoint(); |
---|
| 566 | + |
---|
657 | 567 | // ref.getBounds(minima, maxima, true); |
---|
658 | 568 | // Phys.reference.set((maxima.x+minima.x)/2,(maxima.y+minima.y)/2,(maxima.z+minima.z)/2); |
---|
659 | 569 | //ref. |
---|