Introduction: AR (How Augmented Reality Work?)
ARkit- Getting Started
We actually distinguish 3 main categories of AR tools:
Augmented Reality gaming – imagine shooting zombies while walking in your own bedroom! Thus, the biggest use of AR gaming to-date is definitely Pokémon Go, allowing users to catch virtual Pokémon creatures that are hidden throughout a map of the real environment.
How AR works
Using a process called Visual Inertial Odometry (VIO), ARKit uses your device’s motion sensors, combined with visual information from the camera, to track the real world. Some clever math takes this tracking information and maps features in the real 3D world to your 2D screen.
When your app first starts, the device sets its initial position and orientation. The camera determines features of possible objects in its frame. When you move the device, there’s a new position and orientation. Because you’ve moved, the camera sees the objects slightly differently. The device now has enough information to triangulate on a feature and can work out the distance of an object. As you move, the device constantly refines the information and can gradually work out where there are horizontal surfaces.
Note: At the time of this writing, vertical surfaces are not calculated.
In addition to all this tracking, the sensors can examine the amount of available light and apply the same lighting to the AR objects within the scene. (credit)
So you have to know that the thing you see on the screen is not real 3D object. You just see 2D object that always changes base on your position and orientation to make you feel like see 3D object. Also your phone doesn’t have the ability to know how far from its the object is. Try to put your finger in front of the object then you know what i mean
Technically, to make an AR application we need 2 steps: Create 3D model, Add 3D model into the app.
You can download free 3D models from the internet (https://www.turbosquid.com/). It should be in .dae format then in Xcode, you can convert that .DAE file to .SCN format.
create new ios project, choose Argumented Reality App (by this way, xcode will generate UIViewController included ARSCNView and *.scnassets for you)
In order to convert .dea to .scn: Editor-Convert to SceneKit scene file format
Drag .scn file into art.scnassets, then in viewDidLoad
let configuration = ARWorldTrackingConfiguration() let scene = SCNScene(named: "art.scnassets/car.scn")! self.sceneView.session.run(configuration) //recursively: YES to search the entire child node subtree that named "main", or NO to search only the node’s immediate children. var mainNode = scene.rootNode.childNode(withName: "main", recursively: false) //position of mainNode relatives with nootNode //position of root mainNode.position = SCNVector3(0, 0, 0) self.sceneView.scene.rootNode.addChildNode(mainNode)
Adding videos, images, websites into scene
Textures and Surfaces
3D model and Hit-Testing
A nature, universe, science, music, love lover