Initial work on background visualization

This commit is contained in:
Charles Magahern
2015-12-30 02:51:22 -08:00
parent 58529e96b9
commit 7cf2b3b38d
22 changed files with 762 additions and 129 deletions

View File

@@ -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:.
}
}

View File

@@ -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
}
}

View File

@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>sequence</key>
<array>
<string>firstPass</string>
<string>hblur</string>
<string>vblur</string>
<string>finalRender</string>
</array>
<key>passes</key>
<dict>
<key>firstPass</key>
<dict>
<key>draw</key>
<string>DRAW_QUAD</string>
<key>program</key>
<string>FirstPass</string>
<key>inputs</key>
<dict>
<key>a_position</key>
<string>a_position-symbol</string>
<key>u_colorSampler</key>
<string>COLOR</string>
</dict>
<key>outputs</key>
<dict>
<key>color</key>
<string>firstPass_color</string>
</dict>
</dict>
<key>hblur</key>
<dict>
<key>draw</key>
<string>DRAW_QUAD</string>
<key>program</key>
<string>HorizontalBlur</string>
<key>inputs</key>
<dict>
<key>a_position</key>
<string>a_position-symbol</string>
<key>u_colorSampler</key>
<string>firstPass_color</string>
</dict>
<key>outputs</key>
<dict>
<key>color</key>
<string>hblur_color</string>
</dict>
</dict>
<key>vblur</key>
<dict>
<key>draw</key>
<string>DRAW_QUAD</string>
<key>program</key>
<string>VerticalBlur</string>
<key>inputs</key>
<dict>
<key>a_position</key>
<string>a_position-symbol</string>
<key>u_colorSampler</key>
<string>hblur_color</string>
</dict>
<key>outputs</key>
<dict>
<key>color</key>
<string>bothblurs_color</string>
</dict>
</dict>
<key>finalRender</key>
<dict>
<key>draw</key>
<string>DRAW_QUAD</string>
<key>program</key>
<string>FinalRender</string>
<key>inputs</key>
<dict>
<key>a_position</key>
<string>a_position-symbol</string>
<key>u_blurmapSampler</key>
<string>bothblurs_color</string>
<key>u_colorSampler</key>
<string>firstPass_color</string>
</dict>
<key>outputs</key>
<dict>
<key>color</key>
<string>COLOR</string>
</dict>
</dict>
</dict>
<key>targets</key>
<dict>
<key>firstPass_color</key>
<dict>
<key>type</key>
<string>color</string>
</dict>
<key>hblur_color</key>
<dict>
<key>type</key>
<string>color</string>
</dict>
<key>bothblurs_color</key>
<dict>
<key>type</key>
<string>color</string>
</dict>
</dict>
<key>symbols</key>
<dict>
<key>u_blurRadius-symbol</key>
<dict>
<key>type</key>
<string>float</string>
</dict>
<key>u_viewportSize-symbol</key>
<dict>
<key>type</key>
<string>vec2</string>
</dict>
<key>u_blurKernel-symbol</key>
<dict>
<key>type</key>
<string>mat4</string>
</dict>
<key>a_position-symbol</key>
<dict>
<key>semantic</key>
<string>vertex</string>
</dict>
</dict>
</dict>
</plist>

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -59,6 +59,11 @@
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
</dependencies>
<scenes>
<!--View Controller-->
@@ -15,8 +16,7 @@
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>

View File

@@ -24,17 +24,17 @@
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>

View File

@@ -0,0 +1,23 @@
//
// NSValue+XIONAdditions.h
// XIONControlPanel
//
// Created by Charles Magahern on 12/29/15.
// Copyright © 2015 XION. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GLKit/GLKit.h>
@interface NSValue (XIONAdditions)
- (instancetype)initWithGLKMatrix3:(GLKMatrix3)matrix;
- (instancetype)initWithGLKMatrix4:(GLKMatrix4)matrix;
+ (instancetype)valueWithGLKMatrix3:(GLKMatrix3)matrix;
+ (instancetype)valueWithGLKMatrix4:(GLKMatrix4)matrix;
- (GLKMatrix3)GLKMatrix3Value;
- (GLKMatrix4)GLKMatrix4Value;
@end

View File

@@ -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

View File

@@ -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"

View File

@@ -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.
}
}