Display Teapot and Graph

Hi,

I have the Teapot code https://gist.github.com/cooperaj/10965142 and I would like to know how can I create a graph in the right side with the values that the air plane receives ?

Any indications will be very helpful.

PS: I have the code for graph working, but I do not know to create a space on the right side in order to merge the codes after.

Let’s see it! Chances are good that you will want to render the teapot (airplane?) on one PGraphics object, and then draw the image from that object next to the graph.

Example:

PGraphics pg;

void setup(){
  size(400,200,P3D);
  pg = createGraphics(200,200,P3D);
}

void draw(){
  pg.beginDraw();
  // Am I, perhaps, a teapot in abstract?
  pg.background(60,0,0);
  pg.translate(100,100);
  pg.lights();
  pg.rotateX(map(mouseY,0,height,-PI,PI));
  pg.rotateY(map(mouseX%(width/2),0,width/2,-PI,PI));
  pg.noStroke();
  pg.fill(0,200,0);
  pg.box(90);
  pg.endDraw();
  background(0);
  // Am I, perhaps, a graph, unlabeled?
  stroke(200,200,200);
  line(220,20,220,180);
  line(220,180,380,180);
  stroke(200,0,0);
  line(240,160,260,60);
  line(260,60,280,100);
  line(280,100,300,20);
  // Ah, here is that teapot.
  image(pg, 0, 0);
}

Actually you might want to do the drawing to two different PGraphic objects… That way your 2D graph won’t look… wonky.

1 Like

Excellent answer indeed!

Thank you!