iOS Quick Start

Create an app that allows you to paint real life surfaces with virtual paint.

Overview

Painting a real room with virtual paint is not a trivial task, there is a lot of complexity involved as well as a lot of domain specific knowledge that is required to do it correctly. With Remodel-AR, you don’t need to know anything about how it works, just what you want to do with it. Let Remodel-AR do all the heavy lifting for you.

Creating a new app is as simple as creating an ARController and binding it to your ARKit scene if using UIKit. Using SwiftUI is even easier, just create an ARView using RemodelARLib and add it to your view.

SwiftUI Quick Start

(see Setting up Remodel-AR in SwiftUI for a step by step setup)

Using the Remodel-AR framework with SwiftUI is quite simple. You only need to create an ARStateModel object, then initialize and add an ARView instance as shown below.

struct ContentView: View {
    @ObservedObject var model = ARStateModel()
    
    var body: some View {
        arView
            .edgesIgnoringSafeArea(.all)
            .onAppear {
                model.pickColor(paint: WallPaint(id: "", color: .red))
            }
    }
}

private extension ContentView {
    var arView: ARView { RemodelARLib.makeARView(model: model)
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

UIKit Quick Start

(see Setting up Remodel-AR in UIKit for a step by step setup)

To create a basic Remodel-AR based app, you initialize a new instance of the ARController structure, and supply an instance of ARSCNView, as the following code shows:

@IBOutlet weak var sceneView: ARSCNView!
private var arController: ARController?

override func viewDidLoad() {
    super.viewDidLoad()
    arController = RemodelARLib.makeARController(with: sceneView)
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    arController?.setColor(color: UIColor.red)
    arController?.startScene()
}

override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
    guard let touch = touches.first else { return }
    let point = touch.location(in: sceneView)
    arController?.handleTouch(point: point)
}

Saving a 3D Model

Saving a 3D model of the scene can be done using the following code. The file is shared as a USDZ file that anyone with an iOS device can place in their own space to view.

UIKit:

arController?.savePhoto()

SwiftUI (add this view):

var savePhotoButton: some View {
    Button(action: {
        model.sharePhoto()
    }, label: {
        Image(systemName: "camera.fill")
            .foregroundColor(.white)
    })
    .padding()
    .background(Color(.sRGB, white: 0, opacity: 0.15))
    .cornerRadius(10)
}

Resetting the scene

Resetting the scene can be used to start over, removing all geometry from the view.

UIKit:

arController?.resetScene()

SwiftUI (add this view):

var resetSceneButton: some View {
    Button(action: { model.resetScene() }, label: {
        Image("reset")
            .foregroundColor(.white)
    })
    .padding()
    .background(Color(.sRGB, white: 0, opacity: 0.15))
    .cornerRadius(10)
}

If at any point you need help from the Passio team, please reach out to us at support@passiolife.com

Last updated