LoginSignup
1
3

More than 5 years have passed since last update.

ProcessingでSphereやBoxのPShapeを取得

Last updated at Posted at 2016-06-03

ProcessingでもCinderのgeom::Sphere()や,
oFのofSpherePrimitiveのgetMesh()的なのができた.
これでプリミティブのPShapeを生成できるみたい.

参考URL
https://processing.org/tutorials/pshape/
http://processing.github.io/processing-javadocs/core/processing/core/PShape.html

PShapeSample.pde
PImage img;
PShape sphere;
PShape box;

void setup() {
  size(600, 600, P3D);
  img = loadImage("world32k.jpg");
  sphere = createShape(SPHERE, 100);
  sphere.setTexture(img);
  sphere.setStrokeWeight(0);

  box = createShape(BOX, 100);
  box.setTexture(img);
  box.setStrokeWeight(0);
}

void draw(){
  background(0);

  pushMatrix();
  translate(width/3, height/2, 100);
  rotateX(map(mouseY, 0, width, -PI, PI));
  rotateY(map(mouseX, 0, width, -PI, PI));
  shape(sphere);
  popMatrix();

  pushMatrix();
  translate(width/3 * 2, height/2, 100);
  rotateX(map(mouseY, 0, width, -PI, PI));
  rotateY(map(mouseX, 0, width, -PI, PI));
  shape(box);
  popMatrix();
}

PShapeSample.jpg

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3