Targetware: 3D Dev Guide
Reference: Showing Damage with Animations
Your plane is complete... or is it? Wouldn't it be nice if, when you took combat damage, you could look out on your wing and see bullet holes? Or a big section of the wing missing? With the Targetware engine, visual damage graphics are easy to add to any planeany object at all, for that matter.
Visual damage animations are accomplished by adding additional animation paths to any part in your .anm file that you want to have show damage. Damage graphics can be added in two ways: through geometry, or through textures. With a geometry animation, you can have a part disappear when it is heavily damaged or destroyed. Alternatively, you could prepare special "damaged" versions of your 3D files and swap those in when a part gets damaged. Texture-style damage graphics involves creating a damage-only texture with an alpha layer for transparency, and then having the game merge the "damage" texture with the normal texture to produce an airplane texture that might have bullet holes, burn marks, or big gaping holes in it. You can use the geometry and texture techniques separately, or combine them to create multi-layered damage feedback. It's up to you how you do it. If you are building for Target Rabaul or one of the other "official" projects, check the specs for that project before doing your damage animations.
NOTE: An object's level of damage is recorded on your FE in minute degrees, but for bandwidth reasons, damage is only sent over the network in 4 states:
- 0.0 - no damage
- 0.33 - 1/3 damaged
- 0.66 - 2/3 damaged
- 1.0 - totally destroyed
This means that even if you hitched up 10 levels of damage animations for a part, although you would see all 10 graduations on your end, everyone else playing would only see animations corresponding to 0 to 32% damage, 33-65% damage, 66-99% damage, and 100% damage.
Visual Damage Example 1: Simple Disappearing Part
In this example, we're going to have a wing part disappear entirely once it has been 95% destroyed.
Here is the child object, before any damage code is added:
|
|
[Child 22]
name = Right Outer Wing
geometry = a6m2_wing_o_r.lwo
offset = 0, 0, 0
rotation = 0, 0, 0
num_path = 0
|
The first thing to do is to add a new animation path. Set the "num_path" line to "1". Then add a animation path:
|
|
[Child 22 Path 1]
link = 1
num_anim = 1
|
It's going to be a simple animation, so we just need 1 anim sub section. Notice that the link is set to "1". Remember that a link of 0 ties the animation to the Flight Model, whereas a link of 0 ties the animation to the Damage Model. Here's the actual animation code:
|
|
[Child 22 Path 1 Anim 1]
type = visibility
time = 0.95
visible = 0
|
We're using a geometry animation of the "visibility" type, which simple makes a part visible or invisible, depending on whether you put a 1 or a 0 in the "visible = " line. Since we're linking to the Damage Model, a time factor of 0.95 means "make this part invisible when the part takes 95% damage." That's it! Next time you use your right wing to do your landscaping, the outer portion of the wing will disappear, and everyone who sees you will know you need flying lessons.
Visual Damage Example 2: Geometry Swap
In the last example, we did the simplest form of visual damage feedback. In this example, we're going to use a pre-prepared, "damaged" 3D mesh to replace our normal, undamaged 3D mesh. In this example, we're going to be using a Sherman tank, but you can apply this same technique to an airplane or any other TW object.
|
|
[Object]
name = Hull
geometry = m4sherman.lwo
offset = 0, 0, 0
rotation = 0, 90, 0
num_children = 0
num_path = 1
|
The Sherman tank is a rather simple object, it has no child objects, only the main object. The name of the main object is set to "Hull", which matches the name of the main part in the .acm file for the tank. In order for the damage link to work, the part you are trying to animate must have the same name as a part in the .acm file. Note that animation paths are not limited to just child objects; the main object in an .anm file can have paths as well.
|
|
[Object Path 1]
link = 1
num_anim = 1
[Object Path 1 Anim 1]
type = geometry
time = 1.0
geometry = m4sherman_dmg.lwo
|
As you can see, we have link set to 1, and one anim section set up. The damaged-state 3D file specified in the "geometry =" line (m4sherman_dmg.lwo) will be swapped in over the original mesh (m4sherman.lwo) when the tank is destroyed (time = 1.0). Here is what the tank looks like before and after destruction:
Example 2: Before and after the geometry swap
Example 3: Texture-based Damage Feedback
Texture-based damage can work in two ways: as a simple texture swap, similar to the geometry swap we used in Example 2, or as a compound texture, compositing a file with "damage graphics" in it onto the original texture file. In some cases, the simple texture swap might be the best way to go, it's certainly straightforward. The down side of texture swaps done 1:1 is that you have to keep around a separate "damaged" versions of all your textures. If, for example, you had a PBY Catalina, with 3 schemes (RAAF, US Navy, and a Black Cat setup), you'd have to create separate damage state textures for each of your scheme sets. By creating an overlay graphic with damage, you can apply it to all your textures for an airplane without having to create copies of each one. Here's how it works:
Step 1: Create a damage overlay in a paint program.
This is a TGA file. It can have an alpha layer if desired. Any areas covered by the alpha layer will be invisible in-game (use this feature to make transparent holes in your airplane). The color in the overlay texture is combined with the color in the base texture, rather than replacing it. Since this is light, not pigment, colors are combined by subtraction. If you want to leave the original texture color as is; simply leave that area on the overlay white: white doesn't alter the base color at all. A slight off white will darken the base color slightly. You can test the interaction by setting up a skin file that uses composition instead of replacement.
A normal wing texture, and a damage overlay texture for it.
Step 2: Set up an anim path in your airplane that points to the overlay file.
Let's go back to our Zero wing from Example 1. Say we have produced a damage overlay that shows a great deal of damage. Not 100% damage, but say 65% damage. Let's combine that with the visibility animation to produce a richer feedback system.
|
|
[Child 22]
name = Right Outer Wing
geometry = a6m2_wing_o_r.lwo
offset = 0, 0, 0
rotation = 0, 0, 0
num_path = 1
|
We don't have to add a new animation path, since our new animation is also going to use a link = 1 (damage model) trigger. Just up the num_anim line by one:
|
|
[Child 22 Path 1]
link = 1
num_anim = 2
|
Now, lets insert our new texture animation in as the first anim, since it will take place at time 0.65 (65% damage):
|
|
[Child 22 Path 1 Anim 1]
type = skin
time = 0.65
orig = a6m_wing.tga
skin = a6m_wing_dmg.tga
overlay = 1
|
What this translates to, in English, is: "when this part sustains 65% damage, composite the damaged texture named 'a6m_wing_dmg.tga' with the original texture, 'a6m_wing.tga', on this part only." The overlay=1 line tells the game that it is not a texture swap, but an overlay action that is to be executed. Set the overlay line to 0 if you just want to swap 2 textures around. Note that it only swaps the textures on the child object, and not the textures used on the rest of the plane.
Now let's edit our original visibility damage anim so that it's in the #2 position. We might as well change it's trigger time to "1.0", since we already have a heavy damage feedback kicking in at 65%.
|
|
[Child 22 Path 1 Anim 2]
type = visibility
time = 1.0
visible = 0
|
That's it. If you want, you could add another texture layer, set, for example, to kick in at 10% damage. The graphics might just be a few small bullet holes. It would provide the pilotand anyone else close enough to seewith enough feedback to know that some level of damage has been sustained, but it's not necessarily critical... yet!
On a wing and a prayer...
For our tank example, we might want to add a texture that also shows at 100% damage, adding a black hole in the turret, or scorch marks around the hull. There are a lot of possibilities...
Tying It Together: Damage Animation Examples
We've learned how to move a part, how to substitute a damaged part in, how to show texture damage, and how to make a part disappear when destroyed. Now let's show some examples of those techniques used in combination.
Example 1: F4U-1 Flap - shows texture damage at 15%, 65%, subs in damaged geometry at 75%, and disappears at 100% damage
|
|
[Child 11]
name = left mid flap
geometry = f4uflapl2.lwo
offset = 0.05, -1.42, 0.71
rotation = 1, 0, 4
num_path = 2
[Child 11 path 1]
link = 0
auto_time = 0
num_anim = 1
[Child 11 path 1 anim 1]
type = rotate
time = 1.0
rotate = 0, -50, 0
origin = 0, 0, 0
[Child 11 path 2]
link = 1
num_anim = 3
[Child 11 path 2 anim 1]
type = skin
time = 0.15
orig = f4uw.tga
skin = f4u_wing_dmg15.tga
overlay = 1
[Child 11 path 2 anim 2]
type = skin
time = 0.65
orig = f4uw.tga
skin = f4u_wing_dmg75.tga
overlay = 1
[Child 11 path 2 anim 3]
type = visibility
time = 1.0
visible = 0
|
|