Shapes3d: Box.draw() doesn't work anymore

@quark

using shapes3d (from a very old Sketch from my archives) here and wanted to say (used to say) MyBoxes[i].draw();

    • doesn’t work anymore

It seems, it used to work without a parameter, but now it doesn’t?

Thanks!

Chrisir

MCVE :



// imports ================================================

import shapes3d.utils.*;
import shapes3d.*;

Box [] MyBoxes = new Box [33]; // array


void setup () {

  size (800, 600, P3D);

  // Init
  for (int i = 0; i < 33; i = i+1) {
    MyBoxes[i] = new Box( 44, 3, 44 ); 
    MyBoxes[i].visible(true); // was "false" 
  }  // for
}

void draw () {
  background(0);
  PaintIt ();
}

void PaintIt () {
  for (int i = 0; i < 33; i++) {
    fill(255); 
    MyBoxes[i].draw();
  }//for
} // function 

1 Like

Several things here.

  1. The latest version of Shapes3D (v3.0) was a complete rewrite of the library and is not backwardly compatible
  2. In your code all the boxes are set invisible :smile:
  3. The draw method now expects a parameter of type PGraphics so to draw the shape to the main display use MyBoxes[i].draw(getGraphics());

The reason for the (3) is that it allows shapes to be drawn to offscreen buffers and to improve integration with later versions of G4P

3 Likes

This works!

Thank you so much!

// imports 
import shapes3d.*;

Box [] myBoxes = new Box [33]; // array

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

  // Init
  for (int i = 0; i < 33; i++) {
    myBoxes[i] = new Box( 44, 3, 44 ); 
    myBoxes[i].moveTo(i*10+width/2, 100 + i*14, -3*i); 
    myBoxes[i].visible(true); // was "false"
  }  // for
} // function

void draw () {
  background(0);
  paintIt ();
} // function

void paintIt () {
  for (int i = 0; i < 33; i++) {
    // myBoxes[i].fill(255); 
    myBoxes[i].draw(getGraphics()); // !!!!!
  }//for
} // function
//