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

[P3D] Drawing a sphere with shape() first changes sphereDetail from default. #4192

Closed
RectangleWorld opened this Issue Dec 7, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@RectangleWorld

RectangleWorld commented Dec 7, 2015

I created a 3D PShape with createShape(SPHERE), then later tried to display this PShape and a second sphere drawn simply with sphere() and the latter came out with a sphere detail changed to 4 points per latitude instead of the usual default 30. This behavior depends on drawing order.

The following code:

void setup() {
  size(800,600,P3D);

  noStroke();
  PShape shapeSphere = createShape(SPHERE, 100);

  lights();

  background(0xFF000000);

  //sphere with sphere function
  pushMatrix();
  translate(600, 300);
  sphere(100);
  popMatrix();

  //sphere from prepared PShape
  pushMatrix();
  translate(200, 300);
  shape(shapeSphere);
  popMatrix();
}

creates a fine display of two spheres:

screencap0

But if we reverse the drawing order:

void setup() {
  size(800,600,P3D);

  noStroke();
  PShape shapeSphere = createShape(SPHERE, 100);

  lights();

  background(0xFF000000);

  //sphere from prepared PShape
  pushMatrix();
  translate(200, 300);
  shape(shapeSphere);
  popMatrix();

  //sphere with sphere function
  pushMatrix();
  translate(600, 300);
  sphere(100);
  popMatrix();
}

then the second sphere is drawn with a reduced sphere detail:

screencap1

Putting in sphereDetail(30) prior to drawing the second sphere remedies the problem, but shape() should probably not be changing this default. Note that it is the display of the PShape with shape() that seems to cause the error, not the creation of the PShape with createShape().

You can use the following code with PeasyCam to get a better look:

import peasy.*;

PeasyCam camera;
PShape shapeSphere;

void setup() {
  size(800,600,P3D);

  camera = new PeasyCam(this, 400, 300, 0, 500);

  fill(0xFFFF0000);
  shapeSphere = createShape(SPHERE, 100);  
}

void draw() {
  lights();

  background(0xFF000000);

  //sphere from prepared PShape
  pushMatrix();
  translate(200,300);
  shape(shapeSphere);
  popMatrix();

  //sphere with sphere function
  stroke(0);
  fill(0xFF0080FF);
  //sphereDetail(30);
  pushMatrix();
  translate(600, 300);
  sphere(100);
  popMatrix();
}

@codeanticode codeanticode added the opengl label Dec 8, 2015

@codeanticode codeanticode self-assigned this Dec 8, 2015

@codeanticode

This comment has been minimized.

Show comment
Hide comment
@codeanticode

codeanticode Dec 8, 2015

Member

Fixed with 4a247a3

Member

codeanticode commented Dec 8, 2015

Fixed with 4a247a3

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