private void SetStereoModeToggle(BaseMediaPlayer.StereoMode stereoMode) { monoToggle.isOn = false; leftRightToggle.isOn = false; topBottomToggle.isOn = false; switch (stereoMode) { case BaseMediaPlayer.StereoMode.Mono: monoToggle.isOn = true; break; case BaseMediaPlayer.StereoMode.LeftRight: leftRightToggle.isOn = true; break; case BaseMediaPlayer.StereoMode.TopBottom: topBottomToggle.isOn = true; break; default: monoToggle.isOn = true; break; } }
/// Calculates the aspect ratio of a frame within a texture based on the textures stereo mode. public static float CalculateFrameAspectRatio(float rawAspectRatio, BaseMediaPlayer.StereoMode stereoMode) { float result; switch (stereoMode) { case BaseMediaPlayer.StereoMode.LeftRight: result = rawAspectRatio / 2.0f; break; case BaseMediaPlayer.StereoMode.TopBottom: result = rawAspectRatio * 2.0f; break; default: result = rawAspectRatio; break; } // Some stereo textures pack the texture data of a frame by squashing the frame // and then expecting it to still be rendered at the original aspect ratio. // Make a best guess for when the frame is squashed... // TODO: Make this more robust. if (result > SQUASHED_FRAME_THRESHOLD) { result = rawAspectRatio; } return(result); }
/// Calculates the aspect ratio of a frame within a texture based on the textures stereo mode. public static float CalculateFrameAspectRatio(Texture texture, BaseMediaPlayer.StereoMode stereoMode) { // Avoid dividing by zero. if (texture.height == 0.0f) { return(0.0f); } float rawAspectRatio = (float)texture.width / (float)texture.height; return(CalculateFrameAspectRatio(rawAspectRatio, stereoMode)); }
private void SetStereoMode(BaseMediaPlayer.StereoMode stereoMode) { if (stereoMode == mediaPlayer.CurrentStereoMode) { return; } if (mediaPlayer.MediaScreen == null) { return; } mediaPlayer.CurrentStereoMode = stereoMode; float frameAspectRatio = ImageBasedProjectionDetectorHelpers.CalculateFrameAspectRatio(mediaPlayer.RawAspectRatio, stereoMode); mediaPlayer.CurrentAspectRatio = frameAspectRatio; mediaPlayer.SaveCurrentFormat(); }
/// Calculates the aspect ratio of a frame within a texture based on the textures stereo mode. public static float CalculateFrameAspectRatio(Texture texture, BaseMediaPlayer.StereoMode stereoMode) { float width = texture.width; float height = texture.height; float halfWidth = width * 0.5f; float halfHeight = height * 0.5f; float fullAspectRatio = width / height; float result; switch (stereoMode) { case BaseMediaPlayer.StereoMode.LeftRight: result = halfWidth / height; break; case BaseMediaPlayer.StereoMode.TopBottom: result = width / halfHeight; break; default: result = fullAspectRatio; break; } // Some stereo textures pack the texture data of a frame by squashing the frame // and then expecting it to still be rendered at the original aspect ratio. // Make a best guess for when the frame is squashed... // TODO: Make this more robust. if (result > SQUASHED_FRAME_THRESHOLD) { result = fullAspectRatio; } return(result); }