mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-01 05:20:43 +00:00
- allow FModel::FindFrame to not pick a default.
This commit is contained in:
parent
4d423004e9
commit
8aa96777b0
12 changed files with 30 additions and 20 deletions
|
@ -155,12 +155,13 @@ unsigned FindModel(const char * path, const char * modelfile)
|
|||
FModel * model = nullptr;
|
||||
FString fullname;
|
||||
|
||||
fullname.Format("%s%s", path, modelfile);
|
||||
if (path) fullname.Format("%s%s", path, modelfile);
|
||||
else fullname = modelfile;
|
||||
int lump = fileSystem.CheckNumForFullName(fullname);
|
||||
|
||||
if (lump<0)
|
||||
{
|
||||
Printf("FindModel: '%s' not found\n", fullname.GetChars());
|
||||
Printf(PRINT_HIGH, "FindModel: '%s' not found\n", fullname.GetChars());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -226,7 +227,7 @@ unsigned FindModel(const char * path, const char * modelfile)
|
|||
}
|
||||
else
|
||||
{
|
||||
Printf("LoadModel: Unknown model format in '%s'\n", fullname.GetChars());
|
||||
Printf(PRINT_HIGH, "LoadModel: Unknown model format in '%s'\n", fullname.GetChars());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,13 @@ enum ModelRendererType
|
|||
NumModelRendererTypes
|
||||
};
|
||||
|
||||
enum EFrameError
|
||||
{
|
||||
FErr_NotFound = -1,
|
||||
FErr_Voxel = -2,
|
||||
FErr_Singleframe = -3
|
||||
};
|
||||
|
||||
class FModel
|
||||
{
|
||||
public:
|
||||
|
@ -60,7 +67,7 @@ public:
|
|||
virtual ~FModel();
|
||||
|
||||
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0;
|
||||
virtual int FindFrame(const char * name) = 0;
|
||||
virtual int FindFrame(const char * name, bool nodefault = false) = 0;
|
||||
virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) = 0;
|
||||
virtual void BuildVertexBuffer(FModelRenderer *renderer) = 0;
|
||||
virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) = 0;
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
~FVoxelModel();
|
||||
bool Load(const char * fn, int lumpnum, const char * buffer, int length) override;
|
||||
void Initialize();
|
||||
virtual int FindFrame(const char * name) override;
|
||||
virtual int FindFrame(const char * name, bool nodefault) override;
|
||||
virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) override;
|
||||
virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) override;
|
||||
FTextureID GetPaletteTexture() const { return mPalette; }
|
||||
|
|
|
@ -112,7 +112,7 @@ public:
|
|||
virtual ~FDMDModel();
|
||||
|
||||
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) override;
|
||||
virtual int FindFrame(const char * name) override;
|
||||
virtual int FindFrame(const char * name, bool nodefault) override;
|
||||
virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) override;
|
||||
virtual void LoadGeometry();
|
||||
virtual void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) override;
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
FMD3Model() = default;
|
||||
|
||||
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) override;
|
||||
virtual int FindFrame(const char * name) override;
|
||||
virtual int FindFrame(const char * name, bool nodefault) override;
|
||||
virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) override;
|
||||
void LoadGeometry();
|
||||
void BuildVertexBuffer(FModelRenderer *renderer);
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
FOBJModel(): hasMissingNormals(false), hasSmoothGroups(false), vertFaces(nullptr) {}
|
||||
~FOBJModel();
|
||||
bool Load(const char* fn, int lumpnum, const char* buffer, int length) override;
|
||||
int FindFrame(const char* name) override;
|
||||
int FindFrame(const char* name, bool nodefault) override;
|
||||
void RenderFrame(FModelRenderer* renderer, FGameTexture* skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) override;
|
||||
void BuildVertexBuffer(FModelRenderer* renderer) override;
|
||||
void AddSkins(uint8_t* hitlist, const FTextureID* surfaceskinids) override;
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
};
|
||||
|
||||
bool Load(const char * fn, int lumpnum, const char * buffer, int length) override;
|
||||
int FindFrame(const char * name) override;
|
||||
int FindFrame(const char * name, bool nodefault) override;
|
||||
void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids) override;
|
||||
void BuildVertexBuffer(FModelRenderer *renderer) override;
|
||||
void AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids) override;
|
||||
|
|
|
@ -348,13 +348,13 @@ void FDMDModel::AddSkins(uint8_t *hitlist, const FTextureID*)
|
|||
// FDMDModel::FindFrame
|
||||
//
|
||||
//===========================================================================
|
||||
int FDMDModel::FindFrame(const char * name)
|
||||
int FDMDModel::FindFrame(const char * name, bool nodefault)
|
||||
{
|
||||
for (int i=0;i<info.numFrames;i++)
|
||||
{
|
||||
if (!stricmp(name, frames[i].name)) return i;
|
||||
}
|
||||
return -1;
|
||||
return FErr_NotFound;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -328,13 +328,13 @@ void FMD3Model::AddSkins(uint8_t *hitlist, const FTextureID* surfaceskinids)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FMD3Model::FindFrame(const char * name)
|
||||
int FMD3Model::FindFrame(const char * name, bool nodefault)
|
||||
{
|
||||
for (unsigned i = 0; i < Frames.Size(); i++)
|
||||
{
|
||||
if (!stricmp(name, Frames[i].Name)) return i;
|
||||
}
|
||||
return -1;
|
||||
return FErr_NotFound;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -613,9 +613,9 @@ FVector3 FOBJModel::CalculateNormalSmooth(unsigned int vidx, unsigned int smooth
|
|||
* @param name The name of the frame
|
||||
* @return The index of the frame
|
||||
*/
|
||||
int FOBJModel::FindFrame(const char* name)
|
||||
int FOBJModel::FindFrame(const char* name, bool nodefault)
|
||||
{
|
||||
return 0; // OBJs are not animated.
|
||||
return nodefault? FErr_Singleframe : 0; // OBJs are not animated.
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -221,10 +221,12 @@ void FUE1Model::UnloadGeometry()
|
|||
groups.Reset();
|
||||
}
|
||||
|
||||
int FUE1Model::FindFrame( const char *name )
|
||||
int FUE1Model::FindFrame( const char *name, bool nodefault )
|
||||
{
|
||||
// unsupported, there are no named frames
|
||||
return -1;
|
||||
// there are no named frames, but we need something here to properly interface with it. So just treat the string as an index number.
|
||||
auto index = strtol(name, nullptr, 0);
|
||||
if (index < 0 || index >= numFrames) return FErr_NotFound;
|
||||
return index;
|
||||
}
|
||||
|
||||
void FUE1Model::RenderFrame( FModelRenderer *renderer, FGameTexture *skin, int frame, int frame2, double inter, int translation, const FTextureID* surfaceskinids)
|
||||
|
|
|
@ -378,9 +378,9 @@ bool FVoxelModel::Load(const char * fn, int lumpnum, const char * buffer, int le
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FVoxelModel::FindFrame(const char * name)
|
||||
int FVoxelModel::FindFrame(const char * name, bool nodefault)
|
||||
{
|
||||
return 0;
|
||||
return nodefault? FErr_Voxel : 0; // -2, not -1 because voxels are special.
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
Loading…
Reference in a new issue