Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
michaelluis
michaelluis's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
3d png texture collision
[0 Replies]
23-Mar-2011 07:35 AM
Forum:
Programming Questions
Hello,
I was trying to do a rotating group of shapes, inspired from the brick tower example.
In my scketch, I'm applying texture from a png file, but some background shapes appears over frontground ones.
it's seems to be dependant of the order of drawing, but there is this problem only with png files, it's all right with jpg.
There is a simple example of this problem :
PImage img_png, img_jpg;
boolean value; //switch with mouse clic
int foreGround, backGround; // z position
void setup()
{
size( 600, 300, P3D );
img_jpg = loadImage("http://www.michaelluis.fr/processing/test.jpg");
img_png = loadImage("http://www.michaelluis.fr/processing/test.png");
value = false;
foreGround = 50;
backGround = 100;
}
void draw()
{
background(127);
if( value == false ) //draw first foreground, after background
{
beginShape( QUADS );
texture( img_png );
vertex( 100, 100, foreGround, 0, 0 );
vertex( 200, 100, foreGround, 100, 0 );
vertex( 200, 200, foreGround, 100, 100 );
vertex( 100, 200, foreGround, 0, 100 );
vertex( 100, 100, backGround, 0, 0 );
vertex( 200, 100, backGround, 100, 0 );
vertex( 200, 200, backGround, 100, 100 );
vertex( 100, 200, backGround, 0, 100 );
endShape();
beginShape( QUADS );
texture( img_jpg );
vertex( 400, 100, foreGround, 0, 0 );
vertex( 500, 100, foreGround, 100, 0 );
vertex( 500, 200, foreGround, 100, 100 );
vertex( 400, 200, foreGround, 0, 100 );
vertex( 400, 100, backGround, 0, 0 );
vertex( 500, 100, backGround, 100, 0 );
vertex( 500, 200, backGround, 100, 100 );
vertex( 400, 200, backGround, 0, 100 );
endShape();
}
else //draw first background, after foreground
{
beginShape( QUADS );
texture( img_png );
vertex( 100, 100, backGround, 0, 0 );
vertex( 200, 100, backGround, 100, 0 );
vertex( 200, 200, backGround, 100, 100 );
vertex( 100, 200, backGround, 0, 100 );
vertex( 100, 100, foreGround, 0, 0 );
vertex( 200, 100, foreGround, 100, 0 );
vertex( 200, 200, foreGround, 100, 100 );
vertex( 100, 200, foreGround, 0, 100 );
endShape();
beginShape( QUADS );
texture( img_jpg );
vertex( 400, 100, backGround, 0, 0 );
vertex( 500, 100, backGround, 100, 0 );
vertex( 500, 200, backGround, 100, 100 );
vertex( 400, 200, backGround, 0, 100 );
vertex( 400, 100, foreGround, 0, 0 );
vertex( 500, 100, foreGround, 100, 0 );
vertex( 500, 200, foreGround, 100, 100 );
vertex( 400, 200, foreGround, 0, 100 );
endShape();
}
}
void mousePressed()
{
value = !value;
}
So, must I obligatory check the order of drawing or is it an easier way to fix it ?
«Prev
Next »
Moderate user : michaelluis
Forum