RRAvatarConverter

Objective-C

@interface RRAvatarConverter : NSObject

Swift

class RRAvatarConverter : NSObject

This class implements the conversion of a 3D HeadAvatar to a 2D avatar. To be able to do this conversion you need a proper configuration as well as the instances of an RRGLRenderView and the RRAvatar3DUserAdjustmentsLayout that is used for rendering.

  • The initializer for the converter providing the renderView and the layout. For the conversion to work the renderView instance must have the provided layout attached and the avatar that should be converted must be set for the provided layout.

    Declaration

    Objective-C

    - (nonnull instancetype)
        initWithRenderView:(nonnull RRGLRenderView *)renderView
                    layout:(nonnull RRAvatar3DUserAdjustmentsLayout *)layout;

    Swift

    init(renderView: RRGLRenderView, layout: RRAvatar3DUserAdjustmentsLayout)

    Parameters

    renderView

    The renderView instance.

    layout

    The layout instance with the 3D avatar set that should be converted.

  • The 2D avatar image size. You should normally not need to change this properties default value since its default value should already be fine for every common use-case.

    Declaration

    Objective-C

    @property (nonatomic) CGSize avatarImageSize;

    Swift

    var avatarImageSize: Size { get set }
  • The conversion function that returns a 2D avatar instance ready to be used for try-on. RRUserPhotoLayout is a simple way of using the returned avatar for a try-on. This method will use the avatar body model’s default conversion config.

    Declaration

    Objective-C

    - (RRAvatar *_Nullable)convertTo2DAvatarWithError:
        (NSError *_Nullable *_Nullable)error;

    Swift

    func convertTo2DAvatar() throws -> RRAvatar

    Parameters

    error

    An optional pointer to an NSError pointer. When this method fails, it will set an NSError instance to this pointer if provided.

    Return Value

    The 2D avatar instance representing a 2D version of the 3D avatar that is set in the layout that was provided in the initializer. This method returns nil in case of an error.

  • The conversion function that returns a 2D avatar instance ready to be used for try-on. RRUserPhotoLayout is a simple way of using the returned avatar for a try-on.

    Declaration

    Objective-C

    - (RRAvatar *_Nullable)convertTo2DAvatar:
                               (nonnull RRAvatarConverterConfig *)config
                            didFailWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    func convertTo2DAvatar(_ config: RRAvatarConverterConfig) throws -> RRAvatar

    Parameters

    config

    The configuration instance for the conversion.

    error

    An optional pointer to an NSError pointer. When this method fails, it will set an NSError instance to this pointer if provided.

    Return Value

    The 2D avatar instance representing a 2D version of the 3D avatar that is set in the layout that was provided in the initializer. This method returns nil in case of an error.