2022-09-30 14:25:21 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "vectors.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
HUDFLAG_HIDE = 1,
|
|
|
|
HUDFLAG_NOBOB = 2,
|
|
|
|
HUDFLAG_FLIPPED = 4,
|
|
|
|
HUDFLAG_NODEPTH = 8,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ModelAnimation
|
|
|
|
{
|
|
|
|
int startframe, endframe;
|
|
|
|
int fpssc, flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ModelSkinDef
|
|
|
|
{
|
|
|
|
uint8_t palette, flags;
|
|
|
|
int32_t skinnum, surfnum; // Skin identifier, surface number
|
|
|
|
FTextureID texture;
|
|
|
|
float param, specpower, specfactor;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct ModelDescriptor
|
|
|
|
{
|
|
|
|
unsigned modelID;
|
|
|
|
|
|
|
|
// stuff that can get set from .DEF so we need to keep it.
|
|
|
|
int shadeoff;
|
|
|
|
int flags;
|
|
|
|
float scale, bscale, zadd, yoffset;
|
|
|
|
bool deleted;
|
|
|
|
FGameTexture* texture;
|
|
|
|
TArray<ModelAnimation> anims;
|
|
|
|
TArray<ModelSkinDef> skins;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ModelTileFrame
|
|
|
|
{
|
|
|
|
// maps build tiles to particular animation frames of a model
|
|
|
|
int modelid;
|
|
|
|
int framenum;
|
|
|
|
float smoothduration;
|
|
|
|
int skinnum;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct ModelManager
|
|
|
|
{
|
|
|
|
TArray<ModelDescriptor> modelDescs;
|
|
|
|
TMap<unsigned, ModelTileFrame> frameMap;
|
|
|
|
|
2022-12-30 17:18:58 +00:00
|
|
|
unsigned FrameMapKey(FTextureID tilenum, unsigned palette)
|
2022-09-30 14:25:21 +00:00
|
|
|
{
|
2022-12-30 17:18:58 +00:00
|
|
|
return tilenum.GetIndex() + (palette < 20);
|
2022-09-30 14:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Interface for the .def parser
|
|
|
|
int LoadModel(const char* fn);
|
|
|
|
int SetMisc(int modelid, float scale, int shadeoff, float zadd, float yoffset, int flags);
|
|
|
|
int DefineFrame(int modelid, const char* framename, int tilenum, int skinnum, float smoothduration, int pal);
|
|
|
|
int DefineAnimation(int modelid, const char* framestart, const char* frameend, int fpssc, int flags);
|
|
|
|
int DefineSkin(int modelid, const char* skinfn, int palnum, int skinnum, int surfnum, float param, float specpower, float specfactor, int flags);
|
|
|
|
int DefineHud(int modelid, int tilex, FVector3 add, int angadd, int flags, int fov);
|
|
|
|
int UndefineTile(int tile);
|
|
|
|
int UndefineModel(int modelid);
|
2022-12-30 17:18:58 +00:00
|
|
|
bool CheckModel(FTextureID tilenum, int pal)
|
2022-09-30 14:25:21 +00:00
|
|
|
{
|
|
|
|
return frameMap.CheckKey(FrameMapKey(tilenum, pal)) != nullptr;
|
|
|
|
}
|
2022-12-30 17:18:58 +00:00
|
|
|
ModelTileFrame* GetModel(FTextureID tilenum, int pal)
|
2022-09-30 14:25:21 +00:00
|
|
|
{
|
|
|
|
return frameMap.CheckKey(FrameMapKey(tilenum, pal));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
inline ModelManager modelManager;
|