示例#1
0
 public void displayByArea(DisplayArea area) {
   changeMode();
   position.add(direction);
   if (position.z > 300 || position.z < -300) { // ograniczenie poruszania się obszaru wyświetlania
     direction.mult(-1);
   }
   area.moveCenterTo(position);
   pApplet.stroke(255, 0, 0);
   pApplet.pushMatrix();
   for (int j = 0; j < model.getSegmentCount(); j++) {
     Segment segment = model.getSegment(j);
     Face[] faces = segment.getFaces();
     pApplet.beginShape(PConstants.QUADS);
     for (Face face : faces) {
       if (area.isColliding(face.getCenter())) {
         PVector[] v = face.getVertices();
         PVector[] n = face.getNormals();
         for (int k = 0; k < v.length; k++) {
           pApplet.normal(n[k].x, n[k].y, n[k].z);
           pApplet.vertex(v[k].x, v[k].y, v[k].z);
         }
       }
     }
     pApplet.endShape();
   }
   pApplet.popMatrix();
 }
示例#2
0
 public void moveNormals() {
   changeMode();
   pApplet.pushMatrix();
   for (int j = 0; j < model.getSegmentCount(); j++) {
     Segment segment = model.getSegment(j);
     Face[] faces = segment.getFaces();
     pApplet.beginShape(PConstants.QUADS);
     for (int i = 0; i < faces.length; i++) {
       PVector[] vertices = faces[i].getVertices();
       PVector normal = faces[i].getNormal();
       float nor = PApplet.abs(PApplet.sin(PApplet.radians((pApplet.frameCount + i))) * 100);
       for (PVector vertex : vertices) {
         pApplet.vertex(
             vertex.x + (normal.x * nor),
             vertex.y + (normal.y * nor),
             vertex.z + (normal.z * nor));
       }
     }
     pApplet.endShape();
   }
   pApplet.popMatrix();
 }