Blitz Flight Engine (BFE)
Miscellaneous Forums/General Discussion/Blitz Flight Engine (BFE)
Is anyone interested in contributing to a blitz flight engine project?
The main goal is to get a decent flight simulation going in blitz3d or minib3d. I've been wanting to do this for a few years but either get discouraged or distracted.
I have a lot of code and a few aircraft models. And I'm willing to make a very detailed aircraft model with moving parts for this.
Of course it will be open source and somewhat of a community project. Well as community as people want it to be.
The first thing that needs to be done is research some websites that have good information on flight sim code.
Have you got the history channel?
Their show 'dogfights' has got a lot of good info on tactics
I mean the basics for a flight engine ie. internal nuts and bolts to make a plane fly. Nothing about AI yet.
I've written a lot of code concerning flight simulation and have gotten close. I have a vector and quaternion lib floating around which are a necessity.
Sure thing. Before we go into that, maybe writting a wrapper for
JSBSim might save us a bucketload of time?
> Sure thing. Before we go into that, maybe writting a wrapper for JSBSim
That is cool!
JSBSim
id be willing to take a look at wrapping that if interested.
chroma I contacted you awhile back about writing a flight sim too. I too was not able to figure out how to pull this off.
A good start is Physics for Game Programmers by Grant Palmer. Some pretty good stuff, and he gives pretty good samples (in Java, blech!), including various differential equations math routines that will help the non-math types out there. Not perfect (the aircraft sim is not overly detailed and only one chapter long... though he does have other chapters on projectile and rocket physics), but a good start and includes lots of good equations for various forces/variables/states...
I agree.. And once you mastered Physics for Game Programmers by Grant Palmer you might want to take a look at Physics for Game Developers by David Bourg.
Palmer shows you an easy to understand way of building a flight model like a C172. But the model doesn't allow any aerobatic manouvering. Bourg takes it a step further but is a bit more complicated [using quaternations] and written in C++.
Ghislain
I have the book Physics for Game Developers by David Bourg. That's where I got most of the math lib stuff from a few years ago. I was never successful with getting that flight code in there working though. I have read recently though where a few people are using the ODE physics engine for a flight sim. That might be worth looking into perhaps.
This is a great idea and something I have always wanted to do.
I previously tried to get something simple working with ODE. I think JSBSim or something similar which is more dedicated to the task at hand would be a better way forward.
A wrapper for JSBSim might be a good starting point.
(just my two cents)
Check out Orbiter, a free flight sim. You can add your own planets, spacecrafts and so on.
id be willing to take a look at wrapping that if interested.
Well I'm certainly interested! If nothing else it will be a cool toy to play with. I know at least one other person who would be interested in getting BlitzMAX if this happened (he doesn't have the patience for C++).
A wrapper for JSBSim might be a good starting point.
Agreed. No point in reinventing the wheel.
Keep this going, it sounds good to me.
I'd love to see JSBSim wrapped. Anyone started yet?
Gman, I'm modeling an F-16 for the wrapper. If you're still up for it that'd be awesome.
A reasonable simulation can be done in B3D itself, using euler you can make a pretty decent 5DOF flight sim(think Flightsimulator 98). If 6DOF is your goal then you need to be very clever or use quaternions.
Instead of doing numerical integration, you can simply rely on the variables calculated during the previous frame. This is very accurate and simple, but the calculations have to be done in the right order.
Andy
Sample code Andy?
EDIT: I actually made new progress today. Such as defining lift and thrust vectors and being able to apply forces to them correctly. :)
>Sample code Andy?
Not yet!
Andy
If you make it either directx model compatible or better still lightwave friendly, I can ask a few folks along for a look at quite possibly adding a shed load of good quality content.
There's a fair stack of model makers looking for a "currently in development" flightsim, and who have been champing at the bit for easily a year or more.
You'd probably be quite amazed at the response. They cover planes and scenery, most are really quite talented, and looking for an appreciative platform. They're a bit demanding at times, but boy can they deliver if the facilities are put in place. ;o)
now would this flight engine only be for modern flight or will it work with ww1 and ww2 style flight as well?
I'm guessing it'd be pretty customizable.
I'm really making some decent progress. I have quats working and I'm actually flying the f-16 around like a helicopter. Pitch forward and the plane slowly moves forward, same with rolling. But when I give yaw input....that's what everything goes haywire. I hate YAW!
I'm putting the thrust vector straight up so I can hover atm. But the yaw thing really kills pitch and roll. It seems I have all the quat math right but I'll...keep staring at it.
EDIT: It's probably because I'm accessing the angular velocity directly to pitch and roll the plane atm. I'm sure when I start doing it with forces maybe the yaw problem with clear up. Or I might need to use a rotation matrix. /shrug
You do realise there is no such thing as a dedicated rotary wing flight sim. Crack all that (esp. yaw) and the world could literally be your salami! ;O)
You'd need to pay heavy attention to input devices (anything that windows can see, your sim should) and having it fly nicely. Allowing for good visuals, sound & animations would not hinder it's appeal either. You say you have defined lift, that's good, but make sure you define gravity and ground friction too.
If that was all done well, there is a huge gap in the market.
You do realise there is no such thing as a dedicated rotary wing flight sim.
Koala? Surely there must be a PC version of it.
I'm not shooting for a rotary wing sim, just using lift straight up to make testing at this stage easier.
Defining the forces of flight is the easy part. Drag is the inverse of the velocity vector and lift is perpendicular to drag.
The hard part is orientation. As soon as I yaw and then pitch, the aircraft still goes forward like I didn't yaw at all and it flies sideways.
Until you stir some roll into that, it's going to stay exactly how it is, you got it right as it happens; You are a natural for rotary! ;O) Might be a bit too much for planks if it's going sideways, but right now it's fine for a rotary.
FlameDuck:
"Koala? Surely there must be a PC version of it."
Google reveals nothing.
URL?
I read in old posts that blitz3d quaternions aren't in the regular format. Can anyone corroborate this and maybe shed some light on what's up with them?
Again I think somewhere quats are being confused with angle axis representation, of course I suppose the quats could just be in a different order in Blitz than other places. Perhaps you're looking at a Z up example where Blitz is Y up.
Anyway, I've got a decent simple model that handles yaw, pitch, and roll applied to an impulse source. I wouldn't mind contributing to this so long as we do it all Blitz and don't wrap another engine. I'm more interested in creating it all from the ground up.
I'm down for whatever gets us where we want to be. I don't have the skills to wrap something so I been working on doing it within blitz atm. I think biting it off in chunks is a good idea so it doesn't get overly complicated too fast. I have a working method using TFormNormal that allows access to local orientation which has got me hyped up. I think a good starting point is lift, drag, and thrust. Thrust is worked out np and drag is the inverse of the velocity vector and lift is always perpendicular to drag. Working out how to apply force from a location other than the center of gravity needs to be done. I know it deals with moments and angular force. Just have to work out/find the formulas and stuff.
Say you apply 5 force straight up (0,5,0) on the right wing and 5 force straight down(0,-5,0)...both about 2 units out from the CG. It's gonna cause rotation to the left of the aircraft (roll). A running total of all the moments acting on the airframe are tallied in a vector called vMoments. At some point they are applied and rotate the aircraft. The actual 5 force is affected by it's distance from the CG and also the Inertia of the body...etc etc.
I don't think it's hard...it's just time consuming and tedious.
Here's something to calculate tire resistance while taxiing/takeoff roll.
;Tire Resistance
If rb\speed > 0
Local fRRoll# = rb\weight * rb\roll_coef
ApplyVectorCGForce(rb,0,0,-1,rb\fRRoll)
EndIf
The roll_coef is set at 0.015 which is what a regular car tire is. Then you take the weight that the specific tire is supporting and multiply it by that...once for each tire. This is only added in if the aircraft is on the ground and the speed is greater than zero. You could get really accurate and model it for each tire as it is contacting the ground, but for now I'll go with simplicity.
Physics for Game Developers is a pretty handy book.
I finally got the angle of attack calculation correct. I took the dot product of the drag vector and the local y-axis vector and converted that from radians to degrees. It gives the right reading at all angles and inverted flight. :)
Next on the list is applying lift and drag. I also want to put a lot of effort into ground handling. Tricycle gear physics, steering, correct wheel spin rate based on wheel circumference and speed, bouncy shock struts, etc etc. With all the car physics and verlet code flying around it shouldn't be that hard.
And success! The f-16 lifts off at 120ish knots. I only had the simulation go NAN once so far. Otherwise everything seems ok. I still have to put in drag. Still much to do such as working out a decent flight control system and how they affect the aircraft thru angular force etc. Also, the liftvector is glued to the local y-axis atm until I figure out how to make it stay perpendicular to drag but also stay perpendicular to the wings along the x-axis.
This would work I think. Not sure what cooef's you'd use for lift but you get the jist. Always have a helper pivot handy for this kind of stuff ;)
global Pivot = createpivot()
;get wing direction
TFormNormal 1, 0, 0 , AirplaneMesh , 0
;align helper pivot to wings local roll axis
AlignToVector Pivot , TFormedX() , TFormedY(), TFormedZ(), 1
;align helper pivot to direction of drag on pitch axis
AlignToVector Pivot , DragX, DragY, DragZ, 3
;get lift direction
TFormNormal 0,-1,0,Pivot, 0
LiftX# = TFormedX()
LiftY# = TFormedY()
LiftZ# = TFormedZ()
Thx I'll try this soon as I get home!
Still making progress. Here's proof!
He, what happened to the JBsim-wrapper? Somebody still working on it?
Ghislain
I'm looking for some space to host a demo. It'll be in the showcase forum in about an hour or so! Yes, you read right...I'm actually gonna post a demo.
chroma- email sent...to your yahoo email
I found my old freewebs account ckob but thanks tho. The demo is ready for consumption in the Showcase forum.
Just a question, has anyone used JSBSim together with Blitzbasic? I want to integrate it and would like to know if anyone already use it...
I'd write a wrapper if there is none so far.
Kind regards - Xaron
I have an unreleased module of JSBSim for BlitzMax. Works very well :-)
I have an unreleased module of JSBSim for BlitzMax. Works very well :-)
Naughty! :P
Dabz
I'd be interested how that works in general. So how do I copy all this input stuff to the sim and get the position and rotation values back to display it in BB3D?
I'm still not that deep in this JSBSim stuff, have just read the manual and will have a look into the code next...
Besides JSBSim, you've got Flight Gear ( www.flightgear.org ) that might be worth taking a look at. I believe it has been in development quite long. It's mainly focused on a realistic (hard to fly) flight model. I tried it, but it wasn't quite up my street, as I prefer flying with somewhat cartoony flight models such as that in BF1942. :)