In this paper, we consider the autonomous underwater vehicle (AUV) trajectory planning problem under the influence of a realistic 3D current as simulated by an ocean general circulation model (OGCM). Attention is focused on the case of a deterministic steady OGCM field, which is used to specify data for both the ocean current and for ocean bathymetry. A general framework for optimal trajectory planning is developed for this setting, accounting for the 3D ocean current and for static obstacle avoidance constraints. A nonlinear programming approach is used for this purpose, which leads to a low complexity discrete-time model that can be efficiently solved. To demonstrate the efficiency of the model, we consider the optimal time trajectory planning of an AUV operating in the Red Sea and Gulf of Aden, with velocity, and bathymetric data provided by an eddy-resolving MITgcm. Different optimal-time trajectory planning scenarios are implemented to demonstrate the capabilities of the model to identify trajectories that adapt to favorable and adverse currents and to avoid obstacles corresponding to a complex bathymetry environment. The simulations are also used to evaluate the performance of the proposed approach, and to illustrate the application of advanced visualization tools to interpret the model predictions.