From aab533c04671f7c35258f15921baff57dc2fa8a1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 24 Apr 2009 10:56:45 +0000 Subject: [PATCH] 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)." merged from svn/trunk using: svn merge -r 10092:10093 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk/src/osgPlugins/mdl/ --- src/osgPlugins/mdl/VTXReader.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/osgPlugins/mdl/VTXReader.cpp b/src/osgPlugins/mdl/VTXReader.cpp index f47189a06..ffb9d45f3 100644 --- a/src/osgPlugins/mdl/VTXReader.cpp +++ b/src/osgPlugins/mdl/VTXReader.cpp @@ -328,6 +328,7 @@ ref_ptr VTXReader::processStrip(unsigned short * indexArray, int offset) { VTXStrip strip; + DrawElementsUShort * drawElements; ref_ptr primSet; unsigned short * start; unsigned short * end; @@ -348,13 +349,17 @@ ref_ptr 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; }