Weapon Systems Code Examples - Unguided rockets, Guns, Stinger

Any issues, problems or troubleshooting topics related to the additional features present in the Prepar3D Professional Plus client application.
Locked
whitav8
Posts: 250
Joined: Sat Nov 06, 2010 6:14 am

Weapon Systems Code Examples - Unguided rockets, Guns, Stinger

Post by whitav8 »

Are there any current (P3Dv4) example code samples for general weapon systems in PRO version?

Thanks much

Dave
P3Dv5, P3Dv4.4 9700K@5Ghz, 32gbRam, RTX2070,HP Reverb HMD
User avatar
Rob McCarthy
Lockheed Martin
Posts: 3703
Joined: Wed Aug 24, 2011 1:37 pm

Re: Weapon Systems Code Examples - Unguided rockets, Guns, Stinger

Post by Rob McCarthy »

Hi Dave,

Yes we ship missile and countermeasure samples in our SDK. The SDK is available to download here: https://prepar3d.com/support/sdk/

Regards,
Rob McCarthy
Rob McCarthy
Prepar3D® Core Lead
whitav8
Posts: 250
Joined: Sat Nov 06, 2010 6:14 am

Re: Weapon Systems Code Examples - Unguided rockets, Guns, Stinger

Post by whitav8 »

Rob,
Thanks for the pointer to the SDK but that's only a start and actually I couldn't get the essence from just looking at the SDK examples (what do they do anyway?) - i.e. just what am I able to do with weapons coding:
1) can I see the weapons as they are fired and track them visually?

2) can I score their accuracy - how many feet away did they hit, etc.

3) is there any animation when the weapon hits the target?

4) can I record the flight path of the weapon?

5) what do I have to do to see the weapon on my AC wing?

Thanks for any pointers

Dave
P3Dv5, P3Dv4.4 9700K@5Ghz, 32gbRam, RTX2070,HP Reverb HMD
User avatar
Rob McCarthy
Lockheed Martin
Posts: 3703
Joined: Wed Aug 24, 2011 1:37 pm

Re: Weapon Systems Code Examples - Unguided rockets, Guns, Stinger

Post by Rob McCarthy »

Dave,

We have extensive weapon documentation in the Learning Center: https://www.prepar3d.com/SDKv4/LearningCenter.php
This goes over the required steps for attaching weapons to vehicles.

A camera is generated for each attached weapon. This will follow missiles as they fire until an impact occurs. A Weapons Scoring UI is also available. Effects can be attached to weapons, including explosions, dirt impact, water splash, etc. Weapons will also work with the built-in flight recorder.

Regards,
Rob McCarthy
Rob McCarthy
Prepar3D® Core Lead
whitav8
Posts: 250
Joined: Sat Nov 06, 2010 6:14 am

Re: Weapon Systems Code Examples - Unguided rockets, Guns, Stinger

Post by whitav8 »

Rob,
OK. I'll start reading up. Is there a scenario demo maybe with the F-22 or F-35 or some other aircraft that shows some of the capabilities?
If I build the Missile example in the SDK, how do I demonstrate it working?

Thanks

Dave
P3Dv5, P3Dv4.4 9700K@5Ghz, 32gbRam, RTX2070,HP Reverb HMD
whitav8
Posts: 250
Joined: Sat Nov 06, 2010 6:14 am

Re: Weapon Systems Code Examples - Unguided rockets, Guns, Stinger

Post by whitav8 »

Rob,
OK - I started the Weapons tutorial and found the example with the AIM-120s added to the money Bravo - a very good start! Though I tried adding the same exact Attachments.xml (and the one line change to the Aircraft.cfg file) tothe F-22 Raptor (saved the original in a Backup folder) and the weapons were there as models but I couldn't get them to launch no matter what I tried as far as Arm, select, enable,Fire,... Any ideas? Also, I tried to get Countermeasures and Guns to launch visually (simple flares and basic gun) but didn't see any even with the Mooney Bravo. I will keep experimenting but it sure would help if there was a complete working example for the F-22 or F-35 or some aircraft. Also, I don't see any indication on the bottom right of the screen of whether a weapon is armed or not - just which Station is selected and whether Weapons are enabled or Countermeasures .

Thanks for the help.

Dave
P3Dv5, P3Dv4.4 9700K@5Ghz, 32gbRam, RTX2070,HP Reverb HMD
whitav8
Posts: 250
Joined: Sat Nov 06, 2010 6:14 am

Re: Weapon Systems Code Examples - Unguided rockets, Guns, Stinger

Post by whitav8 »

Rob,
OK - I got the basics working. Use any aircraft other than F-22 or F-35.
Position for attachments stations:
x,y,x -10.20000, -52.7000, -1.00000 x = distance ahead of CG, y = distance outward from CG, z = height above CG

.cfg file
weapon_loadout=Basic Weapons
gun_loadout = Basic Gun
countermeasure_loadout = Basic Countermeasures

Attachments.xml:

==================================================================
<?xml version="1.0" encoding="UTF-8"?>

<SimBase.Document Type="AceXML" version="1,0">

<Attachments.Stations>
<Station PositionOffset="-10.20000, -52.7000, -1.00000" OrientationOffset="0.0, 0.0, 0.0" StationDescription="CM Left" /> <!--00-->
<Station PositionOffset="-10.20000, -42.7000, 1.00000" OrientationOffset="0.0, 0.0, 0.0" StationDescription="Weapon Left" /> <!--01-->
<Station PositionOffset="-15.20000, -32.7000, -1.00000" OrientationOffset="0.0, 0.0, 0.0" StationDescription="Weapon Left2" /> <!--02-->
<Station PositionOffset="-15.20000, 0.0, -6.00000" OrientationOffset="0.0, 0.0, 0.0" StationDescription="Weapon Left2" /> <!--03-->
<Station PositionOffset="-15.20000, 32.7000, -1.00000" OrientationOffset="0.0, 0.0, 0.0" StationDescription="Weapon Right2" /> <!--04-->
<Station PositionOffset="-10.20000, 42.7000, 1.00000" OrientationOffset="0.0, 0.0, 0.0" StationDescription="Weapon Right" /> <!--05-->
<Station PositionOffset="-10.20000, 52.7000, -1.00000" OrientationOffset="0.0, 0.0, 0.0" StationDescription="CM Right" /> <!--06-->
</Attachments.Stations>

<Attachments.Loadouts>
<Attachments.Loadout LoadoutTitle="Basic Weapons" LoadoutType="WEAPON">
<Attachment StationIndex="1" ObjectTitle="AIM-120_AMRAAM" Quantity="1" />
<Attachment StationIndex="2" ObjectTitle="AIM-120_AMRAAM" Quantity="1" />
<Attachment StationIndex="4" ObjectTitle="AIM-120_AMRAAM" Quantity="1" />
<Attachment StationIndex="5" ObjectTitle="AIM-120_AMRAAM" Quantity="1" />
</Attachments.Loadout>
<Attachments.Loadout LoadoutTitle="Basic Countermeasures" LoadoutType="COUNTERMEASURE">
<Attachment StationIndex=" 0" ObjectTitle="Flare" Quantity=" 10" />
<Attachment StationIndex=" 6" ObjectTitle="Flare" Quantity=" 10" />
</Attachments.Loadout>

<Attachments.Loadout LoadoutTitle="Basic Gun" LoadoutType="GUN">
<Attachment StationIndex=" 3" ObjectTitle="M-61_Vulcan" Quantity="400" />
</Attachments.Loadout>
</Attachments.Loadouts>
<Attachments.Pylons>
<Attachments.Pylon PylonTitle="pylon_sidebyside">
<PylonPoint PositionOffset="0.0, -1.0, -2.10" OrientationOffset="0.0, 0.0, 0.0" />
<PylonPoint PositionOffset="0.0, 1.0, -2.10" OrientationOffset="0.0, 0.0, 0.0" />
</Attachments.Pylon>
</Attachments.Pylons>


</SimBase.Document>

==============================================
Keyboard Keys of Interest:
Countermeasures:
cntrl+Shift+2 = Arm (UNarmed message goes away - Station)
cntrl+Shift+4 = Select Station ( maybe only 0 and 6)
cntrl+Shift 5 = Fire Flare

Guns: (no message)
Gun System on/off = Cntrl+Shft+E
cntrl+shft+K = Fire Guns

Weapons:
Cntrl+Shft+W = Enable/Disable
Cntrl+Shft+A = Arm/Disarm
Cntrl+Shft+N = Next Weapon station
Cntrl+Shft+SPACE = fire weapon
Cntrl+Shft+. = Reload

-------------------------------------------
Now for more details:

Thanks

Dave
P3Dv5, P3Dv4.4 9700K@5Ghz, 32gbRam, RTX2070,HP Reverb HMD
whitav8
Posts: 250
Joined: Sat Nov 06, 2010 6:14 am

Re: Weapon Systems Code Examples - Unguided rockets, Guns, Stinger

Post by whitav8 »

Rob,
OK - last question for now. Could you provide just a little assistance in how to utilize the PDK Missile DLL after building it successfully with VisStudio2015 which I have. I see the Missile.dll in the PDK\Missile\Output\x64\Debug\Missile folder along with the add-on.xml and the SimObjects directory which contains the model+texture and the sim.cfg

What I don't understand is now what? Do I include this somehow instead of a standard Basic Weapons example load or what? Do I need to load the Missile.dll into P3Dv4... Just a little help here please.


Thanks

Dave
P3Dv5, P3Dv4.4 9700K@5Ghz, 32gbRam, RTX2070,HP Reverb HMD
whitav8
Posts: 250
Joined: Sat Nov 06, 2010 6:14 am

Re: Weapon Systems Code Examples - Unguided rockets, Guns, Stinger

Post by whitav8 »

Rob,
OK - I figured some of it out. I build the Missile and then copy the C:\P3Dv4_SDK\PDK\Missile\Output\x64\Debug\Missile folder to C:\Users\MYUSERNAME\Documents\Prepar3D v4 Add-ons and then I can start P3D up, answer yess to adding the new missile and then I can mention that in the Attachments.xml file - and there it is!

By the way, that missile model (PDK Sample - Missile) drops down and flies backwards for a while - needs some work!

Thanks

Dave
P3Dv5, P3Dv4.4 9700K@5Ghz, 32gbRam, RTX2070,HP Reverb HMD
User avatar
Rob McCarthy
Lockheed Martin
Posts: 3703
Joined: Wed Aug 24, 2011 1:37 pm

Re: Weapon Systems Code Examples - Unguided rockets, Guns, Stinger

Post by Rob McCarthy »

Dave,

Sounds like you've got most things figured out. Let us know if you run into any specific issues.

Regards,
Rob McCarthy
Rob McCarthy
Prepar3D® Core Lead
whitav8
Posts: 250
Joined: Sat Nov 06, 2010 6:14 am

Re: Weapon Systems Code Examples - Unguided rockets, Guns, Stinger

Post by whitav8 »

Rob,
I hope you are flying around in VR with the Oculus Tray Tool 0.70.1 or better from Apollyon VR (freeware) so you can setup Prepar3Dv4 to use Override Pixel Density (Super Sampling) to 1.5 and ASW off. Then the out the window image as you fire weapons is very nice and clear.
Question: Can I use a Position Offset with an attach point - the Orientation Offset seems to work but not position
Dave


OTT:
https://forums.oculus.com/community/dis ... -hopefully
P3Dv5, P3Dv4.4 9700K@5Ghz, 32gbRam, RTX2070,HP Reverb HMD
Locked