New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PShape 3D: strange extra lines #3006

Closed
RectangleWorld opened this Issue Dec 13, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@RectangleWorld

RectangleWorld commented Dec 13, 2014

First observed in 2.1.1 and in the latest alpha 3.0a5.

I'm pretty sure these extra lines I am seeing are the result of a bug, not my programming (sample program below). Am I missing something? I have seen the same behavior on two different windows machines. It seems only to happen when there is a lot of polygons.

If you try the sample program below (which requires PeasyCam), you'll see a bunch of random triangles arranged in a sphere. Zoom in to near the middle of the sphere and rotate around a bit and, if your results are the same as mine, you'll find some extra long lines drawn in the display that seem not to be part of any triangle. Here is a cropped screencap where you can see the lines:

image_2079_crop

Complete code for this example:

import peasy.*;

int bgColor;
PeasyCam camera;
PShape testShape;
int numTriangles;

void setup() {
  size(1000, 650, P3D);
  //smooth(2);
  bgColor = 0xFF000000;
  background(bgColor);

  camera = new PeasyCam(this, 0, 0, 0, 1000);

  numTriangles = 10000;

  createSurface();
}

void rebuildShape() {
  createSurface();
}

void createSurface() {
  testShape = createShape();

  float theta;
  float phi;
  float mag;
  float x;
  float y;
  float z;
  float minMag = 10;
  float maxMag = 10;
  float bigRadMax = 500;
  float bigRadMin = 500;
  testShape.beginShape(TRIANGLES);
  testShape.stroke(0x80FFFFFF);
  for (int i = 0; i < numTriangles; i++) {
    testShape.fill(random(255), random(255), random(255), 128);
    mag = random(bigRadMin, bigRadMax);
    phi = asin(random(-1, 1));
    theta = random(TWO_PI);
    x = mag*cos(phi)*cos(theta);
    y = mag*cos(phi)*sin(theta);
    z = mag*sin(phi);

    testShape.vertex(x, y, z);
    for (int j = 0; j < 2; j++) {
      mag = random(minMag, maxMag);
      phi = asin(random(-1, 1));
      theta = random(TWO_PI);
      x += mag*cos(phi)*cos(theta);
      y += mag*cos(phi)*sin(theta);
      z += mag*sin(phi);
      testShape.vertex(x, y, z);
    }
  }
  testShape.endShape();
}

void draw() {
  lights();
  background(bgColor);
  shape(testShape);
}

void keyPressed() {
  if (key == 's') {
    saveFrame("image_####.jpg");
  }
  if (key == 'g') {
    rebuildShape();
  }
}

@codeanticode codeanticode self-assigned this Dec 15, 2014

@codeanticode codeanticode added the opengl label Dec 15, 2014

@codeanticode

This comment has been minimized.

Show comment
Hide comment
@codeanticode

codeanticode Jun 3, 2015

Member

Fixed with 00fec71

Member

codeanticode commented Jun 3, 2015

Fixed with 00fec71

@codeanticode

This comment has been minimized.

Show comment
Hide comment
@codeanticode

codeanticode Sep 8, 2015

Member

by fixing #3756 realized this issue was not solved. Extra lines disappeared only because of a bug in the fix 00fec71, addressed with e0e78b8.

Member

codeanticode commented Sep 8, 2015

by fixing #3756 realized this issue was not solved. Extra lines disappeared only because of a bug in the fix 00fec71, addressed with e0e78b8.

@codeanticode codeanticode reopened this Sep 8, 2015

@codeanticode

This comment has been minimized.

Show comment
Hide comment
@codeanticode

codeanticode Sep 9, 2015

Member

fixed (for real) with 1d1ccef

Member

codeanticode commented Sep 9, 2015

fixed (for real) with 1d1ccef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment