AR + 3D API Docs

From WakingApp SDKs
Jump to: navigation, search

ARViewController

A view controller class incharge of initalizing and running the ar+3D sdk. ARViewController must be derived as part of setting up the sdk.

Methods:

-(void)initContent;

Called once the sdk is done initializing and should be used to initialize content (creating scenes, populating them with nodes, setting target image/QR, etc...

-(void)update:(float)deltaTime;

Called once per frame and may be used to update scene's or change tracker settings.
deltaTime represents the elapsed time since the last frame in milliseconds.


ARTrackDelegate

A delegate containing methods called once a change has been detected in the tracking state.

Methods:

-(void)onTrackFound : (NSString*)identifier;

Called once tracking has been found. identifier will contain the QR identifier code during QR tracking, or the name of the image during image tracking.

-(void)onTrackLost : (NSString*)identifier;

Called once tracking has been lost. identifier will contain the QR identifier code during QR tracking, or the name of the image during image tracking.


ARTrackingManager

A singleton class in charge of setting up tracking-related configurations.

Methods:

+ (instancetype) getInstance;

Retrieves the singleton instance. All other methods must be executed on the returned instance.

- (void)setTrackerType: (ARTrackerType) type;

Sets the tracker type to either ARImageTracker or ARQRTracker.
With ARImageTracker, the tracker is capable of tracking a single image.
With ARQRTracker, the tracker will scan for multiple QR codes in parallel (tracking is limited to one QR code at a time).

- (void)setTargetImage:(NSString*)filePath : (ARScene*)scene;

Sets a target image to be tracked and an associated scene to be displayed on top..
Supported image formats: png, bmp, jpg, jpeg, tif, tiff.

- (void)clearTargetImage;

Clears any previously set target images.

- (void)addQRScene:(NSString*)qrIdentifier : (ARScene*)scene;

Associates a QR code identifier with a scene.
The scene will be displayed on top of the QR once it is tracked.

- (void)removeQRScene:(NSString*)qrIdentifier;

Removes a previously assigned QR code identifier from the tracker's database.
Any previously associated scene will no longer be displayed on top of it should it get scanned.

- (void)setTargetToWorldScale: (float) scaleInCentimeters;

Sets the scale of a tracked Image/QR with regards to the 3D world. By default, a square target represents 100x100cm in world space units.
For rectangular targets, the wider side of the rectangle represents 100cm world space units.


ARScene

A class which represents the 3D world in which the AR experience resides. A scene is combined of a collection of different type of nodes that bring content into the virtual world.

Methods:

- (void)setSkybox:(NSString*)skyboxFilePath;

Loads a .was file and sets it as the scene's skybox.
The skybox will not be rendered in the background, but will be used as a reflection map for all the scene's model nodes.

- (void)setCameraDefaultValues:(ARVector3*)position : (ARVector3*) rotation;

Sets the default position for the camera for periods of time when tracking is off.({0,0,0} by default)
During tracking, the camera will move according to the target's location.

- (ARVector3*)getCameraPosition;

Retrieves the current camera position.

- (ARVector3*)getCameraRotation;

Retrieves the current camera rotation.

- (ARVector3*)getCameraDefaultPosition;

Retrieves the default camera position.

- (ARVector3*)getCameraDefaultRotation;

Retrieves the default camera rotation.

- (void)addNode:(ARNode*)node;

Adds a node into the scene. Will also detach the node from its current parent.

- (void)removeNode:(ARNode*)node;

Removes a node from the scene.


ARNode

Base class for nodes which can be added into scenes. Each node class represents a different type of object, which are used to add content into the scene.

Methods:

-(void)setParent:(ARNode*)parentNode;

Sets node parentNode as the parent for this node. Will also detach the node from its current parent.

-(void)setParentSubModel:(ARModelNode*)parentNode : (NSString*) subModelName;

Parents this node to a sub-model inside parentNode. Will also detach the node from its current parent.
This is mostly useful for parenting a node into a specific joint of an animated model.

-(ARVector3*)getWorldPosition;

Retrieves the node's position in world space.

-(ARVector3*)getLocalPosition;

Retrieves the node's position in local space.

-(ARVector3*)getWorldRotation;

Retrieves the node's rotation in world space.

-(ARVector3*)getLocalRotation;

Retrieves the node's position in local space.

-(ARVector3*)getScale;

Retrieves the node's scale in local space.

-(void)setWorldPosition:(float)x : (float)y : (float)z;
-(void)setWorldPosition:(ARVector3*)position;

Sets the node's world position.

-(void)setLocalPosition:(float)x : (float)y : (float)z;
-(void)setLocalPosition:(ARVector3*)position;

Sets the node's position relative to its parent.

-(void)setWorldRotation:(float)x : (float)y : (float)z;
-(void)setWorldRotation:(ARVector3*)rotation;

Sets the node's world rotation.

-(void)setLocalRotation:(float)x : (float)y : (float)z;
-(void)setLocalRotation:(ARVector3*)rotation;

Sets the node's rotation relative to its parent.

-(void)setScale:(float)x : (float)y : (float)z;
-(void)setScale:(ARVector3*)scale;

Sets the node's scale relative to its parent.

-(void)translate:(float)x : (float)y : (float)z;
-(void)translate:(ARVector3*)translation;

Translates the node's position.

-(void)rotate:(float)x : (float)y : (float)z;
-(void)rotate:(ARVector3*)rotation;

Rotates the node by the given degrees.


ARModelNode : ARNode

A node representing a 3D model in the scene.

Methods:

-(instancetype)initWithFile:(NSString*)filePath;

Initializes a model node with a given .wam file.

-(bool)hasAnimations;

Returns whether the model node contains animation data.

-(NSMutableArray *)getAnimationClips;

Returns an array containing all the animation clip names within the model node.

-(void)setClip: (NSString*)clipName;

Sets the active animation clip with the given clip name.

-(void)playAnimation;

Starts playing the current animation clip.

-(void)pauseAnimation;

Pauses the current animation clip.

-(void)stopAnimation;

Stops the current animation clip, resetting it to the beginning.

-(void)setAnimationLoop : (bool)loop;

Sets whether animations should loop or not. loop is off by default.


ARVideoNode : ARNode

A node representing a plane which displays a video clip in the scene.

Methods:

-(instancetype)initWithFile:(NSString*)filePath;

Initializes a video node with a given mp4 file.

-(void)play;

Starts playing the video.

-(void)pause;

Pauses the video.

-(void)stop;

Stops the video, resetting it to the beginning.

-(void)setLooping:(bool)looping;

Sets whether the video should loop or not. loop is off by default.


ARAudioNode : ARNode

A node representing a 2D audio source in the scene.

Methods:

-(instancetype)initWithFile:(NSString*)filePath : (bool)streaming;

Initializes audio node with given file path. straming determines weather the audio clip should be streamed or decompressed upon load.
It is recommended to use the streaming feature for long audio clips (such as background music).
Supported audio formats: wav, mp3.

-(void)play;

Starts playing the audio clip.

-(void)pause;

Pauses the audio clip.

-(void)stop;

Stops the audio clip, resetting it to the beginning.

-(void)setVolume:(float)volume;

Sets the volume of the audio clip. Accepted volume range [0-1].

-(float)getVolume;

Retrieves the audio clip's volume.

-(void)setPitch:(float)pitch;

Sets the pitch of the audio clip. Accepted pitch range [0-1].

-(float)getPitch;

Retrieves the audio clip's pitch.

-(void)setLoop:(bool)loop;

Sets whether the audio clip should loop or not. loop is off by default.


ARLightNode : ARNode

A node representing a light source in the scene.

Methods:

-(instancetype)initWithType:(ARLightType)type;

Initializes a light node with a given type.
ARDirectional for a directional light.
ARSpot for a spot light.
ARPoint for a point light.

-(ARVector3*)getColor;

Retrieves the light's color.

-(float)getIntensity;

Retrieves the light's intensity.

-(float)getRadius;

Retrieves the light's radius. Only applicable for point and spot lights.

-(bool)getCastsShadows;

Retrieves weather the light source casts shadows or not.

-(void)setColor:(float)r : (float)g : (float)b;

Sets the light's color.

-(void)setIntensity:(float)intensity;

Sets the light's intensity.

-(void)setRadius:(float)radius;

Sets the light's radius. Only applicable for point and spot lights.

-(void)setCastsShadows:(bool)castsShadows;

Sets whether the light source should cast shadows or not.


ARVector3

A general-purpose class representing a 3 dimensional vector.

Methods:

- (instancetype)initWithZeroes;

Initializes a new zero vector.

- (instancetype)initWithValues:(float)x : (float)y : (float)z;

Initializes a new vector with values.


Properties:

@property (nonatomic) float x;
@property (nonatomic) float y;
@property (nonatomic) float z;

Allow access to each of the vector's individual values.