This paper presents a trajectory planner for humanoid robots based on nonlinear model predictive control that can generate trajectories with variable center of mass heights and adaptive foot positions in real-time. This is done by analytically formulating the zero moment point constraint as a quadratic function that includes the vertical center of mass state. This constraint is then combined with linear foot position constraints, constraints on the vertical center of mass state and a quadratic goal function to form a quadratically constrained quadratic program. This program is then solved via sequential quadratic programing. It can be solved in less than 5 ms on average with a 3.4 Ghz CPU by taking advantage of the fact that the analytic problem formulation allows the analytical gradients to be computed, thus time consuming numerical differentiation is avoided and the gradient computation time is reduced from 12.4 ms to 0.12 ms. An experiment on a 3.5 Kg robot is conducted to verify the effectiveness of this algorithm in walking on a terrain where the two feet are at different heights. Lastly it is shown via simulation that the proposed approach can improve disturbance recovery capacity by up to 7%.