diff --git a/XIONControlPanel.xcodeproj/project.pbxproj b/XIONControlPanel.xcodeproj/project.pbxproj index 5f3e8c3..e0627ed 100644 --- a/XIONControlPanel.xcodeproj/project.pbxproj +++ b/XIONControlPanel.xcodeproj/project.pbxproj @@ -7,21 +7,43 @@ objects = { /* Begin PBXBuildFile section */ - 0C3CAEA81C3350C800B856AD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C3CAEA71C3350C800B856AD /* AppDelegate.swift */; }; - 0C3CAEAA1C3350C800B856AD /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C3CAEA91C3350C800B856AD /* ViewController.swift */; }; - 0C3CAEAD1C3350C800B856AD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0C3CAEAB1C3350C800B856AD /* Main.storyboard */; }; + 0C20E2B91C33514100BA789B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C20E2B51C33514100BA789B /* AppDelegate.swift */; }; + 0C20E2BB1C33529700BA789B /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C20E2BA1C33529700BA789B /* MainViewController.swift */; }; + 0C20E2BD1C33534F00BA789B /* BackgroundViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C20E2BC1C33534F00BA789B /* BackgroundViewController.swift */; }; 0C3CAEAF1C3350C800B856AD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0C3CAEAE1C3350C800B856AD /* Assets.xcassets */; }; 0C3CAEB21C3350C800B856AD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0C3CAEB01C3350C800B856AD /* LaunchScreen.storyboard */; }; + 0C63A8731C337381007E4B52 /* CubletsTechnique.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0C63A8721C337381007E4B52 /* CubletsTechnique.plist */; }; + 0C63A8761C3373D1007E4B52 /* HorizontalBlur.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 0C63A8751C3373D1007E4B52 /* HorizontalBlur.vsh */; }; + 0C63A8781C3373D9007E4B52 /* HorizontalBlur.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 0C63A8771C3373D9007E4B52 /* HorizontalBlur.fsh */; }; + 0C63A87D1C33C655007E4B52 /* NSValue+XIONAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C63A87C1C33C655007E4B52 /* NSValue+XIONAdditions.m */; }; + 0C63A87F1C33D3D7007E4B52 /* FirstPass.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 0C63A87E1C33D3D7007E4B52 /* FirstPass.vsh */; }; + 0C63A8811C33D3DE007E4B52 /* FirstPass.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 0C63A8801C33D3DE007E4B52 /* FirstPass.fsh */; }; + 0C63A8841C33DC29007E4B52 /* VerticalBlur.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 0C63A8821C33DC29007E4B52 /* VerticalBlur.fsh */; }; + 0C63A8851C33DC29007E4B52 /* VerticalBlur.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 0C63A8831C33DC29007E4B52 /* VerticalBlur.vsh */; }; + 0C63A8881C33EB3B007E4B52 /* FinalRender.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 0C63A8861C33EB3B007E4B52 /* FinalRender.fsh */; }; + 0C63A8891C33EB3B007E4B52 /* FinalRender.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 0C63A8871C33EB3B007E4B52 /* FinalRender.vsh */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 0C20E2B51C33514100BA789B /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 0C20E2BA1C33529700BA789B /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; + 0C20E2BC1C33534F00BA789B /* BackgroundViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundViewController.swift; sourceTree = ""; }; 0C3CAEA41C3350C800B856AD /* XIONControlPanel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = XIONControlPanel.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 0C3CAEA71C3350C800B856AD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 0C3CAEA91C3350C800B856AD /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - 0C3CAEAC1C3350C800B856AD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 0C3CAEAE1C3350C800B856AD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 0C3CAEB11C3350C800B856AD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 0C3CAEB31C3350C800B856AD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0C63A8721C337381007E4B52 /* CubletsTechnique.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = CubletsTechnique.plist; sourceTree = ""; }; + 0C63A8751C3373D1007E4B52 /* HorizontalBlur.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = HorizontalBlur.vsh; sourceTree = ""; }; + 0C63A8771C3373D9007E4B52 /* HorizontalBlur.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = HorizontalBlur.fsh; sourceTree = ""; }; + 0C63A87A1C33C655007E4B52 /* XIONControlPanel-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "XIONControlPanel-Bridging-Header.h"; sourceTree = ""; }; + 0C63A87B1C33C655007E4B52 /* NSValue+XIONAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSValue+XIONAdditions.h"; sourceTree = ""; }; + 0C63A87C1C33C655007E4B52 /* NSValue+XIONAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSValue+XIONAdditions.m"; sourceTree = ""; }; + 0C63A87E1C33D3D7007E4B52 /* FirstPass.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = FirstPass.vsh; sourceTree = ""; }; + 0C63A8801C33D3DE007E4B52 /* FirstPass.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = FirstPass.fsh; sourceTree = ""; }; + 0C63A8821C33DC29007E4B52 /* VerticalBlur.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = VerticalBlur.fsh; sourceTree = ""; }; + 0C63A8831C33DC29007E4B52 /* VerticalBlur.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = VerticalBlur.vsh; sourceTree = ""; }; + 0C63A8861C33EB3B007E4B52 /* FinalRender.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = FinalRender.fsh; sourceTree = ""; }; + 0C63A8871C33EB3B007E4B52 /* FinalRender.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = FinalRender.vsh; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -35,6 +57,56 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 0C20E2B31C33510700BA789B /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 0C3CAEAE1C3350C800B856AD /* Assets.xcassets */, + 0C3CAEB01C3350C800B856AD /* LaunchScreen.storyboard */, + 0C3CAEB31C3350C800B856AD /* Info.plist */, + ); + name = "Supporting Files"; + path = SupportingFiles; + sourceTree = ""; + }; + 0C20E2B41C33514100BA789B /* Application */ = { + isa = PBXGroup; + children = ( + 0C20E2B51C33514100BA789B /* AppDelegate.swift */, + ); + path = Application; + sourceTree = ""; + }; + 0C20E2B61C33514100BA789B /* Controllers */ = { + isa = PBXGroup; + children = ( + 0C20E2BC1C33534F00BA789B /* BackgroundViewController.swift */, + 0C20E2BA1C33529700BA789B /* MainViewController.swift */, + ); + path = Controllers; + sourceTree = ""; + }; + 0C20E2B71C33514100BA789B /* Models */ = { + isa = PBXGroup; + children = ( + ); + path = Models; + sourceTree = ""; + }; + 0C20E2B81C33514100BA789B /* Views */ = { + isa = PBXGroup; + children = ( + ); + path = Views; + sourceTree = ""; + }; + 0C20E2C81C336F2E00BA789B /* Resources */ = { + isa = PBXGroup; + children = ( + 0C63A8721C337381007E4B52 /* CubletsTechnique.plist */, + ); + path = Resources; + sourceTree = ""; + }; 0C3CAE9B1C3350C800B856AD = { isa = PBXGroup; children = ( @@ -54,16 +126,43 @@ 0C3CAEA61C3350C800B856AD /* XIONControlPanel */ = { isa = PBXGroup; children = ( - 0C3CAEA71C3350C800B856AD /* AppDelegate.swift */, - 0C3CAEA91C3350C800B856AD /* ViewController.swift */, - 0C3CAEAB1C3350C800B856AD /* Main.storyboard */, - 0C3CAEAE1C3350C800B856AD /* Assets.xcassets */, - 0C3CAEB01C3350C800B856AD /* LaunchScreen.storyboard */, - 0C3CAEB31C3350C800B856AD /* Info.plist */, + 0C20E2B41C33514100BA789B /* Application */, + 0C20E2B61C33514100BA789B /* Controllers */, + 0C20E2B71C33514100BA789B /* Models */, + 0C63A8741C3373BC007E4B52 /* Shaders */, + 0C20E2C81C336F2E00BA789B /* Resources */, + 0C63A8791C33C622007E4B52 /* Utilities */, + 0C20E2B81C33514100BA789B /* Views */, + 0C20E2B31C33510700BA789B /* Supporting Files */, ); path = XIONControlPanel; sourceTree = ""; }; + 0C63A8741C3373BC007E4B52 /* Shaders */ = { + isa = PBXGroup; + children = ( + 0C63A87E1C33D3D7007E4B52 /* FirstPass.vsh */, + 0C63A8801C33D3DE007E4B52 /* FirstPass.fsh */, + 0C63A8751C3373D1007E4B52 /* HorizontalBlur.vsh */, + 0C63A8771C3373D9007E4B52 /* HorizontalBlur.fsh */, + 0C63A8831C33DC29007E4B52 /* VerticalBlur.vsh */, + 0C63A8821C33DC29007E4B52 /* VerticalBlur.fsh */, + 0C63A8871C33EB3B007E4B52 /* FinalRender.vsh */, + 0C63A8861C33EB3B007E4B52 /* FinalRender.fsh */, + ); + path = Shaders; + sourceTree = ""; + }; + 0C63A8791C33C622007E4B52 /* Utilities */ = { + isa = PBXGroup; + children = ( + 0C63A87B1C33C655007E4B52 /* NSValue+XIONAdditions.h */, + 0C63A87C1C33C655007E4B52 /* NSValue+XIONAdditions.m */, + 0C63A87A1C33C655007E4B52 /* XIONControlPanel-Bridging-Header.h */, + ); + path = Utilities; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -122,9 +221,17 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 0C63A8761C3373D1007E4B52 /* HorizontalBlur.vsh in Resources */, + 0C63A87F1C33D3D7007E4B52 /* FirstPass.vsh in Resources */, + 0C63A8731C337381007E4B52 /* CubletsTechnique.plist in Resources */, + 0C63A8811C33D3DE007E4B52 /* FirstPass.fsh in Resources */, + 0C63A8881C33EB3B007E4B52 /* FinalRender.fsh in Resources */, 0C3CAEB21C3350C800B856AD /* LaunchScreen.storyboard in Resources */, 0C3CAEAF1C3350C800B856AD /* Assets.xcassets in Resources */, - 0C3CAEAD1C3350C800B856AD /* Main.storyboard in Resources */, + 0C63A8841C33DC29007E4B52 /* VerticalBlur.fsh in Resources */, + 0C63A8851C33DC29007E4B52 /* VerticalBlur.vsh in Resources */, + 0C63A8891C33EB3B007E4B52 /* FinalRender.vsh in Resources */, + 0C63A8781C3373D9007E4B52 /* HorizontalBlur.fsh in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -135,22 +242,16 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 0C3CAEAA1C3350C800B856AD /* ViewController.swift in Sources */, - 0C3CAEA81C3350C800B856AD /* AppDelegate.swift in Sources */, + 0C63A87D1C33C655007E4B52 /* NSValue+XIONAdditions.m in Sources */, + 0C20E2BD1C33534F00BA789B /* BackgroundViewController.swift in Sources */, + 0C20E2B91C33514100BA789B /* AppDelegate.swift in Sources */, + 0C20E2BB1C33529700BA789B /* MainViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ - 0C3CAEAB1C3350C800B856AD /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 0C3CAEAC1C3350C800B856AD /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; 0C3CAEB01C3350C800B856AD /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( @@ -249,10 +350,13 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - INFOPLIST_FILE = XIONControlPanel/Info.plist; + CLANG_ENABLE_MODULES = YES; + INFOPLIST_FILE = "$(SRCROOT)/XIONControlPanel/SupportingFiles/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xionsf.XIONControlPanel; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "XIONControlPanel/Utilities/XIONControlPanel-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; name = Debug; }; @@ -260,10 +364,12 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - INFOPLIST_FILE = XIONControlPanel/Info.plist; + CLANG_ENABLE_MODULES = YES; + INFOPLIST_FILE = "$(SRCROOT)/XIONControlPanel/SupportingFiles/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xionsf.XIONControlPanel; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "XIONControlPanel/Utilities/XIONControlPanel-Bridging-Header.h"; }; name = Release; }; @@ -286,6 +392,7 @@ 0C3CAEB81C3350C800B856AD /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/XIONControlPanel/AppDelegate.swift b/XIONControlPanel/AppDelegate.swift deleted file mode 100644 index 2253316..0000000 --- a/XIONControlPanel/AppDelegate.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// AppDelegate.swift -// XIONControlPanel -// -// Created by Charles Magahern on 12/29/15. -// Copyright © 2015 XION. All rights reserved. -// - -import UIKit - -@UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate { - - var window: UIWindow? - - - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - // Override point for customization after application launch. - return true - } - - func applicationWillResignActive(application: UIApplication) { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - } - - func applicationDidEnterBackground(application: UIApplication) { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - } - - func applicationWillEnterForeground(application: UIApplication) { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. - } - - func applicationDidBecomeActive(application: UIApplication) { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - } - - func applicationWillTerminate(application: UIApplication) { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - } - - -} - diff --git a/XIONControlPanel/Application/AppDelegate.swift b/XIONControlPanel/Application/AppDelegate.swift new file mode 100644 index 0000000..b46da2d --- /dev/null +++ b/XIONControlPanel/Application/AppDelegate.swift @@ -0,0 +1,30 @@ +// +// AppDelegate.swift +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + var window: UIWindow? + + func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool + { + application.statusBarHidden = true + + self.window = UIWindow(frame: UIScreen.mainScreen().bounds) + self.window?.rootViewController = MainViewController() + self.window?.makeKeyAndVisible() + + return true + } + + func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask + { + return UIInterfaceOrientationMask.Portrait + } +} diff --git a/XIONControlPanel/Base.lproj/Main.storyboard b/XIONControlPanel/Base.lproj/Main.storyboard deleted file mode 100644 index 3a2a49b..0000000 --- a/XIONControlPanel/Base.lproj/Main.storyboard +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/XIONControlPanel/Controllers/BackgroundViewController.swift b/XIONControlPanel/Controllers/BackgroundViewController.swift new file mode 100644 index 0000000..e013fd2 --- /dev/null +++ b/XIONControlPanel/Controllers/BackgroundViewController.swift @@ -0,0 +1,145 @@ +// +// BackgroundViewController.swift +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +import Darwin +import Foundation +import GLKit +import SceneKit +import UIKit + +let π = Float(M_PI) + +class BackgroundViewController: UIViewController { + private var _scene: SCNScene = SCNScene() + private var _sceneView: SCNView? + private var _cameraNode: SCNNode = SCNNode() + private var _cubletsNode: SCNNode = SCNNode() + + static private let cubletsDimensions = 5 + static private let cubletsSize = 1.0 + static private let cubletsSpacing = 2.0 + + override func loadView() + { + let view = SCNView(frame: UIScreen.mainScreen().bounds, options: nil) + view.backgroundColor = UIColor.blackColor() + view.scene = _scene + view.allowsCameraControl = false + + _sceneView = view + self.view = view + } + + override func viewDidLoad() + { + super.viewDidLoad() + _setupCamera() + _setupLights() + _setupModel() + _setupAnimation() + _setupEffects() + } + + override func viewDidAppear(animated: Bool) + { + super.viewDidAppear(animated) + _sceneView?.play(nil) + } + + override func viewDidDisappear(animated: Bool) + { + super.viewDidDisappear(animated) + _sceneView?.stop(nil) + } + + // MARK: Internal + + internal func _setupCamera() + { + let camera = SCNCamera() + + _cameraNode.camera = camera + _cameraNode.position = SCNVector3Make(0.0, 0.0, 50.0) + _scene.rootNode.addChildNode(_cameraNode) + + let centerNode = SCNNode() + centerNode.position = SCNVector3Zero + _scene.rootNode.addChildNode(centerNode) + + let constraint = SCNLookAtConstraint(target: centerNode) + _cameraNode.constraints = [constraint] + } + + internal func _setupLights() + { + let light = SCNLight() + light.type = SCNLightTypeOmni + light.color = UIColor.whiteColor() + + let lightNode = SCNNode() + lightNode.light = light + lightNode.position = _cameraNode.position + + _scene.rootNode.addChildNode(lightNode) + } + + internal func _setupModel() + { + let sz = Float(BackgroundViewController.cubletsSize) + let dim = BackgroundViewController.cubletsDimensions + let dimf = Float(dim) + let spacing = Float(BackgroundViewController.cubletsSpacing) + let volume = (dimf * sz) + ((dimf - 1.0) * spacing) + let orig = -volume / 2.0 + + // setup material + let material = SCNMaterial() + material.diffuse.contents = UIColor.whiteColor() + material.transparency = 0.75 + + // setup geometry + let geom = SCNBox(width: CGFloat(sz), height: CGFloat(sz), length: CGFloat(sz), chamferRadius: 0.0) + geom.firstMaterial = material + + for var xi = 0; xi < dim; ++xi { + let x = orig + Float(xi) * (sz + spacing) + + for var yi = 0; yi < dim; ++yi { + let y = orig + Float(yi) * (sz + spacing) + + for var zi = 0; zi < dim; ++zi { + let z = orig + Float(zi) * (sz + spacing) + + let node = SCNNode(geometry: geom) + node.position = SCNVector3Make(x, y, z) + _cubletsNode.addChildNode(node) + } + } + } + + _cubletsNode.position = SCNVector3Zero + _scene.rootNode.addChildNode(_cubletsNode) + } + + internal func _setupAnimation() + { + let rotAxis = SCNVector3Make(0.25, 1.75, 1.0) + let rotAngle = CGFloat(Float(2.0)*π) + let rotAction = SCNAction.repeatActionForever(SCNAction.rotateByAngle(rotAngle, aroundAxis: rotAxis, duration: 20.0)) + _cubletsNode.runAction(rotAction) + } + + internal func _setupEffects() + { + let techniqueURL = NSBundle.mainBundle().URLForResource("CubletsTechnique", withExtension: "plist") + let techniqueDict = NSDictionary(contentsOfURL: techniqueURL!) as! [String : AnyObject] + let technique = SCNTechnique(dictionary: techniqueDict) + + _sceneView?.technique = technique + } +} diff --git a/XIONControlPanel/Controllers/MainViewController.swift b/XIONControlPanel/Controllers/MainViewController.swift new file mode 100644 index 0000000..aba8138 --- /dev/null +++ b/XIONControlPanel/Controllers/MainViewController.swift @@ -0,0 +1,36 @@ +// +// MainViewController.swift +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +import UIKit + +class MainViewController: UIViewController { + private var _backgroundController: BackgroundViewController = BackgroundViewController() + + override func viewDidLoad() + { + super.viewDidLoad() + + self.view.backgroundColor = UIColor.blackColor() + + self.addChildViewController(_backgroundController) + self.view.addSubview(_backgroundController.view) + } + + override func prefersStatusBarHidden() -> Bool + { + return true + } + + override func viewDidLayoutSubviews() + { + super.viewDidLayoutSubviews() + + let bounds = self.view.bounds + _backgroundController.view.frame = bounds + } +} diff --git a/XIONControlPanel/Resources/CubletsTechnique.plist b/XIONControlPanel/Resources/CubletsTechnique.plist new file mode 100644 index 0000000..09bda04 --- /dev/null +++ b/XIONControlPanel/Resources/CubletsTechnique.plist @@ -0,0 +1,135 @@ + + + + + sequence + + firstPass + hblur + vblur + finalRender + + passes + + firstPass + + draw + DRAW_QUAD + program + FirstPass + inputs + + a_position + a_position-symbol + u_colorSampler + COLOR + + outputs + + color + firstPass_color + + + hblur + + draw + DRAW_QUAD + program + HorizontalBlur + inputs + + a_position + a_position-symbol + u_colorSampler + firstPass_color + + outputs + + color + hblur_color + + + vblur + + draw + DRAW_QUAD + program + VerticalBlur + inputs + + a_position + a_position-symbol + u_colorSampler + hblur_color + + outputs + + color + bothblurs_color + + + finalRender + + draw + DRAW_QUAD + program + FinalRender + inputs + + a_position + a_position-symbol + u_blurmapSampler + bothblurs_color + u_colorSampler + firstPass_color + + outputs + + color + COLOR + + + + targets + + firstPass_color + + type + color + + hblur_color + + type + color + + bothblurs_color + + type + color + + + symbols + + u_blurRadius-symbol + + type + float + + u_viewportSize-symbol + + type + vec2 + + u_blurKernel-symbol + + type + mat4 + + a_position-symbol + + semantic + vertex + + + + diff --git a/XIONControlPanel/Shaders/FinalRender.fsh b/XIONControlPanel/Shaders/FinalRender.fsh new file mode 100644 index 0000000..99b933f --- /dev/null +++ b/XIONControlPanel/Shaders/FinalRender.fsh @@ -0,0 +1,23 @@ +// +// FinalRender.fsh +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +uniform sampler2D u_colorSampler; +uniform sampler2D u_blurmapSampler; +varying vec2 v_uv; + +float saturate(float v) +{ + return clamp(v, 0.0, 1.0); +} + +void main() +{ + vec4 color = texture2D(u_colorSampler, v_uv) + texture2D(u_blurmapSampler, v_uv); + float dist = length(v_uv - vec2(0.5)); + gl_FragColor = saturate(1.0 / (8.0 * (dist + 0.1))) * color; +} diff --git a/XIONControlPanel/Shaders/FinalRender.vsh b/XIONControlPanel/Shaders/FinalRender.vsh new file mode 100644 index 0000000..a2d4209 --- /dev/null +++ b/XIONControlPanel/Shaders/FinalRender.vsh @@ -0,0 +1,16 @@ +// +// FinalRender.vsh +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +attribute vec4 a_position; +varying vec2 v_uv; + +void main() +{ + v_uv = (a_position.xy + 1.0) * 0.5; + gl_Position = a_position; +} diff --git a/XIONControlPanel/Shaders/FirstPass.fsh b/XIONControlPanel/Shaders/FirstPass.fsh new file mode 100644 index 0000000..425d20d --- /dev/null +++ b/XIONControlPanel/Shaders/FirstPass.fsh @@ -0,0 +1,15 @@ +// +// FirstPass.fsh +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +uniform sampler2D u_colorSampler; +varying vec2 v_uv; + +void main() +{ + gl_FragColor = texture2D(u_colorSampler, v_uv); +} diff --git a/XIONControlPanel/Shaders/FirstPass.vsh b/XIONControlPanel/Shaders/FirstPass.vsh new file mode 100644 index 0000000..48da505 --- /dev/null +++ b/XIONControlPanel/Shaders/FirstPass.vsh @@ -0,0 +1,16 @@ +// +// FirstPass.vsh +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +attribute vec4 a_position; +varying vec2 v_uv; + +void main() +{ + v_uv = (a_position.xy + 1.0) * 0.5; + gl_Position = a_position; +} diff --git a/XIONControlPanel/Shaders/HorizontalBlur.fsh b/XIONControlPanel/Shaders/HorizontalBlur.fsh new file mode 100644 index 0000000..b12e955 --- /dev/null +++ b/XIONControlPanel/Shaders/HorizontalBlur.fsh @@ -0,0 +1,31 @@ +// +// HorizontalBlur.fsh +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +uniform sampler2D u_colorSampler; +varying vec2 v_uv; +varying vec2 v_blurTexCoords[14]; + +void main() +{ + gl_FragColor = vec4(0.0); +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 0])*0.0044299121055113265; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 1])*0.00895781211794; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 2])*0.0215963866053; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 3])*0.0443683338718; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 4])*0.0776744219933; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 5])*0.115876621105; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 6])*0.147308056121; +    gl_FragColor += texture2D(u_colorSampler, v_uv          )*0.159576912161; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 7])*0.147308056121; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 8])*0.115876621105; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 9])*0.0776744219933; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[10])*0.0443683338718; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[11])*0.0215963866053; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[12])*0.00895781211794; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[13])*0.0044299121055113265; +} diff --git a/XIONControlPanel/Shaders/HorizontalBlur.vsh b/XIONControlPanel/Shaders/HorizontalBlur.vsh new file mode 100644 index 0000000..c354278 --- /dev/null +++ b/XIONControlPanel/Shaders/HorizontalBlur.vsh @@ -0,0 +1,32 @@ +// +// HorizontalBlur.vsh +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +attribute vec4 a_position; +varying vec2 v_uv; +varying vec2 v_blurTexCoords[14]; + +void main() +{ + v_uv = (a_position.xy + 1.0) * 0.5; +    v_blurTexCoords[ 0] = v_uv + vec2(-0.028, 0.0); +    v_blurTexCoords[ 1] = v_uv + vec2(-0.024, 0.0); +    v_blurTexCoords[ 2] = v_uv + vec2(-0.020, 0.0); +    v_blurTexCoords[ 3] = v_uv + vec2(-0.016, 0.0); +    v_blurTexCoords[ 4] = v_uv + vec2(-0.012, 0.0); +    v_blurTexCoords[ 5] = v_uv + vec2(-0.008, 0.0); +    v_blurTexCoords[ 6] = v_uv + vec2(-0.004, 0.0); +    v_blurTexCoords[ 7] = v_uv + vec2( 0.004, 0.0); +    v_blurTexCoords[ 8] = v_uv + vec2( 0.008, 0.0); +    v_blurTexCoords[ 9] = v_uv + vec2( 0.012, 0.0); +    v_blurTexCoords[10] = v_uv + vec2( 0.016, 0.0); +    v_blurTexCoords[11] = v_uv + vec2( 0.020, 0.0); +    v_blurTexCoords[12] = v_uv + vec2( 0.024, 0.0); +    v_blurTexCoords[13] = v_uv + vec2( 0.028, 0.0); + + gl_Position = a_position; +} diff --git a/XIONControlPanel/Shaders/VerticalBlur.fsh b/XIONControlPanel/Shaders/VerticalBlur.fsh new file mode 100644 index 0000000..1132e55 --- /dev/null +++ b/XIONControlPanel/Shaders/VerticalBlur.fsh @@ -0,0 +1,31 @@ +// +// VerticalBlur.fsh +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +uniform sampler2D u_colorSampler; +varying vec2 v_uv; +varying vec2 v_blurTexCoords[14]; + +void main() +{ + gl_FragColor = vec4(0.0); +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 0])*0.0044299121055113265; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 1])*0.00895781211794; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 2])*0.0215963866053; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 3])*0.0443683338718; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 4])*0.0776744219933; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 5])*0.115876621105; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 6])*0.147308056121; +    gl_FragColor += texture2D(u_colorSampler, v_uv          )*0.159576912161; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 7])*0.147308056121; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 8])*0.115876621105; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[ 9])*0.0776744219933; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[10])*0.0443683338718; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[11])*0.0215963866053; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[12])*0.00895781211794; +    gl_FragColor += texture2D(u_colorSampler, v_blurTexCoords[13])*0.0044299121055113265; +} diff --git a/XIONControlPanel/Shaders/VerticalBlur.vsh b/XIONControlPanel/Shaders/VerticalBlur.vsh new file mode 100644 index 0000000..65ed631 --- /dev/null +++ b/XIONControlPanel/Shaders/VerticalBlur.vsh @@ -0,0 +1,32 @@ +// +// VerticalBlur.vsh +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +attribute vec4 a_position; +varying vec2 v_uv; +varying vec2 v_blurTexCoords[14]; + +void main() +{ + v_uv = (a_position.xy + 1.0) * 0.5; +    v_blurTexCoords[ 0] = v_uv + vec2(0.0, -0.028); +    v_blurTexCoords[ 1] = v_uv + vec2(0.0, -0.024); +    v_blurTexCoords[ 2] = v_uv + vec2(0.0, -0.020); +    v_blurTexCoords[ 3] = v_uv + vec2(0.0, -0.016); +    v_blurTexCoords[ 4] = v_uv + vec2(0.0, -0.012); +    v_blurTexCoords[ 5] = v_uv + vec2(0.0, -0.008); +    v_blurTexCoords[ 6] = v_uv + vec2(0.0, -0.004); +    v_blurTexCoords[ 7] = v_uv + vec2(0.0,  0.004); +    v_blurTexCoords[ 8] = v_uv + vec2(0.0,  0.008); +    v_blurTexCoords[ 9] = v_uv + vec2(0.0,  0.012); +    v_blurTexCoords[10] = v_uv + vec2(0.0,  0.016); +    v_blurTexCoords[11] = v_uv + vec2(0.0,  0.020); +    v_blurTexCoords[12] = v_uv + vec2(0.0,  0.024); +    v_blurTexCoords[13] = v_uv + vec2(0.0,  0.028); + + gl_Position = a_position; +} diff --git a/XIONControlPanel/Assets.xcassets/AppIcon.appiconset/Contents.json b/XIONControlPanel/SupportingFiles/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 92% rename from XIONControlPanel/Assets.xcassets/AppIcon.appiconset/Contents.json rename to XIONControlPanel/SupportingFiles/Assets.xcassets/AppIcon.appiconset/Contents.json index 36d2c80..eeea76c 100644 --- a/XIONControlPanel/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/XIONControlPanel/SupportingFiles/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -59,6 +59,11 @@ "idiom" : "ipad", "size" : "76x76", "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" } ], "info" : { diff --git a/XIONControlPanel/Base.lproj/LaunchScreen.storyboard b/XIONControlPanel/SupportingFiles/Base.lproj/LaunchScreen.storyboard similarity index 74% rename from XIONControlPanel/Base.lproj/LaunchScreen.storyboard rename to XIONControlPanel/SupportingFiles/Base.lproj/LaunchScreen.storyboard index 2e721e1..da2fb86 100644 --- a/XIONControlPanel/Base.lproj/LaunchScreen.storyboard +++ b/XIONControlPanel/SupportingFiles/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -15,8 +16,7 @@ - - + diff --git a/XIONControlPanel/Info.plist b/XIONControlPanel/SupportingFiles/Info.plist similarity index 88% rename from XIONControlPanel/Info.plist rename to XIONControlPanel/SupportingFiles/Info.plist index 40c6215..96efb36 100644 --- a/XIONControlPanel/Info.plist +++ b/XIONControlPanel/SupportingFiles/Info.plist @@ -24,17 +24,17 @@ UILaunchStoryboardName LaunchScreen - UIMainStoryboardFile - Main UIRequiredDeviceCapabilities armv7 + UIRequiresFullScreen + + UIStatusBarHidden + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad diff --git a/XIONControlPanel/Utilities/NSValue+XIONAdditions.h b/XIONControlPanel/Utilities/NSValue+XIONAdditions.h new file mode 100644 index 0000000..74ac577 --- /dev/null +++ b/XIONControlPanel/Utilities/NSValue+XIONAdditions.h @@ -0,0 +1,23 @@ +// +// NSValue+XIONAdditions.h +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +#import +#import + +@interface NSValue (XIONAdditions) + +- (instancetype)initWithGLKMatrix3:(GLKMatrix3)matrix; +- (instancetype)initWithGLKMatrix4:(GLKMatrix4)matrix; + ++ (instancetype)valueWithGLKMatrix3:(GLKMatrix3)matrix; ++ (instancetype)valueWithGLKMatrix4:(GLKMatrix4)matrix; + +- (GLKMatrix3)GLKMatrix3Value; +- (GLKMatrix4)GLKMatrix4Value; + +@end diff --git a/XIONControlPanel/Utilities/NSValue+XIONAdditions.m b/XIONControlPanel/Utilities/NSValue+XIONAdditions.m new file mode 100644 index 0000000..5371cdc --- /dev/null +++ b/XIONControlPanel/Utilities/NSValue+XIONAdditions.m @@ -0,0 +1,47 @@ +// +// NSValue+XIONAdditions.m +// XIONControlPanel +// +// Created by Charles Magahern on 12/29/15. +// Copyright © 2015 XION. All rights reserved. +// + +#import "NSValue+XIONAdditions.h" + +@implementation NSValue (XIONAdditions) + +- (instancetype)initWithGLKMatrix3:(GLKMatrix3)matrix +{ + return [self initWithBytes:&matrix objCType:@encode(GLKMatrix3)]; +} + +- (instancetype)initWithGLKMatrix4:(GLKMatrix4)matrix +{ + return [self initWithBytes:&matrix objCType:@encode(GLKMatrix4)]; +} + ++ (instancetype)valueWithGLKMatrix3:(GLKMatrix3)matrix +{ + return [[[self class] alloc] initWithGLKMatrix3:matrix]; +} + ++ (instancetype)valueWithGLKMatrix4:(GLKMatrix4)matrix +{ + return [[[self class] alloc] initWithGLKMatrix4:matrix]; +} + +- (GLKMatrix3)GLKMatrix3Value +{ + GLKMatrix3 mat; + [self getValue:&mat]; + return mat; +} + +- (GLKMatrix4)GLKMatrix4Value +{ + GLKMatrix4 mat; + [self getValue:&mat]; + return mat; +} + +@end diff --git a/XIONControlPanel/Utilities/XIONControlPanel-Bridging-Header.h b/XIONControlPanel/Utilities/XIONControlPanel-Bridging-Header.h new file mode 100644 index 0000000..3df906e --- /dev/null +++ b/XIONControlPanel/Utilities/XIONControlPanel-Bridging-Header.h @@ -0,0 +1,5 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +#import "NSValue+XIONAdditions.h" diff --git a/XIONControlPanel/ViewController.swift b/XIONControlPanel/ViewController.swift deleted file mode 100644 index ccf2bd0..0000000 --- a/XIONControlPanel/ViewController.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// ViewController.swift -// XIONControlPanel -// -// Created by Charles Magahern on 12/29/15. -// Copyright © 2015 XION. All rights reserved. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - -} -