ARKit的简单使用

 2015年苹果收购当时AR领域的佼佼者Metaio,两年之后,苹果终于放出憋了很久的大招。

当年在手机市场上出现指纹解锁一段时间之后,苹果收购了当时指纹解锁最成熟的那家公司,然后推出自己独有的指纹解锁技术,瞬间成为业界标杆,接下来被其他手机厂商苦苦追赶。当双摄像头出现了很多年之后,苹果也推出了自己的双摄像头手机,人像模式的景深效果也是目前手机市场做的最好的。苹果总是这样,不鸣则已,一鸣惊人,当他们觉得自己没有十足把握成为业内最好的话,他们就不会推出这项技术。

所以,随着iOS 11一起出现的ARKit,是否成为一个大招,我想答案不言而喻了。

贴一个使用ARKit做的一个小demo。

#import "ViewController.h"

#import@interface ViewController (){

ARSCNView * scnView;

SCNScene * scene;

ARSessionConfiguration * config;

}

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

scnView = [[ARSCNView alloc]initWithFrame:[UIScreen mainScreen].bounds];

[self.view addSubview:scnView];

scnView.session.delegate = self;

scnView.delegate = self;

config = [[ARWorldTrackingSessionConfiguration alloc]init];

[scnView.session runWithConfiguration:config];

scene = [[SCNScene alloc]init];

SCNText * text = [[SCNText alloc]init];

text =  [SCNText textWithString:@"Hello World" extrusionDepth:5];

text.firstMaterial.diffuse.contents = [UIColor redColor];

text.firstMaterial.specular.contents = [UIColor whiteColor];

SCNNode * node = [[SCNNode alloc]init];

node.geometry = text;

node.position = SCNVector3Make(-1, -0.1, -2);

node.scale = SCNVector3Make(0.05, 0.05, 0.05);

[scene.rootNode addChildNode:node];

scnView.scene = scene;

scnView.autoenablesDefaultLighting = true;

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

@end

你可能感兴趣的:(ARKit的简单使用)