The main objects managed and used by RpHAnim are the RpHAnimHierarchy and the RtAnimAnimation. The RpHAnimHierarchy data structure describes the order of the joints, the shoulder, elbow and so on, that control the model's animation. Its topology is a tree structure, or hierarchy of nodes that represent the model's animated joints. The RtAnimAnimation holds the state of the animation as it is being run. So it stores the current position of each joint as it is interpolated between key frames at the current point in the animation.
A sub-hierarchy can be defined by specifying a node in the main hierarchy. All nodes that are descendants of it (children, grandchildren etc) become part of this sub-hierarchy. This is useful for running more than one animation at a time on a single model. The main hierarchy normally has an animation that can animate the joints of the whole model (or at least the part of the model not animated by a sub-hierarchy). Any sub-hierarchies can have an animation, and this animation replaces the main hierarchy animation for the sub-hierarchy (i.e. that branch of the main hierarchy) to which it is applied. It does this by overwriting the joint matrices held in the main hierarchy data structure directly.
For each node (i.e. joint) in the hierarchy (or sub-hierarchy) that the animation is applied to, the RtAnimAnimation contains a start keyframe, an end keyframe, and any number of intermediate keyframes as necessary. Each keyframe consists of a quaternion (the positional information for the joint) and a time, at which the joint is at exactly that position. This is normally created by loading an ANM file. They can be run on multiple hierarchies at once as long as all the hierarchies were created with the same topology. When the joint is at a time where no keyframe is applied the joint is positioned by linear interpolation between the two adjacent keyframes. It is possible to use non-linear interpolations, see overloadable interpolation schemes in RtAnim.
RpHAnimHierarchy's can be attached and detached from a standard RwFrame hierarchy and when attached flags can be set so that the RwFrame's modeling matrices and/or LTMs (Local Transform Matrices) are updated when the animation is being run. This allows the animation system to provide animation to atomics attached to the RwFrame hierarchy. The RpHAnimHierarchy also (optionally) maintains an array of matrices held as either world space or local hierarchy space LTMs. These are used to drive RpSkin atomics as skinned models. A Hierarchy that is attached to RwFrame, updating RwFrame and attached to a skin will provide animation to both atomic hierarchies and skinned atomics whilst only needing to update a single animation.
Alternatively, the RtAnimAnimation system may be completely overridden for animating skinned atomics by accessing the array of matrices in the RpHAnimHierarchy directly. See RpHAnimHierarchyGetMatrixArray in the API Reference Guide.
rws
file containing an rwID_CLUMP and an rwID_HANIMANIMATION chunk
representing the model and its animation. For more complex
animations, there may be more than one rwID_CLUMP chunk (you only need
one main one), and more than one rwID_HANIMANIMATION (animations
to play back each hierarchy or subhierarchy) in the
.rws
file.rws
file.
|
RpHAnimFrameExtension typedef for struct RpHAnimFrameExtension |
|
RpHAnimHierarchy typedef for struct RpHAnimHierarchy |
|
RpHAnimInterpFrame typedef for struct RpHAnimInterpFrame. Based on RtAnimInterpFrameHeader. |
|
RpHAnimKeyFrame typedef for struct RpHAnimKeyFrame. Based on RtAnimKeyFrameHeader. |
|
RpHAnimNodeInfo typedef for struct RpHAnimNodeInfo |
|
RpHAnimHierarchyFlag defines type and update modes in HAnimHierarchies
|
|
RpHAnimFrameGetHierarchy gets the hierarchy pointed to by this RwFrame.
|
|
RpHAnimFrameGetID gets the ID stored with the RwFrame, these are used to attach hierarchies to RwFrames.
|
|
RpHAnimFrameSetHierarchy sets the RwFrame to point to a hierarchy allowing it to be streamed out
|
|
RpHAnimFrameSetID sets the ID stored with the RwFrame, these are used to attach hierarchies to RwFrames.
|
|
RpHAnimHierarchyAddAnimTime add anim time will step through the keyframes to find the current pair for each node to interpolate. These will then be interpolated by calling the appropriate overloaded interpolation scheme functions. If the animation loops or passes the time set in RpHAnimHierarchySetKeyFrameCallBacks then the appropriate callback will be called. By default the animation will simply loop continuously. This function does not make assumptions about the direction of animation prior to calling. It is not therefore necessary for the user to keep track of the direction of play, nor handle a change of direction explicitly. The hierarchy's matrices and attached RwFrames will not update until RpHAnimHierarchyUpdateMatrices is called.
|
|
RpHAnimHierarchyAddSubHierarchy adds together two hierarchies. Each hierarchy should have an animation attached, and the result will be the addition of the two input hierarchies. The output hierarchy must be identical in structure to either the main or sub-hierarchy.
|
|
RpHAnimHierarchyAddTogether adds together two hierarchies. Each hierarchy should have an animation attached, and the result will be the addition of the two input hierarchies. This is mainly useful where the second hierarchy's pose is a delta from a set pose to be added to the pose held in the first hierarchy. For example, a walk animation could have a crouch pose added to it as a delta from a standing pose.
|
|
RpHAnimHierarchyAttach attaches hierarchies from RwFrame. When attached the RpHAnimHierarchy's can update RwFrame directly through animation updates. The attachment is done by linking ID's set on the RwFrame with RpHAnimFrameSetID and the ID's for the nodes passed into RpHAnimHierarchyCreate.
|
|
RpHAnimHierarchyAttachFrameIndex attaches a single node within the hierarchy to an RwFrame. This allows you to setup RwFrame updates on only a few necessary RwFrames rather than the whole RwFrame hierarchy.
|
|
RpHAnimHierarchyBlend interpolates between two hierarchies.The result will be interpolated between the current state of the two input hierarchies. The most common use of this function will probably be to blend from the end of one animation to the start of the next. This would be done with 3 hierarchies, anim1skel, hanimskel and tempskel. Initially anim1 would be running on anim1skel which is attached to the skin. When the blend is required hanim is attached to hanimskel and tempskel is now attached to the skin. For each update during the blend duration RpHAnimHierarchyBlend is used to blend between anim1skel and hanimskel, storing the results in tempskel. At the end of the blend hanimskel is attached to the skin.
|
|
RpHAnimHierarchyBlendSubHierarchy interpolates the nodes in a sub-hierarchy with it parent hierarchy. Each hierarchy should have an animation attached, and the result will be interpolated between the current state of the two input hierarchies. Either source hierarchy can be the sub-hierarchy, the blend is performed from inHierarchy1 to inHierarchy2. The output hierarchy must be identical in structure to either the main or sub-hierarchy.
|
|
RpHAnimHierarchyCopy copies state of nodes in the in-hierarchy into the out-hierarchy.
|
|
RpHAnimHierarchyCreate creates and returns a standard RpHAnimHierarchy . This takes the number of nodes in the hierarchy and arrays of push/pop node flags and node IDs. It also takes hierarchy flags and a maximum keyframe size. The flags are used to define certain creation time aspects and update aspects of a hierarchy (see below for description)
Creation time flags:
|
|
RpHAnimHierarchyCreateFromHierarchy creates a hierarchy with the same structure as the source hierarchy. This can be used to create multiple secondary hierarchies for blending.
|
|
RpHAnimHierarchyCreateSubHierarchy This function creates a sub-hierarchy of a given main hierarchy. The parent-hierarchy and the offset into the hierarchy are given along with flags defining the sub-hierarchies settings. You can specify a different maxkeyframesize for the sub-hierarchy and use different types of keyframe on sub-hierarchies and main hierarchies, specifying -1 will adopt the parent hierarchies size settings. The sub-hierarchy can then be used to run a different animation from the base hierarchy. The general loop process would be as follows.
|
|
RpHAnimHierarchyDestroy destroys a hierarchy
|
|
RpHAnimHierarchyDetach detaches hierarchies from RwFrame. When attached the RpHAnimHierarchy's can update RwFrame directly through anim updates. Hierarchies are automatically detached when they are destroyed, however currently if you destroy an RwFrame which is referenced by an AnimHierarchy but not at the root of a hierarchy things may break. Since in general RwFrame hierarchies are destroyed in one go rather than one at a time this shouldn't be a huge issue.
|
|
RpHAnimHierarchyDetachFrameIndex detaches a single node within the hierarchy from an RwFrame.
|
|
RpHAnimHierarchyGetCurrentAnim Returns the current animation on the hierarchy.
|
|
RpHAnimHierarchyGetFlags allows you flags defining how the RpHAnimHierarchy was created and how it should be updated. Only the flags defining update modes should be changed after creation.
|
|
RpHAnimHierarchyGetMatrixArray function call access to the pMatrixArray in a hierarchy.
|
|
RpHAnimHierarchySetAnimCallBack is used to set a callback function that will be called when a hierarchy reaches a specified time. The callback function should return a pointer to the hierarchy if the function should continue to be called, or NULL if it should never be called again.
|
|
RpHAnimHierarchySetAnimLoopCallBack is used to set a callback function that will be called when a hierarchy's animation loops. The callback function should return a pointer to the hierarchy if the function should continue to be called, or NULL if it should never be called again.
|
|
RpHAnimHierarchySetCurrentAnim Sets the current animation on the hierarchy. It is assumed that the animation is designed for the hierarchy it is being set on and no hierarchy structure comparisons are made. The animation defines the interpolation schemes used and they will be setup on the hierarchy at this call. The max keyframe size of the hierarchy must be sufficient to support the keyframe size required by the interpolation scheme. The animation is initialized to time zero at this call. If the hierarchy is attached to a skin, the skin will not update until RpHAnimHierarchyUpdateMatrices is called.
|
|
RpHAnimHierarchySetCurrentAnimTime sets the current animation time of a hierarchy. If the hierarchy is attached to a skin, the skin will not update until RpHAnimHierarchyUpdateMatrices is called.
|
|
RpHAnimHierarchySetFlags allows you to set flags defining how the RpHAnimHierarchy was created and how it should be updated. Only the flags defining update modes should be changed after creation.
|
|
RpHAnimHierarchySetFreeListCreateParams allows the developer to specify how many RpHAnimHierarchy s to preallocate space for. Call before RwEngineInit.
|
|
RpHAnimHierarchySetKeyFrameCallBacks Sets up the callbacks to be used by the hierarchy. These callbacks perform keyframe blending, interpolation and conversion to matrices. The callback setup is implicitly performed when setting the current animation on a hierarchy, however if you wish to fully procedurally drive the keyframe data this function allows the callbacks to be setup so that RpHAnimHierarchyUpdateMatrices performs correctly.
|
|
RpHAnimHierarchySubAnimTime subtract anim time will step through the keyframes to find the current pair for each node to interpolate. These will then be interpolated by calling the appropriate overloaded interpolation scheme functions. If the animation loops or passes the time set in RpHAnimHierarchySetAnimCallBack then the appropriate callback will be called. By default the animation will simply loop continuously. If the hierarchy is attached to a skin, the skin will not update until RpHAnimHierarchyUpdateMatrices is called.
|
|
RpHAnimHierarchyUpdateMatrices iterates over all the nodes in the hierarchy updating a combination of three members those being the local array of matrices, the modeling matrices in RwFrame's and the LTMs in RwFrame. If this hierarchy is a sub-hierarchy then the matrices updated will be a sub range of the parent hierarchies matrices.
|
|
RpHAnimIDGetIndex returns the index of a node in the node arrays based on a given node ID. This is useful for procedurally animating nodes since you need the index to access the matrices/keyframes. This is also very useful for creating sub-hierarchies. Given the ID on the root of the sub-hierarchy this gives you the index to pass into RpHAnimHierarchyCreateSubHierarchy
|
|
RpHAnimKeyFrameAdd adds two interpolated keyframes together.
|
|
RpHAnimKeyFrameApply converts a standard keyframe to a matrix
|
|
RpHAnimKeyFrameBlend blends between two RpHAnimInterpFrame objects using a given blend factor.
|
|
RpHAnimKeyFrameInterpolate interpolates between two skin frames and returns the result.
|
|
RpHAnimKeyFrameMulRecip multiplies one keyframe by the reciprocal of another (in place).
|
|
RpHAnimKeyFrameStreamGetSize calculates the size of a hierarchical animation keyframes when written to a stream.
|
|
RpHAnimKeyFrameStreamRead reads a hierarchical animation from a stream.
|
|
RpHAnimKeyFrameStreamWrite writes a hierarchical animation to a stream.
|
|
RpHAnimPluginAttach is used to attach the Animation plugin to the RenderWare system to enable the manipulation of animating node hierarchies. The plugin must be attached between initializing the system with RwEngineInit and opening it with RwEngineOpen.
|
Converted from CHM to HTML with chm2web Pro 2.85 (unicode) |