Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

What engine supports air-friction with "push-back"?

  1. Jul 3, 2015 #1
    Hello Community!

    Hope I've finally found a forum which could help me with this question :)

    Currently I'm preparing for a rather big software project in college.
    For this, I need a 3D Physics Environment/engine which supports more or less realistic air friction.
    What I want to achieve is to enable a skeletal model of a bird to fly on it's own wings (driven by a genetic algorithm).

    Physical correctness (like in professional airflow simulations) or particle-simulation is not required as I am studying programming (the genetic algorithm is my focus), not physics. The system needs to be real-time capable though.
    The programming language is also open (but it'd be a point as I know C#, Java and Lua already..)

    To make it easier to understand what the Engine has to support, let's say I have a simple plate attached with a hinge-joint to an object.
    When I apply a torque to the horizontal plate so its loose end moves downwards, the attached object has to gain a vertical force/impulse. Simple newton mechanic (action -> Reaction), I guess.
    However, if I make the plate smaller (or rotate it along its axis) but give it the same mass and same torque-speed, the vertical force/impulse on the other object should be smaller because the smaller plate pushed off less air due to its smaller surface in movement-direction.

    Sadly the second point takes out all open 3D Game engines I know, like Unity3D for example.

    Does someone here around know an alternative?
    Would be really thankful!

  2. jcsd
  3. Jul 3, 2015 #2
    I think you have likely chosen a problem that is too difficult.

    Realistic aerodynamic modeling is much different from writing game code.
  4. Jul 3, 2015 #3
    Thank you very much for the answer!
    What do you mean exactly?
    And realism is not directly required...
  5. Jul 3, 2015 #4


    User Avatar
    Gold Member

    Because simple action/reaction is not going to take into account things like the viscosity of air, pressure and air flow. Without those things, you don't have flight.
  6. Jul 3, 2015 #5
    Of course, but are there no graphical simulation engines which take this into account and which can be controlled by some sort of code like from another program?
  7. Jul 3, 2015 #6
    Wow, what an interesting project. I just looked into the question out of curiosity. I guess the field of fluid dynamics includes air, which I didn't know. Mechanical engineers use various CFD (computational fluid dynamics) packages to work this stuff out. A quick google search turns up a few open source CFD packages. But you might want to ask the engineering forum about what's out there, and see if you can adapt it.
  8. Jul 3, 2015 #7
    Still looking... This is interesting, if you really need something basic, and just need to evolve wings:
    There's a very approachable paper there too:
    Anyway, none of this is part of the 3D engine, but that doesn't matter. You can use whatever engine, you just need to properly render the evolved wing shape, and properly render what happens to the bird/plane based on the lift generated by the wing shape. Here is a javascript port:
    There's probably more out there to grab code from. It would be fun to do planes, styrofoam RC planes, computationally evolved, would be fantastic project for a resume.
  9. Jul 3, 2015 #8
    Hey, thank you for paying attention to my thread :)

    Yes, the kind of air-friction I need is very similar to fluid dynamics.
    Also thank you for the link!
    Think that's not really what I need though, as my target isn't actually developing the wing shape.
    So the streamlining-effect (which keeps artificial planes in the air) is not necessary.
    What I plan to achieve is something like that: http://www.goatstream.com/research/papers/SA2013/index.html
    Just with a flying creature instead of walking dinos...
  10. Jul 3, 2015 #9
    LOL! I love that link, especially, where the cube man is getting cubes thrown at him. Why are cube creatures so hilarious? Reminds me of this, from MIT talk on AI evolutionary algorithms:
    EDIT: PhysicsForums seems to be stripping the time information from the link. Go to 40:45

    (Something to note to you if you haven't seen it, its very similar to what you are after, but in water.)
  11. Jul 3, 2015 #10
    Haha, this one is even more hilarious!
    Nope didn't see it before and it has quite a bit of a similarity to what I plan, except for my creature needing to fight a lot more against gravity. Damn, I hoped to be the first :( XD

    Hmm.. over in the Unity3D Forums, I got the suggestion to program this calculation by myself. Actually I could model a dragon or bird wing easily from 6 or 7 plates where I would calculate the air-resistance depending on their moving direction and speed. Wont look as good (though I probably could map a rigged model of the creature simply around it) but fulfill its purpose.
    Perhaps I should modify my project-plan a bit and do it together with my "Gameplay Physics" professor too (and not only the one for AI)..

    EDIT: But what Environment did they use there at the MIT? Sorry, my spoken English is sadly not the best and I'm tired ><
  12. Jul 3, 2015 #11


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    That is probably overkill for a real-time simulation program. Although CFD is a valuable tool for developing aerodynamic coefficients, it is very computationally intensive and turning the results into usable aerodynamic tables is an art. There is a small set of functions that are needed to model aerodynamic flight fairly well. You would need some reasonable approximations for the coefficients of drag, lift, and side force.
  13. Jul 3, 2015 #12
    Karl Sims work shown there was from 1994 and done on many distributed computers, who's combined powers would be equivalent to a modern GPU. So whatever he used is probably really dated and not useful for you. But its also worth noting that he simulated swimming in water not flying, so I think your idea is still unique.

    Edit: Sanity check, I was said you could simulate air based on cells, but when I thought about it, that's totally too expensive for an evolutionary algorithm, that needs to model huge populations over large time. You need a simple approximation to make it work.
  14. Jul 3, 2015 #13
    Hey, you seem to know a little more about this stuff. I know its a branch off from the OPs project, but how hard do you think it would be to model accurately the flight of an RC plane aerodynamically based on a given shape? Not pinpoint accurate, but close enough so a simulation could evolve some body designs, and they could be 3D printed, and fly more or less as modeled? I know they can be 3D printed now:

    An autonomous drone breeding program would be creepy, but cool if you do most of it in simulation.
  15. Jul 5, 2015 #14
    Automated breeding program? You mean which develops and prints drones full automatically?
    Hmm.. the game designer in me sparks up, haha X3

    Aaaanyways, since I didn't have to celebrate my country all day yesterday xD I spontaneously programmed a small simulation!

    The following idea came to my mind before:
    What if instead of trying to think about what the air does to the wings, I just calculate the volume which the wings travel each step through the air?
    I mean if I can sum up the whole "difference" from one step to another, the result will be all the virtual "air" which the wing has pushed within this step.
    In the end this value tells how strong and in what direction the force has to be applied.

    Well, for this prototype I reduced the whole concept to simple 2D wings made of elements which are connected to each other with hinges. The hinges are constantly alternating like a sinus wave between two angles. For this example I used -25° and 40° for the left wing and the negated values for the right wing:

    Here you can see the wing movement but without applied force. Therefore the center doesn't move.
    Full Static.gif
    The wing is the darker blue line and the bright quadrangles symbolize the amount of air pushed off by each element. They are just a visualization and not part of the actual physic simulation.

    Next I applied the summed area to the object, simply changing its y-value on the screen. The result was a bird flying perfectly up and down but since the way all segments were doing were identical when swinging and and when swinging down. the bird simply remained in place after a whole flap of the wings.

    However, it was surprisingly easy to break this balance. Only the two inner elements have a headstart of 30% (that's already seen in the upper animation) and it already caused a difference of the maximal force between swinging up and swinging down.
    You can also see this slight difference as the graph moves more in the green area (= force upwards) than in the red area (negative force downwards).

    And well, what shall I say? It flies! It flies!!! Muahaha! XD

    With the movement "unleashed" (yet still without gravity) it looks like this:
    View attachment 85563

    To be honest I'm amazed how well that all worked. This conecpt allows already a lot of variables to use as "genomes" in the genetic algorithm (which I'll probably do directly in 3D).

    If someone wants to try this himself, you can find the zipped GM81 file down there. This is for Game Maker 8.1 (the program I'm the most fond of for prototypes, lol) but you can also open import it in the free version of Game Maker Studio.
    The code is hopefully easy to be understood and mostly commented (as I'll probably show it to my prof too).

    Still a question to the physic experts here around: Is this form of calculating the force "realistic"?
    Of course it's only an assumption as interactions between moving air is not taken into account (every segment works on its own) and air-pressure is not being taken into account either. In this example I applied the resulting forces directly to the root/center. In 3D with a rigid physics engine (msot likely the one in Unity3D), I'll apply it individually to each segment of the wing.
    So would you say that those are too many breaks with the physic laws for my purpose already?

    Again thank you for your help :)

    Attached Files:

  16. Jul 6, 2015 #15
    Yeah printable drones, RC flying things that automomously design themselves and their behavior based on genetic algorithms. Its an idea of social value more than engineering value, designed to delight the press with its creepiness, and start a conversation more than anything else. The concept is you have this 3D world where all the drones are testing, flying around, and mating, that you can actually see it all. You can take a reporter into the virtual ecosystem via Oculus rift, and maybe give them a virtual orange stick that some drones are attracted to and others avoid to move around. Then you show them some drones in the virtual world that have been printed, and you take them out to physical reality, in your back yard, and let them interact with the drones with the same orange stick to see they look and behave the same way.

    The idea is, you start through their journalism a conversation in the public a conversation about things like this: Virtual worlds where A.I.s train and design robots, which get implemented into reality. It gives people an idea of what's coming down the road, that's why I like it. Of course, there could be some fun RC drone flying games in their too, like trained drones to chase your RC drone at the park.

    As far as your work, WOW! Thanks for posting! I can't believe you pulled off something so good so fast! Is it reasonably fast running? Its gonna be cool to meet my first dragon that really flies in a video game. It already looks good too, I love the look of those wings.

    I hope you get a physics person to answer... I think you'll be close when your wings can fly without flapping, like many birds do: http://www.sciencedirect.com/science/article/pii/S0079661110001072
  17. Jul 6, 2015 #16
    Ahh, yes, there are quite a few things which can be "learned" in an simulated environment. I agree that this will definitely gain more and more popularity over time, even if some people fear that Skynet will be the result... xD

    Very glad you like my work =D Yes, sometimes I have such real surges of creativity x3

    You are right about that something is missing, though I rather think not what the article you linked says (about vertical winds and the like).
    My simulation misses the effect which keeps normal planes in the air: The fact that the curved upper side of the wing compared to the flat underside causes a pressure-difference which pulls the whole plane upwards. Birds like albatross use this effect too.
    I'm not 100% sure whether I really need this, since I think about doing a dragon and they usually have a wing structure similar to a bat which lack this cove. They are rather flat.
    When I do the whole thing in 3D, I might think about finding a way to implement this too.

    As for having a dragon like this in a game, yep that would be cool! xD Sadly the benefit of actually having such a physics simulation in the game is not very big. After all it doesn't really interact with the environment. It would be cool if I could actually simulate winds and currents this way, but that doesn't work directly with my method, I fear.
    Unless I modify this area(in 3D: volume)-calculation to take movement of the air into account.

    As for performance, i'd say it works reasonably well. On my Gaming machine I reach 3000fps with that wing (without air-visualisation) in game Maker studio. I didn't optimize very much though and it's all based on an interpreted language.
  18. Jul 6, 2015 #17
    Good, the main thing is you're in the performance range where you can let genetic algorithms work effectively, given some days of running time.

    After I read your post, I remembered a toy I had as a kid, from France. Timmy Bird:

    Its basically two bent rods for wings, and in between is a material that doesn't stretch much if at all, like mylar, but its a little loose. The up and down motion of the wings results in almost just a simple fanning motion, with the tail positionable to give it lift, so its flight curves upward until it "stalls" and dips back down. Its a design I feel would have a simple simulation. Maybe something to think about. BTW, are you comfortable with calculus / vectors?
  19. Jul 7, 2015 #18
    Ohh that's one cool toy!
    A tad too simple for my purpose though, I think.. after all I'm gaining 8 "ECTS" for this project, meaning I'm supposed to spend about 240 hours on it in total.

    What do you mean by comfortable?
    3D calculus works (had this in school already too).. but when it comes to hell like matrices or theoretical math, I have to pass (very glad those basic courses are behind me) x-x
  20. Jul 7, 2015 #19
    I was just curious where you were at with math, musing about how a vector model of bird flight might be constructed.
    I have no great ideas, just thinking about how you could model plan wings as airplane wings (like from NASA link) along with a thrust forward from flapping like Timmy bird, with tail defining direction.

    ECTS, you must be in Europe, right? What country? I am in US.
  21. Jul 7, 2015 #20
    Well, since I want to keep the option of including this whole project perhaps into something "larger" as to make more of it than just this single term project, I'll do it either in Unity3D or in Unreal Engine 4. Those engines both support complex skeleton-based models and animations which are computed efficiently with PhysX. That means I wont have to do the actual mechanics (and the related computations) all by myself.
    I'll only have to improve the existing physic engine by this "air-friction" aspect I've realized here in 2D already.
    The wings will consist of a couple of plates (probably ~8) connected by hinge-joints (which have a comparable behavior to the ones I did in 2D) as well as ball-joints.
    Over in the Unity forums, I got told that even polygon-accurate applying works fast enough too (someone realized a boat racing through water in a very similar way to my wings here), but in fact I'd love to realize a type of realtime-KI as in the dragon would be able to learn new behaviors at runtime (of the game where it would be implemented in) and not before at programming time.

    So there will be some computation.. that's why I'm currently unsure whether to go with Unity3D which uses the jit-compiled language C# (where I'd have to compute) or UnrealEngine4 which uses the full compiled, faster C++.

    However, I've got exam period now and will start this project properly in ~3 months. I'll post some progress here :)

    Yep, I'm from good ol', boring Germany xP
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook