The following is an excerpt from page 19 of the Warhammer Annual 2002 release with an expanded explanation by Gav Thorpe regarding legal targets for various war machines based on line of sight.
(Or, "what can I shoot at?")
More than anything else to do with war machines, what they can and cannot target can be an area of contention. First of all, it varies from machine to machine whether they require a line of sight or not. Let's deal with them one by one:
Stone Thrower, Screaming Skull Catapult, Earthshaker Cannon, Death Rocket
These must be able to see enemy models in the direction you shoot, although they may fire over these at a target beyond. This means that as long as there is an enemy unit along your line of fire you can attempt to target any enemy along that line (see diagram 1).
Flame Cannons
These war machines require line of sight to their target (note that although not a war machine, this also applies to Warpfire Throwers).
Cannons, Mortars
These require line of sight to their target. Deliberate over-guessing of ranges to attack targets beyond those in sight is not nice and is against the spirit of the rules (see diagram 2).
Non-guess Range Weapons (Bolt Thrower, Organ Gun, Helblaster Volley Gun, etc)
These require line of sight to their target.
Shooting at Characters
Something which often crops up is whether characters can be targeted by war machines. War machines that require a line of sight may target characters only within the normal restrictions (ie, they can't single them out of units, target them if they are within 5" of friends, etc). Also note that if a character is in a unit of less than five models when hit by such a war machine, there is no "Look Out, Sir!" roll and hits are allocated as normal (see page 97 of Warhammer) All hits from a single war machine in one turn are considered to be a single attack, so if it inflicts multiple hits (such as the Volley Gun) it is the number of models at the start of the attack that determines if the character can be hit. This may mean that the unit is wiped out except for the character that joined it - that's why they're heroic characters!
If a war machine is guess range, then characters on their own are fair game (not a good idea to wander about on your own when facing armies with lots of cannons!), though characters in units of five or more models will get the "Look Out, Sir!" roll.
Many people have pointed out that it is not very heroic or realistic to be able to pick out characters with, say, a cannon when a unit of bowmen can't. There are three reasons why the rules work this way. First, guess range war machines are not particularly accurate and so if you can pick off a character on their own in this manner then the gods are obviously smiling on you. Secondly, although it was discouraged (some of you may know that quotation from Wellington at Waterloo) it was possible for historical cannons and such to target enemy commanders and their retinues. Thirdly, writing a set of rules which protected characters in such a fashion would make the process either hideously complicated or open to some serious abuse by deliberately mis-guessing, targeting nearby units and hoping for scatter, and so on, and best avoided altogether.