Regarding the "names, locations, weights"... if only it were that easy haha. The MiG-21 payloads.nas is fairly specific to the MiG-21.
I have some time, so I'll walk you through some stuff. First part will be payload setup, second part for submodels. I may have missed something, I apologize if I did.
This is assuming JSBSim, I've no idea if YASim works the same. Also, this is how I do this, there are possibly other ways to accomplish this that may be better or worse. Necolatis' method he is using on the F-16 seems easier than this, but there's still nasal and coding. I'm not well versed enough in his method enough to speak to it, but if you'd like to investigate it, his repo is
right here. He's also one of the major authors of the guided-missile code, and knows it better than anybody.
All that said, here's how I do it.
To add a new "payload" to the equipment menu:
First, in your jsbsim file, you need to add new pointmasses. For the MiG-21, there are 5 pylons, so we add 5 of these:
- Code: Select all
<pointmass name="station1"><!-- left wing outboard pylon pointmass 0 -->
<weight unit="LBS"> 0 </weight>
<location name="POINTMASS" unit="M">
<x> 1.20 </x>
<y> -2.73 </y>
<z> -0.15 </z>
</location>
</pointmass>
Weight should be 0, and the name should be unique for each, and the pointmass name="" should be unique for each.
MiG-21 code here. If the JSBSim VRP is 0,0,0 (which it should be, IMO), then you can easily find the coordinates for each pylon in blender.
Next, in our set file, we are going to define the pylon, and what munition options it has. You should also include a "none" option.
- Code: Select all
<payload>
<weight n="0">
<name>Left wing outboard pylon (#3)</name>
<selected>none</selected>
<weight-lb alias="/fdm/jsbsim/inertia/pointmass-weight-lbs[0]"/>
<opt>
<name>none</name>
<lbs>0</lbs>
<weight-lb>0</weight-lb>
</opt>
<opt>
<name>R-3S</name>
<lbs>165</lbs>
<weight-lb>165</weight-lb>
</opt>
</weight>
</payload>
You will need a <weight> for each pylon, and an <opt> for each munition.
Here's how I have it set up in the MiG-21bis. At this point, if you select one of these options in the equipment menu, it will add the weight to the airframe (not drag!), however you still wont be able to see it in the external view.
To enable it in the external view, here is how I accomplish this. I have a
Stores.xml which is called from my
main model xml fileIn the stores.xml, for each missile, I have an include, and a conditional that only displays the munition if the munition is selected in the equipment menu. For instance,
here's the leftmost Kh-25MP (with a slight modification to make the conditional property clearer here):
- Code: Select all
<model>
<name>Kh-25MP Left</name>
<path>Aircraft/MiG-21bis/Models/Stores/KH-25MP/KH-25MP.xml</path>
<offsets>
<x-m> 0.23552 </x-m>
<y-m>-2.10877 </y-m>
<z-m>-0.25002 </z-m>
<pitch-deg>0.0</pitch-deg>
</offsets>
</model>
<animation>
<object-name>Kh-25MP Left</object-name>
<type>select</type>
<condition>
<equals>
<property>/payload/weight[1]/selected</property>
<value>Kh-25MP</value>
</equals>
</condition>
</animation>
Each missile for each pylon needs one of these.
If you are still with me, awesome! That's part 1. Now, onto how to release as a submodel.
For each bomb/submodel you want to release, you need one submodel entry per pylon.
- Code: Select all
<submodel>
<name>FAB-100</name>
<model>Aircraft/MiG-21bis/Models/Stores/FAB-100/FAB-100-sub.xml</model>
<trigger>payload/released/FAB-100[1]</trigger>
<trigger-once>true</trigger-once>
<speed>0.0</speed>
<repeat>true</repeat>
<delay>20</delay>
<count>-1</count>
<offsets>
<x-m> 0.20</x-m>
<y-m>-2.11 </y-m>
<z-m>-0.25</z-m>
</offsets>
<eda>1.0</eda>
<weight>220.0</weight>
<cd>0.3</cd>
<collision>true</collision>
<collision-report>sim/ai/aircraft/collision/cannon</collision-report>
<impact>true</impact>
<impact-report>sim/ai/aircraft/impact/bomb</impact-report>
<submodel-path>Aircraft/MiG-21bis/Models/Effects/Bomb/Bomb-Submodel.xml</submodel-path>
</submodel>
This is the actual model that will be floating through the air. <model> points to what model you want to appear, <trigger> should be unique (probably), <submodel-path> is for the explosion at the end, and points to another model/particle system, whatever you want to use for the big boom. If you want to have bomb messages, you'll also need <impact-report> and <collision-report>.
You have two options for the trigger. You can either bind a key to release each pylon (so, for instance, 'h' releases pylon 1, 'j' releases pylon 2, and so on), or you can use nasal to write some trigger propagation code. The MiG-21 uses a knob to select bombs on pylons 1 and 2, 3 and 4, or 1 through 4. Trigger propagation logic
is here, and the actual trigger "pulling"
is here. Basically what it does is figure out where the knob is, and the other function sets that <trigger> property we set up earlier to 1. Depending on your plane, you'll want to rewrite that as you see fit.
After all that is successful, you should be able to drop bombs. For an explosion message, when the bomb hits the ground, it sets the "/ai/models/model-impact" property. You use a setlistener() on this property, and can read it to see what type of bomb hit. My impact listener code is
here, but keep in mind I also use it for guns and rockets. If you're only using bombs, it can be simplified. It's also really important in my humble opinion to include an option to make the messages either display over MP or not.
So, that's submodel bombs. Guided missiles are much more complicated, so if you'd like a "guide" on those, let me know. If you've never done nasal before, I'd recommend trying to get submodel bombs working with the trigger propagation first. TL;DR, guided missiles will include creating a radar or targeting scheme, defining the target, actually targeting the target, defining a bunch of missile properties, selecting the missile/trigger propagation, and a bunch of testing the missile flight characteristics.