support flat shading

This commit is contained in:
Ian Curtis 2016-05-05 00:01:17 +00:00
parent 3693a51cbb
commit b2da849d90
3 changed files with 21 additions and 7 deletions

View file

@ -912,9 +912,16 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data)
p.v[j].pos[1] = (GLfloat)(((INT32)iy) >> 8) * m_vertexFactor; p.v[j].pos[1] = (GLfloat)(((INT32)iy) >> 8) * m_vertexFactor;
p.v[j].pos[2] = (GLfloat)(((INT32)iz) >> 8) * m_vertexFactor; p.v[j].pos[2] = (GLfloat)(((INT32)iz) >> 8) * m_vertexFactor;
if (ph.SmoothShading()) {
p.v[j].normal[0] = (INT8)(ix & 0xFF) / 128.f; p.v[j].normal[0] = (INT8)(ix & 0xFF) / 128.f;
p.v[j].normal[1] = (INT8)(iy & 0xFF) / 128.f; p.v[j].normal[1] = (INT8)(iy & 0xFF) / 128.f;
p.v[j].normal[2] = (INT8)(iz & 0xFF) / 128.f; p.v[j].normal[2] = (INT8)(iz & 0xFF) / 128.f;
}
else {
p.v[j].normal[0] = p.faceNormal[0];
p.v[j].normal[1] = p.faceNormal[1];
p.v[j].normal[2] = p.faceNormal[2];
}
if ((ph.header[1] & 2) == 0) { if ((ph.header[1] & 2) == 0) {
UINT32 colorIdx = ((ph.header[4] >> 8) & 0x7FF); UINT32 colorIdx = ((ph.header[4] >> 8) & 0x7FF);

View file

@ -149,6 +149,11 @@ bool PolyHeader::FixedShading()
return (header[1] & 0x20) > 0; return (header[1] & 0x20) > 0;
} }
bool PolyHeader::SmoothShading()
{
return (header[1] & 0x8) > 0;
}
// //
// header 2 // header 2
// //

View file

@ -23,16 +23,17 @@ xxxxxxxx xxxxxxxx xxxxxxxx-------- Polygon normal X coordinate(2.22 fixed point
-------- -------- -------- -x------ UV scale (0 = 13.3, 1 = 16.0) -------- -------- -------- -x------ UV scale (0 = 13.3, 1 = 16.0)
-------- -------- -------- --x----- Fixed shading (seems to only be enabled if lighting is enabled) -------- -------- -------- --x----- Fixed shading (seems to only be enabled if lighting is enabled)
-------- -------- -------- ---x---- 1 = Double-sided polygon -------- -------- -------- ---x---- 1 = Double-sided polygon
-------- -------- -------- ----x--- 1 = smooth shading, 0 = flat shading
-------- -------- -------- -----x-- If set, this is the last polygon -------- -------- -------- -----x-- If set, this is the last polygon
-------- -------- -------- ------x- Poly color, 1 = RGB, 0 = color table -------- -------- -------- ------x- Poly color, 1 = RGB, 0 = color table
-------- -------- -------- x---x--x ? -------- -------- -------- x------x ?
0x02: 0x02:
xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Y coordinate(2.22 fixed point) xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Y coordinate(2.22 fixed point)
-------- -------- -------- ---x---- Microtexture (aka multitexture) -------- -------- -------- ---x---- Microtexture (aka multitexture)
-------- -------- -------- ------x- Texture U mirror enable -------- -------- -------- ------x- Texture U mirror enable
-------- -------- -------- -------x Texture V mirror enable -------- -------- -------- -------x Texture V mirror enable
-------- -------- -------- xxx-xx-- I think first 3 bits might be microtex number 0-7, next 2 maybe UV un-smooth wrap -------- -------- -------- xxx-xx-- ?
0x03: 0x03:
xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Z coordinate(2.22 fixed point) xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Z coordinate(2.22 fixed point)
@ -97,6 +98,7 @@ public:
bool LastPoly(); bool LastPoly();
bool PolyColor(); // if false uses LUT from ram bool PolyColor(); // if false uses LUT from ram
bool FixedShading(); bool FixedShading();
bool SmoothShading();
//header 2 //header 2
bool TexUMirror(); bool TexUMirror();