Model-based Diffusion for Trajectory Optimization