boids and better particles

http://www.abs2net.com/robert/3d_boids/

http://www.reptilelabour.com/software/flow/index.htm

with blender becomming open source is it possible to incorporate other open source programs into blender- the two above are just some examples which I think would be pretty awesome inside blender. – actually I didn’t check if they were os!

is this kind of thing possible?

matt

WHISTLE

Yeah, that would be very cool indeed. I’m not sure what the exact letter of the law is on something like this - including other open source stuff inside other products, I mean. If it was allowed, we could include all sorts of cool stuff - POVRay for one thing.

Well, failing that, we can always just do some damn good implementations of our own stuff inside the Blender source which does exactly the same thing (like Dynamica, for example…)

LethalSideParting

Just for anyone reading this, Dynamica is ‘frozen’ for the time being. Things are about to change radically for Blender, the whole things needs a different implementation in C/C++, in other words, a complete rewrite, not just python scripts. Also, since a lot of professional (or at least more experienced) programmers have joined recently, some of them might well have better and different idea’s on how to implement these things. So it could be that Dynamica will soon only be a vague memory…
I’m sure Theeth has other (and more optimistic) things to say about this, but he seems rather busy lately with other things (school).

Anyway, the boids algorithm was part of the earliest Dynamica implementation. But there was also a plugin that did this. I don’t know where you can still get that (python extension) plugin, maybe somewhere on SirDude’s site.

yeehaw! yea, a cool particle and soft body dynamics engine would really whip the lover’s ass inside blender. another cool thing would be to embed virtualight of lightflow or bmrt inside blender, so those awful exports wouldnt be necessary anymore.

Tom

and then MYRENDER engine comes out and kick ass, 10000 times the rendering speed and you cannot use it with blender

The export scripts are a MUST

yeah, that and trying to organize the Montreal meeting, running a contest, participating in that contest, keeping some time for relaxing, …

Anyway, the boids algorithm was part of the earliest Dynamica implementation.

indeed, and the code was very ugly. Still, the principle are there.

But there was also a plugin that did this. I don’t know where you can still get that (python extension) plugin, maybe somewhere on SirDude’s site.

I think you can find it on Ingiebee’s site, in one of the old Blender.nl announcement.

Like Eeshlo said, Dynamica is temporarely frozen, so we don’t loose time working on code that will probably be discarded after the open source. However, after the initial open source rush is over, I’ll try to get a team together, so everyone that wants to integerate physics/particles/boids could help one another in a single integration/cooperation.

Martin

Theeth, I have some basic knowledge of physics but have a fairly thorough grasp of the dynamics of the trajectory of non-aerodynamic objects (ie cannon balls.)

Of course I would be delighted to give you any info you would need on this subject.

Great! I’ll recontact you when we’ll restart Dynamica with a new team, if you can to help us then.

Martin

not if you have more brain cells than the average chicken, which you obviously dont.

I’ve compiled Tatsuya Nakamura’s boid module with Python20. I hope it can work with Blender 2.25, but all the birds flew away from the box. Is there something wrong with my flock.dll or Blender 2.25 Python Interface?
BTW:Is it possible to put an attachment here?

as i’m very new at this (python and all) the following code is probably a disaster, but it works… It’s based on the pseudocode for boids at http://www.vergenet.net/~conrad/boids/pseudocode.html

1.create empty (name = initGame)
in realtime tab add always sensor with fire pulse switched off
link always sensor to Python script (initGame):

import GameLogic as g

#creates the objectlist
g.ObjectList = []


2.create empty (name = Add) with property int ‘N’ = 0 and int ‘Add’ = 1
in realtime tab add property sensor with fire pulse switched on
Prop: Add - Equal - 1
Link this to Pythonscript (newPos)
This script randomly places an amount of boids

import GameLogic as g

c = g.getCurrentController()
o = c.getOwner()
AddBoid = c.getActuator('AddBoid')

print 'newstart'
N = o.N

#the maximum amount of boids is set to 10
if N<11:
	#set new random position
	x = g.getRandomFloat() * 50
	y = g.getRandomFloat() * 50
	z = g.getRandomFloat() * 50

	newPos = [x,y,z]

	#move empty to new position
	o.setPosition(newPos)

	#add new boid
	g.addActiveActuator(AddBoid,1)
	
	#add boid to objectlist
	lastBoid = AddBoid.getLastCreatedObject()
	if lastBoid != None:
		g.ObjectList.append(lastBoid)
	o.N = o.N +1
	
else:
	o.Add = 0
	print g.ObjectList

connect the script to an Edit Object actuator named AddBoid
Add Object - Boid

3.In a new layer add a boid named ‘Boid’ with property int ‘dx’ = 0,
int ‘dy’ = 0 and int ‘dz’ = 0.
in realtime tab add always sensor with fire pulse switched on
link always sensor to Python script (Rules):

import GameLogic as g

c = g.getCurrentController()
o = c.getOwner()

x = o.getPosition()[0]
y = o.getPosition()[1]
z = o.getPosition()[2]

dx = o.dx
dy = o.dy
dz = o.dz

print 'vel =',dx,dy,dz

#xxxxxxxxx RULE 1 xxxxxxxx

#count of objects in list (just to know)
max = len(g.ObjectList)
print 'max =',max


sum = [0,0,0]

for boid in g.ObjectList:
	#if boid is not equal to this boid
	if boid.getPosition() != o.getPosition():
		sum[0] = sum[0] + boid.getPosition()[0]
		sum[1] = sum[1] + boid.getPosition()[1]
		sum[2] = sum[2] + boid.getPosition()[2]
	else:
		print 'boid is thisboid'

# pc = percieved center of mass
pc = [sum[0]/(max-1),sum[1]/(max-1),sum[2]/(max-1)]
print pc
v1 = [(pc[0]-x)/100,(pc[1]-y)/100,(pc[2]-z)/100]
print v1

#xxxxxxxxx RULE 2 xxxxxxxx

dist = 10
v2 = [0,0,0]

for boid in g.ObjectList:
	#if boid is not equal to this boid
	if boid.getPosition() != o.getPosition():
		if abs(x - boid.getPosition()[0]) < dist:
			if abs(y - boid.getPosition()[1]) <dist:
				if abs(z - boid.getPosition()[2]) <dist:
					v2[0] = (x - boid.getPosition()[0])/50
					v2[1] = (y - boid.getPosition()[1])/50
					v2[2] = (z - boid.getPosition()[2])/50

#xxxxxxxxx RULE 3 xxxxxxxx

#sum of all velocities
sumvel = [0,0,0]
#factor of influence
f = 1.5

for boid in g.ObjectList:
	#if boid is not equal to this boid
	if boid.getPosition() != o.getPosition():
		sumvel[0] = sumvel[0] + boid.dx
		sumvel[1] = sumvel[1] + boid.dy
		sumvel[2] = sumvel[2] + boid.dz
	else:
		print 'boid is thisboid'

# vc = percieved velocity
vc = [sumvel[0]/(max-1),sumvel[1]/(max-1),sumvel[2]/(max-1)]
print vc
v3 = [(vc[0]-dx)/f,(vc[1]-dy)/f,(vc[2]-dz)/f]

print v3

#xxxxxxxxx POSITION xxxxxxxx

print 'initial velocity = ',dx,dy,dz
vel = [dx+v1[0]+v2[0]+v3[0],dy+v1[1]+v2[1]+v3[1],dz+v1[2]+v2[2]+v3[2]]
newPos = [x+vel[0],y+vel[1],z+vel[2]]
o.setPosition(newPos)

in realtime tab add always sensor with fire pulse switched off
link always sensor to Python script (Velocity):

import GameLogic as g

c = g.getCurrentController()
o = c.getOwner()
vel = [-1,-1,-1,0,0,0,1,1,1,0]

i = int(g.getRandomFloat()*10)
o.dx = vel[i]
j = int(g.getRandomFloat()*10)
o.dy = vel[j]
k = int(g.getRandomFloat()*10)
o.dz = vel[k]

AND THAT’s it… It’s probably a nightmare for those of you who know how to program Python but as i don’t (not really :expressionless: ) i very much welcome any changes etc…

I’d love to help with this. I am a Comp. Sci & Physics major after all. :smiley:

Hey theeth, i tohught I’d tie up a loose end her and re-offer my hep on dynamica/pysics engine. I know nothing aobut Python, but I’ll gladl help on algorithms.

Hmm, no rules on necrophilia (reviving dead threads) on this board? Anyway, did a quick search and there’s a python BOID implementation available under GPL here: http://sourceforge.net/projects/pyboids/
It’s a bit large, and probably needs major reworking to be ported over to Blender. Any takers?