mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-18 14:41:40 +00:00
- consider pixel stretching when rendering models. For non-voxels an aspect ratio of 1:1 must always be assumed while voxels need to be stretched so that 1 voxel unit == 1 map unit.
This commit is contained in:
parent
e6d59ec429
commit
4f08b20df5
5 changed files with 20 additions and 7 deletions
|
@ -915,6 +915,12 @@ void gl_RenderModel(GLSprite * spr)
|
|||
gl_RenderState.mModelMatrix.rotate(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0);
|
||||
gl_RenderState.mModelMatrix.rotate(smf->pitchoffset, 0, 0, 1);
|
||||
gl_RenderState.mModelMatrix.rotate(-smf->rolloffset, 1, 0, 0);
|
||||
|
||||
// consider the pixel stretching. For non-voxels this must be factored out here
|
||||
float stretch = (smf->models[0] != NULL ? smf->models[0]->getAspectFactor() : 1.f) / glset.pixelstretch;
|
||||
gl_RenderState.mModelMatrix.scale(1, stretch, 1);
|
||||
|
||||
|
||||
gl_RenderState.EnableModelMatrix(true);
|
||||
gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), NULL, translation );
|
||||
gl_RenderState.EnableModelMatrix(false);
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
enum { VX, VZ, VY };
|
||||
|
||||
static const float rModelAspectMod = 1 / 1.2f; //.833334f;
|
||||
|
||||
#define MD2_MAGIC 0x32504449
|
||||
#define DMD_MAGIC 0x4D444D44
|
||||
#define MD3_MAGIC 0x33504449
|
||||
|
@ -35,6 +33,7 @@ public:
|
|||
virtual int FindFrame(const char * name) = 0;
|
||||
virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0;
|
||||
virtual void BuildVertexBuffer() = 0;
|
||||
virtual float getAspectFactor() { return 1.f; }
|
||||
|
||||
FModelVertexBuffer *mVBuf;
|
||||
FString mFileName;
|
||||
|
@ -298,6 +297,7 @@ public:
|
|||
virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0);
|
||||
FTexture *GetPaletteTexture() const { return mPalette; }
|
||||
void BuildVertexBuffer();
|
||||
float getAspectFactor();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -186,8 +186,6 @@ bool FDMDModel::Load(const char * path, int, const char * buffer, int length)
|
|||
frame->vertices[k].xyz[axis[c]] =
|
||||
(pVtx->vertex[c] * FLOAT(pfr->scale[c]) + FLOAT(pfr->translate[c]));
|
||||
}
|
||||
// Aspect undo.
|
||||
frame->vertices[k].xyz[VZ] *= rModelAspectMod;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -467,8 +465,6 @@ bool FMD2Model::Load(const char * path, int, const char * buffer, int length)
|
|||
frame->vertices[k].xyz[axis[c]] =
|
||||
(pVtx->vertex[c] * pfr->scale[c] + pfr->translate[c]);
|
||||
}
|
||||
// Aspect ratio adjustment (1.33 -> 1.6.)
|
||||
frame->vertices[k].xyz[VZ] *= rModelAspectMod;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ bool FMD3Model::Load(const char * path, int, const char * buffer, int length)
|
|||
{
|
||||
s->vertices[i].x = LittleShort(vt[i].x)/64.f;
|
||||
s->vertices[i].y = LittleShort(vt[i].y)/64.f;
|
||||
s->vertices[i].z = LittleShort(vt[i].z)/64.f * rModelAspectMod;
|
||||
s->vertices[i].z = LittleShort(vt[i].z)/64.f;
|
||||
UnpackVector( LittleShort(vt[i].n), s->vertices[i].nx, s->vertices[i].ny, s->vertices[i].nz);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -420,6 +420,17 @@ int FVoxelModel::FindFrame(const char * name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Voxels need aspect ratio correction according to the current map's setting
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
float FVoxelModel::getAspectFactor()
|
||||
{
|
||||
return glset.pixelstretch;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Voxels never interpolate between frames, they only have one.
|
||||
|
|
Loading…
Reference in a new issue