Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How to draw Shapes3D objects on PGraphics

$
0
0

I have recently installed the Shapes3D library and I'm so much enjoying it :) I'm wondering how to draw 3D objects on a PGraphics object not directly on the screen. In the following code, I want to draw the box object on 'canvas'. Please teach me how to do it. Thanks!

import shapes3d.*;

Box box;
PGraphics canvas;

public void setup() {
  size(720, 720, P3D);

  box = new Box(this, 60, 60, 100);
  box.fill(color(32, 32, 200));
  box.stroke(color(200, 200, 200));
  box.strokeWeight(1.2f);
  box.moveTo(0, 0, 0);
  box.drawMode(Shape3D.WIRE);
  box.tag = "box";

  canvas = createGraphics(720, 720, P3D);
}

public void draw() {

  background(0);

  pushStyle();
  pushMatrix();

  box.rotateBy(radians(4.0f), radians(4.0f), radians(4.0f));
  camera(0, -190, 350, 0, 0, 0, 0, 1, 0);
  box.draw();    // How to make this drawn onto the 'canvas' object?

  popMatrix();
  popStyle();
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles