Duplicate edges in sphere()?

edited October 2016 in Questions about Code

Is it just me, or does anyone else get the feeling there's something not quite right with the sphere() mesh?

void setup() {
  size(480, 480, P3D);
  colorMode(HSB, 6.0, 1.0, 1.0, 1.0);
  noFill();
}

void draw()
{ // For tweaking
  translate(width/2, height/2);  
  background(0);
  stroke(0.0, 0.4, 1.0, 0.5);
  rotateX(-0.1);
  rotateY(0.01*millis()/100);
  strokeWeight(5);
  sphereDetail(4);sphere(100);
}

Answers

  • Can you be more specific about exactly what you think is incorrect?

    Note that a sphere is a series of triangles, not edges, so two triangles will share the same edge, if that's what you're talking about.

  • edited October 2016

    @chrisjj --

    if you want to quickly understanding of how this triangle edge sharing works out at many different detail levels:

    1. launch your sketch with Menu > Sketch > Tweak for Tweaks mode.
    2. Click on sphereDetail() and try dragging it right and left -- way up and all the way down.
  • jeremydouglass, this duplication appears near one pole at every different spehereDetail() value I have tried.

  • Again, what is the duplication?

  • the brighter line at the bottom of the northern cap is from two identical lines being drawn on top of each other.

    (the sphere is actually 3 different bits, a triangle fan at the top and bottom, a triangle mesh for the rest of it.)

    https://github.com/processing/processing/blob/7445d10718a9b2cdbf7c3b3469d37928e93695dd/core/src/processing/opengl/PGraphicsOpenGL.java#L9010

  • edited October 2016

    @KevinWorkman

    I think the point @chrisjj is making is that, with transparency, it is visible that one and only one of the sphere rings (near the pole) is darker / less transparent, as if it is being drawn twice while all others are being drawn once. This isn't an artifact of camera angle -- it is the same ring, from any angle at any detail.

    To see this in action, I added a 3D rotation and a time-based sphereDetail to the above sketch. You can clearly track one "heavy / less transparent" ring as the sphere tumbles and changes detail.

    // https:// forum.processing.org/two/discussion/18731/duplicate-edges-in-sphere#latest
    // 2016-10-26 Processing 3.2.1
    int sDetail;
    float SPEED = 2000;
    
    void setup() {
      size(200, 200, P3D);
      colorMode(HSB, 6.0, 1.0, 1.0, 1.0);
      noFill();
    } 
    void draw()
    { // For tweaking
      translate(width/2, height/2);  
      background(0);
      stroke(0.0, 0.4, 1.0, 0.5);
      rotateX(-0.1);
      rotateY(0.01*millis()/100);
      rotateZ(0.003*millis()/100);
      strokeWeight(5);
      sDetail = 1 + (int)(4+4*sin(PI+millis()/(SPEED/4)));
      sphereDetail(sDetail);
      println(sDetail);
      sphere(75);
    }
    

    Triangular ring at the equator (pole-1):

    sphere_ring_1

    Quad ring at pole-1:

    sphere_ring_2

    Octagonal ring at pole-1:

    sphere_ring_3

  • edited October 2016

    Thanks Jeremy and koogs. I've reported it as an issue: https://github.com/processing/processing/issues/4720

  • This issue was resolved, the fix should be available in the next release:

Sign In or Register to comment.