2019-06-11 06:59:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "AnimBlendList.h"
|
|
|
|
#include "AnimBlendNode.h"
|
2019-06-24 14:57:54 +00:00
|
|
|
#include "AnimBlendHierarchy.h"
|
2019-06-11 06:59:28 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
ASSOC_RUNNING = 1,
|
|
|
|
ASSOC_REPEAT = 2,
|
|
|
|
ASSOC_DELETEFADEDOUT = 4,
|
|
|
|
ASSOC_FADEOUTWHENDONE = 8,
|
|
|
|
ASSOC_PARTIAL = 0x10,
|
|
|
|
ASSOC_MOVEMENT = 0x20, // ???
|
|
|
|
ASSOC_HAS_TRANSLATION = 0x40,
|
2020-05-10 21:47:53 +00:00
|
|
|
ASSOC_HAS_X_TRANSLATION = 0x80, // for 2d velocity extraction
|
|
|
|
ASSOC_WALK = 0x100, // for CPed::PlayFootSteps(void)
|
2020-05-29 19:05:33 +00:00
|
|
|
ASSOC_IDLE = 0x200, // only xpress scratch has it by default, but game adds it to player's idle animations later
|
2020-05-10 21:47:53 +00:00
|
|
|
ASSOC_NOWALK = 0x400, // see CPed::PlayFootSteps(void)
|
|
|
|
ASSOC_BLOCK = 0x800, // unused in assoc description, blocks other anims from being played
|
|
|
|
ASSOC_FRONTAL = 0x1000, // anims that we fall to front
|
2020-05-15 14:30:25 +00:00
|
|
|
ASSOC_DRIVING = 0x2000, // new in VC
|
2019-06-11 06:59:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Anim hierarchy associated with a clump
|
|
|
|
// Holds the interpolated state of all nodes.
|
|
|
|
// Also used as template for other clumps.
|
|
|
|
class CAnimBlendAssociation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum {
|
|
|
|
// callbackType
|
|
|
|
CB_NONE,
|
|
|
|
CB_FINISH,
|
|
|
|
CB_DELETE
|
|
|
|
};
|
|
|
|
|
|
|
|
CAnimBlendLink link;
|
|
|
|
|
2020-05-08 13:59:57 +00:00
|
|
|
int16 numNodes; // taken from CAnimBlendClumpData::numFrames
|
|
|
|
int16 groupId; // ID of CAnimBlendAssocGroup this is in
|
2019-06-11 06:59:28 +00:00
|
|
|
// NB: Order of these depends on order of nodes in Clump this was built from
|
|
|
|
CAnimBlendNode *nodes;
|
|
|
|
CAnimBlendHierarchy *hierarchy;
|
|
|
|
float blendAmount;
|
|
|
|
float blendDelta; // how much blendAmount changes over time
|
|
|
|
float currentTime;
|
|
|
|
float speed;
|
|
|
|
float timeStep;
|
2020-05-08 13:59:57 +00:00
|
|
|
int16 animId;
|
|
|
|
int16 flags;
|
2019-06-11 06:59:28 +00:00
|
|
|
int32 callbackType;
|
|
|
|
void (*callback)(CAnimBlendAssociation*, void*);
|
|
|
|
void *callbackArg;
|
|
|
|
|
|
|
|
bool IsRunning(void) { return !!(flags & ASSOC_RUNNING); }
|
|
|
|
bool IsRepeating(void) { return !!(flags & ASSOC_REPEAT); }
|
|
|
|
bool IsPartial(void) { return !!(flags & ASSOC_PARTIAL); }
|
|
|
|
bool IsMovement(void) { return !!(flags & ASSOC_MOVEMENT); }
|
|
|
|
bool HasTranslation(void) { return !!(flags & ASSOC_HAS_TRANSLATION); }
|
|
|
|
bool HasXTranslation(void) { return !!(flags & ASSOC_HAS_X_TRANSLATION); }
|
|
|
|
|
|
|
|
float GetBlendAmount(float weight) { return IsPartial() ? blendAmount : blendAmount*weight; }
|
|
|
|
CAnimBlendNode *GetNode(int i) { return &nodes[i]; }
|
|
|
|
|
|
|
|
CAnimBlendAssociation(void);
|
|
|
|
CAnimBlendAssociation(CAnimBlendAssociation &other);
|
2020-05-11 23:24:57 +00:00
|
|
|
#ifndef FIX_BUGS
|
|
|
|
virtual
|
|
|
|
#endif
|
|
|
|
~CAnimBlendAssociation(void);
|
2019-06-11 06:59:28 +00:00
|
|
|
void AllocateAnimBlendNodeArray(int n);
|
|
|
|
void FreeAnimBlendNodeArray(void);
|
|
|
|
void Init(RpClump *clump, CAnimBlendHierarchy *hier);
|
|
|
|
void Init(CAnimBlendAssociation &assoc);
|
|
|
|
void SetBlend(float amount, float delta);
|
|
|
|
void SetFinishCallback(void (*callback)(CAnimBlendAssociation*, void*), void *arg);
|
|
|
|
void SetDeleteCallback(void (*callback)(CAnimBlendAssociation*, void*), void *arg);
|
|
|
|
void SetCurrentTime(float time);
|
|
|
|
void SyncAnimation(CAnimBlendAssociation *other);
|
|
|
|
void Start(float time);
|
2020-05-10 21:47:53 +00:00
|
|
|
void UpdateTimeStep(float timeDelta, float relSpeed);
|
2020-05-08 13:59:57 +00:00
|
|
|
bool UpdateTime(float timeDelta, float relSpeed);
|
2019-06-11 06:59:28 +00:00
|
|
|
bool UpdateBlend(float timeDelta);
|
|
|
|
|
2019-07-23 14:39:30 +00:00
|
|
|
void SetRun(void) { flags |= ASSOC_RUNNING; }
|
|
|
|
|
2020-05-17 17:36:48 +00:00
|
|
|
float GetTimeLeft() { return hierarchy->totalLength - currentTime; }
|
|
|
|
float GetProgress() { return currentTime / hierarchy->totalLength; }
|
2019-06-24 14:57:54 +00:00
|
|
|
|
2019-06-11 06:59:28 +00:00
|
|
|
static CAnimBlendAssociation *FromLink(CAnimBlendLink *l) {
|
|
|
|
return (CAnimBlendAssociation*)((uint8*)l - offsetof(CAnimBlendAssociation, link));
|
|
|
|
}
|
|
|
|
};
|