Steve, I'm a bit rusty on that topic right now. I was seeing similarities in some "flocking" algorithms and the Iterator/particle systems in QC. Basically, for a "flock" to occur, you have to have independent elements, that try to anticipate and adjust to the average movement of the group -- collision detection would also be useful.
You can approximate this by having a random variable in movement with an iterator, or a more realistic, processor-intensive one where elements poll each other for direction and movement. The iterator is an "instance" of the code and objects within it -- so it's more efficient to compute the states of the iterated content and images in a parent patch, and then pass the results to the iterator, where it can figure the values of the element by knowing it's own iteration number. Anything "inside" the iterator, is computed for EACH AND EVERY iteration. So, make that object as dumb as possible -- it should get all it's data from an array by indexing it's own 'iterator variables: Current Index' patch. I had adapted someone's code for a map routing composition -- basically, creating an array of objects in Javascript. But the newer Queue in QC does this more elegantly, it in fact, replaces all of the code I played with in JavaScript, with just some variable inputs -- the Queue seems to be the way to go for a series of memory objects, something we've used the multiplexer or Javascript for in the past -- I'm guessing that is where you want to look. In your Developer's tools samples, look for "2 Queue.qtz" -- it has 4 numbers chase the mouse clicks in series around the screen. Those could easily be 4 "birds" that have varying degrees of accuracy in chasing the current "flock." Each bird flapping, could be pulling from a multiplexer of images to animate (which is hugely more efficient, than having each one pull an image from an animation from disk themselves). The past position of the current bird, can be used for a current bird in the flock with some random value making it "chase" the lead bird, which visually, nobody could see since all birds in the flock are randomizations of the same path. Particle systems will get you more performance, and you can keep changing the image used by the particle -- or perhaps use it's physical attributes to compute a flocking system -- but I don't think it will get you true flocking. Each particle can be a picture or a changing picture. You would want to play with the values and "particle life" so that birds did not move away from the flock or just disappear. This can be quite quick and easy and use a low random factor for the X and Y, while you just move the parent patch of the "flock" to move the birds as a group. So, a low birth rate, long-life particle patch will be a flock. You just have birds that fly through each other without regard. IF you want some collision detection; the X and Y values in a Queue, can be tested by the next "bird" in the queue, such that, you would take the current X,Y of the bird, add the velocity of speed to try to "catch the flock" and then see if any previous bird in the queue has this position, -- change direction if it does, until X,Y Not= any previous position. Do all this in your code BEFORE you create the queue that you pass on to the iterator. You have limits on the size of your flock with this method. I'm not hard core with any of this stuff yet. But, my guess is that if you were really wanted to have a lot of objects animated with individual behaviors, you might play around with the GLSL and Core Image patches. The data sets for 3D vertexes are huge -- but there is no reason that the computations made in these core image patches have to be on image data -- there just has to be a correlation between how you use the data going in and going out to what you are trying to compute -- make sense? You have positional and double-float values and massive data arrays if you consider one bird as a pixel -- but instead of processing a single mega-pixel image, you could use this to control a mega-flock of birds. More than a million -- more than your screen could display. I mentioned the same thing to a developer who was trying to image a huge data set of values he wanted to graph. The QC engine is designed for processing huge amounts of pixel data -- it's just that it doesn't have to be a pixel when you are done. So, you could start with a "flock of pixels", then perhaps, say that Red is X, and Green is Y and Blue is Z. Alpha might be used to determine which image in an array is used for the bird animation. Processing the pixel next in the array to "chase" the values of the previous pixel could be done super fast. You don't have to sample every pixel in this image at all times -- you might choose to have a "window" that was viewing the flock -- which correlates to "cropping" the image. Feed this data to an iterator, such that each "bird" knows that it is pixel(i) --the limits on the number would be drawing the various "layers" that the iterator creates. Less limited would be purely drawing the iterations in OpenGL-- as there are many more objects possible in that realm than in the iterator. Sorry I don't have some great proof of concept on this. I hope this might be a promising "way to look" at the problem. Regards, Mark Johnson > From: Steve Sheets <[EMAIL PROTECTED]> > Date: Fri, 7 Mar 2008 16:22:05 -0500 > To: <[EMAIL PROTECTED]> > Subject: Animated Swams > > Dear Mark, > > Today, after posting a question in the QC list regarding composition > that have flocking sprites, I saw your email from Nov 2007. You were > answer another new QC programmers question about creating groups of > sprites. Would you be able to share any QC examples that show the type > of behavior you mentioned? I am an experienced Mac developer, but new > to QC. I have been able to animated a QC composition inside a > CALayer, for some nice layered effects. Any bit would help! > > Thank you > > Steve Sheets > > _______________________________________________ Do not post admin requests to the list. They will be ignored. Quartzcomposer-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]

