2019-06-11 06:59:28 +00:00
|
|
|
#include "common.h"
|
2020-04-17 13:31:11 +00:00
|
|
|
|
2020-05-11 02:55:57 +00:00
|
|
|
#if defined _WIN32 && !defined __MINGW32__
|
2020-04-19 16:34:08 +00:00
|
|
|
#include "ctype.h"
|
2020-05-11 02:55:57 +00:00
|
|
|
#else
|
|
|
|
#include <cwctype>
|
|
|
|
#endif
|
2020-04-19 16:34:08 +00:00
|
|
|
|
2019-10-29 23:12:58 +00:00
|
|
|
#include "General.h"
|
2020-05-08 13:59:57 +00:00
|
|
|
#include "RwHelper.h"
|
|
|
|
#include "ModelIndices.h"
|
2019-06-11 06:59:28 +00:00
|
|
|
#include "ModelInfo.h"
|
|
|
|
#include "AnimManager.h"
|
|
|
|
#include "RpAnimBlend.h"
|
|
|
|
#include "AnimBlendAssociation.h"
|
|
|
|
#include "AnimBlendAssocGroup.h"
|
|
|
|
|
2020-05-08 13:59:57 +00:00
|
|
|
//--MIAMI: file done
|
|
|
|
|
2019-06-11 06:59:28 +00:00
|
|
|
CAnimBlendAssocGroup::CAnimBlendAssocGroup(void)
|
|
|
|
{
|
2020-05-08 13:59:57 +00:00
|
|
|
animBlock = nil;
|
2019-06-11 06:59:28 +00:00
|
|
|
assocList = nil;
|
|
|
|
numAssociations = 0;
|
2020-05-08 13:59:57 +00:00
|
|
|
firstAnimId = 0;
|
|
|
|
groupId = -1;
|
2019-06-11 06:59:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CAnimBlendAssocGroup::~CAnimBlendAssocGroup(void)
|
|
|
|
{
|
|
|
|
DestroyAssociations();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CAnimBlendAssocGroup::DestroyAssociations(void)
|
|
|
|
{
|
|
|
|
if(assocList){
|
|
|
|
delete[] assocList;
|
|
|
|
assocList = nil;
|
|
|
|
numAssociations = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CAnimBlendAssociation*
|
|
|
|
CAnimBlendAssocGroup::GetAnimation(uint32 id)
|
|
|
|
{
|
2020-05-15 14:30:25 +00:00
|
|
|
return &assocList[id - firstAnimId];
|
2019-06-11 06:59:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CAnimBlendAssociation*
|
|
|
|
CAnimBlendAssocGroup::GetAnimation(const char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < numAssociations; i++)
|
2019-10-29 23:12:58 +00:00
|
|
|
if(!CGeneral::faststricmp(assocList[i].hierarchy->name, name))
|
2019-06-11 06:59:28 +00:00
|
|
|
return &assocList[i];
|
2020-05-08 13:59:57 +00:00
|
|
|
debug("\n\nCan't find the fucking animation %s\n\n\n", name);
|
2019-06-11 06:59:28 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CAnimBlendAssociation*
|
|
|
|
CAnimBlendAssocGroup::CopyAnimation(uint32 id)
|
|
|
|
{
|
|
|
|
CAnimBlendAssociation *anim = GetAnimation(id);
|
|
|
|
if(anim == nil)
|
|
|
|
return nil;
|
|
|
|
CAnimManager::UncompressAnimation(anim->hierarchy);
|
|
|
|
return new CAnimBlendAssociation(*anim);
|
|
|
|
}
|
|
|
|
|
|
|
|
CAnimBlendAssociation*
|
|
|
|
CAnimBlendAssocGroup::CopyAnimation(const char *name)
|
|
|
|
{
|
|
|
|
CAnimBlendAssociation *anim = GetAnimation(name);
|
2020-04-18 10:29:28 +00:00
|
|
|
if(anim == nil)
|
|
|
|
return nil;
|
2019-06-11 06:59:28 +00:00
|
|
|
CAnimManager::UncompressAnimation(anim->hierarchy);
|
|
|
|
return new CAnimBlendAssociation(*anim);
|
|
|
|
}
|
|
|
|
|
2019-10-29 23:12:58 +00:00
|
|
|
bool
|
2019-06-11 06:59:28 +00:00
|
|
|
strcmpIgnoringDigits(const char *s1, const char *s2)
|
|
|
|
{
|
|
|
|
char c1, c2;
|
|
|
|
|
2020-04-18 10:29:28 +00:00
|
|
|
for(;;){
|
2019-06-11 06:59:28 +00:00
|
|
|
c1 = *s1;
|
|
|
|
c2 = *s2;
|
|
|
|
if(c1) s1++;
|
|
|
|
if(c2) s2++;
|
2020-04-19 16:34:08 +00:00
|
|
|
if(c1 == '\0' && c2 == '\0') return true;
|
|
|
|
#if defined _WIN32 && !defined __MINGW32__
|
2019-10-29 23:12:58 +00:00
|
|
|
if(__ascii_iswdigit(c1) && __ascii_iswdigit(c2))
|
2020-04-19 16:34:08 +00:00
|
|
|
#else
|
|
|
|
if(iswdigit(c1) && iswdigit(c2))
|
|
|
|
#endif
|
2019-06-11 06:59:28 +00:00
|
|
|
continue;
|
2020-04-19 16:34:08 +00:00
|
|
|
#if defined _WIN32 && !defined __MINGW32__
|
2019-10-29 23:12:58 +00:00
|
|
|
c1 = __ascii_toupper(c1);
|
|
|
|
c2 = __ascii_toupper(c2);
|
2020-04-19 16:34:08 +00:00
|
|
|
#else
|
|
|
|
c1 = toupper(c1);
|
|
|
|
c2 = toupper(c2);
|
|
|
|
#endif
|
|
|
|
|
2020-04-18 10:29:28 +00:00
|
|
|
if(c1 != c2)
|
|
|
|
return false;
|
2019-06-11 06:59:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CBaseModelInfo*
|
|
|
|
GetModelFromName(const char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
CBaseModelInfo *mi;
|
2020-05-08 13:59:57 +00:00
|
|
|
char playername[32];
|
|
|
|
|
|
|
|
if(strncasecmp(name, "CSplay", 6) == 0 &&
|
|
|
|
strncasecmp(CModelInfo::GetModelInfo(MI_PLAYER)->GetName(), "ig", 2) == 0){
|
|
|
|
strcpy(playername, CModelInfo::GetModelInfo(MI_PLAYER)->GetName());
|
|
|
|
playername[0] = 'C';
|
|
|
|
playername[1] = 'S';
|
|
|
|
name = playername;
|
|
|
|
}
|
2019-06-11 06:59:28 +00:00
|
|
|
|
|
|
|
for(i = 0; i < MODELINFOSIZE; i++){
|
|
|
|
mi = CModelInfo::GetModelInfo(i);
|
2019-06-12 08:50:23 +00:00
|
|
|
if(mi && mi->GetRwObject() && RwObjectGetType(mi->GetRwObject()) == rpCLUMP &&
|
2019-06-11 06:59:28 +00:00
|
|
|
strcmpIgnoringDigits(mi->GetName(), name))
|
|
|
|
return mi;
|
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CAnimBlendAssocGroup::CreateAssociations(const char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
CAnimBlock *animBlock;
|
|
|
|
|
2020-05-08 13:59:57 +00:00
|
|
|
DestroyAssociations();
|
2019-06-11 06:59:28 +00:00
|
|
|
|
|
|
|
animBlock = CAnimManager::GetAnimationBlock(name);
|
|
|
|
assocList = new CAnimBlendAssociation[animBlock->numAnims];
|
|
|
|
numAssociations = 0;
|
|
|
|
|
|
|
|
for(i = 0; i < animBlock->numAnims; i++){
|
|
|
|
CAnimBlendHierarchy *anim = CAnimManager::GetAnimation(animBlock->firstIndex + i);
|
|
|
|
CBaseModelInfo *model = GetModelFromName(anim->name);
|
2020-05-08 13:59:57 +00:00
|
|
|
if(model){
|
|
|
|
debug("Associated anim %s with model %s\n", anim->name, model->GetName());
|
|
|
|
RpClump *clump = (RpClump*)model->CreateInstance();
|
|
|
|
RpAnimBlendClumpInit(clump);
|
|
|
|
assocList[i].Init(clump, anim);
|
|
|
|
if(IsClumpSkinned(clump))
|
|
|
|
RpClumpForAllAtomics(clump, AtomicRemoveAnimFromSkinCB, nil);
|
|
|
|
RpClumpDestroy(clump);
|
|
|
|
assocList[i].animId = firstAnimId + i;
|
|
|
|
assocList[i].groupId = groupId;
|
|
|
|
}else
|
|
|
|
debug("\n\nCANNOT FIND MODELINFO WITH NAME %s\n\n\n", anim->name);
|
2019-06-11 06:59:28 +00:00
|
|
|
}
|
|
|
|
numAssociations = animBlock->numAnims;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create associations from hierarchies for a given clump
|
|
|
|
void
|
2019-08-16 18:17:15 +00:00
|
|
|
CAnimBlendAssocGroup::CreateAssociations(const char *blockName, RpClump *clump, const char **animNames, int numAssocs)
|
2019-06-11 06:59:28 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2020-05-08 13:59:57 +00:00
|
|
|
DestroyAssociations();
|
2019-06-11 06:59:28 +00:00
|
|
|
|
|
|
|
animBlock = CAnimManager::GetAnimationBlock(blockName);
|
2019-06-17 21:31:00 +00:00
|
|
|
assocList = new CAnimBlendAssociation[numAssocs];
|
2019-06-11 06:59:28 +00:00
|
|
|
|
|
|
|
numAssociations = 0;
|
|
|
|
for(i = 0; i < numAssocs; i++){
|
|
|
|
assocList[i].Init(clump, CAnimManager::GetAnimation(animNames[i], animBlock));
|
2020-05-08 13:59:57 +00:00
|
|
|
assocList[i].animId = firstAnimId + i;
|
|
|
|
assocList[i].groupId = groupId;
|
2019-06-11 06:59:28 +00:00
|
|
|
}
|
|
|
|
numAssociations = numAssocs;
|
|
|
|
}
|