Shapes 3D Library: can't get stroke function to work for any shapes

according to Shapes 3D Box - Stroke Documentation i am attempting to add stroke to my box correctly, any of the other functions that I try are working (e.g. the .fill()) but not stroke. i want to be able to have no fill but still have the wireframe of the object showing on screen. Any help?

Box test = new Box(this, 300);
test.stroke(255);
test.strokeWeight(10);
test.fill(color(255,0,0));
test.draw();
1 Like

You must set the draw mode e.g.

// Show surfaces and edges
test.drawMode(Shape3D.SOLID | Shape3D.WIRE);

You can also use Shape3D.TEXTURE if you are using images as textures.

2 Likes

Thank you!!! time to finish my assignment :slight_smile:

would you happen to know how i can get the color of an object? in the simplest form,

i.e.

//something like this?
color c = test.shape;
1 Like

color c = text.fill();

This will work with all shapes except Box because a box can have 6 different colour (one for each face) so it wouldn’t know which one to return.

2 Likes
Box test = new Box(this, 300);
test.stroke(255);
test.drawMode(Shape3D.SOLID);
test.draw();

// this is where I'm stuck
color c = test.getColor();

You have already asked this question so go here to see my answer.

1 Like

One more question!
How can I get the type of an object?
i.e…

if (testObject.type == Box){
  //do something
} else if (testObject.type == Cone){
  //do something different
}

You may try out the operator instanceof: :thinking:
if (testObject instanceof Box) { }