Linguistic studies by Haruko Cook (1996/7) show that in general, teachers use the distal form (polite as some call it) when addressing elementary school students as a class, and switch into direct form (plain as some call it) when addressing individual students. However, male teachers were more likely to use direct style forms when addressing the class than women. And while women occasionally used distal form when talking to individuals, men never used distal form. So part of your choice in language lies with gender identity as well (though she does not focus on this point). Her conclusion is that when presenting a "model image" of oneself, or in a situation, as Senko Maynard has described, where "awareness of the addressee is high" (as when you are addressing an entire class and are quite aware everyone is paying attention to you and how you act), the distal form is the form of choice.
Again, this is no hard-and-fast rule, but more of a general trend that bends depending on each individual's identity of him/herself.
At the university level, my sensei has always talked to me in direct form at higher levels, probably because we (as a class and sensei) did become more amiable as we reached those levels and could joke around more.
I hope this helps.