diff --git a/RealityMixer.xcodeproj/project.pbxproj b/RealityMixer.xcodeproj/project.pbxproj index 48a6989..5d75318 100644 --- a/RealityMixer.xcodeproj/project.pbxproj +++ b/RealityMixer.xcodeproj/project.pbxproj @@ -71,6 +71,9 @@ A3837F6D263A239F0053951E /* next.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = A3837F6B263A239F0053951E /* next.mp3 */; }; A3837F6E263A239F0053951E /* reset.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = A3837F6C263A239F0053951E /* reset.mp3 */; }; A39033ED256859A8004CB638 /* Shaders.swift in Sources */ = {isa = PBXBuildFile; fileRef = A39033EC256859A8004CB638 /* Shaders.swift */; }; + A39F72CD269D277800501C49 /* QuickCalibrationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A39F72CB269D277800501C49 /* QuickCalibrationViewController.swift */; }; + A39F72CE269D277800501C49 /* QuickCalibrationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A39F72CC269D277800501C49 /* QuickCalibrationViewController.xib */; }; + A39F72D1269D306900501C49 /* UIScreenExtension in Frameworks */ = {isa = PBXBuildFile; productRef = A39F72D0269D306900501C49 /* UIScreenExtension */; }; A3A50C0725F4945700413E01 /* SwiftlyAttributedStrings in Frameworks */ = {isa = PBXBuildFile; productRef = A3A50C0625F4945700413E01 /* SwiftlyAttributedStrings */; }; A3A50C0C25F57AB700413E01 /* ProjectionPickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3A50C0A25F57AB700413E01 /* ProjectionPickerViewController.swift */; }; A3A50C0D25F57AB700413E01 /* ProjectionPickerViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A3A50C0B25F57AB700413E01 /* ProjectionPickerViewController.xib */; }; @@ -167,6 +170,8 @@ A3837F6B263A239F0053951E /* next.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = next.mp3; sourceTree = ""; }; A3837F6C263A239F0053951E /* reset.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = reset.mp3; sourceTree = ""; }; A39033EC256859A8004CB638 /* Shaders.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shaders.swift; sourceTree = ""; }; + A39F72CB269D277800501C49 /* QuickCalibrationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickCalibrationViewController.swift; sourceTree = ""; }; + A39F72CC269D277800501C49 /* QuickCalibrationViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = QuickCalibrationViewController.xib; sourceTree = ""; }; A3A50C0A25F57AB700413E01 /* ProjectionPickerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProjectionPickerViewController.swift; sourceTree = ""; }; A3A50C0B25F57AB700413E01 /* ProjectionPickerViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ProjectionPickerViewController.xib; sourceTree = ""; }; A3A50C4425F5B71000413E01 /* FFmpeg.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = FFmpeg.xcframework; path = Frameworks/FFmpeg.xcframework; sourceTree = ""; }; @@ -186,6 +191,7 @@ A328D96B253C95BD00B90E62 /* AudioToolbox.framework in Frameworks */, A328D96D253C95C300B90E62 /* CoreMedia.framework in Frameworks */, A328D966253C95AD00B90E62 /* libiconv.tbd in Frameworks */, + A39F72D1269D306900501C49 /* UIScreenExtension in Frameworks */, A3A50C4525F5B71000413E01 /* FFmpeg.xcframework in Frameworks */, A328D969253C95B700B90E62 /* VideoToolbox.framework in Frameworks */, A328D963253C95A000B90E62 /* libz.tbd in Frameworks */, @@ -278,6 +284,8 @@ A32416342554E41E008D4B90 /* ProjectionViewController.xib */, A3A50C0A25F57AB700413E01 /* ProjectionPickerViewController.swift */, A3A50C0B25F57AB700413E01 /* ProjectionPickerViewController.xib */, + A39F72CB269D277800501C49 /* QuickCalibrationViewController.swift */, + A39F72CC269D277800501C49 /* QuickCalibrationViewController.xib */, ); path = ViewControllers; sourceTree = ""; @@ -483,6 +491,7 @@ packageProductDependencies = ( A3A50C0625F4945700413E01 /* SwiftlyAttributedStrings */, A3A50C4025F5B3B100413E01 /* SwiftSocket */, + A39F72D0269D306900501C49 /* UIScreenExtension */, ); productName = MRTest2; productReference = A328D8AC253C8C4000B90E62 /* RealityMixer.app */; @@ -515,6 +524,7 @@ packageReferences = ( A3A50C0525F4945700413E01 /* XCRemoteSwiftPackageReference "swiftly-attributed-strings" */, A3A50C3F25F5B3B100413E01 /* XCRemoteSwiftPackageReference "SwiftSocket" */, + A39F72CF269D306900501C49 /* XCRemoteSwiftPackageReference "UIScreenExtension" */, ); productRefGroup = A328D8AD253C8C4000B90E62 /* Products */; projectDirPath = ""; @@ -541,6 +551,7 @@ A31C0A2126435F980059A492 /* avatar1.usdz in Resources */, A324162B2554E1B8008D4B90 /* CalibrationViewController.xib in Resources */, A3837F6E263A239F0053951E /* reset.mp3 in Resources */, + A39F72CE269D277800501C49 /* QuickCalibrationViewController.xib in Resources */, A31C0A2226435F980059A492 /* avatar4.usdz in Resources */, A3837F6D263A239F0053951E /* next.mp3 in Resources */, A324161F2554DABE008D4B90 /* InitialViewController.xib in Resources */, @@ -563,6 +574,7 @@ A32285AF25580A8800FF3200 /* Definitions.swift in Sources */, A3228605255B864900FF3200 /* AudioDataHeader.m in Sources */, A328D8B4253C8C4000B90E62 /* MixedRealityConnectionViewController.swift in Sources */, + A39F72CD269D277800501C49 /* QuickCalibrationViewController.swift in Sources */, A324161E2554DABE008D4B90 /* InitialViewController.swift in Sources */, A30B22EA2693D9F2005EB78F /* CameraPermissionHelper.swift in Sources */, A32285AA2558050600FF3200 /* AboutViewController.swift in Sources */, @@ -809,6 +821,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + A39F72CF269D306900501C49 /* XCRemoteSwiftPackageReference "UIScreenExtension" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/marchv/UIScreenExtension"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 0.0.9; + }; + }; A3A50C0525F4945700413E01 /* XCRemoteSwiftPackageReference "swiftly-attributed-strings" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/fabio914/swiftly-attributed-strings.git"; @@ -828,6 +848,11 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + A39F72D0269D306900501C49 /* UIScreenExtension */ = { + isa = XCSwiftPackageProductDependency; + package = A39F72CF269D306900501C49 /* XCRemoteSwiftPackageReference "UIScreenExtension" */; + productName = UIScreenExtension; + }; A3A50C0625F4945700413E01 /* SwiftlyAttributedStrings */ = { isa = XCSwiftPackageProductDependency; package = A3A50C0525F4945700413E01 /* XCRemoteSwiftPackageReference "swiftly-attributed-strings" */; diff --git a/RealityMixer/Calibration/ViewControllers/CalibrationConnectionViewController.swift b/RealityMixer/Calibration/ViewControllers/CalibrationConnectionViewController.swift index 808db02..cdc2241 100644 --- a/RealityMixer/Calibration/ViewControllers/CalibrationConnectionViewController.swift +++ b/RealityMixer/Calibration/ViewControllers/CalibrationConnectionViewController.swift @@ -8,6 +8,11 @@ import UIKit import SwiftSocket +enum CalibrationType { + case quick + case standard +} + final class CalibrationConnectionViewController: UIViewController { @IBOutlet private weak var scrollView: UIScrollView! @@ -17,6 +22,8 @@ final class CalibrationConnectionViewController: UIViewController { @IBOutlet private weak var scaleSegmentedControl: UISegmentedControl! @IBOutlet private weak var poorPerformanceWarningLabel: UILabel! + @IBOutlet private weak var calibrationTypeSegmentedControl: UISegmentedControl! + @IBOutlet private weak var showInstructionsButton: UIButton! @IBOutlet private weak var instructionsContainer: UIStackView! @IBOutlet private weak var infoLabel: UILabel! @@ -82,7 +89,7 @@ final class CalibrationConnectionViewController: UIViewController { """ } - private func startConnection(address: String, port: Int32) { + private func startConnection(address: String, port: Int32, calibrationType: CalibrationType) { let connectionAlert = UIAlertController(title: "Connecting...", message: nil, preferredStyle: .alert) present(connectionAlert, animated: true, completion: { [weak self] in @@ -119,12 +126,22 @@ final class CalibrationConnectionViewController: UIViewController { let scaleFactor = (Double(self.scaleSegmentedControl.selectedSegmentIndex) + 1.0)/Double(self.scaleSegmentedControl.numberOfSegments) connectionAlert.dismiss(animated: false, completion: { [weak self] in - - let viewController = CalibrationViewController( - client: client, - scaleFactor: scaleFactor, - delegate: self - ) + let viewController: UIViewController + + switch calibrationType { + case .quick: + viewController = QuickCalibrationViewController( + client: client, + scaleFactor: scaleFactor, + delegate: self + ) + case .standard: + viewController = CalibrationViewController( + client: client, + scaleFactor: scaleFactor, + delegate: self + ) + } viewController.modalPresentationStyle = .overFullScreen self?.present(viewController, animated: true, completion: nil) @@ -148,8 +165,10 @@ final class CalibrationConnectionViewController: UIViewController { return } + let calibrationType: CalibrationType = calibrationTypeSegmentedControl.selectedSegmentIndex == 0 ? .standard:.quick + CameraPermissionHelper.ensurePermission(from: self, completion: { [weak self] in - self?.startConnection(address: address, port: port) + self?.startConnection(address: address, port: port, calibrationType: calibrationType) }) } @@ -172,6 +191,20 @@ final class CalibrationConnectionViewController: UIViewController { present(alert, animated: true, completion: nil) } + @IBAction private func openCalibrationTypeInstructions(_ sender: Any) { + // TODO + let alert = UIAlertController( + title: "TODO", + message: """ + TODO + """, + preferredStyle: .alert + ) + + alert.addAction(.init(title: "OK", style: .default, handler: nil)) + present(alert, animated: true, completion: nil) + } + @IBAction private func downloadMRCAction(_ sender: Any) { UIApplication.shared.open(Definitions.oculusMRCapp, options: [:], completionHandler: nil) } diff --git a/RealityMixer/Calibration/ViewControllers/CalibrationConnectionViewController.xib b/RealityMixer/Calibration/ViewControllers/CalibrationConnectionViewController.xib index d1b4d6a..6e894c8 100644 --- a/RealityMixer/Calibration/ViewControllers/CalibrationConnectionViewController.xib +++ b/RealityMixer/Calibration/ViewControllers/CalibrationConnectionViewController.xib @@ -12,6 +12,7 @@ + @@ -36,10 +37,10 @@ - + - + @@ -139,8 +140,48 @@ + + + + + + + + + + + + + + + + + + + + + + + - + @@ -246,7 +287,7 @@ - + diff --git a/RealityMixer/Calibration/ViewControllers/QuickCalibrationViewController.swift b/RealityMixer/Calibration/ViewControllers/QuickCalibrationViewController.swift new file mode 100644 index 0000000..5f2e524 --- /dev/null +++ b/RealityMixer/Calibration/ViewControllers/QuickCalibrationViewController.swift @@ -0,0 +1,42 @@ +// +// QuickCalibrationViewController.swift +// RealityMixer +// +// Created by Fabio de Albuquerque Dela Antonio on 13/07/2021. +// + +import UIKit +import ARKit +import AVFoundation +import SwiftSocket +import UIScreenExtension + +final class QuickCalibrationViewController: UIViewController { + weak var delegate: CalibrationViewControllerDelegate? + private let scaleFactor: Double + private let client: TCPClient + + @IBOutlet private weak var aligmentWidthConstraint: NSLayoutConstraint! + @IBOutlet private weak var aligmentImageView: UIImageView! + + init(client: TCPClient, scaleFactor: Double, delegate: CalibrationViewControllerDelegate?) { + self.client = client + self.scaleFactor = scaleFactor + self.delegate = delegate + super.init(nibName: String(describing: type(of: self)), bundle: Bundle(for: type(of: self))) + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func viewDidLoad() { + super.viewDidLoad() + + let alignmentImagePixelsWidth: CGFloat = 1000 + let alignmentImagePixelsPerInch: CGFloat = 264 + let pointsPerInch: CGFloat = UIScreen.pointsPerInch ?? 0 + + aligmentWidthConstraint.constant = (alignmentImagePixelsWidth/alignmentImagePixelsPerInch) * pointsPerInch + } +} diff --git a/RealityMixer/Calibration/ViewControllers/QuickCalibrationViewController.xib b/RealityMixer/Calibration/ViewControllers/QuickCalibrationViewController.xib new file mode 100644 index 0000000..d043921 --- /dev/null +++ b/RealityMixer/Calibration/ViewControllers/QuickCalibrationViewController.xib @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RealityMixer/Resources/Assets.xcassets/alignment.imageset/Contents.json b/RealityMixer/Resources/Assets.xcassets/alignment.imageset/Contents.json new file mode 100644 index 0000000..9d3ec5d --- /dev/null +++ b/RealityMixer/Resources/Assets.xcassets/alignment.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "alignment.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/RealityMixer/Resources/Assets.xcassets/alignment.imageset/alignment.png b/RealityMixer/Resources/Assets.xcassets/alignment.imageset/alignment.png new file mode 100644 index 0000000..bc7cb2a Binary files /dev/null and b/RealityMixer/Resources/Assets.xcassets/alignment.imageset/alignment.png differ