search
LoginSignup
3
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

ProcessingでSphereやBoxのPShapeを取得

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

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
What you can do with signing up
3
Help us understand the problem. What are the problem?