Unless directed by the officer, you should remain in your vehicle. If you begin to get out, especially if it is against a direct order, the officer may draw his/her weapon on you. For safety reasons, officers anticipate the worst. Exiting the vehicle may indicate that you are going to draw a weapon of your own or that you are going to flee the scene.
However, an officer has the right to ask you and your passengers to exit the vehicle and it is advisable that you comply with the order. One reason an officer may ask you to exit the vehicle is to conduct a pat down, if he/she has reason to believe that you are dangerous. During a pat down, an officer may take out any object he/she feels that is the size of a weapon.
Obviously, whether by remaining in or getting out of the vehicle, it is best to follow the commands of the police officer to avoid any further trouble.