Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions SwiftARlps.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
CE43AEF2E18524F924BE58A5 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8524A246D8DFAA4CD472DE35 /* CoreTelephony.framework */; };
D7D405F240B24C036B07D812 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25E95722BBA12C622919F581 /* CoreText.framework */; };
DD8574D0EC668488A46A15EA /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B74C538658DA39BD2183AAC /* AssetsLibrary.framework */; };
FEE7A9E11FC87B190019DA72 /* UIDeviceOrientation+CameraOrientation.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEE7A9E01FC87B190019DA72 /* UIDeviceOrientation+CameraOrientation.swift */; };
FEE7A9E31FC885B10019DA72 /* SCNVector3+Distance.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEE7A9E21FC885B10019DA72 /* SCNVector3+Distance.swift */; };
FEF69C8D1FC8870D00A62594 /* EmojiFace.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEF69C8C1FC8870D00A62594 /* EmojiFace.swift */; };
FEF69C8F1FC88AC900A62594 /* String+Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEF69C8E1FC88AC900A62594 /* String+Image.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -94,6 +98,10 @@
E80C42879941D13A174F590C /* BuddyBuildSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = BuddyBuildSDK.framework; sourceTree = "<group>"; };
EDEAD543F9C5D3E64B9CC319 /* SampleCode.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = SampleCode.xcconfig; path = Configuration/SampleCode.xcconfig; sourceTree = "<group>"; };
FA66759253A43DA05D9DABA5 /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
FEE7A9E01FC87B190019DA72 /* UIDeviceOrientation+CameraOrientation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIDeviceOrientation+CameraOrientation.swift"; sourceTree = "<group>"; };
FEE7A9E21FC885B10019DA72 /* SCNVector3+Distance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SCNVector3+Distance.swift"; sourceTree = "<group>"; };
FEF69C8C1FC8870D00A62594 /* EmojiFace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiFace.swift; sourceTree = "<group>"; };
FEF69C8E1FC88AC900A62594 /* String+Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Image.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -183,6 +191,9 @@
3929C48A1E89EC2C00E00B60 /* SwiftARlps */ = {
isa = PBXGroup;
children = (
FEF69C8E1FC88AC900A62594 /* String+Image.swift */,
FEE7A9E01FC87B190019DA72 /* UIDeviceOrientation+CameraOrientation.swift */,
FEE7A9E21FC885B10019DA72 /* SCNVector3+Distance.swift */,
1FB542991FC861A80026CB94 /* SCNNode+Extensions.swift */,
3929C48B1E89EC2C00E00B60 /* AppDelegate.swift */,
3929C48D1E89EC2C00E00B60 /* ViewController.swift */,
Expand Down Expand Up @@ -228,6 +239,7 @@
B3C1D8BF1FC079560002729A /* Cube.swift */,
B399C9A21FC834C700102E39 /* Plane.swift */,
B399C9A41FC83CF400102E39 /* Ball.swift */,
FEF69C8C1FC8870D00A62594 /* EmojiFace.swift */,
);
path = "Virtual Objects";
sourceTree = "<group>";
Expand Down Expand Up @@ -280,7 +292,7 @@
TargetAttributes = {
3929C4871E89EC2C00E00B60 = {
CreatedOnToolsVersion = 9.0;
DevelopmentTeam = 729WVZ5N33;
DevelopmentTeam = 53B99NSR52;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
Expand Down Expand Up @@ -326,19 +338,23 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FEF69C8F1FC88AC900A62594 /* String+Image.swift in Sources */,
C812D8681F47628300344E73 /* ThresholdPanGesture.swift in Sources */,
11BD822A1F09D750003F11C8 /* ViewController+ObjectSelection.swift in Sources */,
1488323F1EFC378A0043E0AB /* ViewController+Actions.swift in Sources */,
3929C48E1E89EC2C00E00B60 /* ViewController.swift in Sources */,
FEE7A9E31FC885B10019DA72 /* SCNVector3+Distance.swift in Sources */,
B3C1D8C01FC079560002729A /* Cube.swift in Sources */,
B3F65D9D1FC867D2005F5F43 /* BallCube.swift in Sources */,
B399C9A31FC834C700102E39 /* Plane.swift in Sources */,
C41366B91EB80DD400EC054A /* StatusViewController.swift in Sources */,
B3C1D8C21FC07D130002729A /* Positionable.swift in Sources */,
39C0B95A1E9C6B1F003FCA0C /* Utilities.swift in Sources */,
FEF69C8D1FC8870D00A62594 /* EmojiFace.swift in Sources */,
147062641F06FA790003EE03 /* VirtualObjectSelection.swift in Sources */,
B399C9A51FC83CF400102E39 /* Ball.swift in Sources */,
C8C12A711F29277B00B011FE /* ViewController+ARSCNViewDelegate.swift in Sources */,
FEE7A9E11FC87B190019DA72 /* UIDeviceOrientation+CameraOrientation.swift in Sources */,
1FB5429A1FC861A90026CB94 /* SCNNode+Extensions.swift in Sources */,
C8C2AC521F3A545C00E86BA3 /* VirtualObjectInteraction.swift in Sources */,
C46356671EF9CC500080C8D9 /* VirtualObjectARView.swift in Sources */,
Expand Down Expand Up @@ -483,14 +499,14 @@
CODE_SIGN_IDENTITY = "-";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 729WVZ5N33;
DEVELOPMENT_TEAM = 53B99NSR52;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = "$(SRCROOT)/SwiftARlps/Resources/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.swiftalps.SwiftARlps;
PRODUCT_BUNDLE_IDENTIFIER = ink.jal.SwiftARlps;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Bridging-Header.h";
Expand All @@ -507,14 +523,14 @@
CODE_SIGN_IDENTITY = "-";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 729WVZ5N33;
DEVELOPMENT_TEAM = 53B99NSR52;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = "$(SRCROOT)/SwiftARlps/Resources/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.swiftalps.SwiftARlps;
PRODUCT_BUNDLE_IDENTIFIER = ink.jal.SwiftARlps;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Bridging-Header.h";
Expand Down
51 changes: 51 additions & 0 deletions SwiftARlps/SCNVector3+Distance.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// SCNVector3+Distance.swift
// SwiftARlps
//
// Created by Eran Jalink on 24/11/2017.
// Copyright © 2017 Apple. All rights reserved.
//

import Foundation
import ARKit

public extension SCNVector3 {

/**
Calculates vector length based on Pythagoras theorem
*/
var length:Float {
get {
return sqrtf(x*x + y*y + z*z)
}
}

func distance(toVector: SCNVector3) -> Float {
return (self - toVector).length
}

static func positionFromTransform(_ transform: matrix_float4x4) -> SCNVector3 {
return SCNVector3Make(transform.columns.3.x, transform.columns.3.y, transform.columns.3.z)
}

static func -(left: SCNVector3, right: SCNVector3) -> SCNVector3 {
return SCNVector3Make(left.x - right.x, left.y - right.y, left.z - right.z)
}

static func center(_ vectors: [SCNVector3]) -> SCNVector3 {
var x: Float = 0
var y: Float = 0
var z: Float = 0

let size = Float(vectors.count)
vectors.forEach {
x += $0.x
y += $0.y
z += $0.z
}
return SCNVector3Make(x / size, y / size, z / size)
}
}



23 changes: 23 additions & 0 deletions SwiftARlps/String+Image.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// String+Image.swift
// SwiftARlps
//
// Created by Eran Jalink on 24/11/2017.
// Copyright © 2017 Apple. All rights reserved.
//

import UIKit

extension String {
func emojiToImage() -> UIImage? {
let size = CGSize(width: 30, height: 35)
UIGraphicsBeginImageContextWithOptions(size, false, 0)
UIColor.white.set()
let rect = CGRect(origin: CGPoint(), size: size)
UIRectFill(CGRect(origin: CGPoint(), size: size))
(self as NSString).draw(in: rect, withAttributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 30)])
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}
}
20 changes: 20 additions & 0 deletions SwiftARlps/UIDeviceOrientation+CameraOrientation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// UIDeviceOrientation+CameraOrientation.swift
// SwiftARlps
//
// Created by Eran Jalink on 24/11/2017.
// Copyright © 2017 Apple. All rights reserved.
//

import UIKit

extension UIDeviceOrientation {
func cameraOrientation() -> CGImagePropertyOrientation {
switch self {
case .landscapeLeft: return .up
case .landscapeRight: return .down
case .portraitUpsideDown: return .left
default: return .right
}
}
}
Loading