Thursday, October 25, 2012

Initialize vector onto mesh face

Here is a little function i wrote some time ago. If you want to initialize your agents onto a specific face of your mesh , this is what you're looking for mate!.You provide,as argument, aWEFace and it returns a vec3D (toxiclibs library needed).

Vec3D initInTriangle3D(WEFace f) {
  Vec3D r = new Vec3D();
  float a1 = random(1.0);
  float a2 = random(1.0);
  Vec3D v0 = f.a.copy();
  Vec3D v1 = f.b.copy().sub(v0);
  Vec3D v2 = f.c.copy().sub(v0);
  r = v1.copy().scaleSelf(a1).addSelf(v2.copy().scaleSelf(a2).scaleSelf(1-a1));
  Vec3D r1 = new Vec3D(r.x, r.y, r.z);
  return r1;

Grab the processing file here.
I have other functions and piece of code that i'll be posting (hope weekly).

Friday, October 19, 2012

More to come

If i have to be honest, this is a fake post (had to upload at least a pic..sorry guys).

Thursday, October 11, 2012

Body studies

These are some of the initial studies a i did,about agent and bodies.Trying to escape as far as possible form isosurfacing, i decided to extend my agent class with toxiclibs VerletParticle class.This allowed me to connect different agents with springs.Now..."this is a story of a lonley agent named Bob walking on his way.One day he finally met another bob and said"hey mate,take my hand and we will walk toghether fo evah!(true story!).

SpringAgentsChain from Paolo Alborghetti on Vimeo.

The logical next step was implement that logic on mesh,turning vertices into agents,edges into spring.Changing flocking paramenters you can guide the deformation of the mesh.Interesting morphologies emerge.

SpringMeshAgent from Paolo Alborghetti on Vimeo.

Monday, October 8, 2012

Stigmergy models

Some mounths ago i've been working on some models of stigmergy,just to get confidence with the tools(processing) and the systems i'd have been working with, for my thesis.
The first model is basically based on a common flocking algorithm,but every agent perform flocking towards tail points, and not towards other agents.Here the diffusion of pheromone (like what happen in nature,see ants and termites) is simulated by range of vision of every agents, and pheromone decay by tail length (longer the tail,higer the probability of an agent to follow the others).
I implemented toxi pointoctree (thanks Tommaso Casucci),for optimisation of tail point search (long tails means bigger array of points---->kill framerate) and because i was interested in working with huge population of agents.Here a short video of the model:

stigmergic fibrous systems from Paolo Alborghetti on Vimeo.

The second model was based on the idea of using a vector field.The outcome was really simple and computationally lightweight.It was not stigmergy,but a kind of model of percolation.Here Every agent reads its future location and writes his speed in the field.I have to say that it's funny when you're trying something and you end up with something completely different.Here a short video of the model:

percolation 2 from Paolo Alborghetti on Vimeo.

The third model i've been working with,and was the one i've been working on the most,is based on a semplified version of the model of jeff jones based on chemotaxis (for the simulation of slime molds behavior).You can find more information here:
This code is based on a  pheromone field (field of values).Every cicle each agent deposits pheromone (like little farts...we can call it  "farting agent" ) and reads pheromone value correspondent to his future location (smell other agents farts).For more information about the model i suggest to take a look at the link above(nothing about farting in Jones papers obviously!!).
I have to say that this model is amazing!It is really lightweight,you can work with huge population and tuning parameters you can obtain a wide range of patterns.
Here a short video of the model (10000 agents,two different populations fighting for space occupation,each one eating the other one pheromone):

stigmergic networks_2 populations from Paolo Alborghetti on Vimeo.