Anti-aircraft (AA) guns are an important part of any air combat simulation. Creating AA guns involves several steps: (1) creating an animated gun model; (2) creating animated tracer bullets; (3) creating gunfire animations and sound; and (4) creating explosion animations and sound.
We used Blender to create a model of a WWI AA gun. The gun includes several parts, the most important of which are the base and the barrel. The center of the barrel is located where the barrel is connected to the base.
Only only animation required for the barrel is along the X-axis (latitude). Following our normal practice, the animation range is 0 to 360, with 180 as the center position, 90 is straight up and 270 is straight down. We compute the latitude required in the program, ranging from 90 (straight up) to 270 (straight down). We can use these values directly in the animation.
The program also compute the longitude required in the program. This value is used to rotate the entire gun object to point towards the target.
For each gun, we create several tracer bullets, in case there are more than one in the air at the same time. This is similar to what we do for aircraft bullets. If the gun is firing slow enough, each bullet can be a "tracer". The program must perform the following tasks: (1) Fire the bullets at the appropriate interval, (2) For each frame, compute position and rotation for all active bullets, (3) End the bullet after an approptiate time, or at the appropriate altitude.