Apple layout VR/AR! Yu Fang, what do you think?

Original title: Apple Layout VR/AR! Yu Fang, what do you think?

Authors | nethanhan

Editing | Tu Min

WeChat Public ID | mobilehub

Editor's note: Is AR disillusioned? Is VR in recovery? Looking at the industry layout of tech giants such as Google, Microsoft, Facebook, Sony, and Samsung, the pace of VR/AR exploration has never stopped. The so-called disillusionment and recovery are personally considered to be only necessary for technological development. However, Apple Inc., one of the leaders in technology, has always been a savagery for the VR/AR industry. However, there has been no formative product, which is an appetite for many developers. At this year's WWDC 2017, Apple finally launched the first shot to enter the VR/AR industry. Not only did it announce cooperation with Valve, it also announced the first VR Ready new iMac Pro. The final highlight was the launch of the ARKit platform for iOS 11. Undoubtedly pushed the VR/AR industry to a small climax.

What is ARKit

Augmented Reality (AR) describes the user experience of adding 2D or 3D elements in the device's camera to a live view so that these elements appear in the real world. ARKit combines device motion tracking, camera capture, advanced scene processing, and display convenience to simplify the task of creating an AR experience.

AR Demo

The author of this article nethanhan refers to the official website of Apple ARKit, build a basic AR Demo, hope to share and learn together.

Note: The development environment is Xcode 9, the operating environment is iPhone 6s and above, and the system is iOS 11.

Because Apple regulations (click here to query) ARKit is running on A9 and A10 processors, so iPhone or iPad self-control CPU.

If this prompt appears after running Demo, it means that the currently running device does not support ARKit:

2017-06-07 11:41:35.317768+0800 ARDemo[2970:1228240] [Session] Unable to run the session, configuration is not supported on this device: ARWorldTrackingSessionConfiguration: 0x60800009f310 planeDetection=Horizontal worldAlignment=Gravity lightEstimation=Enabled>

There are two things to understand when using ARKit:

1. ARSCNView A view showing the AR experience that enhances the camera view with 3D SceneKit content.

2. ARSKView A view that shows the AR experience and adds a camera view of the 2D SpriteKit content.

Before using it, we first need to instantiate a session configuration class in the viewWillAppear method, and set how the session maps the real device motion to the coordinate system of the 3D scene in the configuration class object. The default is to use gravity, and it should be a gyroscope. Instrument; also need to develop several other values. Finally set the configuration class object to the session of the view. as follows:

- (void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];

// Create a session configuration

ARWorldTrackingSessionConfiguration *configuration = [ARWorldTrackingSessionConfiguration new];

configuration.worldAlignment = ARWorldAlignmentGravity;

// configuration.lightEstimationEnabled = YES;

configuration.planeDetection = ARPlaneDetectionHorizontal;

// Run the view's session

[self.sceneView.session runWithConfiguration:configuration];

}

Next set the ARSCNView proxy in the viewDidLoad method, and then add the content to be displayed in the view in the following method:

- (void)renderer:(id )renderer didAddNode:(SCNNode *)node forAnchor:(ARAnchor *)anchor

{

ARPlaneAnchor *planeAnchor = anchor;

SCNPlane *plane = [SCNPlane planeWithWidth:planeAnchor.extent.x height:planeAnchor.extent.z];

SCNNode *planeNode = [SCNNode nodeWithGeometry:plane];

planeNode.position = SCNVector3Make(planeAnchor.center.x, 0, planeAnchor.center.z);

planeNode.transform = SCNMatrix4MakeRotation(- M_PI/2, 1, 0, 0);

[node addChildNode:planeNode];

}

Add a system view ARPlaneAnchor here, in fact, the system also built a lot of views, can be used as a basic use. After this proxy method sets the various properties of the view, it is added to the ARSCNView object.

The operating effect is as follows:

Demo Download Address: http://download.csdn.net/detail/yunkai666/9863298

Editor:

LED Lamp

Steel poles are commonly used to carry several types of electric power lines, distribution lines and lighting system. Distribution lines carry power from local substations to customers. They generally carry voltages from 4.6 to 33kV for distances up to 30 miles, and include transformers to step the voltage down from the primary voltage to the lower secondary voltage used by the customer. A service drop carries this lower voltage to the customer's premises.

LED Lamp,High Brightness LED Lamp,Led Street Bulbs Lamp,LED Wall Lamps

Yixing Steel Pole International Trading Co., Ltd , https://www.yx-steelpole.com

Posted on