I'd like to make game with some windmill in it and want to make wind via b2vec2 gravity vector. I can't find开发者_开发问答 some clear explanation about wind resistance. Is it possible with box2d? May I ask you to point me to necessary functions and documentation please.
What you are trying to do is most likely impossible with box2d, as that would involve the physics being simulated in 3d, while box2d only does 2d physics. If I was you, I would just fake the animation. By having the blades of the windmill in a separate CCSprite than the body of the windmill and then rotating the blades around the z-axis using a CCAnimation that matches the wind speed.
For games
Depending on the game, you may not need to worry about drag force (wind resistance). You could probably get away with pushing objects in the direction the wind is blowing, using an ApplyForce
or messing with gravity (like you mentioned in the question).
If you really want to model wind resistance
Looks like linearDampening
could be helpful, though unrealistic. True air resistance isn't linear.
You could also do an ApplyForce
every frame, opposite the velocity. Unfortunately its been a while since I've taken my mechanics class, so I can't help you with the code, but you could look at this wikipedia article for the formulas
I stole most of this info from this thread:
http://www.box2d.org/forum/viewtopic.php?f=3&t=2718
If you are still having problems
I made some assumptions in my answer. I assumed that you're making rudimentary approximations of things like wind and air resistance. I also assumed you're not truly trying to model a gas pushing a fan, as you probably won't have much luck doing that in 2D, and even if you tried, I can't imagine it adding much to your game.
If you're still confused, try adding some example code to your question, or describe what you are trying to simulate in more detail.
精彩评论