This project has moved and is read-only. For the latest updates, please go here.

SPH (Smoothed Particle Hydrodynamics) in 3.5

Sep 10, 2013 at 9:36 AM
I noticed Genbox mentioned 3.5 was going to have SPH in it but I can't seem to figure out how to actually implement it.

Also I want to simulate airflow using either a very light fluid in SPH or using smaller circle objects with a repulsive force (to minimize number of actual collisions) to kind of approximate it. Any thoughts on how to do this?
Sep 10, 2013 at 10:25 AM
SPH was not implemented in the end for 3.5

for the airflow, there are a number of ways to do it. 1 being sensor objects that add a repulsive force as you mention

Depending on the effect you are going for, if there is a specific complex path for the airflow i'd be inclined to use a number of path vertices (just positions) and work out the nearest two to your objects position, work out the direction normal of the path between those two points and apply a force in that direction.
Sep 11, 2013 at 7:36 AM
It seems like someone made a SPH demo using Farseer but it appears to be an older version (can't tell which) that has some deprecated functions.

PolygonShape.SetAsBox is used but I'm not sure what the current equivalent is in 3.5.
Sep 11, 2013 at 10:45 AM
Just pass the vertices in the constructor

      Body bottomBody = BodyFactory.CreateBody(_world, new Vector2(0, 7f));
            PolygonShape bottomShape = new PolygonShape(FarseerPhysics.Common.PolygonTools.CreateRectangle(12f, 1f), 1f);
            Body leftBody = BodyFactory.CreateBody(_world, new Vector2(-11f, 0f));
            PolygonShape leftShape = new PolygonShape(FarseerPhysics.Common.PolygonTools.CreateRectangle(1f, 10f), 1f);

            Body rightBody = BodyFactory.CreateBody(_world, new Vector2(11f, 0f));
            PolygonShape rightShape = new PolygonShape(FarseerPhysics.Common.PolygonTools.CreateRectangle(1f, 10f), 1f);