RRSceneGraphSerializer

Objective-C

@interface RRSceneGraphSerializer : NSObject

Swift

class RRSceneGraphSerializer : NSObject

Serializes/deserializes a scene graph from/to various data formats. Currently only deserialization functionality is exposed.

  • Initializes a new instance of RRSceneGraphSerializer with a format provider. The format provider contains the logic for actually handling the underlying data provided to serialize/deserialize methods.

    Declaration

    Objective-C

    - (instancetype _Nullable)initWithFormatProvider:
        (RRAbstractSceneGraphFormatProvider *_Nonnull)formatProvider;

    Swift

    init?(formatProvider: RRAbstractSceneGraphFormatProvider)

    Parameters

    formatProvider

    Instance of a format provider class. This further decides what file types can be serialized/deserialized with this object.

    Return Value

    A instance of RRSceneGraphSerializer on success, nil otherwise.

  • Deserializes a scene graph including resources from a given file path into a target render view. See -deserializeFromByteBuffer:renderView: for details. Does not remove any renderables that are currently attached to the render view.

    See

    -deserializeFromByteBuffer:renderView:

    Declaration

    Objective-C

    - (BOOL)deserializeFromPath:(NSString *_Nonnull)path
                     renderView:(RRGLRenderView *_Nonnull)renderView
               didFailWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    func deserialize(fromPath path: String, renderView: RRGLRenderView) throws

    Parameters

    path

    Path to the scene graph file containing data that is readable by the underlying format provider.

    renderView

    Target render view to which the scene graph is attached to.

    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

    YES if successful, NO otherwise.

  • Deserializes a scene graph including resources from a byte buffer into a target render view. Does not remove any renderables that are currently attached to the render view.

    Note

    This can take a while depending on the size and complexity of the scene. Consider using the two step deserialization based on -deserializeResourcesFromByteBuffer: and -deserializeSceneGraphFromByteBuffer:renderView:

    Declaration

    Objective-C

    - (BOOL)deserializeFromByteBuffer:(NSData *_Nonnull)byteBuffer
                           renderView:(RRGLRenderView *_Nonnull)renderView
                     didFailWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    func deserialize(fromByteBuffer byteBuffer: Data, renderView: RRGLRenderView) throws

    Parameters

    path

    A Byte buffer containing data that is readable by the underlying format provider.

    renderView

    Target render view to which the scene graph is attached to.

    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

    YES if successful, NO otherwise.

  • Deserializes the resources of a scene graph and stores them internally. It is safe to call this method from a thread other than the main thread. Resource deserialization usually is the time consuming part of the process. Therefore, splitting up the process into resource deserialization (asynchronous) and scene graph deserialization is advisable.

    Declaration

    Objective-C

    - (BOOL)deserializeResourcesFromByteBuffer:(NSData *_Nonnull)byteBuffer
                              didFailWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    func deserializeResources(fromByteBuffer byteBuffer: Data) throws

    Parameters

    byteBuffer

    A Byte buffer containing data that is readable by the underlying format provider.

    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

    YES if successful, NO otherwise.

  • Deserializes the scene graph and attaches it to the target render view. This requires that the resources have been loaded seperately beforehand. See -deserializeResourcesFromScene:scene: for how to use the optimized two step deserialization process. Does not remove any renderables that are currently attached to the render view.

    Declaration

    Objective-C

    - (BOOL)deserializeSceneGraphFromByteBuffer:(NSData *_Nonnull)byteBuffer
                                     renderView:(RRGLRenderView *_Nonnull)renderView
                               didFailWithError:
                                   (NSError *_Nullable *_Nullable)error;

    Swift

    func deserializeSceneGraph(fromByteBuffer byteBuffer: Data, renderView: RRGLRenderView) throws

    Parameters

    byteBuffer

    A Byte buffer containing data that is readable by the underlying format provider.

    renderView

    Target render view to which the scene graph is attached to.

    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

    YES if successful, NO otherwise.