ARController

This is the main entry point to Remodel-AR. All interaction will be done through an ARController instance.

Declaration

protocol ARController : NSObject

Topics

Variables

var planarMeshCountUpdated: ((Int) -> Void)? This gets called when the number of planar meshes changes. Only used for Lidar.

var cameraAimInfoUpdated: ((CameraAimInfo?) -> Void)? This gets called every frame with information relating to where the user camera is pointing. Reflects where the current user camera is pointing as well as an estimate of what surface it is pointing at (wall, floor, ceiling).

var wallPainted: (() -> Void)? This gets called when a wall is painted by the user.

var trackingReady: ((Bool) -> Void)? This gets called when the tracking state changes.

User Interaction

func handleTouch(point: CGPoint) Call this method when the user touches the ARSCNView for mesh hit testing to determine which mesh to color when the users taps on the view. Also used for geometry creation and shader based occlusions. Parameters: - point: the point which the user tapped

func dragStart(point: CGPoint) Call when the user starts dragging their finger on the screen. Parameters: - point: current location of the users finger

func dragMove(point: CGPoint) Call when the user is dragging their finger on the screen Parameters: - point: current location of the users finger

func dragEnd() Call when the current drag gesture is finished.

func setColor(paint: WallPaint) Use this to set the current selected color that will be applied to the next mesh that is tapped. Parameters: - paint: the paint to apply to the next tapped wall or the currently active wall.

func setTexture(texture: UIImage?) Use this to set the current selected texture that will be applied to the next mesh that is tapped. Parameters: - texture: the image to apply as a texture to the next tapped wall or the currently active wall.

func retrievePaintInfo() -> PaintInfo Retrieves the list of painted walls along with any important information.

func clearColor(id: String) Removes color from the surface and returns it to the default state. Parameters: - id: the ID of the surface to clear the color from.

func enableBrightnessTapAdjustment(enabled: Bool) Enables or disables the ability to set wall brightness by tapping on different parts of the wall *enabled by default Parameters: - enabled: determines if tap to adjust brightness is enabled.

func enableBrightnessDragAdjustment(enabled: Bool) Enables or disables the ability to set wall brightness by dragging on a wall after it's created *enabled by default Parameters: - enabled: determines if drag to adjust brightness is enabled.

AR Activities

func startScene(reset: Bool?) Starts the AR scene or resumes the scene if it was paused. Parameters: - reset: if set to true, the scene will reset and delete all geometry.

func pauseScene() Pauses the AR scene. Use when the app is backgrounded or inactive.

func resetScene() Resets the AR scene

func resetMaskColors() Resets the masking colors currently selected. Only used for ShaderPainting.

Export Functions

func savePhoto() -> UIImage Saves an image of the current scene to the camera roll

func save3DModel() Saves the current mesh of the room to an OBJ file and a USDZ file to the documents directory. Both "Mesh.obj" and "Mesh.usdz" are created in the documents directory after calling this.

func retrieveRawCameraImage() -> UIImage? Gets an image capture of the raw AR camera feed before any effects or geometry are applied.

Lidar Approach

The Lidar approach scans the room geometry using the Lidar sensor. After the user has scanned the room, they can optionally pause the room meshing by sending the setScanMode(scanMode: ScanMode) command. The user can now tap to paint the walls.

var planarMeshCountUpdated: ((Int) -> Void)? This gets called when the number of planar meshes changes.

func setScanMode(scanMode: ScanMode) Changes the current scanning mode, used to pause and resume Lidar meshing of the room. Only used for Lidar. Parameters: - scanMode: determines if Lidar meshing will be active or paused.

Legacy Approach

The Legacy approach allows users to manually create wall patches to be painted. The process to follow is first to prompt the user to place their phone against the wall with the top of the phone against the wall and the screen facing the ceiling, then send the placeWallBasePlane() command. A grid will appear on the wall with a dot that is projected onto the grid. The user should then be prompted to place the first wall point, triggered by the setFirstCorner() command. At this point, a wall patch will be rendered on the grid between the first point and the current projected point. Now the user should be prompted to place the second wall point, triggered by the setSecondCorner() command. At this point the user can paint the wall with different colors. The wall can be modified by tapping the wall to select it, then either dragging the wall with your finger or dragging the corners to adjust the size.

var wallStateUpdated: ((WallState) -> Void)? This gets called when the wall state is updated. Only used for Legacy.

var placeWallStateUpdated: ((PlaceWallState) -> Void)? This gets called when the place wall state is updated. Only used for Legacy.

func placeWallBasePlane() Adds the base plane (grid plane) to the scene at the current location of the phone. Only used for Legacy.

func updateWallBasePlane() Updates the base plane (grid plane) to the current location of the phone. Only used for Legacy.

func endAddWall() Cancels/finishes the current wall being added and removes all related elements. Only used for Legacy.

func setFirstCorner() Sets the first corner of the current wall being placed. Only used for Legacy.

func setSecondCorner() Sets the second corner of the current wall being placed. Only used for Legacy.

Floorplan Approach

The Floorplan approach allows users to draw the floorplan of their room on the floor, then drag to set the height of the walls. This creates geometry that covers all the room surfaces which can now be painted and textured. When the Floorplan approach is loaded, it automatically starts scanning until it finds a floor plane. At that point, it displays a grid on the floor and a target indicator. Every time the user taps on the screen, a point is placed. Once all the corners of the room have been selected, the user can either place a last point on top of the first point, or send the finishCorners(closeShape: true) command. The library automatically switches to setting the wall height. At this point, the user should be prompted to drag the wall up using their finger to set the height. Once the height is set, the finishHeight() command should be sent. At this point, the walls may be painted by tapping.

func showUnpaintedWalls(visible: Bool) Toggles the visibility of unpainted walls. Only used for Floorplan. Parameters: - visible: determines if the surfaces that haven't been painted yet and their outlines should be visible.

func finishCorners(closeShape: Bool) Finishes the process of placing corners. Moves the user experience on to the step of setting the height. Parameters: - closeShape: determines if the first and last placed points should be connected to form a closed shape.

func finishHeight() This is to be called after the room height is at the desired position.

Shader Paint Approach

The Shader Paint approach allows paints to be previewed on older devices that don't support AR. This approach allows the user to select up to three colors from the wall that is to be painted and an adjustable color threshold. Any color that is close enough to the selected colors will be painted the selected color. Brightness can be set by either tapping or dragging a finger on the screen.

func setTouchMode(mode: TouchMode) This feature allows you to occlude foreground objects for all the render modes. Up to three separate colors can be selected from the wall that is to be painted. The colorThreshold then needs to be set using the setColorThreshold(threshold: Float) function. Adjusting the threshold determines how close a color has to be to the selected colors in order to be painted. Used for any approach where shader based occlusions is to be added. Parameters: - mode: the touch mode to set as active. See TouchMode.

func setColorThreshold(threshold: Float) Sets the current threshold used for masking foreground objects using colors. Used for any approach where shader based occlusions is to be added. Parameters: - threshold: the threshold to use to remove occlusions. Higher values paint more of the wall and occlusions. Lower values paint less of the wall.

Abnormalities Approach

The Abnormalities approach scans the room using the Lidar sensor, then allows the user to capture images that can be passed into a ML model. Passio provides an SDK that allows wall defects to be classified that works hand in hand with this feature. If a defect is recognized, then the defect can be added to the Remodel-AR library, which will then project a bounding box onto the meshed wall with the name of the defect.

var abnormalitySelected: ((Abnormality) -> Void)? Called when the user selects the button attached to a detected abnormality. This should cause the UI to display a list of abnormalities to manually change the abnormality to a different type. Parameters: - abnormality: The abnormality whose button the user tapped on.

func setScanArea(rect: CGRect) Sets the area of the UI that the scan graphic is covering. Also determines which part of the screen is projected onto the wall to represent any detected abnormalities. Parameters: - rect: the area to project the bounding box onto, in screen coordinates.

func captureAbnormalityImage(callback: @escaping (ImageCapture) -> Void) Triggers a capture of the next raw camera image, returned in the abnormalitySelected() callback. This is different from the normal retrieveRawCameraImage() function in that it also captures the location of the scanArea projected onto the wall if addAbnormality() is subsequently called. Parameters: - callback: called when the image is finished being generated.

func addAbnormality(name: String) -> String? Adds an abnormality to the AR scene and returns the created abnormality ID. Parameters: - name: The name of the abnormality as reported by the SDK.

func updateAbnormality(abnormality: Abnormality) Updates an abnormality type in the AR scene. Parameters: - abnormality: The object containing the updated abnormality information.

func deleteAbnormality(identifier: String) Deletes an abnormality from the AR scene. Parameters: - identifier: The identifier of the abnormality to be deleted

func retrieveAbnormalitiesInfo() -> AbnormalitiesInfo? Retrieves the list of abnormalities along with any important information.

UI Customization

The UI elements and colors can be customized as desired to match branding and design.

func setGridImage(gridImage: UIImage) Overrides the texture used for the grid background. Only used for Legacy and Floorplan. Parameters: - gridImage: the texture to use for the grid background image

func setLegacyUIImages(cornerTextures: [Corners: UIImage], centerDot: UIImage) Overrides the texture used for user interface images. Only used for Legacy. Parameters: - cornerTextures: a dictionary of the textures to use for the corner indicators - centerDot: the texture to use for the center dot

func setDeselectedColor(color: UIColor) Overrides the color used to outline deselected meshes. Only used for Floorplan. Parameters: - color: the color to use for mesh highlights

func setSelectedColor(color: UIColor) Overrides the color used for the target indicator and the ceiling mesh highlights. Only used for Floorplan. Parameters: - color: the color to use for target indicator, ceiling highlights, and Lidar mesh highlights

func setMeshColor(color: UIColor) Overrides the color used for the generated mesh lines. Only used for Lidar and Abnormalities. Parameters: - color: the color to use for the mesh lines

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

Last updated