We in this paper derive the analytical expressions of ground-state energy, average photon-number, and the atomic population by means of the spin-coherent-state variational method for arbitrary number of atoms in an optomechanical cavity. It is found that the existence of mechanical oscil- lator does not affect the phase boundary between the normal and superradiant phases. However, the superradiant phase collapses by the resonant damping of the oscillator when the atom-field coupling increases to a so-called turning point. As a consequence the system undergoes at this point an additional phase transition from the superradiant phase to a new normal phase of the atomic population-inversion state. The region of superradiant phase decreases with the increase of photon-phonon coupling. It shrinks to zero at a critical value of the coupling and a direct atomic population transfer appears between two atom-levels. Moreover we find an unstable nonzero-photon state, which is the counterpart of the superradiant state. In the absence of oscillator our result re- duces exactly to that of Dicke model. Particularly the ground-state energy for N = 1 (i.e. the Rabi model) is in perfect agreement with the numerical diagonalization in a wide region of coupling constant for both red and blue detuning. The Dicke phase transition remains for the Rabi model in agreement with the recent observation.