We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Code
PShape head, body,leftleg, rightleg;
//head,body,arm1,arm2,leg1,leg2;
void setup()
{
size (400,300,P3D);
// frame.setLocation(0,0);
//parent shape
// satori = createShape
// PShape satori_head;
head = createShape(SPHERE,20);
head.setStroke(color(255));
head.setStrokeWeight(4);
head.setFill(color(126));
//now unto the body
body= createShape(LINE,0, 0,0,0,25,0);
body.setStroke(color(255,0,0));
body.setStrokeWeight(4);
body.setFill(color(126));
//drawing the left leg
leftleg=createShape(LINE, 5,25,5,0,0,0);
leftleg.setStroke(color(189,0,0));
leftleg.setStrokeWeight(4);
leftleg.setFill(color(126));
//drawing the right leg
//rightleg=createShape(LINE, 0,80,70,80,0,100);
//rightleg.setStroke(color(200,0,0));
//rightleg.setStrokeWeight(4);
//rightleg.setFill(color(126));
}
void draw() {
background(51);
//head translation
translate(width/2, 50);
shape(head);
//body translation
translate(-0,53,100);
shape(body);
//leftleg translation
translate(-0,53,100);
shape(body);
//rightleg translation
translate(-0,53,100);
shape(body);
}
like how does line in 3d works? How can i connect the line to the body to create legs and arms. Thank You ?
Answers
Go back edit your post
Empty line before the entire code section and after it
Select code with mouse
Hit ctrl-o
Oh click C in command bar
I did , thanks.
@emmaliecious --
Your problem is that you are trying to move the pieces around in space in two different ways -- once with createShape parameter, and then again later with translate commands. If the pieces is drawn off-center with createShape, then moving it further off-center with translate can do surprising things.
Think carefully about how you want your pieces (head, body, leg) to be related to 0,0,0 when you create your shapes. Keep it simple. Then use translate() and rotate() and align each piece around the origin while building your stick figure.
Notice that unless your pieces are different, you don't need to create one per limb. If you have a "leg" shape, you can arrange and draw it twice -- once for the left and for the right leg.
Here is your sketch with a few corrections and a simple PeasyCam added to the top and setup -- now you can drag the figure with the mouse to inspect what you are doing.