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.
Page Index Toggle Pages: 1
help me (Read 555 times)
help me
Feb 12th, 2008, 5:44am
 
I'm trying to create a crowd of people in a 3 dimensional space on processing using only 8 images of figures.  Anyone have any ideas how I could do this?
Re: help me
Reply #1 - Feb 12th, 2008, 8:29am
 
I'd approach it like this

Make an array of PImages.
Make an array of random x positions
Make an array of random y positions

Do this till you run out of array positions
Pick an image from the image array
Draw the image at the x and y position

is that the kind of thing you're after?
Re: help me
Reply #2 - Feb 13th, 2008, 6:23pm
 
i think that could work, but i want a set y coordinate so it looks like the people are walking on the same plane....i want the 8 figures to be repeated randomly at x and z coordinates so that altogether there appears to be a lot of people.
Re: help me
Reply #3 - Feb 13th, 2008, 6:23pm
 
i think that could work, but i want a set y coordinate so it looks like the people are walking on the same plane....i want the 8 figures to be repeated randomly at x and z coordinates so that altogether there appears to be a lot of people.
Re: help me
Reply #4 - Feb 13th, 2008, 6:53pm
 
You can do it quite easily:

Code:
int[] personX;
int[] personZ;

PImage[] images;

void setup()
{
//size...
images=new PImage[8];
images[0]=loadImage(".....");
//load all images

personX=new int[50]; //50 people
personZ=new int[50];
for(int i=0;i<50;i++)
{
personX[i]=random(width);
personZ[i]=random(height);
}
}

void draw()
{
background(255);
//some transalte stuff to set your 0,0,0 point..
for(int i=0;i<50;i++)
{
pushMatrix();
translate(personX[i],0,personZ[i]);
image(0,0,images[i%8]);
popMatrix();
}
}


This will draw 50 people on the screen using the 8 images.
(I've not actually tried it so there may be minor bugs, but the theory should be sound)
Re: help me
Reply #5 - Feb 13th, 2008, 8:41pm
 
thank you so much.  this really helped me get started.  i've loaded all my images and set my size, but i'm running into problems with the personX and PersonZ arrays somehow....
Page Index Toggle Pages: 1