Sérvalpilot Posted March 26 Posted March 26 (edited) After over a year of refinement, trial and error and learning from other flight model projects, I present to you the successor to my previous FM project. Basic External Flight Model (EFM) template! This is an enhanced version of the EFM template provided by Eagle Dynamics, with emphasis on simplicity and editability while also feeling smooth and believable. This FM template was designed to work "out of the box", designed like a two-engine subsonic trainer/fighter. What is included: Lift, drag, side, and thrust forces. Axis and discrete (keyboard) pitch, roll, and yaw controls with trim. Landing gear, flaps, slats, and air brakes. Engine startup/shutdown. Basic fuel draining system. Basic damage mechanics. Semi-realistic stalling, Dutch-rolling, and other oscillations. Infinite fuel and easy flight options. Example parameter to interface with the Lua environment. Lots of comments explaining how things work. The template itself and a pre-built .DLL file can be found on GitHub! https://github.com/IGServal/DCS-Basic-EFM-Template Here is a pre-built .DLL with instructions on getting it integrated in a mod: BasicEFM mod.zip Requirements: Microsoft Visual Studio (2019 was used to create this, but other versions might work as well). Basic understanding of C++, Lua, and flight physics. Feedback, bug reports, and suggestions are always appreciated! Edited May 10 by Sérvalpilot Added demo zip 3 5
freebirddz Posted March 27 Posted March 27 Great contribution, thank you for sharing. You work will help very much, EFM/ASM Works. Best wishes for next 1
SVKSniper Posted March 30 Posted March 30 Hi @Sérvalpilot. When i test your template i see one bug. bool ed_fm_enable_debug_info() { return false; /* When set to true, DCS draws lines on the aircraft. The blue box is the center of mass, green line is net force vector, pink line is the velocity vector. */ } If you change to true, it won't do anything. But is good work(comments help a lot) Support my work
Copprhead Posted March 30 Posted March 30 2 hours ago, SVKSniper said: Hi @Sérvalpilot. When i test your template i see one bug. bool ed_fm_enable_debug_info() { return false; /* When set to true, DCS draws lines on the aircraft. The blue box is the center of mass, green line is net force vector, pink line is the velocity vector. */ } If you change to true, it won't do anything. But is good work(comments help a lot) Try single thread version. Last time i checked the display doesn't work in MT version. 1
SVKSniper Posted March 30 Posted March 30 11 minutes ago, Copprhead said: Try single thread version. Last time i checked the display doesn't work in MT version. I did test only with single thread. Support my work
Sérvalpilot Posted March 31 Author Posted March 31 Thanks for the feedback! The debug info bug is weird, that shouldn't happen. I'll look into it if I can. 1
ExoLight Posted March 31 Posted March 31 (edited) ed_fm_enable_debug_info would only show you one force vector (plus velocity vector) anyway, since the ed_fm_add_*_component functions aren't used. You won't see individual force vectors (stuff like airbrakes, control surfaces, gear, etc), only their sum as one big vector. If you want to see individual forces, you need to apply them in ed_fm_add_local_force_component instead of in ed_fm_add_local_force. One easy way to do it is to collect each force in a container (std::stack works very well for this), and each time ed_fm_add_local_force_component is called, apply the force at the top of the stack, pop it, and return true. When the stack is empty, return false. This way, you can easily visualize and debug them without having them merged in one big vector that's located inside the airframe, at the center of mass. It doesn't change anything about the MT problem though, you still need to run it in ST. Edited March 31 by ExoLight 1
SVKSniper Posted March 31 Posted March 31 3 hours ago, Sérvalpilot said: Thanks for the feedback! The debug info bug is weird, that shouldn't happen. I'll look into it if I can. Hi Serval, sorry for misleading you, the error was launching single thread version(i launch DCS_updater.exe on my desktop) but I was still in MT. I have tested it wtih ST and it works great. Thank you. Support my work
freebirddz Posted April 1 Posted April 1 On 3/30/2024 at 5:09 PM, SVKSniper said: Hi @Sérvalpilot. When i test your template i see one bug. bool ed_fm_enable_debug_info() { return false; /* When set to true, DCS draws lines on the aircraft. The blue box is the center of mass, green line is net force vector, pink line is the velocity vector. */ } If you change to true, it won't do anything. But is good work(comments help a lot) Hi, Last time I tested it I was not working on MT but worked fine when no MT ! need to give it a try to confirm.
diasmon Posted April 1 Posted April 1 Hello. Can this be applied to a FC3 / VSN mod for example? I am refining the VSN Mirage 2000 to act as a 2000-5 for A2A and 2000D for A2G with somewhat realistic (looking) loadouts of PGMs and MICAs. So i am wondering if this template can help it have a better flight dynamic than the quirky one of a FC3 mod.
freebirddz Posted April 1 Posted April 1 On 3/31/2024 at 7:12 PM, SVKSniper said: Hi Serval, sorry for misleading you, the error was launching single thread version(i launch DCS_updater.exe on my desktop) but I was still in MT. I have tested it wtih ST and it works great. Thank you. Confirmed null
Sérvalpilot Posted April 2 Author Posted April 2 23 hours ago, diasmon said: Hello. Can this be applied to a FC3 / VSN mod for example? I am refining the VSN Mirage 2000 to act as a 2000-5 for A2A and 2000D for A2G with somewhat realistic (looking) loadouts of PGMs and MICAs. So i am wondering if this template can help it have a better flight dynamic than the quirky one of a FC3 mod. Absolutely! The main reason I started making this stuff was because I hate the standard flight model (SFM), and I wanted to provide an alternative. Here is a pre-built dll and instructions on how to implement it: BasicEFM mod.zip (This can also be found on the GitHub repository) The flight model is meant to be a template for people to build on top of, so it would take a bit of work to make it perform like the Mirage-2000 (like changing it to one engine with an afterburner, stability augmentation, etc). There is a problem with FC3 avionics, there is a problem with some mods that use FC3 avionics, and it's that DCS crashes if the pilot dies or ejects. There is a way around that, however. I'll add to the GitHub's wiki section soon. 1
joey45 Posted April 2 Posted April 2 Very nice thank you… even though I have no idea what I’m looking at. also it doesn’t work in VS 2017 so had to update to 22. The only way to make sense out of change is to plunge into it, move with it, and join the dance. "Me, the 13th Duke of Wybourne, here on the ED forums at 3 'o' clock in the morning, with my reputation. Are they mad.." https://ko-fi.com/joey45
Jack McCoy Posted April 26 Posted April 26 (edited) If any of your ed_fm_* functions are not called, make sure they are decared in ED_FM_Template.h. They weren't in my version which caused me a lot of frustration (i.e. modding fun!). ED_FM_TEMPLATE_API void ed_fm_on_damage(int Element, double element_integrity_factor); ED_FM_TEMPLATE_API bool ed_fm_enable_debug_info(); This ensures the functions are visible to be called by DCS. Edited April 26 by Jack McCoy Fixed typos 1 i7-7700K@4.8GHz, 16Gb-3200, GTX-1080Ti-Strix-11Gb, Maximus IX Hero, Oculus Rift, Thrustmaster Warthog+F/A-18C, Logitech G940 Pedals.
lee1hy Posted April 26 Posted April 26 This is Best MOD ever 1 kim_123456#3214 My awesome liveries user files https://shorturl.at/cdKV5
TeTeT Posted April 28 Posted April 28 Hi, great source for a head start into EFM and this C++ stuff! While I coded C some 20 years ago, it was probably never my virtue. I compiled and changed the template slightly with some printf debug output, and enabled the debug view. Works great in ST but leads to a CTD with the MT binary all time. Any advice how to fix this for MT? I guess most players will use that binary nowadays.
Jack McCoy Posted April 28 Posted April 28 13 hours ago, TeTeT said: Hi, great source for a head start into EFM and this C++ stuff! While I coded C some 20 years ago, it was probably never my virtue. Technically, the API is in C. But since we use a C++ compiler, we can write our extensions using classes and stuff but it is not mandatory. 1 i7-7700K@4.8GHz, 16Gb-3200, GTX-1080Ti-Strix-11Gb, Maximus IX Hero, Oculus Rift, Thrustmaster Warthog+F/A-18C, Logitech G940 Pedals.
TeTeT Posted April 29 Posted April 29 Hi, forgive my ignorance, but I tried to carrier enable the VWV F-8 but the ed_fm_push_simulation_event is never called. I see the 'Attempting cat launch' in the debug console, but nothing for push. Here the code, both functions have been added to Basic_EFM_Template.h as well: ED_FM_TEMPLATE_API bool ed_fm_push_simulation_event(const ed_fm_simulation_event&); ED_FM_TEMPLATE_API bool ed_fm_pop_simulation_event(ed_fm_simulation_event&); bool ed_fm_pop_simulation_event(ed_fm_simulation_event &out) { static bool cat = false; if (!cat) { printf("vwv F-8: Attempting cat launch\n"); out.event_type = ED_FM_EVENT_CARRIER_CATAPULT; out.event_params[0] = 1; out.event_params[1] = 2.0f; out.event_params[2] = 70.0f; out.event_params[3] = 10000.0f; cat = true; return true; } return false; } bool ed_fm_push_simulation_event(const ed_fm_simulation_event &in) { if (in.event_type == ED_FM_EVENT_CARRIER_HOOKED) { printf("vwv F-8: Carrier Hooked Event\n"); } if (in.event_type == ED_FM_EVENT_CARRIER_CATAPULT) { printf("vwv F-8: Carrier Catapult event\n"); } printf("vwv F-8 Some event: %d\n", in.event_type); return true; } Any advice?
Sérvalpilot Posted April 29 Author Posted April 29 8 hours ago, TeTeT said: Any advice? To be honest, I'm not sure how simulation events work. The A-4 and A-6 mods have that catapult stuff figured out, so maybe you can check the source code for those mods. On 4/26/2024 at 8:17 PM, Jack McCoy said: If any of your ed_fm_* functions are not called, make sure they are decared in ED_FM_Template.h. They weren't in my version which caused me a lot of frustration (i.e. modding fun!). ED_FM_TEMPLATE_API void ed_fm_on_damage(int Element, double element_integrity_factor); ED_FM_TEMPLATE_API bool ed_fm_enable_debug_info(); This ensures the functions are visible to be called by DCS. That's right. I'll be sure to update it if I messed up somewhere.
TeTeT Posted April 29 Posted April 29 2 hours ago, Sérvalpilot said: The A-4 and A-6 mods have that catapult stuff figured out, so maybe you can check the source code for those mods. Great idea, I looked at the A-4 code, and it makes use of ed_fm_push_simulation_event as well. I now went on a wild chase to see if I need to export this function somehow differently, and saw some code in wHumanCustomPhysicsAPI_ImplementationDeclare.h. It uses a different MACRO for exporting, EXPORT_ED_FM_PHYSICS_IMP and I wonder if this is the key? But I admit my C / C++ knowledge is not good enough for determining if this might be the root cause. Thanks for checking in!
Jack McCoy Posted April 30 Posted April 30 9 hours ago, Sérvalpilot said: That's right. I'll be sure to update it if I messed up somewhere. I started with the Eagle Dynamics API a few years back, not your project. My statement was more general but since this is the only topic in the English forums to discuss ed_fm_enable_debug_info(), I just wanted to share a clue for when things don't work as expected. i7-7700K@4.8GHz, 16Gb-3200, GTX-1080Ti-Strix-11Gb, Maximus IX Hero, Oculus Rift, Thrustmaster Warthog+F/A-18C, Logitech G940 Pedals.
TeTeT Posted April 30 Posted April 30 Hi, got massive help on discord via "I'm You": there was a variable missing in the lua and hence the F-8 never was hooked to the catapult. Once this was in place, the ed_fm_push_simulation_event reported an event. Now any insight why the EFM dll crashes MT? Is there a compile option missing or something? Cheers, TeTeT
Sérvalpilot Posted May 2 Author Posted May 2 This was made on the single-thread version. I'll see if I can experiment with the MT version. 1
Sérvalpilot Posted May 8 Author Posted May 8 On 4/30/2024 at 8:06 PM, TeTeT said: Now any insight why the EFM dll crashes MT? Maybe it's something fixed with the latest update or it's something on your end, but I don't get any problems with this on the MT version. Make sure you're building it as x64 and check dcs.log for errors.
=Katze= Posted May 10 Posted May 10 (edited) Hi I'm trying to integrate this into my mod but I'm unsure of the basic files needed to get it up and running? In the readme it says create the Basic_EFM_template.dll in the bin file and then it should be fine this leads to an error with missing cfg file. I'm also unsure if any other files are missing (the file which says Basic_EFM_Template with cpp files) or how to install them inside the mod folder. Is anyone able to list the files or post a screen shot of the correct file structure. Thanks! (I found the previous version and have the same issue as people reported where the aircraft only works as an Ai aircraft) Edited May 10 by =Katze=
Recommended Posts