Advertisement

3D Flock Code Challenge

Started by May 06, 2011 04:19 AM
15 comments, last by zedz 13 years, 4 months ago
Considering it's running in Flash, I've developed some very fast 3D flock code.

There's a lot of experienced programmers on gamedev , so if you're up for a challenge, see how fast you can get an epic 3D flock running.

A few rules.

1) It must be browser based for accessibility and fairness. But you can use anything, Flash, Java, Unity etc, as long as it runs in the browser.

2) The flocking objects can be anything, however they must have rotation, so you can see the direction they're moving in etc. So no dots/ pixels. Because I'm using a software engine, doing everything on the CPU, I choose to render 3D lines for max performance.

3) Mininum resolution of 750 by 422.

4) Must be a proper cohesive flock, not just a bunch of objects randomly moving around.

5) Must have a moving camera, tracking the Flock.


Here is my demo - http://rumblesushi.com/turbo_flock.html

Runs at around 45fps on my humble Dual Core with 5600 objects.

So you can see how much juice rendering polys uses, this runs at the same framerate, but with only 1100 objects - http://rumblesushi.com/cube_flock.html

I look forward to seeing what you can do ;)

RumbleSushi
Looks cool! sounds interesting but Iam not to sure what a flock is... is it like a swarm?
Advertisement
Flocking is what birds do, basically a small number of independent entities moving together as one larger body and can shift directions seemingly as one.

Technically swarming is a slightly different, but related, concept that stands apart due to its more chaotic nature caused by staying in a more local area. Basically it kind of boils down to swarming characteristics being found in semi stationary formations as the population flies around in a small general area. Flocking tends to happen while on the move, so you get less changes of position relative to the rest of the formation. A swarm might have half the flies doing roughly clockwise rotations about the centre of mass while the other half does it counter clockwise, but in a flock they are all travelling in roughly the same direction at similar speeds.


For computer flocking/swarming simulations, the real interesting bits are whether or not you allow entity intersection and if you calculate each entity as its own independent AI making choices about where it should be, or if you copy and translate positions. (basically taking 100 entities, copying them 10 times, shifting their position slightly, and giving the appearance of 1000.)
Old Username: Talroth
If your signature on a web forum takes up more space than your average post, then you are doing things wrong.
you should move the camera outside of the center of the box. It's kind of hard to appreciate it when the camera is whipping around like a cat on heroin.

edit: ahhh you can move around with the mouse.
This is a proper flock, each entity has it's own behaviour/basic AI.

I've never seen the copy/paste with random offset method, but I can't imagine it would look very good at all.

I've never seen the copy/paste with random offset method, but I can't imagine it would look very good at all.

It depends entirely on what you are using it for.
Advertisement
If you're using it to simulate a flock, as is generally the case with Flock code, I imagine it would look very sub par.

[quote name='rumblesushi' timestamp='1304694199' post='4807361']
I've never seen the copy/paste with random offset method, but I can't imagine it would look very good at all.

It depends entirely on what you are using it for.
[/quote]

Yeah, it really depends on what you are using it for and exactly how you do it.

If you have 1,000,000 entities are you going to notice that there are really only 10,000 unique ones with the rest copied out? The real way to make it look good is to make the copy-cats flexible so they can break off and become a new core entity to change things up, and then merge back in with another core entity and leech of its calculations.

Keep more 'unique' elements facing the camera, and fudge the inner and far sides. When you have thousands of fast moving objects you'll notice if the two closest to you pass directly through each other. But the ones on the far side that are half covered by 20 other entities? They can be flying a preset loop and clipping each other every other second, and you'll be hard pressed to spot them.
Old Username: Talroth
If your signature on a web forum takes up more space than your average post, then you are doing things wrong.
Fair point, I guess if they randomly switched, you could get a more organic look. I can't really imagine how it would look though, with the cloned positions etc.
By the way, do you have any examples of a flock using this cloned position technique?

Also, any of guys proficient in Unity or Java want to have a bash at outperforming my humble Flash Flock?

This topic is closed to new replies.

Advertisement