PDA

View Full Version : Flat shading with vertex arrays



gimp
08-27-2001, 01:29 AM
I have generated my normals in the following fashion:

CVector Edge_01 = m_Model->Vertices[Point1] - m_Model->Vertices[Point0];
CVector Edge_12 = m_Model->Vertices[Point2] - m_Model->Vertices[Point1];
CVector Edge_20 = m_Model->Vertices[Point0] - m_Model->Vertices[Point2];
CVector Normal = Edge_01.Cross(Edge_12);

m_Model->Normals[Point0] += ACos(Edge_20.Dot(Edge_01)) * Normal;
m_Model->Normals[Point1] += ACos(Edge_01.Dot(Edge_12)) * Normal;
m_Model->Normals[Point2] += ACos(Edge_12.Dot(Edge_20)) * Normal;

When smooth shading these appear as they should however when I switch the shading mode to flat, boxy objects appear to have every second triangle black...

Any thoughts?

Many thanks

Chris