Most visited

Recently visited

ARScene

public class ARScene
extends Scene

java.lang.Object
   ↳ com.viro.core.Scene
     ↳ com.viro.core.ARScene


ARScene blends virtual 3D content with the device camera's view of the real world. Similar to a normal Scene, an ARScene contains a hierarchy of Node objects representing the virtual 3D world. Behind these objects the camera's live video feed is rendered. ARScene ensures the two worlds -- real and virtual -- stay in sync with a unified coordinate system.

There are two ways to add virtual content to the ARScene. The first is to simply place content manually. The origin of the coordinate system is the initial position of the user, and the scale is meters. To add content you only need to set the position of the Node within this coordinate system, and add it to the scene graph.

The second way to add virtual content is to use ARAnchor. ARAnchors represent features detected in the real-world. You can associate (or "anchor") your content to these features by adding your content to the ARNode that corresponds to each detected ARAnchor. To do this, implement the ARScene ARScene.Listener. The ARScene.Listener callbacks are invoked whenever ARAnchors are found (or updated, or removed) in the real-world.

For a higher level guide on building AR in Viro, refer to the Augmented Reality Guide.

Summary

Nested classes

class ARScene.ARSceneBuilder<R extends ARScene, B extends ARSceneBuilder<R, B>>

ARSceneBuilder for building ARScene

interface ARScene.Listener

Callback interface for ARScene events. 

enum ARScene.TrackingState

Values representing position tracking quality. 

enum ARScene.TrackingStateReason

Diagnoses to explain cases where we have limited position tracking quality in AR. 

Public constructors

ARScene()

Construct a new ARScene.

Public methods

void addARImageTarget(ARImageTarget target)

Add an ARImageTarget to the Scene.

static ARSceneBuilder<? extends Scene, ? extends SceneBuilder> builder()

Creates a builder for building complex ARScene objects.

void displayPointCloud(boolean displayPointCloud)

Set to true to display a point cloud representing the rough feature points that the AR tracking system is detecting.

void dispose()

Release native resources associated with this ARScene.

void removeARImageTarget(ARImageTarget target)

Remove an ARImageTarget from the Scene.

void resetPointCloudSurface()

Reset the point cloud surface to the default values.

void setListener(ARScene.Listener listener)

Set the ARScene.Listener to use for responding to AR events.

void setPointCloudMaxPoints(int maxPoints)

Set the maximum number of points to render when drawing the AR point cloud.

void setPointCloudSurface(Surface surface)

Set the Surface that should be used to render each point in the rendered AR point cloud.

void setPointCloudSurfaceScale(Vector scale)

Set the scale factor to use when rendering each point in the AR point cloud.

void setPointCloudUpdateListener(PointCloudUpdateListener listener)

Set the PointCloudUpdateListener to use for receiving point cloud updates.

Public constructors

ARScene

ARScene ()

Construct a new ARScene.

Public methods

addARImageTarget

void addARImageTarget (ARImageTarget target)

Add an ARImageTarget to the Scene. Once added, Viro will search for this reference image in the real-world, and alert you when an instance is found by invoking onAnchorFound(ARAnchor, ARNode) with an ARImageAnchor anchor.

Parameters
target ARImageTarget: The reference ARImageTarget you want to find in the real-world.

See also:

builder

ARSceneBuilder<? extends Scene, ? extends SceneBuilder> builder ()

Creates a builder for building complex ARScene objects.

Returns
ARSceneBuilder<? extends Scene, ? extends SceneBuilder> ARScene.ARSceneBuilder object.

displayPointCloud

void displayPointCloud (boolean displayPointCloud)

Set to true to display a point cloud representing the rough feature points that the AR tracking system is detecting. This is useful for debugging and analysis, but can also be used for rendering effects.

Parameters
displayPointCloud boolean: True to display the point cloud, false to remove.

dispose

void dispose ()

Release native resources associated with this ARScene.

removeARImageTarget

void removeARImageTarget (ARImageTarget target)

Remove an ARImageTarget from the Scene. Viro will stop searching for this image.

Parameters
target ARImageTarget: The target to stop searching for in the real-world.

resetPointCloudSurface

void resetPointCloudSurface ()

Reset the point cloud surface to the default values. The point cloud surface is the Surface that will be used to render each point in the point cloud.

setListener

void setListener (ARScene.Listener listener)

Set the ARScene.Listener to use for responding to AR events. This enables your application to receive ARAnchor and ARNode objects as they are detected by the AR tracking system.

Parameters
listener ARScene.Listener: The ARScene.Listener to use for this ARScene.

setPointCloudMaxPoints

void setPointCloudMaxPoints (int maxPoints)

Set the maximum number of points to render when drawing the AR point cloud.

Parameters
maxPoints int: The maximum number of points to render.

setPointCloudSurface

void setPointCloudSurface (Surface surface)

Set the Surface that should be used to render each point in the rendered AR point cloud. This allows you to customize the appearance of the cloud with a textured (or otherwise colored) Surface.

Parameters
surface Surface: The Surface to use for representing each point in the cloud.

setPointCloudSurfaceScale

void setPointCloudSurfaceScale (Vector scale)

Set the scale factor to use when rendering each point in the AR point cloud.

Parameters
scale Vector: The scale as a Vector in X, Y, and Z dimensions.

setPointCloudUpdateListener

void setPointCloudUpdateListener (PointCloudUpdateListener listener)

Set the PointCloudUpdateListener to use for receiving point cloud updates. The provided listener will receive an updated ARPointCloud as the point cloud updates.

Parameters
listener PointCloudUpdateListener: The PointCloudUpdateListener to use to receive point cloud updates.

Hooray!