Nonspherical dynamical approximations and models for gravitational collapse are used to extend the well-known Press and Schechter (PS) approach, in order to determine analytical expressions for the mass function of cosmic structures. The problem is rigorously set up by considering the intrinsic Lagrangian nature of the mass function. The Lagrangian equations of motion of a cold and irrotational fluid in the single-stream regime show that the shear, which is nonlocally determined by the entire matter field, is the quantity which characterizes nonspherical perturbations. The Zel'dovich approximation, being a self-consistent first-order Lagrangian and a local one, is used as a suitable guide to develop realistic estimates of the collapse time of a mass clump, starting from the local initial values of density and shear. Both Zel'dovich-based Ansatze and models and the homogeneous ellipsoidal model predict that more large-mass objects are expected to form than the usual PS relation. In particular, the homogeneous ellipsoid model is consistent at large masses with a PS mass function having a lower value of the delta(c) parameter, in the range 1.4-1.6. This gives a dynamical explanation of why lower delta(c) values have been found to fit the results of several N-body simulations. When more small-scale structure is present, highly nonlinear dynamical effects can effectively slow down the collapse rate of a perturbation, increasing the effective value of delta(c). This may have interesting consequences on the abundance of large-mass high-redshift objects.