a very simple way is this:
first off, you will need this setup:
-tank, turret and gun are exported as separate models
-turret is a cylinder-like shape (generally..), you will want to have the center of the circle (cross-section of the cylinder) at the center x/z in model space, y (height) of the turret is not important
-gun must be at the origin (x,y,z 0,0,0), i mean the beginning of it, and will probably be parallel to Z axis in model space
now for the code:
-have your turret to be positioned exactly at the same place as your tank (or if you have the turret y(height) centered, move it UP x units (x = turret height)(do that AFTER next step))
-have your turret rotated exactly like your tank, unless you want the turret rotating independantly(changes might occur to the next step)
-let YAW be the turret's angle, you will basically dbTurnObjectRight (or something..) on the turret and pass YAW as the angle (so that you can change it anytime)
-have your gun positioned exactly ontop of your turret, and if the turret was at the origin of the model space, move the gun UP x units (x is the y(height)(do that AFTER next step)
-have your gun rotated exactly like your turret
-now let PITCH be the angle of the gun, use dbPitchObjectUp (or something like that) on the gun and pass PITCH as the angle
-these steps are done every loop
a couple of notes:
-i forgot the function that could rotate an object to be at the same rotation as another, figure it out yourself, sorry.
-i'm not sure if a function to move UP exists, if not, you could do this:
dbPitchObjectUp ( 90 );
dbMoveObject ( upwardsSteps );
dbPitchObjectDown ( 90 );
-moving UP is not like positioning at (x, y+upOffset, z), because in this case, up will always be the world-space up, we want it relative to the current(tank's) angle
-if you want turrent rotation independant, guess it's tricky, it could work if you use YAW angle instead of the tank's y angle, but this could get buggy because of euler angle stuff, you will usually want the turret rotated with the tank as it rotates anyway