Wind simulation

Post Reply
davidc538
Posts: 7
Joined: Mon Nov 08, 2010 2:00 am

Wind simulation

Post by davidc538 »

I've been looking at using bullet to build a portfolio peace. I've read through the documentation and it looks like a very good physics solution but i still have one major question. Is it capable of simulating wind? or are there any simple techniques i could use it with to simulate wind?
marios
Posts: 52
Joined: Mon Jul 19, 2010 3:11 am
Contact:

Re: Wind simulation

Post by marios »

i think the best way to achieve this is to iterate over all dynamic bodies and apply central inpulse/force in the direction that you want, on every physics tick, like this:

Code: Select all

int i;
for (i=dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
	btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[i];
	btRigidBody* body = btRigidBody::upcast(obj);
	if(!body->isStaticObject())
	body->applyCentralForce(btVector3(10.f,0.f,0.f)); 
}

//....

dynamicsWorld->stepSimulation(/*....*/);

it gonna make wind in x direction. Of corse you can randomly or by formula change direction/power to make wind more unpredictable
stnal
Posts: 7
Joined: Wed Nov 10, 2010 8:57 am

Re: Wind simulation

Post by stnal »

Nice solution!
benadler
Posts: 8
Joined: Tue Mar 09, 2010 12:52 pm

Re: Wind simulation

Post by benadler »

I have a file of wind-data collected by an ultrasound-anemometer at 10Hz in 10m height. From this file, I'm using the x/y/z-components (in m/s) and simply convert these to a btVector3 and then applyCentralForce().

Now, this moves my object around very nicely, but, it induces no rotation at all. Since it is not a sphere, I think the wind should also cause some torque to be applied. Are there any ideas for adding some torque (which surely depends on the object's shape)?
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm
Contact:

Re: Wind simulation

Post by dphil »

I think the kind of thing you could try for that is to get the faces of the object that are facing the wind and add a force to the object for each face, based on that face's surface area and angle with respect to the wind direction (ie larger SA and more perpendicular to win direction = greater force applied on the body in the direction of that face). This would involve a decent bit more computation, but would give more realistic results. On a side note, this is basically how bullet's soft body cloths process aerodynamic forces.

Edit: Actually if those are all centrally applied forces you still wouldn't get rotation. The soft body situation avoids this by having forces applied to individual nodes spread around the soft body's surface, after first solving for the forces on each face (and splitting that force to the nodes that share that face). So for a rigid body I suppose you could calculate the positions of the vertices or face centers and apply forces there... anyway, just some thoughts.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Wind simulation

Post by Flix »

stnal wrote:Now, this moves my object around very nicely, but, it induces no rotation at all. Since it is not a sphere, I think the wind should also cause some torque to be applied.
Hehe :D , this has no connection with the fact that you're simulating wind! If you look closely, when rigid bodies fall in Bullet, they do it regardless of their mass and they won't rotate at all while falling (they should if they're not spherical).
This happens because air friction is not simulated. It's not trivial to add air friction to rigid bodies. The total force applied to a body should be: gravity force + air friction force + hydrostatic force (the latter makes balloons go up and buoyant objects possible). Maybe it's possible to approximate it in different points of a body (by applying forces in a few local points, we can skip the torque calculations...), but I don't have any clue about how to do it :? .

P.S. I remember that there was a demo called appHeightFieldFluidDemo in the Bullet package that simulated hydrostatic force on rigid body. You can check if air friction force was simulated too.
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm
Contact:

Re: Wind simulation

Post by dphil »

The "Aero" demo in the "AllBulletDemos" Xcode project shows how air resistance causes "sheets" of material to flutter/glide down to the ground. The relevant code that causes this behaviour is in the applyForces() function in btSoftBody.cpp.
Post Reply