Skip to content

Commit

Permalink
Merge pull request #27 from fabio914/hide-background
Browse files Browse the repository at this point in the history
Adding option to hide the background layer
  • Loading branch information
fabio914 authored Dec 2, 2020
2 parents 0efed75 + 467293f commit 9729900
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
8 changes: 4 additions & 4 deletions RealityMixer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_TEAM = ZTJ55TM37B;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -948,7 +948,7 @@
"$(inherited)",
"$(PROJECT_DIR)/RealityMixer/FFmpeg-iOS/lib",
);
MARKETING_VERSION = 0.1.5;
MARKETING_VERSION = 0.1.6;
PRODUCT_BUNDLE_IDENTIFIER = com.bluenose.reality.mixer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "RealityMixer/RealityMixer-Bridging-Header.h";
Expand All @@ -965,7 +965,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_TEAM = ZTJ55TM37B;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -981,7 +981,7 @@
"$(inherited)",
"$(PROJECT_DIR)/RealityMixer/FFmpeg-iOS/lib",
);
MARKETING_VERSION = 0.1.5;
MARKETING_VERSION = 0.1.6;
PRODUCT_BUNDLE_IDENTIFIER = com.bluenose.reality.mixer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "RealityMixer/RealityMixer-Bridging-Header.h";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final class MixedRealityConnectionViewController: UIViewController {
@IBOutlet private weak var audioSwitch: UISwitch!
@IBOutlet private weak var magentaSwitch: UISwitch!
@IBOutlet private weak var unflipSwitch: UISwitch!
@IBOutlet private weak var hideBackgroundSwitch: UISwitch!
@IBOutlet private weak var infoLabel: UILabel!
@IBOutlet private weak var secondInfoLabel: UILabel!
@IBOutlet private weak var thirdInfoLabel: UILabel!
Expand Down Expand Up @@ -121,7 +122,8 @@ final class MixedRealityConnectionViewController: UIViewController {
let configuration = MixedRealityConfiguration(
shouldUseMagentaAsTransparency: self.magentaSwitch.isOn,
enableAudio: self.audioSwitch.isOn,
shouldFlipOutput: !self.unflipSwitch.isOn
shouldFlipOutput: !self.unflipSwitch.isOn,
shouldHideBackground: self.hideBackgroundSwitch.isOn
)

connectionAlert.dismiss(animated: false, completion: { [weak self] in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<connections>
<outlet property="addressTextField" destination="DZi-cu-2ge" id="Klz-WA-Xd6"/>
<outlet property="audioSwitch" destination="gwP-RT-jgL" id="Gao-5y-rvF"/>
<outlet property="hideBackgroundSwitch" destination="PQM-HS-mFN" id="Cbj-hH-2yR"/>
<outlet property="infoLabel" destination="Cvo-ep-K0W" id="ZvL-Zh-Kd4"/>
<outlet property="magentaSwitch" destination="mmC-l6-vWp" id="Uda-GP-MSq"/>
<outlet property="portTextField" destination="Lky-ae-zSD" id="2KE-UZ-PBo"/>
Expand All @@ -34,10 +35,10 @@
<rect key="frame" x="0.0" y="0.0" width="1194" height="784"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BKZ-mI-AUe">
<rect key="frame" x="0.0" y="0.0" width="1194" height="677.5"/>
<rect key="frame" x="0.0" y="0.0" width="1194" height="753"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="ThD-0e-MfL">
<rect key="frame" x="347" y="40" width="500" height="597.5"/>
<rect key="frame" x="347" y="40" width="500" height="673"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="WA0-LP-4eU">
<rect key="frame" x="0.0" y="0.0" width="500" height="52.5"/>
Expand Down Expand Up @@ -78,7 +79,7 @@
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Options" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PaV-dE-23N">
<rect key="frame" x="0.0" y="0.0" width="500" height="14.5"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="12"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="12"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2VB-LH-Qd3">
Expand Down Expand Up @@ -131,8 +132,34 @@
</stackView>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="BiT-6m-fnJ">
<rect key="frame" x="0.0" y="302.5" width="500" height="55.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="AR Options" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sxK-WR-eLd">
<rect key="frame" x="0.0" y="0.0" width="500" height="14.5"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="12"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ihK-xB-jKC">
<rect key="frame" x="0.0" y="24.5" width="500" height="31"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hide background layer" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ruk-eu-0cK">
<rect key="frame" x="0.0" y="0.0" width="451" height="31"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="14"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="PQM-HS-mFN">
<rect key="frame" x="451" y="0.0" width="51" height="31"/>
<color key="onTintColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="thumbTintColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</switch>
</subviews>
</stackView>
</subviews>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="r2g-AA-pGA">
<rect key="frame" x="0.0" y="302.5" width="500" height="40"/>
<rect key="frame" x="0.0" y="378" width="500" height="40"/>
<color key="backgroundColor" white="0.10000000000000001" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="IpD-EI-bUf"/>
Expand All @@ -151,20 +178,20 @@
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Bgm-b4-8r2">
<rect key="frame" x="0.0" y="362.5" width="500" height="1"/>
<rect key="frame" x="0.0" y="438" width="500" height="1"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="5cw-uV-ee1"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Info" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Cvo-ep-K0W">
<rect key="frame" x="0.0" y="383.5" width="500" height="18"/>
<rect key="frame" x="0.0" y="459" width="500" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ruk-RS-qSj">
<rect key="frame" x="0.0" y="421.5" width="500" height="40"/>
<rect key="frame" x="0.0" y="497" width="500" height="40"/>
<color key="backgroundColor" white="0.10000000000000001" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="Ke5-K4-nlc"/>
Expand All @@ -183,13 +210,13 @@
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Info" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="i5n-Pa-HjL">
<rect key="frame" x="0.0" y="481.5" width="500" height="18"/>
<rect key="frame" x="0.0" y="557" width="500" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cLW-1L-KGI">
<rect key="frame" x="0.0" y="519.5" width="500" height="40"/>
<rect key="frame" x="0.0" y="595" width="500" height="40"/>
<color key="backgroundColor" white="0.10000000000000001" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="dng-VS-vKF"/>
Expand All @@ -208,7 +235,7 @@
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Info" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IU3-yK-ZhP">
<rect key="frame" x="0.0" y="579.5" width="500" height="18"/>
<rect key="frame" x="0.0" y="655" width="500" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct MixedRealityConfiguration {

let enableAudio: Bool
let shouldFlipOutput: Bool
let shouldHideBackground: Bool
}

final class MixedRealityViewController: UIViewController {
Expand Down Expand Up @@ -116,7 +117,9 @@ final class MixedRealityViewController: UIViewController {
sceneView.scene = scene
sceneView.session.delegate = self

sceneView.pointOfView?.addChildNode(makePlane(size: .init(width: 9999, height: 9999), distance: 120))
if !configuration.shouldHideBackground {
sceneView.pointOfView?.addChildNode(makePlane(size: .init(width: 9999, height: 9999), distance: 120))
}

if let metalDevice = sceneView.device {
let result = CVMetalTextureCacheCreate(
Expand Down Expand Up @@ -169,6 +172,7 @@ final class MixedRealityViewController: UIViewController {
}

private func configureBackground(with frame: ARFrame) {
guard !configuration.shouldHideBackground else { return }
let backgroundPlaneNode = makePlaneNodeForDistance(100.0, frame: frame)

// Flipping image
Expand Down

0 comments on commit 9729900

Please sign in to comment.