newspeoplefor developersdocumentationdownloads

nAnimation Class Reference
[Animation Subsystem]

#include <nanimation.h>

Inheritance diagram for nAnimation:

nResource nRoot nObject nNode nReferenced nSignalEmitter nMemoryAnimation nStreamingAnimation nCombinedAnimation List of all members.

Detailed Description

An nAnimation is a nResource subclass which holds one or more animation curves, which must all share the same number of keys, frame rate and loop type. The nAnimation object can be sampled for a given curve index at a given sample time.

One nAnimation object points to the data of exactly one "animation group" in an animation file (an animation group is a collection of curves that share the same attributes (number of keys, frame rate and looping type). Several nAnimation objects may access one animation file (since one animation file may contain several animation groups).

Subclasses of nAnimation may provide file streaming or sampling in-memory animation data.

After creation the object should be configured by setting the file and group name, after that, LoadResource() should be called (and also when IsValid() returns false), this is normal nResource class behavior.

To get a sample from a curve, call the SampleCurves() method.

Animation file formats:

ASCII: .nanim2 (not streamable)

    type nanim2
    numgroups [numGroups]
    numkeys [numKeys]

    FOR EACH GROUP {
        group [numCurves] [startKey] [numKeys] [keyStride] [keyTime] [FadeInFrames] [clamp|repeat]
        FOR EACH CURVE {
            curve [step|linear|quat|none] [firstKeyIndex] [collapsedKey(x,y,z,w)]
            curve
            ...
        }
        FOR EACH KEY (Keys are interleaved) {
            key [x y z w]   // first key of first non-collapsed curve
            key [x y z w]   // first key of second non-collapsed curve
            key [x y z w]   // first key of third non-collapsed curve
            ...             // etc...
        }
    }
    

BINARY: .nax2 (optionally streamable)

    HEADER {
        int32 magic         // NAX2
        int32 numGroups     // number of groups in file
        int32 numKeys       // number of keys in file
    }

    FOR EACH GROUP {
        int32 numCurves         // number of curves in group
        int32 startKey          // first key index
        int32 numKeys           // number of keys in group
        int32 keyStride         // key stride in key pool
        float keyTime           // key duration
        float fadeInFrames      // number of fade in frames
        int32 loopType          // nAnimation::LoopType
    }

    FOR EACH CURVE {
        int16 ipolType          // nAnimation::Curve::IpolType
        int32 firstKeyIndex     // index of first curve key in key pool (-1 if collapsed!)
        int32 isAnimated        // flag, if the curve's joint is animated
        float[4] collapsedKey   // the key value if this is a collapsed curve
    }

    FOR EACH KEY {
        float[4] value
    }
    

(C) 2003 RadonLabs GmbH

Definition at line 92 of file nanimation.h.


Public Member Functions

 nAnimation ()
 constructor
virtual ~nAnimation ()
 destructor
virtual void SampleCurves (float time, int groupIndex, int firstCurveIndex, int numCurves, vector4 *keyArray)
 sample values from curve range
nTime GetDuration (int groupIndex) const
 get duration of entire animation
void SetNumGroups (int g)
 set number of groups in animation
int GetNumGroups () const
 get number of groups in animation
GroupGetGroupAt (int i) const
 get group at index

Protected Member Functions

virtual void UnloadResource ()
 unload the resource (clears the valid flag)
void FixKeyOffsets ()
 fix the firstKeyIndex and keyStride members in the contained animation curve objects

Protected Attributes

nArray< GroupgroupArray

Classes

class  Curve
 holds animation curve information More...
class  Group
 holds animation group information (a group of curves) More...

Constructor & Destructor Documentation

nAnimation::nAnimation  ) 
 

constructor

Definition at line 12 of file nanimation_main.cc.

nAnimation::~nAnimation  )  [virtual]
 

destructor

Definition at line 21 of file nanimation_main.cc.


Member Function Documentation

void nAnimation::SampleCurves float  time,
int  groupIndex,
int  firstCurveIndex,
int  numCurves,
vector4 keyArray
[virtual]
 

sample values from curve range

This method should be overwritten by subclasses.

Reimplemented in nMemoryAnimation.

Definition at line 43 of file nanimation_main.cc.

nTime nAnimation::GetDuration int  groupIndex  )  const
 

get duration of entire animation

Returns the playback duration in seconds of an animation group.

Definition at line 53 of file nanimation_main.cc.

void nAnimation::SetNumGroups int  g  )  [inline]
 

set number of groups in animation

Definition at line 668 of file nanimation.h.

int nAnimation::GetNumGroups  )  const [inline]
 

get number of groups in animation

Definition at line 678 of file nanimation.h.

nAnimation::Group & nAnimation::GetGroupAt int  i  )  const [inline]
 

get group at index

Definition at line 688 of file nanimation.h.

void nAnimation::UnloadResource  )  [protected, virtual]
 

unload the resource (clears the valid flag)

Reimplemented from nResource.

Reimplemented in nMemoryAnimation.

Definition at line 33 of file nanimation_main.cc.

void nAnimation::FixKeyOffsets  )  [protected]
 

fix the firstKeyIndex and keyStride members in the contained animation curve objects


Member Data Documentation

nArray<Group> nAnimation::groupArray [protected]
 

Definition at line 234 of file nanimation.h.


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

Copyright © 1999-2005 by the contributing authors. Ideas, requests, problems: Send feedback.