KudanAR - iOS
ARNode Class Reference

#import <ARNode.h>

+ Inheritance diagram for ARNode:
+ Collaboration diagram for ARNode:

Instance Methods

(void) - addChild:
 
(void) - addChildren:
 
(void) - removeChild:
 
(void) - removeAllChildren
 
(void) - remove
 
(ARNode *) - findChildWithName:
 
(void) - markWorldTransformAsDirty
 
(void) - translateByX:y:z:
 
(void) - translateByX:y:z:transformSpace:
 
(void) - translateByVector:
 
(void) - translateByVector:transformSpace:
 
(void) - scaleByUniform:
 
(void) - scaleByX:y:z:
 
(void) - scaleByVector:
 
(void) - rotateByDegrees:axisX:y:z:
 
(void) - rotateByRadians:axisX:y:z:
 
(void) - rotateByQuaternion:
 
(ARVector3 *) - positionToWorld:
 
(ARVector3 *) - positionToEye:
 
(ARQuaternion *) - orientationToWorld:
 
(ARQuaternion *) - orientationToEye:
 
(CGPoint) - viewPortFromNodePosition:
 
(void) - render
 
(void) - preRender
 
(void) - postRender
 
(void) - addTouchTarget:withAction:
 
(void) - didReceiveTouch
 
(ARVector3 *) - nodeFromViewPort:
 

Class Methods

(instancetype) + nodeWithName:
 

Protected Member Functions

(typedef) - NS_ENUM
 

Properties

NSString * name
 
ARNodeparent
 
NSArray< ARNode * > * children
 
NSArray * descendants
 
ARVector3position
 
ARVector3scale
 
ARQuaternionorientation
 
ARMatrix4localTransform
 
ARMatrix4worldTransform
 
ARMatrix4fullTransform
 
ARQuaternionfullOrientation
 
ARQuaternionworldOrientation
 
ARVector3worldScale
 
ARVector3worldPosition
 
ARVector3fullPosition
 
ARNodeworld
 
NSUInteger childCount
 
BOOL visible
 

Detailed Description

An ARNode represents the base object of the scene-graph. It is responsible for the spatial layout of content, and is the node type from which all other nodes derive.

Method Documentation

- (void) addChild: (ARNode *)  child

Adds a node as a child of this node. Any transformations applied to a node also apply to all its children.

Example of use:

ARNode *parentNode = [ARNode nodeWithName:@"parentNode"];
ARNode *childNode = [ARNode nodeWithName:@"childNode"];
[parentNode addChild:childNode];
Parameters
childThe node to be added.
- (void) addChildren: (NSArray *)  children

Add a list of nodes as children of this node.

Example of use:

ARNode *parentNode = [ARNode nodeWithName:@"parentNode"];
ARNode *child1Node = [ARNode nodeWithName:@"child1Node"];
ARNode *child2Node = [ARNode nodeWithName:@"child2Node"];
NSArray *childNodes = @[child1Node, child2Node];
[parentNode addChildren:childNodes];
Parameters
childrenThe array of nodes to be added.
- (void) addTouchTarget: (id)  target
withAction: (SEL)  action 

Add an action that is triggered whenever this node or one of its children is touched.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
[node addTouchTarget:self withAction:@selector(wasTouched)];
// Then you can implement
- (void)wasTouched
{
// This code will run whenever the node is touched.
}
Parameters
targetThe object to receive the event.
actionThe method to call on the object.
- (void) didReceiveTouch

Method called whenever this node or one of its children is touched. This shouldn't be altered, instead simply create a new selector to run your code when the event fires.

- (ARNode *) findChildWithName: (NSString *)  name

Find a child of this node with the given name. If there are multiple child nodes with the same name, they cannot be found using this method, as it will always return the first one. In order to be able to find all child nodes, they must all have unique names.

Example of use:

[parentNode findChildWithName:@"childNode"];
Parameters
nameThe name of the node to search for.
Returns
The first ARNode in the list with the given name, or nil if no Node with the given name is found.
- (ARVector3 *) nodeFromViewPort: (CGPoint)  point

Unproject a 2D position in the ARViewPort to this nodes coordinate space.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
[node translateByX:10 y:10 z:10];
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchPosition = [touch locationInView:touch.view];
ARVector3 *intersect = [node nodeFromViewPort:touchPosition];
Parameters
pointThe 2D position in the viewport.
Returns
If the given point intersects with the Node, returns the 3D position where the point intersects this node. If the point does not intersect, returns nil.
+ (instancetype) nodeWithName: (NSString *)  name

Class method that creates a node with the given name.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
Parameters
nameThe name to give this node. Ideally, this will be unique, so that it will always be found correctly when using findChildWithName.
- (typedef) NS_ENUM (NSInteger) 
(TransformSpace)   

Different transformation spaces that the various transformation methods can act in.

Transform is applied relative to the existing local transform. Translations take the local rotation into account. If, for example, an object rotated at 45 degrees were translated to move up in its own local space, it would move diagonally relative to the camera, following the trajectory of the rotation.

Transform is applied relative to the parent's transform. Translations are unaffected by the local scale and rotation. If, for example, an object rotated at 45 degrees were translated to move up in its parent space, it would move upwards relative to the camera.

Transform is applied relative to the node's closest ARWorld grandparent. This is useful for moving around in world space. If, for example, an object and its child were both rotated 45 degrees, and they were translated both translated upwards in world space, both objects would move upwards relative to the camera.

- (ARVector3 *) positionToEye: (ARVector3 *)  position

Convert an ARVector3 position from this node's local space to eye/camera space.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
ARVector3 *eyePosition = [node positionToWorld:node.position];
Parameters
positionThe position in this node's local space as a vector.
Returns
The position in eye space as a vector.
- (ARVector3 *) positionToWorld: (ARVector3 *)  position

Convert an ARVector3 position from this node's local space to the nearest world space.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
ARVector3 *worldPosition = [node positionToWorld:node.position];
Parameters
positionThe position in this node's local space as a vector.
Returns
The position in world space as a vector.
- (void) postRender

Method called just after this node has been rendered.

- (void) preRender

Method called just before this node is rendered.

- (void) remove

Remove this node from its parent node.

Example of use:

[childNode remove];
- (void) removeAllChildren

Remove all children from this node.

Example of use:

[parentNode removeAllChildren];
- (void) removeChild: (ARNode *)  child

Remove a node from this node's children.

Example of use:

[parentNode removeChild:childNode];
Parameters
childThe node to be removed.
- (void) render

Method called when this node is being rendered.

- (void) rotateByDegrees: (float)  angle
axisX: (float)  x
y: (float)  y
z: (float)  z 

Rotate this node by the given number of degrees around each noted axis.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
[node rotateByDegrees:90 axisX:1 y:0 z:1];
Parameters
angleThe angle, in degrees, to rotate by.
xWhether or not to rotate about this node's X axis. 0 for no, 1 for yes.
yWhether or not to rotate about this node's Y axis. 0 for no, 1 for yes.
zWhether or not to rotate about this node's Z axis. 0 for no, 1 for yes.
- (void) rotateByQuaternion: (ARQuaternion *)  rotation

Multiply this node's orientation by a quaternion. For simple rotations, using rotateByDegrees is recommended instead.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
[node rotateByQuaternion:[ARQuaternion quaternionWithDegrees:90 axisX:1 y:0 z:0]];
Parameters
rotationThe quaternion to rotate this node by.
- (void) rotateByRadians: (float)  angle
axisX: (float)  x
y: (float)  y
z: (float)  z 

Rotate this node by the given number of radians around each noted axis.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
[node rotateByRadians:M_PI_2 axisX:0 y:1 z:0];
Parameters
angleThe angle, in radians, to rotate by.
xWhether or not to rotate about this node's X axis. 0 for no, 1 for yes.
yWhether or not to rotate about this node's Y axis. 0 for no, 1 for yes.
zWhether or not to rotate about this node's Z axis. 0 for no, 1 for yes.
- (void) scaleByUniform: (float)  scale

Scales the node uniformly across each axis. This does not set the scale, but rather adds to the existing scales by the given amount. For example, if you scale a node by 2, then by 4, its overall scale will be 8 times bigger. Likewise, if you scale by 0.5, then by 0.5 again, the overall scale will be 0.25 times bigger, or 4 times smaller. Scaling occurs in the node's local space.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
[node scaleByUniform:2];
Parameters
scaleThe amount to scale by.
- (void) scaleByVector: (ARVector3 *)  scale

Scale this node separately along each axis using values taken from a vector. Scale can be non-uniform. Scaling occurs in the node's local space.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
[node scaleByVector:[ARVector3 vectorWithValuesX:1 y:2 z:3]];
Parameters
scaleA vector containing the x, y and z scale factors.
- (void) scaleByX: (float)  x
y: (float)  y
z: (float)  z 

Scales the node separately along each axis. Scale can be non-uniform.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
[node scaleByX:1 y:2 z:3];
Parameters
xThe amount to scale in the x-axis.
yThe amount to scale in the y-axis.
zThe amount to scale in the z-axis.
- (void) translateByVector: (ARVector3 *)  translation

Translate the position of this node by the given vector in local space.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
ARVector3 *vector = [ARVector3 vectorWithValuesX:10 y:20 z:30];
[node translateByVector:vector];
Parameters
translationA vector containing the x, y and z units to translate by.
- (void) translateByVector: (ARVector3 *)  translation
transformSpace: (TransformSpace)  transformSpace 

Translate the position of this node by the given vector, relative to the given transform space.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
ARVector3 *vector = [ARVector3 vectorWithValuesX:10 y:20 z:30];
[node translateByVector:vector transformSpace:ARNodeTransformSpaceParent];
Parameters
translationA vector containing the x, y and z units to translate by.
transformSpacethe specified TransformSpace determines the coordinate system of the units.
- (void) translateByX: (float)  x
y: (float)  y
z: (float)  z 

Translate the position of this node by a number of units in each axis in local space.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
[node translateByX:10 y:20 z:30];
Parameters
xunits to translate along the x-axis.
yunits to translate along the y-axis.
zunits to translate along the z-axis.
- (void) translateByX: (float)  x
y: (float)  y
z: (float)  z
transformSpace: (TransformSpace)  transformSpace 

Translate the position of this node by a number of units in each axis, relative to the given transform space.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
[node translateByX:10 y:20 z:30 transformSpace:ARNodeTransformSpaceParent];
Parameters
xUnits to translate along the x-axis.
yUnits to translate along the y-axis.
zUnits to translate along the z-axis.
transformSpaceThe specified TransformSpace determines the coordinate system of the units. Local space to translate the node relative to its own transform. Parent space to translate the node relative to its parent's transform. World space to translate the node relative to the nearest ARWorld's transform.
- (CGPoint) viewPortFromNodePosition: (ARVector3 *)  position

Project a point in this node's coordinate space to its position in the ARViewPort this node is attached to.

Example of use:

ARNode *node = [ARNode nodeWithName:@"example node"];
CGPoint *viewPortPosition = [node viewPortFromNodePosition:node.position];
Parameters
positionThe 3D position in this node's coordinate space to project.
Returns
The 2D position in the ARViewPort.

Property Documentation

- (NSUInteger) childCount
readnonatomicassign

The number of direct children this node has. This is the number of elements in the children array.

- (NSArray<ARNode *>*) children
readnonatomicassign

Array containing all direct child nodes of this node. This returns only nodes added to this node as children. Any nodes added to those nodes will not be listed here.

- (NSArray*) descendants
readnonatomicassign

Array containing all child nodes of this node. This returns nodes added to this node and any nodes added to them, and so on, checking the entire graph. If this is the root node of the graph, this will return all nodes in the graph.

- (ARQuaternion*) fullOrientation
readnonatomicassign

The full orientation of this node in eye space.

- (ARVector3*) fullPosition
readnonatomicassign

The full orientation of this node in eye space.

- (ARMatrix4*) fullTransform
readnonatomicassign

The full transformation of this node in eye space.

- (ARMatrix4*) localTransform
readnonatomicassign

The combination of the local position, scale and orientation of this node.

- (NSString*) name
readwritenonatomicassign

The name of this node. The name should be unique so that the tracker can find it when using findChildByName.

- (ARQuaternion*) orientation
readwritenonatomicassign

This node's orientation relative to its parent in the form (X, Y, Z, W).

- (ARNode*) parent
readwritenonatomicweak

This node's parent node. If it's parent is a root node, this returns nil.

- (ARVector3*) position
readwritenonatomicassign

This node's position relative to its parent in the form (X, Y, Z).

- (ARVector3*) scale
readwritenonatomicassign

This node's scale relative to its parent in the form (X, Y, Z).

- (BOOL) visible
readwritenonatomicassign

Whether or not this node and all its children should be drawn. If NO, this node and all of its child nodes will not render, even if the child's visibility is set to YES. Default is YES.

- (ARNode*) world
readwritenonatomicassign

The ARWorld this node descends from.

- (ARQuaternion*) worldOrientation
readnonatomicassign

The orientation of this node in the space of the nearest ARWorld this node descends from.

- (ARVector3*) worldPosition
readnonatomicassign

The position of this node in the space of the nearest ARWorld this node descends from.

- (ARVector3*) worldScale
readnonatomicassign

The scale of this node in the space of the nearest ARWorld this node descends from.

- (ARMatrix4*) worldTransform
readnonatomicassign

The transformation of the nearest ARWorld that this node descends from.


The documentation for this class was generated from the following file: