CC3NodeAnimationState Class Reference
Inherits from | NSObject |
Declared in | CC3NodeAnimation.h |
Overview
CC3NodeAnimationState holds the state associated with the animation of a single node on a single track.
Each node can participate in multiple tracks of animation, and during animation, these tracks can be mixed to perform sophisticated animation blending techniques.
Each instance of this class bridges a single CC3Node with an CC3NodeAnimation running on on a particular track, and keeps track of the animation state on behalf of the node.
Tasks
-
node
property -
animation
property -
trackID
property -
blendingWeight
property -
isEnabled
property -
isLocationAnimationEnabled
property -
isQuaternionAnimationEnabled
property -
isScaleAnimationEnabled
property -
– enable
-
– disable
-
animationTime
property -
location
property -
quaternion
property -
scale
property -
frameCount
property -
isAnimatingLocation
property -
isAnimatingQuaternion
property -
isAnimatingScale
property -
isAnimating
property -
hasVariableFrameTiming
property -
– establishFrameAt:
-
– initWithAnimation:onTrack:forNode:
-
+ animationStateWithAnimation:onTrack:forNode:
-
+ generateTrackID
-
– describeCurrentState
-
– describeStateForFrames:
-
– describeStateForFrames:fromTime:toTime:
Properties
animation
The animation whose state is being tracked by this instance.
@property (nonatomic, strong, readonly) CC3NodeAnimation *animation
Declared In
CC3NodeAnimation.h
animationTime
Returns the current animation time. This is the value submitted to the most recent invocation of the establishFrameAt: method, or zero if that method has not yet been invoked.
@property (nonatomic, readonly) CCTime animationTime
Declared In
CC3NodeAnimation.h
blendingWeight
The relative weight to use when blending this animation track with the other tracks. For each animation state in a node, this value can be set to a value between zero and one. During animation, the animated node properties (location, quaternion, scale) are derived from a weighted average of the contributions from each animation track, as determined by the relative weights assigned to each animation track, as specified by this property.
@property (nonatomic, assign) GLfloat blendingWeight
Discussion
For each track, the blending weight is relative to the blending weights of the other tracks, and the absolute values used for this property are unimportant. So, for instance, setting the value of this property to 0.2 on one track and 0.1 on another is equivalent to setting the value of this property to 1.0 and 0.5 respectively. In both cases, the first animation track will contribute twice the effect on the node’s animated properties than the second animation track.
It is important to understand that with multi-track animation, each animation track will contribute to the node’s animated properties according to its weight even in the absence of a CC3ActionAnimate action running on that track. This is to ensure smooth transitions before and after a CC3ActionAnimate is run. To stop a track from contributing to the animated properties of the node, either set the value of this property to zero, or set the isEnabled property to NO.
The initial value of this property is one.
Declared In
CC3NodeAnimation.h
frameCount
The number of frames of animated content.
@property (nonatomic, readonly) GLuint frameCount
Discussion
The value of this property is retrieved from the same property on the contained animation instance.
Declared In
CC3NodeAnimation.h
hasVariableFrameTiming
Indicates whether the time interval between frames can vary from frame to frame, or whether the time interval between frames is constant across all frames.
@property (nonatomic, readonly) BOOL hasVariableFrameTiming
Discussion
If this property returns NO, the frames of this animation are equally spaced in time.
The value of this property is retrieved from the same property on the contained animation instance.
Declared In
CC3NodeAnimation.h
isAnimating
Indicates whether any of the properties of the node are being animated. Returns YES if any of the isAnimatingLocation, isAnimatingQuaternion or isAnimatingScale properties returns YES.
@property (nonatomic, readonly) BOOL isAnimating
Declared In
CC3NodeAnimation.h
isAnimatingLocation
Indicates whether the location property of the node is being animated. It is if both the isLocationAnimationEnabled property of this instance, and the isAnimatingLocation property of the contained animation, are set to YES.
@property (nonatomic, readonly) BOOL isAnimatingLocation
Declared In
CC3NodeAnimation.h
isAnimatingQuaternion
Indicates whether the quaternion property of the node is being animated. It is if both the isQuaternionAnimationEnabled property of this instance, and the isAnimatingQuaternion property of the contained animation, are set to YES.
@property (nonatomic, readonly) BOOL isAnimatingQuaternion
Declared In
CC3NodeAnimation.h
isAnimatingScale
Indicates whether the scale property of the node is being animated. It is if both the isScaleAnimationEnabled property of this instance, and the isAnimatingScale property of the contained animation, are set to YES.
@property (nonatomic, readonly) BOOL isAnimatingScale
Declared In
CC3NodeAnimation.h
isEnabled
Indicates whether this animation is enabled, and will participate in animating the contained node if an animate action is run on the node.
@property (nonatomic, assign) BOOL isEnabled
Discussion
The initial value of this property is YES.
Declared In
CC3NodeAnimation.h
isLocationAnimationEnabled
Indicates whether animation of the location property of the node is enabled.
@property (nonatomic, assign) BOOL isLocationAnimationEnabled
Discussion
The initial value of this property is YES. Setting this property to NO will disable animation of the node’s location property, but will permit other properties to be animated.
Declared In
CC3NodeAnimation.h
isQuaternionAnimationEnabled
Indicates whether animation of the quaternion property of the node is enabled.
@property (nonatomic, assign) BOOL isQuaternionAnimationEnabled
Discussion
The initial value of this property is YES. Setting this property to NO will disable animation of the node’s quaternion property, but will permit other properties to be animated.
Declared In
CC3NodeAnimation.h
isScaleAnimationEnabled
Indicates whether animation of the scale property of the node is enabled.
@property (nonatomic, assign) BOOL isScaleAnimationEnabled
Discussion
The initial value of this property is YES. Setting this property to NO will disable animation of the node’s scale property, but will permit other properties to be animated.
Declared In
CC3NodeAnimation.h
location
The current animated location.
@property (nonatomic, assign) CC3Vector location
Discussion
The value of this property is updated by the animation when the establishFrameAt: is invoked.
Declared In
CC3NodeAnimation.h
node
The node whose animation state is being tracked by this instance.
@property (nonatomic, assign, readonly) CC3Node *node
Declared In
CC3NodeAnimation.h
quaternion
The current animated rotation quaternion.
@property (nonatomic, assign) CC3Quaternion quaternion
Discussion
The value of this property is updated by the animation when the establishFrameAt: is invoked.
Declared In
CC3NodeAnimation.h
Class Methods
animationStateWithAnimation:onTrack:forNode:
Allocates and initializes an autoreleased instance tracking the animation state for the specified animation running on the specified track for the specified node.
+ (id)animationStateWithAnimation:(CC3NodeAnimation *)animation onTrack:(GLuint)trackID forNode:(CC3Node *)node
Discussion
Returns nil if either the animation or the node are nil.
Declared In
CC3NodeAnimation.h
generateTrackID
Returns the next available trackID value. The value returned is guaranteed to be different each time this method is invoked.
+ (GLuint)generateTrackID
Discussion
When using multi-track animation in a node assembly, the trackID identifies a particular animation track within that node assembly. Since any particular track may only affect a few nodes within the entire node assembly, when adding a new animation track to the node assembly, it can be difficult to know how to select a track ID that will not conflict with any existing tracks within that node assembly. This method can be used to generate a unique track ID to use when adding a new track of animation to a node assembly.
Declared In
CC3NodeAnimation.h
Instance Methods
describeCurrentState
Returns a description of the current state, including time and animated location, quaternion and scale.
- (NSString *)describeCurrentState
Declared In
CC3NodeAnimation.h
describeStateForFrames:
Returns a description of the state at each of frameCount frames over the entire animation.
- (NSString *)describeStateForFrames:(GLuint)frameCount
Declared In
CC3NodeAnimation.h
describeStateForFrames:fromTime:toTime:
Returns a description of the state at each of frameCount frames between the specified start and end times, which should each be in the range between zero and one.
- (NSString *)describeStateForFrames:(GLuint)frameCount fromTime:(CCTime)startTime toTime:(CCTime)endTime
Declared In
CC3NodeAnimation.h
establishFrameAt:
Updates the currentFrame, location, quaternion, and scale of this instance based on the animation content found in the contained animation at the specified time, which should be a value between zero and one, with zero indicating the first animation frame, and one indicating the last animation frame.
- (void)establishFrameAt:(CCTime)t
Declared In
CC3NodeAnimation.h
initWithAnimation:onTrack:forNode:
Initializes this instance tracking the animation state for the specified animation running on the specified track for the specified node.
- (id)initWithAnimation:(CC3NodeAnimation *)animation onTrack:(GLuint)trackID forNode:(CC3Node *)node
Discussion
Returns nil if either the animation or the node are nil.
Declared In
CC3NodeAnimation.h