This commit is contained in:
parent
07556e2b04
commit
13a2191670
122
source/gfx/actor.cpp
Normal file
122
source/gfx/actor.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
/******************/
|
||||
/*** Actor Bank ***/
|
||||
/******************/
|
||||
|
||||
#include "system\global.h"
|
||||
#include "mem\memory.h"
|
||||
#include "fileio\fileio.h"
|
||||
#include "utils\quat.h"
|
||||
#include "gfx\actor.h"
|
||||
#include "utils\utils.h"
|
||||
|
||||
#include <dstructs.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
CActorGfx *CActorPool::ActorList[CActorPool::MAX_ACTORS];
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
CActorGfx::CActorGfx(FileEquate _Filename)
|
||||
{
|
||||
Filename=_Filename;
|
||||
/* ActorData=(sActorHdr*)CFileIO::loadFile(Filename);
|
||||
|
||||
for (int i=0; i<ActorData->AnimCount; i++)
|
||||
{
|
||||
ActorData->AnimList[i].Move=(s32*) MakePtr(ActorData,(int)ActorData->AnimList[i].Move);
|
||||
ActorData->AnimList[i].Anim=(AnimIdx*) MakePtr(ActorData,(int)ActorData->AnimList[i].Anim);
|
||||
}
|
||||
|
||||
DAVE_DBGMSG("Nodes %i\n",ActorData->BoneCount);
|
||||
DAVE_DBGMSG("Tris %i\n",ActorData->TriCount);
|
||||
DAVE_DBGMSG("Vtx %i\n",ActorData->VtxCount);
|
||||
DAVE_DBGMSG("Anims %i\n",ActorData->AnimCount);
|
||||
*/
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
CActorGfx::~CActorGfx()
|
||||
{
|
||||
MemFree(ActorData);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CActorGfx::Render(DVECTOR &Pos,int Anim,int Frame,bool FlipX)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CActorGfx::Dump()
|
||||
{
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CActorPool::Init()
|
||||
{
|
||||
for (int i=0; i<MAX_ACTORS; i++)
|
||||
{
|
||||
ActorList[i]=0;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int CActorPool::FindIdx(FileEquate Filename)
|
||||
{
|
||||
for (int i=0; i<MAX_ACTORS; i++)
|
||||
{
|
||||
if (ActorList[i] && ActorList[i]->GetFilename()==Filename) return(i);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int CActorPool::FindFreeIdx()
|
||||
{
|
||||
for (int i=0; i<MAX_ACTORS; i++)
|
||||
{
|
||||
if (!ActorList[i]) return(i);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Load ********************************************************************/
|
||||
/*****************************************************************************/
|
||||
CActorGfx *CActorPool::GetActor(FileEquate Filename)
|
||||
{
|
||||
CActorGfx *NewActor;
|
||||
int Idx;
|
||||
// Already Loaded?
|
||||
Idx=FindIdx(Filename);
|
||||
if (Idx!=-1) return(ActorList[Idx]);
|
||||
|
||||
// Create and Load
|
||||
Idx=FindFreeIdx();
|
||||
ASSERT(Idx!=-1);
|
||||
|
||||
NewActor=new ("ActorPool") CActorPool(Filename);
|
||||
ActorList[Idx]=NewActor;
|
||||
|
||||
return(NewActor);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Dump ********************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CActorPool::DumpActor(FileEquate Filename)
|
||||
{
|
||||
CActorPool *ThisActor;
|
||||
int Idx;
|
||||
|
||||
// Is Loaded?
|
||||
Idx=FindIdx(Filename);
|
||||
ASSERT(Idx!=-1);
|
||||
ThisActor=ActorList[Idx];
|
||||
ActorList[Idx]=0;
|
||||
delete ThisActor;
|
||||
}
|
||||
|
60
source/gfx/actor.h
Normal file
60
source/gfx/actor.h
Normal file
@ -0,0 +1,60 @@
|
||||
/******************/
|
||||
/*** Actor Bank ***/
|
||||
/******************/
|
||||
|
||||
#ifndef __ACTOR_HEADER__
|
||||
#define __ACTOR_HEADER__
|
||||
|
||||
#include "system\global.h"
|
||||
#include <dstructs.h>
|
||||
|
||||
#ifndef __BigLump_H__
|
||||
#include <biglump.h>
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
class CActorGfx
|
||||
{
|
||||
public:
|
||||
CActorGfx(){};
|
||||
CActorGfx(FileEquate Filename);
|
||||
~CActorGfx();
|
||||
|
||||
void Render(DVECTOR &Pos,int Anim,int Frame,bool FlipX);
|
||||
void Dump();
|
||||
|
||||
int getFrameCount() {return(0);}
|
||||
|
||||
FileEquate GetFilename() {return(Filename);}
|
||||
private:
|
||||
FileEquate Filename;
|
||||
sSpriteAnimBank *ActorData;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
class CActorBank
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
MAX_ACTORS=8,
|
||||
};
|
||||
// virtual ~ActorBank(){};
|
||||
|
||||
static void Init();
|
||||
|
||||
static void AddActor(FileEquate Filename) {GetActor(Filename);}
|
||||
static CActorGfx *GetActor(FileEquate Filename);
|
||||
static void DumpActor(FileEquate Filename);
|
||||
|
||||
private:
|
||||
static int FindIdx(FileEquate Filename);
|
||||
static int FindFreeIdx();
|
||||
|
||||
static CActorGfx *ActorList[MAX_ACTORS];
|
||||
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user