Particle rotations and energy dissipation during mechanical compression of granular materials