This paper presents a general method for generating walking primitives for anthropomorphic 3D-bipeds. Corresponding control torques allowing straight ahead walking with pre-swing, swing, and heel-contact are derived by dynamic optimization using a direct collocation approach. The computed torques minimize an energy based, mixed performance index. Zero moment point (ZMP) and friction conditions at the feet ensuring postural stability of the biped, as well as bounds on the joint angles and on the control torques, are treated as constraints. The method is applied to the model of a biped with 12 joints for the purpose of developing a walking primitive database allowing straight ahead walking with situation dependent step-length adaptation. The resulting biped motions are dynamically stable and the overall motion behaviour is remarkably close to that of humans.