diff --git a/Src/Graphics/New3D/New3D.cpp b/Src/Graphics/New3D/New3D.cpp index 25522ae..f73f6d0 100644 --- a/Src/Graphics/New3D/New3D.cpp +++ b/Src/Graphics/New3D/New3D.cpp @@ -869,7 +869,7 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data) currentMesh->height = ph.TexHeight(); currentMesh->mirrorU = ph.TexUMirror(); currentMesh->mirrorV = ph.TexVMirror(); - currentMesh->microTexture = ph.MicroTexture(); + currentMesh->microTexture = ph.MicroTexture(); } } @@ -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[2] = (GLfloat)(((INT32)iz) >> 8) * m_vertexFactor; - p.v[j].normal[0] = (INT8)(ix & 0xFF) / 128.f; - p.v[j].normal[1] = (INT8)(iy & 0xFF) / 128.f; - p.v[j].normal[2] = (INT8)(iz & 0xFF) / 128.f; + if (ph.SmoothShading()) { + p.v[j].normal[0] = (INT8)(ix & 0xFF) / 128.f; + p.v[j].normal[1] = (INT8)(iy & 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) { UINT32 colorIdx = ((ph.header[4] >> 8) & 0x7FF); @@ -940,7 +947,7 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data) p.v[j].color[0] = (UINT8)(p.v[j].color[0] * shade); p.v[j].color[1] = (UINT8)(p.v[j].color[1] * shade); p.v[j].color[2] = (UINT8)(p.v[j].color[2] * shade); - } + } if ((ph.header[6] & 0x00800000)) { // if set, polygon is opaque p.v[j].color[3] = 255; diff --git a/Src/Graphics/New3D/PolyHeader.cpp b/Src/Graphics/New3D/PolyHeader.cpp index 0404566..4507bf8 100644 --- a/Src/Graphics/New3D/PolyHeader.cpp +++ b/Src/Graphics/New3D/PolyHeader.cpp @@ -149,6 +149,11 @@ bool PolyHeader::FixedShading() return (header[1] & 0x20) > 0; } +bool PolyHeader::SmoothShading() +{ + return (header[1] & 0x8) > 0; +} + // // header 2 // diff --git a/Src/Graphics/New3D/PolyHeader.h b/Src/Graphics/New3D/PolyHeader.h index 74bdd08..5a2237b 100644 --- a/Src/Graphics/New3D/PolyHeader.h +++ b/Src/Graphics/New3D/PolyHeader.h @@ -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----- Fixed shading (seems to only be enabled if lighting is enabled) -------- -------- -------- ---x---- 1 = Double-sided polygon +-------- -------- -------- ----x--- 1 = smooth shading, 0 = flat shading -------- -------- -------- -----x-- If set, this is the last polygon -------- -------- -------- ------x- Poly color, 1 = RGB, 0 = color table --------- -------- -------- x---x--x ? +-------- -------- -------- x------x ? 0x02: xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Y coordinate(2.22 fixed point) -------- -------- -------- ---x---- Microtexture (aka multitexture) -------- -------- -------- ------x- Texture U 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: xxxxxxxx xxxxxxxx xxxxxxxx -------- Polygon normal Z coordinate(2.22 fixed point) @@ -97,6 +98,7 @@ public: bool LastPoly(); bool PolyColor(); // if false uses LUT from ram bool FixedShading(); + bool SmoothShading(); //header 2 bool TexUMirror();