From Jason Daly, "Currently, the .mdl plugin loads vertices in the native DirectX order, which is the reverse of OpenGL order. This means that the back faces are currently rendered as front faces, and vice versa.

This fix reverses the vertex order and sets up proper OpenGL facing.  I didn't notice this problem until I started using the plug-in in my own code (osgviewer seems to not enable backface culling)."
This commit is contained in:
Robert Osfield
2009-04-24 10:54:50 +00:00
parent 7b16ff5ae1
commit d91e9db152

View File

@@ -328,6 +328,7 @@ ref_ptr<PrimitiveSet> VTXReader::processStrip(unsigned short * indexArray,
int offset)
{
VTXStrip strip;
DrawElementsUShort * drawElements;
ref_ptr<PrimitiveSet> primSet;
unsigned short * start;
unsigned short * end;
@@ -348,13 +349,17 @@ ref_ptr<PrimitiveSet> VTXReader::processStrip(unsigned short * indexArray,
// Create the primitive set (based on the flag)
if (strip.strip_flags & STRIP_IS_TRI_LIST)
primSet =
drawElements =
new DrawElementsUShort(PrimitiveSet::TRIANGLES, start, end);
else
primSet =
drawElements =
new DrawElementsUShort(PrimitiveSet::TRIANGLE_STRIP, start, end);
// Flip the indices to get the front faces correct
std::reverse(drawElements->begin(), drawElements->end());
// Return the primitive set
primSet = drawElements;
return primSet;
}