Developer Guide

Tutorial: Customize AR Contents in CraftAR

icon Date Developer Guide

icon Date Dec 14, 2020

icon author Catchoom Team

icon folder , , ,

This section applies only to the Augmented Reality SDK v4 +. For earlier versions of the Augmented Reality SDK, check out the section below

The CraftAR Augmented Reality SDK allows you to show AR Contents of different types. All AR Contents have a default behavior. In order to customize AR Contents, you need to use the default contents and override their behavior. In this article, we describe how to extend default AR Contents for Android and for iOS.

In case you’re not familiar with AR Contents, we suggest you to read the article Overview of AR Contents in CraftAR.

Android

Create your own class extending from an existing CraftARTrackingContent type (video, image, image button, or 3D model). In this example, we extend from CraftARTrackingContentImage.

Create a class extending from CraftARTrackingContentFactory. The role of this class is to indicate the SDK which type of content has to be created for a given response from the CraftAR Service. By changing the factory, you can override the assignation of the content class. In the following example, we’re overriding any object with ContentType equal to CONTENT_TYPE_IMAGE with the class that we just created ( MyImageContent).

Finally, set your content factory:

Now the SDK will create contents of the type MyImageContent instead of creating them for the type CraftARImage. You can do the same for any kind of content.

iOS

Create your own class extending from an existing CraftARTrackingContent type (video, image, image button, or 3D model). In this example we extend from CraftARTrackingContentImage.

Indicate the SDK which type of content has to be created for a given response from the CraftAR Service:

This section applies only to the Augmented Reality SDK v3 or earlier. For the Augmented Reality SDK v4 or newer, check out the section above

The CraftAR Augmented Reality SDK allows you to show AR Contents of different types. All AR Contents have a default behavior. In order to customize AR Contents, you need to use the default contents and override their behavior. In this article, we describe how to extend default AR Contents for Android and for iOS.

In case you’re not familiar with AR Contents, we suggest you to read the article Overview of AR Contents in CraftAR.

Android

Create your own class extending from an existing CraftARTrackingContent type (video, image, image button, or 3D model). In this example, we extend from CraftARTrackingContentImage.

Create a class extending from CraftARTrackingContentFactory. The role of this class is to indicate the SDK which type of content has to be created for a given response from the CraftAR Service. By changing the factory, you can override the assignation of the content class. In the following example, we’re overriding any object with ContentType equal to CONTENT_TYPE_IMAGE with the class that we just created ( MyImageContent).

Finally, set your content factory in the CraftARItemAR class.

Now the SDK will create contents of the type MyImageContent instead of creating them for the type CraftARImage. You can do the same for any kind of content.

iOS

Create your own class extending from an existing CraftARTrackingContent type (video, image, image button, or 3D model). In this example we extend from CraftARTrackingContentImage.

Indicate the SDK which type of content has to be created for a given response from the CraftAR Service:

Related Posts in Developer Guide