mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
Added SurfaceSkin MODELDEF property, allows overriding MD3 per-surface skins.
This commit is contained in:
parent
bc7b439dd0
commit
b3b2eb42c6
4 changed files with 59 additions and 3 deletions
|
@ -460,7 +460,7 @@ void gl_InitModels()
|
|||
{
|
||||
int Lump, lastLump;
|
||||
FString path;
|
||||
int index;
|
||||
int index, surface;
|
||||
int i;
|
||||
|
||||
FSpriteModelFrame smf;
|
||||
|
@ -696,6 +696,39 @@ void gl_InitModels()
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (sc.Compare("surfaceskin"))
|
||||
{
|
||||
sc.MustGetNumber();
|
||||
index = sc.Number;
|
||||
sc.MustGetNumber();
|
||||
surface = sc.Number;
|
||||
|
||||
if (index<0 || index >= MAX_MODELS_PER_FRAME)
|
||||
{
|
||||
sc.ScriptError("Too many models in %s", smf.type->TypeName.GetChars());
|
||||
}
|
||||
|
||||
if (surface<0 || index >= MD3_MAX_SURFACES)
|
||||
{
|
||||
sc.ScriptError("Invalid MD3 Surface %d in %s", MD3_MAX_SURFACES, smf.type->TypeName.GetChars());
|
||||
}
|
||||
|
||||
sc.MustGetString();
|
||||
FixPathSeperator(sc.String);
|
||||
if (sc.Compare(""))
|
||||
{
|
||||
smf.surfaceskinIDs[index][surface] = FNullTextureID();
|
||||
}
|
||||
else
|
||||
{
|
||||
smf.surfaceskinIDs[index][surface] = LoadSkin("", sc.String);
|
||||
if (!smf.surfaceskinIDs[index][surface].isValid())
|
||||
{
|
||||
Printf("Surface Skin '%s' not found in '%s'\n",
|
||||
sc.String, smf.type->TypeName.GetChars());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sc.Compare("frameindex") || sc.Compare("frame"))
|
||||
{
|
||||
bool isframe=!!sc.Compare("frame");
|
||||
|
@ -901,6 +934,8 @@ void gl_RenderFrameModels( const FSpriteModelFrame *smf,
|
|||
mdl->BuildVertexBuffer();
|
||||
gl_RenderState.SetVertexBuffer(mdl->mVBuf);
|
||||
|
||||
mdl->PushSpriteFrame(smf, i);
|
||||
|
||||
if ( smfNext && smf->modelframes[i] != smfNext->modelframes[i] )
|
||||
mdl->RenderFrame(tex, smf->modelframes[i], smfNext->modelframes[i], inter, translation);
|
||||
else
|
||||
|
|
|
@ -16,9 +16,12 @@ enum { VX, VZ, VY };
|
|||
#define DMD_MAGIC 0x4D444D44
|
||||
#define MD3_MAGIC 0x33504449
|
||||
#define NUMVERTEXNORMALS 162
|
||||
#define MD3_MAX_SURFACES 32
|
||||
|
||||
FTextureID LoadSkin(const char * path, const char * fn);
|
||||
|
||||
// [JM] Necessary forward declaration
|
||||
typedef struct FSpriteModelFrame FSpriteModelFrame;
|
||||
|
||||
class FModel
|
||||
{
|
||||
|
@ -42,6 +45,10 @@ public:
|
|||
}
|
||||
virtual float getAspectFactor() { return 1.f; }
|
||||
|
||||
const FSpriteModelFrame *curSpriteMDLFrame;
|
||||
int curMDLIndex;
|
||||
void PushSpriteFrame(const FSpriteModelFrame *smf, int index) { curSpriteMDLFrame = smf; curMDLIndex = index; };
|
||||
|
||||
FModelVertexBuffer *mVBuf;
|
||||
FString mFileName;
|
||||
};
|
||||
|
@ -347,6 +354,7 @@ struct FSpriteModelFrame
|
|||
{
|
||||
int modelIDs[MAX_MODELS_PER_FRAME];
|
||||
FTextureID skinIDs[MAX_MODELS_PER_FRAME];
|
||||
FTextureID surfaceskinIDs[MAX_MODELS_PER_FRAME][MD3_MAX_SURFACES];
|
||||
int modelframes[MAX_MODELS_PER_FRAME];
|
||||
float xscale, yscale, zscale;
|
||||
// [BB] Added zoffset, rotation parameters and flags.
|
||||
|
|
|
@ -319,6 +319,11 @@ void FMD3Model::AddSkins(BYTE *hitlist)
|
|||
{
|
||||
for (int i = 0; i < numSurfaces; i++)
|
||||
{
|
||||
if (curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid())
|
||||
{
|
||||
hitlist[curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].GetIndex()] |= FTexture::TEX_Flat;
|
||||
}
|
||||
|
||||
MD3Surface * surf = &surfaces[i];
|
||||
for (int j = 0; j < surf->numSkins; j++)
|
||||
{
|
||||
|
@ -365,8 +370,15 @@ void FMD3Model::RenderFrame(FTexture * skin, int frameno, int frameno2, double i
|
|||
FTexture *surfaceSkin = skin;
|
||||
if (!surfaceSkin)
|
||||
{
|
||||
if (surf->numSkins==0 || !surf->skins[0].isValid()) return;
|
||||
if (curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid())
|
||||
{
|
||||
surfaceSkin = TexMan(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i]);
|
||||
}
|
||||
else if(surf->numSkins > 0 && surf->skins[0].isValid())
|
||||
{
|
||||
surfaceSkin = TexMan(surf->skins[0]);
|
||||
}
|
||||
|
||||
if (!surfaceSkin) return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1113,6 +1113,7 @@ void FGLInterface::Precache(BYTE *texhitlist, TMap<PClassActor*, bool> &actorhit
|
|||
}
|
||||
else if (smf->modelIDs[i] != -1)
|
||||
{
|
||||
Models[smf->modelIDs[i]]->PushSpriteFrame(smf, i);
|
||||
Models[smf->modelIDs[i]]->AddSkins(texhitlist);
|
||||
}
|
||||
if (smf->modelIDs[i] != -1)
|
||||
|
|
Loading…
Reference in a new issue