⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 daewgeometry.cpp

📁 最新osg包
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                            polylist->setCount( polylist->getCount() + nbPolygons);                        }                        break;                    }                }                unsigned int indexBegin = drawArray->getFirst();                unsigned int nbVerticesPerPoly=(indexEnd-indexBegin)/p.size();                unsigned int indexPolyEnd = indexBegin+nbVerticesPerPoly;                for( unsigned int iPoly = 0; iPoly < p.size(); ++iPoly )                {                    for (unsigned int vindex=indexBegin; vindex< indexPolyEnd;vindex++)                    {                       appendGeometryIndices(geom,p[iPoly],vindex,                                     norm,color,                                     verts,normals,colors,texcoords,                                     ncount,ccount);                       if ( vcount % primLength == 0 )                       {                         if ( geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE )                         {                           ncount++;                         }                         if ( geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE )                         {                           ccount++;                         }                       }                       vcount++;                    }                    indexBegin+=nbVerticesPerPoly;                    indexPolyEnd+=nbVerticesPerPoly;                }                break;            }            //(primitive type) + (end1),(end2),(end3)...            case osg::PrimitiveSet::DrawArrayLengthsPrimitiveType:            {                //osg::notify( osg::WARN ) << "DrawArrayLengths" << std::endl;                osg::DrawArrayLengths* drawArrayLengths = static_cast<osg::DrawArrayLengths*>( ps );                unsigned int vindex = drawArrayLengths->getFirst();                for( osg::DrawArrayLengths::iterator primItr = drawArrayLengths->begin();                    primItr != drawArrayLengths->end();                    ++primItr )                {                    unsigned int localPrimLength;                    if ( primLength == 0 ) localPrimLength = *primItr;                    else localPrimLength = primLength;                    std::vector<domP *> p;                    switch ( mode )                    {                        case GL_LINES:                        {                            p.push_back(lines->getP());                            lines->setCount( lines->getCount() + (*primItr)/localPrimLength );                            break;                        }                        case GL_TRIANGLES:                        {                            p.push_back(tris->getP());                            tris->setCount( tris->getCount() + (*primItr)/localPrimLength );                            break;                        }                        case GL_LINE_STRIP:                        {                            p.push_back(daeSafeCast<domP>( linestrips->createAndPlace( COLLADA_ELEMENT_P ) ));                            linestrips->setCount( linestrips->getCount() + 1 );                            break;                        }                        case GL_TRIANGLE_STRIP:                        {                            p.push_back(daeSafeCast<domP>( tristrips->createAndPlace( COLLADA_ELEMENT_P ) ));                            tristrips->setCount( tristrips->getCount() + 1 );                            break;                        }                        case GL_TRIANGLE_FAN:                        {                            p.push_back(daeSafeCast<domP>( trifans->createAndPlace( COLLADA_ELEMENT_P ) ));                            trifans->setCount( trifans->getCount() + 1 );                            break;                        }                        default:                                   {                            if (usePolygons)                            {                                //for( unsigned int idx = 0; idx < nbPolygons; ++idx )                                p.push_back(polys->getP_array()[0]);                                polys->setCount( polys->getCount() + 1 );                            }                            else                            {                                polylist->getVcount()->getValue().append( localPrimLength );                                p.push_back(polylist->getP());                                polylist->setCount( polylist->getCount() + 1);                            }                            break;                        }                    }                    unsigned int indexBegin = 0;                    unsigned int nbVerticesPerPoly=*primItr/p.size();                    unsigned int indexEnd=indexBegin+nbVerticesPerPoly;                    for( unsigned int iPoly = 0; iPoly < p.size(); ++iPoly )                    {                       // printf("indexBegin %d,indexPolyEnd %d \n",indexBegin,indexEnd);                       for( unsigned int primCount = indexBegin; primCount < indexEnd; ++primCount )                        {                          appendGeometryIndices(geom,p[iPoly],vindex,                                           norm,color,                                           verts,normals,colors,texcoords,                                           ncount,ccount);                                                    if ( primCount % localPrimLength == 0 )                                                  {                             if ( geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE )                              {                                    ncount++;                             }                             if ( geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE )                              {                                    ccount++;                             }                          }                                             vindex++;                       }                       indexBegin+=nbVerticesPerPoly;                       indexEnd+=nbVerticesPerPoly;                       }                }                break;            }            //draw elements (array of shared vertices + array of indices)           case osg::PrimitiveSet::DrawElementsUBytePrimitiveType:                     {                //osg::notify( osg::WARN ) << "DrawElementsUByte" << std::endl;                if ( primLength == 0 ) primLength = ps->getNumIndices();                osg::DrawElementsUByte* drawElements = static_cast<osg::DrawElementsUByte*>( ps );                                std::vector<domP *> p;                switch ( mode )                {                    case GL_LINES:                    {                        p.push_back(lines->getP());                        lines->setCount( lines->getCount() + drawElements->size()/primLength );                        break;                    }                    case GL_TRIANGLES:                    {                        p.push_back(tris->getP());                        tris->setCount( tris->getCount() + drawElements->size()/primLength );                        break;                    }                    case GL_LINE_STRIP:                    {                        p.push_back(daeSafeCast<domP>( linestrips->createAndPlace( COLLADA_ELEMENT_P ) ));                        linestrips->setCount( linestrips->getCount() + 1 );                        break;                    }                    case GL_TRIANGLE_STRIP:                    {                        p.push_back(daeSafeCast<domP>( tristrips->createAndPlace( COLLADA_ELEMENT_P ) ));                        tristrips->setCount( tristrips->getCount() + 1 );                        break;                    }                    case GL_TRIANGLE_FAN:                    {                        p.push_back(daeSafeCast<domP>( trifans->createAndPlace( COLLADA_ELEMENT_P ) ));                        trifans->setCount( trifans->getCount() + 1 );                        break;                    }                    default:                               {                        unsigned int nbPolygons=drawElements->size()/primLength;                        if (usePolygons)                        {                            //for( unsigned int idx = 0; idx < nbPolygons; ++idx ) /*idx*/                            //huh ? why only one ?                            p.push_back(polys->getP_array()[0]);                            polys->setCount( polys->getCount() + nbPolygons );                        }                        else                        {                            polylist->getVcount()->getValue().append( primLength );                            p.push_back(polylist->getP());                            polylist->setCount( polylist->getCount() + nbPolygons );                        }                        break;                    }                }                unsigned int primCount = 0;                osg::DrawElementsUByte::iterator primItrBegin = drawElements->begin();                unsigned int nbVerticesPerPoly= drawElements->size()/p.size();                osg::DrawElementsUByte::iterator primItrEnd=primItrBegin+nbVerticesPerPoly;                for( unsigned int iPoly = 0; iPoly < p.size(); ++iPoly )                {                    for( osg::DrawElementsUByte::iterator primItr = primItrBegin;primItr != primItrEnd;                    ++primCount, ++primItr )                    {                        unsigned int vindex = *primItr;                            appendGeometryIndices(geom,p[iPoly],vindex,                                              norm,color,                                              verts,normals,colors,texcoords,                                              ncount,ccount);                                                if ( primCount % primLength == 0 )                        {                            if ( geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE )                            {                              ncount++;                            }                            if ( geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE )                            {                              ccount++;                            }                        }                    }                    primItrBegin+=nbVerticesPerPoly;#if ( _SECURE_SCL == 1 )                    if (primItrBegin != drawElements->end())#endif                    primItrEnd+=nbVerticesPerPoly;                }                break;            }            case osg::PrimitiveSet::DrawElementsUShortPrimitiveType:            {                //osg::notify( osg::WARN ) << "DrawElementsUShort" << std::endl;                if ( primLength == 0 ) primLength = ps->getNumIndices();                osg::DrawElementsUShort* drawElements = static_cast<osg::DrawElementsUShort*>( ps );                                                std::vector<domP *> p;                switch ( mode )                {                    case GL_LINES:                    {                        p.push_back(lines->getP());                        lines->setCount( lines->getCount() + drawElements->size()/primLength );                        break;                    }                    case GL_TRIANGLES:                    {                        p.push_back(tris->getP());                        tris->setCount( tris->getCount() + drawElements->size()/primLength );                        break;                    }                    case GL_LINE_STRIP:                    {                        p.push_back(daeSafeCast<domP>( linestrips->createAndPlace( COLLADA_ELEMENT_P ) ));                        linestrips->setCount( linestrips->getCount() + 1 );                        break;                    }                    case GL_TRIANGLE_STRIP:                    {                        p.push_back(daeSafeCast<domP>( tristrips->createAndPlace( COLLADA_ELEMENT_P ) ));                        tristrips->setCount( tristrips->getCount() + 1 );                        break;                    }                    case GL_TRIANGLE_FAN:                    {                        p.push_back(daeSafeCast<domP>( trifans->createAndPlace( COLLADA_ELEMENT_P ) ));                        trifans->setCount( trifans->getCount() + 1 );                        break;                    }                    default:                               {                        unsigned int nbPolygons=drawElements->size()/primLength;                        if (usePolygons)                        {                            //for( unsigned int idx = 0; idx < nbPolygons; ++idx ) /*idx*/                            //huh ? why only one ?                            p.push_back(polys->getP_array()[0]);                            polys->setCount( polys->getCount() + nbPolygons );                        }                        else                        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -