We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › 2d shapes on a plane
Page Index Toggle Pages: 1
2d shapes on a plane (Read 619 times)
2d shapes on a plane
Jun 21st, 2006, 4:21pm
 
I am really new (2 days) to Processing, looking over the documentation on the site and a few months of forum posts, I couldn't find out how to put 2d primitives on to a plane (or even create a plane for that matter).
I was wondering how I would go about placing 2d primitives in a 3d enviroment? Would it be creating a plane first then placing them on that or just putting the shapes straight in?
Re: 2d shapes on a plane
Reply #1 - Jun 21st, 2006, 6:08pm
 
It's really just a matter of specifying the right renderer in the size() function call:
size(400, 400, P3D).
Here's some code that plots 2d shapes in projective 3D space.
I used Processing's built-in rect() call as well as a simple custom poly function.

Code:


void setup(){
size(400, 400, P3D);
framerate(30);
noStroke();
}
void draw(){
background(50);
translate(width/2, height/2);

//built-in
fill(0, 0, 255, 50);
rotateY(frameCount*PI/150);
rect(-150, -150, 300, 300);

// custom poly calls
rotateX(frameCount*PI/120);
makePoly(5, 150, color(255, 255, 0, 100));
rotateY(frameCount*PI/110);
makePoly(3, 100, color(0, 255, 255, 100));
rotateX(frameCount*PI/130);
makePoly(8, 45, color(255, 0, 255, 100));
rotateY(frameCount*PI/50);
makePoly(12, 25, color(255, 255, 255, 100));
}

//custom poly
void makePoly(int pts, float radius, color c){
float angle = 0;
float x=0, y=0;
fill(c);
beginShape();
for (int i=0; i<pts; i++){
x = cos(radians(angle))*radius;
y = sin(radians(angle))*radius;
vertex(x, y);
angle+=360/pts;
}
endShape();
}
Re: 2d shapes on a plane
Reply #2 - Jun 21st, 2006, 8:44pm
 
"SHAPES ON A MF PLANE!!!"

i couldn't resist Tongue
( http://www.snakesonaplane.com )
Re: 2d shapes on a plane
Reply #3 - Jun 21st, 2006, 9:03pm
 
lol Smiley  good one!
Re: 2d shapes on a plane
Reply #4 - Jun 22nd, 2006, 12:36am
 
I was thinking snakes on a plane when I was writing this but I managed to resist Tongue Thanks, for the help, I'll let you know how I get along.
Page Index Toggle Pages: 1