We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I can't see the stroke of the box() when the png image is in front. What am I doing wrong?
PImage body1;
int w = 400;
int h = 200;
void setup() {
size(1000, 700, P3D);
body1 = loadImage("Basketball.png");
}
void draw() {
background(200);
translate(width/2, height/2);
float x = map(mouseX, 0, width, -PI/2, PI/2);
rotateY(x);
noFill();
box(w, h, w);
pushMatrix();
translate(-100, 15);
scale(.25);
image(body1, 0, 0);
popMatrix();
}
Answers
Please edit your post above (gear icon) and format you code:
https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text
you are drawing an image over your stroke!
z distance is important in 3d - things nearer the camera will block things further away, regardless of the order in which you draw them.
but we can't run your code without the image (or some idea about the image like a size and transparency)
I guess I wasn't clear. The stroke of box() is not visible through the transparent portion of my png file. I can place a rect() behind it and the fill() color is visible but the stroke is not.
@frankbass -- We can't test with your particular PNG or see what you are seeing because you didn't upload your image to the forum or provide a url to the file.
If you choose you could also choose another publicly available online file with a similar transparency issue and include the full url in your loadImage line.
Thank you. This basketball png demonstrates what I'm talking about. The background color is visible directly surrounding the basketball but the wire frame of the box() passes behind the png but is not visible through the transparent portion of the image.
https://www.google.de/imgres?imgurl=https://upload.wikimedia.org/wikipedia/commons/7/7a/Basketball.png&imgrefurl=https://commons.wikimedia.org/wiki/File:Basketball.png&docid=SN1E-DXjJnMetM&tbnid=EJmjEDyJzrhAuM:&vet=10ahUKEwjGv9G70uLUAhUDPFAKHbWIDkEQMwh0KAkwCQ..i&w=340&h=340&client=safari&bih=689&biw=1240&q=png ball&ved=0ahUKEwjGv9G70uLUAhUDPFAKHbWIDkEQMwh0KAkwCQ&iact=mrc&uact=8
for fans of short urls:
https://upload.wikimedia.org/wikipedia/commons/7/7a/Basketball.png
add
to draw(). it will slow things down.
That's great! Thanks! Perfect.
Sorry for the long url. How did you shorten it?
(you linked to the google image search page containing the image. chose 'view image' and posted that. (the short url is inside the long url if you look, but there's also a lot of google noise))
Thanks.