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/
This commit is contained in:
Robert Osfield
2009-04-24 10:56:45 +00:00
parent b2e40572e5
commit aab533c046

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;
}