How to Create Bullet Hole Effects
You can either apply small texture decals directly over model polygons, or create multiple texture files and use dynamic texture swapping to show increasing bullet damage as the aircraft gets hit.
The Polygon Method
CFS2 stock aircraft will display bullet holes on the model only when the aircraft is hit in combat and only in those areas which get hit. If the model is shot only through the right wing, bullet holes appear only on the upper and lower surfaces of the right wing.
How'd they do that?
In CFS2 stock models, the "bullet hole" is actually a small square/rectangular textured polygon created and placed at a location on the model where the bullet hole will appear. Therefore, if you want bullet holes, then your model file has to contain every polygon needed to display every bullet hole you want to see on your model.
Earlier, when you added the parameters bullets0 through bullets7 to the Parameter Dictionary, you added the variables CFS2 uses to determine when and where a bullet passes through your model.
CFS2 tests each "bullet" variable to see if a bullet has passed through a particular damage box. If there's no bullet, then no bullet hole is drawn. If there is a bullet, CFS2 renders your bullet hole polygon, which appears one pixel above the underlying polygon to eliminate any flickering of the bullet hole texture.
CFS2 can handle a maximum of 120 bullet hits on a single aircraft (that's a lot of holes!). If you want to track and use them all, you'll need to create 120 small polygons ... each designed as a separate part ... each with a parent part on the aircraft (either breaking or non-breaking) ... each with its own bullet hole texture applied.
Each bullet hole or bullet hole pattern will appear on a small, 4-point polygon. Each polygon is named in a manner that identifies its parent part, whether it is on the top, bottom, left, or right side of the part, the CFS2 offset of the bullet variable to test for a hit, and the hex mask used to make that test.
For example, bh106_R_fuselage.0001 is a "bullet hole" polygon (offset 0106 hex) attached to the right side of the fuselage and the mask to use in the test is "0x0001."
You can use any naming convention you like, but this method makes it easy to locate where the bullet hole is supposed to appear and the parameters to use in testing the var "bullets3." This convention also has the benefit of putting all your bullet hole parts in order by hit location in the Parts List.
In creating these small polygons, keep one thing in mind. A bullet hole polygon must lie in the exact same plane as the polygon over which you place it.
If you put a polygon on the side, top, or bottom of a rectangular part, this is easy. Just match the X,Y coordinates for each point in the polygon with the X,Y coordinates for the side of the rectangle onto which you're locating the small polygon.
On a curved surface, such as the fuselage, things get a bit tricky. It would be far too much work to rotate a small 4-point polygon to exactly match the planar position of a polygon defining the fuselage surface.
Instead, create a polygon "in place" on the fuselage surface, copy it, paste it in place, then split it off as a seperate part and rename it.
As an example, to put a bullet hole polygon on the right side of the fuselage, first select the part and then set FSDS for point mode. Highlight all points on the left side of the fuselage and hide them.
In the right view window, select a fuselage polygon over which you want to make a bullet hole.
While still in point mode, select two points from that polygon that define a long side and add a point between them. Do the same thing for the other two points on the same polygon. You now have six points defined on this fuselage polygon. Any four of them can be used to make your bullet hole polygon. If these four points would result in a polygon too large for your taste, repeat the process using the two just added points and two from the original polygon.
Now, select the four points you want to use to define the bullet polygon and, from the main menu, select Polygon/Make Polygon from Select Points. Pay attention to the direction of the polygon's normal vector. You may have to flip the polygon to make it visible.
Select the polygon you just created, then copy and paste the polygon in place. Do not move it! The polygon will have the name fuselage.1.
From the main menu, return to Part Mode. Select Edit/Part Properties and change the new part's name to bp_fus_R01 (bullet polygon, fuselage, right side, no. 1). Set the Part Parent to "fuselage." Also add the display condition, "Fuselage Visible." You now have your first bullet hole polygon ready for texturing!
Repeat this process for each bullet hole you want to include on your model.
Bullet holes are not rendered on the model unless ...
A. FSDS is set to include the bullets flag parameters in its Parameter Dictionary,
B. The appropriate flag integers are added to the [BOXES] tab definitions for the appropriate damage boxes and,
C. The SCASM code within the model is modified to test each of the bullet flags to determine if a bullet impact has occured on a given system.
There are 8 CFS2 variables bullets0 ... bullets7 used to indicate bullet strikes on the aircraft. Each 16-bit flag will track up to sixteen hits, which means that each of sixteen possible bullet strikes can be tested to determine if a hit has occurred.
If the flag bit is set, a bullet impact occurred. If the flag bit is clear, no impact has occurred.
|CFS2 Bullet Variables|
|bullets0||Upper Right Wing, Aileron, Flap, Wing Structure, Wing Tip|
|bullets1||Upper Left Wing, Aileron, Flap, Wing Structure, Wing Tip|
|bullets2||Left Fuselage, Nose Structure|
|bullets3||Right Fuselage, Nose Structure|
|bullets4||Right Tail (Fwd), Vertical Stabilizer, Rudder, Upper Horizontal Stabilizer|
|bullets5||Lower Right Wing, Aileron, Flap, Wing Structure, Wing Tip|
|bullets6||Lower Left Wing, Aileron, Flap, Wing Structure, Wing Tip|
|bullets7||Left Tail (Fwd), Vertical Stabilizer, Rudder, Lower Horizontal Stabilizer|
There are 120 integers (1-120) that can be used in connection with damage boxes. The order of the integers for a given box isn't important, but the value range is important, since they relate to specific aircraft surfaces.
Grouped in clusters of either 4, 8, or 12, each integer represents a bullet hit.
|CFS2 Bullet Hole Groups
|Bullet Flag||CFS2 Variable||Aircraft Surface|
|bullets0||Right Wing - Upper|
|13,14,15,16||bullets0||Right Wing Tip - Upper|
|bullets1||Left Wing - Upper|
|29,30,31,32||bullets1||Left Wing Tip - Upper|
|33,34,35,36||bullets2||Nose - Left Side|
|37,38,39,41,40,42,43,44||bullets2||Fuselage - Left Side|
|45,46,47,48||bullets7||Tail (fwd) - Left Side|
|49,50,51,52||bullets7||Vertical Stabilizer - Left Side|
|53,54,55,56||bullets3||Nose - Right Side|
|57,58,59,60,61,62,63,64||bullets3||Fuselage - Right Side|
|65,66,67,68||bullets3||Tail (fwd) - Right Side|
|73,74,75,76||bullets4||Right Elevator - Upper|
|77,78,79,80||bullets4||Left Elevator - Upper|
|bullets5||Right Wing - Lower|
|93,94,95,96||bullets5||Right Wing Tip - Lower|
|bullets6||Left Wing - Lower|
|109,110,111,112||bullets6||Left Wing Tip - Lower|
|113,114,115,116||bullets7||Right Elevator - Lower|
|117,118,119,120||bullets7||Left Elevator - Lower|
The damge box section below is from the DP file for the CFS2 A6M5 Zero model. The integers in bold at the end of each data string are the index values shown in the above table. They tell CFS2 to track bullet hits on that damage box.
Box.0 is defined for the nose. The integers 33, 34, 35, and 36 track hits on the left side of the nose and the integers 53, 54, 55, and 56 track hits on the right side.
[BOXES] ; Comment lines added to identify each damage box
; Nose -
; Fuselage -
; Pilot -
; Port Wing -
; Port Wing Tip -
; Starboard Wing -
; Starboard Wing Tip -
; Tail (forward) -
; Tail (aft) -
; Port Elevator -
; Starboard Elevator -
; Rudder -
When the first bullet passes through the right side of the damage box for the nose, CFS2 sets the flag bit for index 53. The next hit sets the flag bit for index 54, and so on, until index 56 is set. After that, further bullet hits on the right side of the nose aren't tracked.
To see if the nose has been hit, test the bullets2 variable using the appropriate bit mask for hits to the left side of the nose and the bullets3 variable for hits to the right side.
If you've ever wondered about the integers following the damage box coordinates ... now you know.