• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ osg::Geometry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中osg::Geometry的典型用法代码示例。如果您正苦于以下问题:C++ Geometry类的具体用法?C++ Geometry怎么用?C++ Geometry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Geometry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: apply

void OBJWriterNodeVisitor::apply(osg::Geometry& geometry)
{
    osg::Matrix m = osg::computeLocalToWorld(getNodePath());

    pushStateSet(geometry.getStateSet());

    processGeometry(&geometry,m);

    popStateSet(geometry.getStateSet());
}
开发者ID:aitormoreno,项目名称:OpenSceneGraph,代码行数:10,代码来源:OBJWriterNodeVisitor.cpp


示例2: apply

void KdTreeBuilder::apply(osg::Geometry& geometry)
{
    osg::KdTree* previous = dynamic_cast<osg::KdTree*>(geometry.getShape());
    if (previous) return;

    osg::ref_ptr<osg::KdTree> kdTree = osg::clone(_kdTreePrototype.get());

    if (kdTree->build(_buildOptions, &geometry))
    {
        geometry.setShape(kdTree.get());
    }
}
开发者ID:AlexBobkov,项目名称:OpenSceneGraph,代码行数:12,代码来源:KdTree.cpp


示例3:

bool
FltExportVisitor::atLeastOneMesh( const osg::Geometry& geom ) const
{
    // Return true if at least one PrimitiveSet mode will use a Mesh record.
    unsigned int jdx;
    for (jdx=0; jdx < geom.getNumPrimitiveSets(); jdx++)
    {
        const osg::PrimitiveSet* prim = geom.getPrimitiveSet( jdx );
        if( isMesh( prim->getMode() ) )
            return true;
    }
    // All PrimitiveSet modes will use Face records.
    return false;
}
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:14,代码来源:expGeometryRecords.cpp


示例4: deleteFaces

void deleteFaces(osg::Geometry& geometry)
{
    geometry.removePrimitiveSet(0, geometry.getNumPrimitiveSets());

    auto _vertices = detail::getOrCreateVertexArray(geometry);
    auto _normals = detail::getOrCreateNormalArray(geometry);
    auto _colors = detail::getOrCreateColorArray(geometry);

    _vertices->clear();
    _normals->clear();
    _colors->clear();

    _vertices->dirty();
    _normals->dirty();
    _colors->dirty();
}
开发者ID:kloffy,项目名称:osgKaleido,代码行数:16,代码来源:PolyhedronGeometry.cpp


示例5: simplify

void DrawElementTypeSimplifier::simplify(osg::Geometry & geometry) const
{
    osg::Geometry::PrimitiveSetList & psl = geometry.getPrimitiveSetList();
    osg::Geometry::PrimitiveSetList::iterator it, end = psl.end();

    unsigned int max = 0;

    for (it = psl.begin(); it!=end; ++it)
    {
        switch ((*it)->getType())
        {
            case osg::PrimitiveSet::DrawElementsUShortPrimitiveType:
            {
                osg::DrawElementsUShort & de = *static_cast<osg::DrawElementsUShort*>(it->get());

                max = getMax<osg::DrawElementsUShort>(de);
                if (max < 255) *it = copy<osg::DrawElementsUShort, osg::DrawElementsUByte>(de);

                break;
            }
            case osg::PrimitiveSet::DrawElementsUIntPrimitiveType:
            {
                osg::DrawElementsUInt & de = *static_cast<osg::DrawElementsUInt*>(it->get());

                max = getMax<osg::DrawElementsUInt>(de);
                if (max < 256) *it = copy<osg::DrawElementsUInt, osg::DrawElementsUByte>(de);
                else if (max < 65536) *it = copy<osg::DrawElementsUInt, osg::DrawElementsUShort>(de);

                break;
            }
            default: break;
        }
    }
}
开发者ID:yueying,项目名称:osg,代码行数:34,代码来源:DrawElementTypeSimplifier.cpp


示例6: numLayers

void
FltExportVisitor::writeUVList( int numVerts, const osg::Geometry& geom )
{
    unsigned int numLayers( 0 );
    uint32 flags( 0 );
    unsigned int idx;
    for( idx=1; idx<8; idx++)
    {
        if( isTextured( idx, geom ) )
        {
            flags |= LAYER_1 >> (idx-1);
            numLayers++;
        }
    }
    if( numLayers == 0 )
        return;

    uint16 length( 8 + (8*numLayers*numVerts) );

    _records->writeInt16( (int16) UV_LIST_OP );
    _records->writeUInt16( length );
    _records->writeInt32( flags );

    osg::Vec2 defaultCoord( 0., 0. );
    // const osg::StateSet* ss = getCurrentStateSet();
    for( idx=1; idx<8; idx++)
    {
        if( isTextured( idx, geom ) )
        {
            osg::Array* t = const_cast<osg::Array*>( geom.getTexCoordArray( idx ) );
            osg::ref_ptr<osg::Vec2Array> t2 = dynamic_cast<osg::Vec2Array*>( t );
            if (!t2.valid())
            {
                std::ostringstream warning;
                warning << "fltexp: No Texture2D for unit " << idx;
                osg::notify( osg::WARN ) << warning.str() << std::endl;
                _fltOpt->getWriteResult().warn( warning.str() );
                t2 = new osg::Vec2Array;
            }
            else if (static_cast<int>(t2->getNumElements()) != numVerts)
            {
                std::ostringstream warning;
                warning << "fltexp: Invalid number of texture coordinates for unit " << idx;
                osg::notify( osg::WARN ) << warning.str() << std::endl;
                _fltOpt->getWriteResult().warn( warning.str() );
            }

            const int size = t2->getNumElements();
            int vIdx;
            for( vIdx=0; vIdx<numVerts; vIdx++)
            {
                osg::Vec2& tc( defaultCoord );
                if (vIdx < size)
                    tc = (*t2)[ vIdx ];
                _records->writeFloat32( tc[0] );
                _records->writeFloat32( tc[1] );
            }
        }
    }
}
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:60,代码来源:expGeometryRecords.cpp


示例7: subdivide

void
MeshSubdivider::run(osg::Geometry& geom, double granularity, GeoInterpolation interp)
{
    if ( geom.getNumPrimitiveSets() < 1 )
        return;

    subdivide( granularity, interp, geom, _world2local, _local2world, _maxElementsPerEBO );
}
开发者ID:mysticbob,项目名称:osgearth,代码行数:8,代码来源:MeshSubdivider.cpp


示例8: createDAIGeometry

void
createDAIGeometry( osg::Geometry& geom, int nInstances=1 )
{
    const float halfDimX( .5 );
    const float halfDimZ( .5 );

    osg::Vec3Array* v = new osg::Vec3Array;
    v->resize( 4 );
    geom.setVertexArray( v );

    // Geometry for a single quad.
    (*v)[ 0 ] = osg::Vec3( -halfDimX, 0., -halfDimZ );
    (*v)[ 1 ] = osg::Vec3( halfDimX, 0., -halfDimZ );
    (*v)[ 2 ] = osg::Vec3( halfDimX, 0., halfDimZ );
    (*v)[ 3 ] = osg::Vec3( -halfDimX, 0., halfDimZ );

    // Use the DrawArraysInstanced PrimitiveSet and tell it to draw 1024 instances.
    geom.addPrimitiveSet( new osg::DrawArrays( GL_QUADS, 0, 4, nInstances ) );
}
开发者ID:LaurensVoerman,项目名称:OpenSceneGraph,代码行数:19,代码来源:osgdrawinstanced.cpp


示例9: setVertexAttrib

        void setVertexAttrib(osg::Geometry& geom, const AttributeAlias& alias, osg::Array* array, bool normalize, osg::Array::Binding binding = osg::Array::BIND_UNDEFINED)
        {
            unsigned int index = alias.first;
            const std::string& name = alias.second;
            array->setName(name);
            if (binding!=osg::Array::BIND_UNDEFINED) array->setBinding(binding);
            array->setNormalize(normalize);
            geom.setVertexAttribArray(index, array);

            osg::notify(osg::NOTICE)<<"   vertex attrib("<<name<<", index="<<index<<", normalize="<<normalize<<" binding="<<binding<<")"<<std::endl;
        }
开发者ID:3dcl,项目名称:osg,代码行数:11,代码来源:osgvertexattributes.cpp


示例10: VertexAttribComparitor

 VertexAttribComparitor(osg::Geometry& geometry)
 {
     add(geometry.getVertexArray());
     add(geometry.getNormalArray());
     add(geometry.getColorArray());
     add(geometry.getSecondaryColorArray());
     add(geometry.getFogCoordArray());
     unsigned int i;
     for(i=0;i<geometry.getNumTexCoordArrays();++i)
     {
         add(geometry.getTexCoordArray(i));
     }
     for(i=0;i<geometry.getNumVertexAttribArrays();++i)
     {
         add(geometry.getVertexAttribArray(i));
     }
 }
开发者ID:,项目名称:,代码行数:17,代码来源:


示例11: apply

 void apply(osg::Geometry& geom) {
     osg::Vec3Array* array = dynamic_cast<osg::Vec3Array*>(geom.getVertexArray());
     if (array) {
         for (unsigned int i = 0; i < array->size(); i++) {
             double x,y,z;
             double lng = (*array)[i][0];
             double lat = (*array)[i][1];
             _coordinates->convertLatLongHeightToXYZ(osg::DegreesToRadians(lat), osg::DegreesToRadians(lng), 0, x, y, z);
             (*array)[i] = osg::Vec3(x,y,z);
         }
     }
 }
开发者ID:cedricpinson,项目名称:ProjectToHeightfield,代码行数:12,代码来源:ProjectorVisitor.cpp


示例12: setUseDisplayList

MorphGeometry::MorphGeometry(const osg::Geometry& b) :
    osg::Geometry(b, osg::CopyOp::DEEP_COPY_ARRAYS),
    _dirty(false),
    _method(NORMALIZED),
    _morphNormals(true)
{
    setUseDisplayList(false);
    setUpdateCallback(new UpdateVertex);
    setDataVariance(osg::Object::DYNAMIC);
    setUseVertexBufferObjects(true);
    if (b.getInternalOptimizedGeometry())
        computeInternalOptimizedGeometry();
}
开发者ID:Sylla,项目名称:osg,代码行数:13,代码来源:MorphGeometry.cpp


示例13: createDAIGeometry

void createDAIGeometry( osg::Geometry& geom, int nInstances=1 )
{
    const float halfDimX( .5 );
    const float halfDimZ( .5 );

    osg::Vec3Array* v = new osg::Vec3Array;
    v->resize( 4 );
    geom.setVertexArray( v );

    // Geometry for a single quad.
    (*v)[ 0 ] = osg::Vec3( -halfDimX, 0., 0. );
    (*v)[ 1 ] = osg::Vec3( halfDimX, 0., 0. );
    (*v)[ 2 ] = osg::Vec3( halfDimX, 0., halfDimZ*2.0f );
    (*v)[ 3 ] = osg::Vec3( -halfDimX, 0., halfDimZ*2.0f );


	// create color array data (each corner of our triangle will have one color component)
    osg::Vec4Array* pColors = new osg::Vec4Array;
    pColors->push_back( osg::Vec4( 1.0f, 0.0f, 0.0f, 1.0f ) );
    pColors->push_back( osg::Vec4( 0.0f, 1.0f, 0.0f, 1.0f ) );
    pColors->push_back( osg::Vec4( 0.0f, 0.0f, 1.0f, 1.0f ) );
	pColors->push_back( osg::Vec4( 0.0f, 0.0f, 1.0f, 1.0f ) );
    geom.setColorArray( pColors );

	// make sure that our geometry is using one color per vertex
    geom.setColorBinding( osg::Geometry::BIND_PER_VERTEX );

    osg::Vec2Array* pTexCoords = new osg::Vec2Array( 4 );
    (*pTexCoords)[0].set( 0.0f, 0.0f );
    (*pTexCoords)[1].set( 1.0f, 0.0f );
    (*pTexCoords)[2].set( 1.0f, 1.0f );
    (*pTexCoords)[3].set( 0.0f, 1.0f );
    geom.setTexCoordArray( 0, pTexCoords );

    // Use the DrawArraysInstanced PrimitiveSet and tell it to draw 1024 instances.
    geom.addPrimitiveSet( new osg::DrawArrays( GL_QUADS, 0, 4, nInstances ) );
}
开发者ID:Crisium,项目名称:sigmaosg,代码行数:37,代码来源:Grass.cpp


示例14: _initSkinning

    bool InstancesManagerImpl::_initSkinning(osg::Geometry& geom, const image_data& id )
    {
        osg::Geometry& source = geom;
        osg::Vec3Array* positionSrc = dynamic_cast<osg::Vec3Array*>(source.getVertexArray());
        if (!positionSrc)
        {
            OSG_WARN << "InstancedAnimationManager no vertex array in the geometry " << geom.getName() << std::endl;
            return false;
        }

        osg::ref_ptr<osg::Program> cSkinningProg = creators::createProgram("skininst2").program; 
        cSkinningProg->setName("SkinningShader");

        const int attribIndex = cAttribSkinningBaseIndex;
        int nbAttribs = id.bonesWeights.size();
        for (int i = 0; i < nbAttribs; i++)
        {
            osg::ref_ptr<osg::Vec4Array> array = new osg::Vec4Array(osg::Array::BIND_PER_VERTEX);
            const image_data::weights_t&  w = id.bonesWeights[i];
            for (unsigned j = 0; j < w.size(); j+=id.divisor)
            {
                array->push_back(osg::Vec4(w.at(j),w.at(j+1),w.at(j+2),w.at(j+3)));
            }		

            std::stringstream ss;
            ss << "boneWeight" << i;
            cSkinningProg->addBindAttribLocation(ss.str(), attribIndex + i);
            geom.setVertexAttribArray(attribIndex + i, array);
            OSG_INFO << "set vertex attrib " << ss.str() << std::endl;
        }

        osg::ref_ptr<osg::StateSet> ss = geom.getOrCreateStateSet();
        ss->addUniform(new osg::Uniform("nbBonesPerVertex", id.bonesPerVertex));
        ss->setAttributeAndModes(cSkinningProg.get());

        return true;
    }
开发者ID:yaroslav-tarasov,项目名称:test_osg,代码行数:37,代码来源:InstancesManagerImpl.cpp


示例15: switch

void osgToy::FacetingVisitor::facet( osg::Geometry& geom )
{
    // count #surfaces, exit if none
    osg::Geometry::PrimitiveSetList& primitives = geom.getPrimitiveSetList();
    osg::Geometry::PrimitiveSetList::iterator itr;
    unsigned int numSurfacePrimitives=0;
    for(itr=primitives.begin();
        itr!=primitives.end();
        ++itr)
    {
        switch((*itr)->getMode())
        {
            case osg::PrimitiveSet::TRIANGLES:
            case osg::PrimitiveSet::TRIANGLE_STRIP:
            case osg::PrimitiveSet::TRIANGLE_FAN:
            case osg::PrimitiveSet::QUADS:
            case osg::PrimitiveSet::QUAD_STRIP:
            case osg::PrimitiveSet::POLYGON:
                ++numSurfacePrimitives;
                break;

            default:
                break;
        }
    }
    if (!numSurfacePrimitives) return;

    // exit if no vertices
    osg::Vec3Array *coords = dynamic_cast<osg::Vec3Array*>(geom.getVertexArray());
    if (!coords || !coords->size()) return;
    
    // generate the normals
    osg::Vec3Array *normals = new osg::Vec3Array(coords->size());
    osg::TriangleIndexFunctor<FacetingOperator> ftif;
    ftif.set( coords, normals );
    geom.accept(ftif);

    geom.setNormalArray( normals );
    geom.setNormalIndices( geom.getVertexIndices() );
    geom.setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
    geom.dirtyDisplayList();
}
开发者ID:mew-cx,项目名称:osgtoy,代码行数:42,代码来源:FacetingVisitor.cpp


示例16: createFaces

void createFaces(osg::Geometry& geometry, Polyhedron const& polyhedron, unsigned int faceMask = PolyhedronGeometry::All)
{
    osgUtil::Tessellator tessellator;
    tessellator.setTessellationType(osgUtil::Tessellator::TESS_TYPE_POLYGONS);
    tessellator.setWindingType(osgUtil::Tessellator::TESS_WINDING_NONZERO);

    auto _vertices = getOrCreateVertexArray(geometry);
    auto _normals = getOrCreateNormalArray(geometry);
    auto _colors = getOrCreateColorArray(geometry);

    osg::ref_ptr<osg::Vec3Array> vertices = createVertexArray(polyhedron);
    VertexIndexArrays polygons = createVertexIndexArrays(polyhedron);

    for (auto const& polygon: polygons)
    {
        assert(polygon && polygon->size() >= 3);

        if (!(faceMask & PolyhedronGeometry::FaceMaskFromSides(polygon->size()))) continue;

        auto first = _vertices->size();
        auto count = polygon->size();

        auto normal = detail::calculateNormal(vertices, polygon);
        auto color = detail::calculateColor(vertices, polygon);

        for (auto i = 0u; i < polygon->size(); ++i)
        {
            auto vertex = vertices->at(polygon->at(i));
            _vertices->push_back(vertex);
            _normals->push_back(normal);
            _colors->push_back(color);
        }

        geometry.addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON, first, count));
    }

    tessellator.retessellatePolygons(geometry);
}
开发者ID:kloffy,项目名称:osgKaleido,代码行数:38,代码来源:PolyhedronGeometry.cpp


示例17: apply

    void ShaderVisitor::apply(osg::Geometry& geometry)
    {
        bool needPop = (geometry.getStateSet() != NULL);
        if (geometry.getStateSet())
        {
            pushRequirements();
            applyStateSet(geometry.getStateSet(), geometry);
        }

        if (!mRequirements.empty())
        {
            const ShaderRequirements& reqs = mRequirements.back();

            if (mAllowedToModifyStateSets)
            {
                // make sure that all UV sets are there
                for (std::map<int, std::string>::const_iterator it = reqs.mTextures.begin(); it != reqs.mTextures.end(); ++it)
                {
                    if (geometry.getTexCoordArray(it->first) == NULL)
                        geometry.setTexCoordArray(it->first, geometry.getTexCoordArray(0));
                }
            }

            if (reqs.mTexStageRequiringTangents != -1 && mAllowedToModifyStateSets)
            {
                osg::ref_ptr<osgUtil::TangentSpaceGenerator> generator (new osgUtil::TangentSpaceGenerator);
                generator->generate(&geometry, reqs.mTexStageRequiringTangents);

                geometry.setTexCoordArray(7, generator->getTangentArray(), osg::Array::BIND_PER_VERTEX);
            }

            // TODO: find a better place for the stateset
            if (reqs.mShaderRequired || mForceShaders)
                createProgram(reqs, geometry);
        }

        if (needPop)
            popRequirements();
    }
开发者ID:HedgehogGrandpa,项目名称:openmw,代码行数:39,代码来源:shadervisitor.cpp


示例18: changeGeo

OSG::Action::ResultE changeGeo(OSG::Node *node)
{   
    OSG::Geometry *geo = dynamic_cast<OSG::Geometry *>(node->getCore());
    
    if(geo == NULL)
        return OSG::Action::Continue;


    OSG::GeoColor3fPropertyRefPtr col = dynamic_cast<OSG::GeoColor3fProperty *>(geo->getColors());
    if(col == NULL)
    {
        col = OSG::GeoColor3fProperty::create();

        col->resize(geo->getPositions()->getSize());
        
        // Change the geometry to use the new colors
        geo->setColors(col);
        // If multi-indexed, make the colors use the same index as
        // the geometry
        if(geo->getIndex(OSG::Geometry::PositionsIndex) != NULL)
        {
            geo->setIndex(geo->getIndex(OSG::Geometry::PositionsIndex),
                          OSG::Geometry::ColorsIndex                   );
        }
    }
    
    OSG::Real32 size = col->getSize();
    for(OSG::UInt32 i = 0; i < size; ++i)
    {
        OSG::Color3f c;
        c[0] = 0.0f;
        c[1] = static_cast<OSG::Real32>(i) / size;
        c[2] = 0.0f;
        col->setValue(c, i);
    }
    
    return OSG::Action::Continue; 
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:38,代码来源:deepclone.cpp


示例19: if

void
GeometryValidator::apply(osg::Geometry& geom)
{
    unsigned numVerts = geom.getVertexArray()->getNumElements();

    if ( geom.getColorArray() )
    {
        if ( geom.getColorBinding() == osg::Geometry::BIND_OVERALL && geom.getColorArray()->getNumElements() != 1 )
        {
            OE_WARN << "Color: BIND_OVERALL with wrong number of elements" << std::endl;
        }
        else if ( geom.getColorBinding() == osg::Geometry::BIND_PER_VERTEX && geom.getColorArray()->getNumElements() != numVerts )
        {
            OE_WARN << "Color: BIND_PER_VERTEX with color.size != verts.size" << std::endl;
        }
    }

    if ( geom.getNormalArray() )
    {
        if ( geom.getNormalBinding() == osg::Geometry::BIND_OVERALL && geom.getNormalArray()->getNumElements() != 1 )
        {
            OE_WARN << "Normal: BIND_OVERALL with wrong number of elements" << std::endl;
        }
        else if ( geom.getNormalBinding() == osg::Geometry::BIND_PER_VERTEX && geom.getNormalArray()->getNumElements() != numVerts )
        {
            OE_WARN << "Normal: BIND_PER_VERTEX with color.size != verts.size" << std::endl;
        }
    }

    const osg::Geometry::PrimitiveSetList& plist = geom.getPrimitiveSetList();

    for( osg::Geometry::PrimitiveSetList::const_iterator p = plist.begin(); p != plist.end(); ++p )
    {
        osg::PrimitiveSet* pset = p->get();

        osg::DrawElementsUByte* de_byte = dynamic_cast<osg::DrawElementsUByte*>(pset);
        if ( de_byte )
        {
            if ( numVerts > 0xFF )
            {
                OE_WARN << "DrawElementsUByte used when numVerts > 255 (" << numVerts << ")" << std::endl;
            }
            validateDE(de_byte, 0xFF, numVerts );
        }

        osg::DrawElementsUShort* de_short = dynamic_cast<osg::DrawElementsUShort*>(pset);
        if ( de_short )
        {
            if ( numVerts > 0xFFFF )
            {
                OE_WARN << "DrawElementsUShort used when numVerts > 65535 (" << numVerts << ")" << std::endl;
            }
            validateDE(de_short, 0xFFFF, numVerts );
        }

        osg::DrawElementsUInt* de_int = dynamic_cast<osg::DrawElementsUInt*>(pset);
        if ( de_int )
        {
            validateDE(de_int, 0xFFFFFFFF, numVerts );
        }
    }
}
开发者ID:bblu,项目名称:osgearth,代码行数:62,代码来源:Utils.cpp


示例20: switch

void
MeshConsolidator::convertToTriangles( osg::Geometry& geom, bool force )
{
    if ( !force && !canOptimize(geom) )
        return;

    osg::Geometry::PrimitiveSetList& primSets = geom.getPrimitiveSetList();
    osg::Geometry::PrimitiveSetList  triSets, nonTriSets;

    for( osg::Geometry::PrimitiveSetList::iterator i = primSets.begin(); i != primSets.end(); ++i )
    {
        osg::PrimitiveSet* pset = i->get();
        switch( pset->getMode() )
        {
        case osg::PrimitiveSet::TRIANGLES:
        case osg::PrimitiveSet::TRIANGLE_STRIP:
        case osg::PrimitiveSet::TRIANGLE_FAN:
        case osg::PrimitiveSet::QUADS:
        case osg::PrimitiveSet::QUAD_STRIP:
        case osg::PrimitiveSet::POLYGON:
            triSets.push_back( pset );
            break;

        default:
            nonTriSets.push_back( pset );
        }
    }

    if ( triSets.size() > 0 )
    {
        // we are assuming at this point that all the primitive sets in a single geometry
        // share a single user data structure.
        osg::Referenced* sharedUserData = triSets[0]->getUserData();

        osg::Array* vertexArray = geom.getVertexArray();
        unsigned numVerts = vertexArray->getNumElements();
        osg::Geometry::PrimitiveSetList newPrimSets;

        if ( numVerts < 0x100 )
        {
            osg::TriangleIndexFunctor< Collector<osg::DrawElementsUByte> > collector;
            collector._newPrimSets = &newPrimSets;
            collector._maxSize = 0xFF;
            geom.accept( collector );
        }
        else if ( numVerts < 0x10000 )
        {
            osg::TriangleIndexFunctor< Collector<osg::DrawElementsUShort> > collector;
            collector._newPrimSets = &newPrimSets;
            collector._maxSize = 0xFFFF;
            geom.accept( collector );
        }
        else
        {
#ifdef OSG_GLES2_AVAILABLE
            // GLES only supports UShort, not UInt
            osg::TriangleIndexFunctor< Collector<osg::DrawElementsUShort> > collector;
            collector._newPrimSets = &newPrimSets;
            collector._maxSize = 0xFFFF;
            geom.accept( collector );
#else
            osg::TriangleIndexFunctor< Collector<osg::DrawElementsUInt> > collector;
            collector._newPrimSets = &newPrimSets;
            collector._maxSize = 0xFFFFFFFF;
            geom.accept( collector );
#endif
        }

        for( osg::Geometry::PrimitiveSetList::iterator i = newPrimSets.begin(); i != newPrimSets.end(); ++i )
        {
            i->get()->setUserData( sharedUserData );
            nonTriSets.push_back( i->get() );
        }
    }

    geom.setPrimitiveSetList( nonTriSets );
}
开发者ID:RealRui,项目名称:osgearth,代码行数:77,代码来源:MeshConsolidator.cpp



注:本文中的osg::Geometry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ osg::GeometryUnrecPtr类代码示例发布时间:2022-05-31
下一篇:
C++ osg::Geode类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap