-
Notifications
You must be signed in to change notification settings - Fork 35
Getting started.
To get started, you need to initialize the ARKit framework. This can be done a couple of different ways. ofxARKit provides a helper api to quickly initialize a session without too much fuss.
SessionSetup
ofxARKit::core::SessionFormat format;
format.enablePlaneTracking().enableLighting();
auto session = ARCore::generateNewSession(format);
The SessionFormat
object is a way to enable various features of ARKit in a more straightforward manner. Passing an instance of an SessionFormat
object to ARCore::generateNewSession
will automatically generate a new ARSession
object, while ensuring the specified features are useable on your device.
You can of course, write things by hand which isn't too difficult either.
Raw Objective-C
@interface <your view controller name>()
@property (nonatomic, strong) ARSession *session;
@end
// then somewhere in your implementation block...
// official example shows you ought to declare the session in viewWillLoad and initialize in viewWillAppear but it probably doesn't matter.
self.session = [ARSession new];
// World tracking is used for 6DOF, there are other tracking configurations as well, see
// https://developer.apple.com/documentation/arkit/arconfiguration
ARWorldTrackingConfiguration *configuration = [ARWorldTrackingConfiguration new];
// setup horizontal plane detection - note that this is optional
configuration.planeDetection = ARPlaneDetectionHorizontal;
// start the session
[self.session runWithConfiguration:configuration];
As to where to initialize, it really doesn't matter all that much, if your project setup is more in the form of a traditional IOS objective-c app, you can set things up in your view controller, or if your app is more like a normal oF app, you should be able to just as easily set things up in your setup
function.