2020-05-30 22:01:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "textureid.h"
|
|
|
|
#include "i_modelvertexbuffer.h"
|
2022-10-20 20:24:25 +00:00
|
|
|
#include "matrix.h"
|
2023-11-09 21:39:55 +00:00
|
|
|
#include "palettecontainer.h"
|
2022-11-06 10:46:26 +00:00
|
|
|
#include "TRS.h"
|
2023-12-10 12:30:50 +00:00
|
|
|
#include "tarray.h"
|
|
|
|
#include "name.h"
|
2020-05-30 22:01:00 +00:00
|
|
|
|
2022-11-06 10:46:26 +00:00
|
|
|
class DBoneComponents;
|
2020-05-30 22:01:00 +00:00
|
|
|
class FModelRenderer;
|
|
|
|
class FGameTexture;
|
|
|
|
class IModelVertexBuffer;
|
|
|
|
class FModel;
|
|
|
|
struct FSpriteModelFrame;
|
|
|
|
|
|
|
|
FTextureID LoadSkin(const char* path, const char* fn);
|
|
|
|
void FlushModels();
|
2022-07-23 10:05:27 +00:00
|
|
|
extern TArray<FString> savedModelFiles;
|
2020-05-30 22:01:00 +00:00
|
|
|
extern TDeletingArray<FModel*> Models;
|
|
|
|
extern TArray<FSpriteModelFrame> SpriteModelFrames;
|
2023-12-10 12:30:50 +00:00
|
|
|
extern TMap<void*, FSpriteModelFrame> BaseSpriteModelFrames;
|
2020-05-30 22:01:00 +00:00
|
|
|
|
|
|
|
#define MD3_MAX_SURFACES 32
|
2021-03-07 12:21:15 +00:00
|
|
|
#define MIN_MODELS 4
|
2020-05-30 22:01:00 +00:00
|
|
|
|
|
|
|
struct FSpriteModelFrame
|
|
|
|
{
|
2021-03-07 12:21:15 +00:00
|
|
|
uint8_t modelsAmount = 0;
|
|
|
|
TArray<int> modelIDs;
|
|
|
|
TArray<FTextureID> skinIDs;
|
|
|
|
TArray<FTextureID> surfaceskinIDs;
|
|
|
|
TArray<int> modelframes;
|
2022-10-20 20:24:25 +00:00
|
|
|
TArray<int> animationIDs;
|
2020-05-30 22:01:00 +00:00
|
|
|
float xscale, yscale, zscale;
|
|
|
|
// [BB] Added zoffset, rotation parameters and flags.
|
|
|
|
// Added xoffset, yoffset
|
|
|
|
float xoffset, yoffset, zoffset;
|
|
|
|
float xrotate, yrotate, zrotate;
|
|
|
|
float rotationCenterX, rotationCenterY, rotationCenterZ;
|
|
|
|
float rotationSpeed;
|
|
|
|
unsigned int flags;
|
|
|
|
const void* type; // used for hashing, must point to something usable as identifier for the model's owner.
|
|
|
|
short sprite;
|
|
|
|
short frame;
|
|
|
|
int hashnext;
|
|
|
|
float angleoffset;
|
|
|
|
// added pithoffset, rolloffset.
|
|
|
|
float pitchoffset, rolloffset; // I don't want to bother with type transformations, so I made this variables float.
|
|
|
|
bool isVoxel;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum ModelRendererType
|
|
|
|
{
|
|
|
|
GLModelRendererType,
|
|
|
|
SWModelRendererType,
|
|
|
|
PolyModelRendererType,
|
|
|
|
NumModelRendererTypes
|
|
|
|
};
|
|
|
|
|
2021-12-29 08:24:13 +00:00
|
|
|
enum EFrameError
|
|
|
|
{
|
|
|
|
FErr_NotFound = -1,
|
|
|
|
FErr_Voxel = -2,
|
|
|
|
FErr_Singleframe = -3
|
|
|
|
};
|
|
|
|
|
2020-05-30 22:01:00 +00:00
|
|
|
class FModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FModel();
|
|
|
|
virtual ~FModel();
|
|
|
|
|
|
|
|
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0;
|
2023-12-10 12:30:50 +00:00
|
|
|
|
2021-12-29 08:24:13 +00:00
|
|
|
virtual int FindFrame(const char * name, bool nodefault = false) = 0;
|
2023-12-10 12:30:50 +00:00
|
|
|
|
|
|
|
// [RL0] these are used for decoupled iqm animations
|
|
|
|
virtual int FindFirstFrame(FName name) { return FErr_NotFound; }
|
|
|
|
virtual int FindLastFrame(FName name) { return FErr_NotFound; }
|
|
|
|
virtual double FindFramerate(FName name) { return FErr_NotFound; }
|
|
|
|
|
2023-11-09 21:39:55 +00:00
|
|
|
virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, FTranslationID translation, const FTextureID* surfaceskinids, const TArray<VSMatrix>& boneData, int boneStartPosition) = 0;
|
2020-05-30 22:01:00 +00:00
|
|
|
virtual void BuildVertexBuffer(FModelRenderer *renderer) = 0;
|
2022-07-23 10:05:27 +00:00
|
|
|
virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) = 0;
|
2020-05-30 22:01:00 +00:00
|
|
|
virtual float getAspectFactor(float vscale) { return 1.f; }
|
2022-11-06 10:46:26 +00:00
|
|
|
virtual const TArray<TRS>* AttachAnimationData() { return nullptr; };
|
2023-12-10 12:30:50 +00:00
|
|
|
virtual const TArray<VSMatrix> CalculateBones(int frame1, int frame2, float inter, int frame1_prev, float inter1_prev, int frame2_prev, float inter2_prev, const TArray<TRS>* animationData, DBoneComponents* bones, int index) { return {}; };
|
2020-05-30 22:01:00 +00:00
|
|
|
|
|
|
|
void SetVertexBuffer(int type, IModelVertexBuffer *buffer) { mVBuf[type] = buffer; }
|
|
|
|
IModelVertexBuffer *GetVertexBuffer(int type) const { return mVBuf[type]; }
|
|
|
|
void DestroyVertexBuffer();
|
|
|
|
|
2022-09-30 14:25:21 +00:00
|
|
|
bool hasSurfaces = false;
|
2020-05-30 22:01:00 +00:00
|
|
|
FString mFileName;
|
2023-12-10 12:30:50 +00:00
|
|
|
|
|
|
|
FSpriteModelFrame *baseFrame;
|
2020-05-30 22:01:00 +00:00
|
|
|
private:
|
|
|
|
IModelVertexBuffer *mVBuf[NumModelRendererTypes];
|
|
|
|
};
|
|
|
|
|
|
|
|
int ModelFrameHash(FSpriteModelFrame* smf);
|
2022-09-30 14:25:21 +00:00
|
|
|
unsigned FindModel(const char* path, const char* modelfile, bool silent = false);
|
2020-05-30 22:01:00 +00:00
|
|
|
|