public OculusCamera(OculusRift rift, Vector3 position, Quaternion orientation) { if (rift == null) throw new ArgumentNullException(); this.rift = rift; Position = position; Orientation = orientation; EventHandler<EventArgs> update_frustum = (sender, e) => { float view_center = rift.HScreenSize * 0.25f; float eye_projection_shift = view_center - rift.LensSeparationDistance * 0.5f; float projection_center_offset = rift.IsConnected ? 4.0f * eye_projection_shift / rift.HScreenSize : 0; GetProjectionMatrix(out mono_frustum); left_frustum = mono_frustum * Matrix4.CreateTranslation(projection_center_offset, 0, 0); right_frustum = mono_frustum * Matrix4.CreateTranslation(-projection_center_offset, 0, 0); float half_ipd = rift.InterpupillaryDistance * 0.5f; if (view_center != 0) { left_modelview = Matrix4.CreateTranslation(half_ipd * view_center, 0, 0); right_modelview = Matrix4.CreateTranslation(-half_ipd * view_center, 0, 0); } }; //FieldOfViewChanged += update_frustum; //AspectRatioChanged += update_frustum; //ZNearChanged += update_frustum; FusionDistanceChanged += update_frustum; InterocularDistanceChanged += update_frustum; update_frustum(this, EventArgs.Empty); }
public OculusCamera(OculusRift rift) : this(rift, Vector3.Zero, Quaternion.Identity) { }