当前位置: 首页>>代码示例>>C++>>正文


C++ GeometryUnrecPtr::setLengths方法代码示例

本文整理汇总了C++中GeometryUnrecPtr::setLengths方法的典型用法代码示例。如果您正苦于以下问题:C++ GeometryUnrecPtr::setLengths方法的具体用法?C++ GeometryUnrecPtr::setLengths怎么用?C++ GeometryUnrecPtr::setLengths使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeometryUnrecPtr的用法示例。


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

示例1: read


//.........这里部分代码省略.........
                       // Some faces contain texture coords and others do not.
                       // The old version did just skip this geometry.
                       // This version should continue if there's at least
                       // the vertex index
                       // I've seen the change in the maskIndex only after a smooth group,
                       // so it's perhaps smarter to not ignore the smooth group further up in this code
                       if( !(indexMask & 1) )
                       {
                         // if there are vertex indices there's no reason to get in here
                          FFATAL (( "IndexMask unmatch, can not create geo\n"));
                          meshIndexMask = 0;
                          break;
                       }
                       else
                       {
                         // consider the minimum similarities of mesh masks
                         meshIndexMask &= indexMask;
                       }
                    }
                }
            }
            else
            {
                FWARNING (("Mesh with empty faceList\n"));
            }

            // fill the geo properties
            if (meshIndexMask)
            {
                geoPtr->setPositions ( coordPtr );
                posIndexPtr = GeoUInt32Property::create();
                if(!isSingleIndex)
                    geoPtr->setIndex(posIndexPtr, Geometry::PositionsIndex);
                geoPtr->setLengths   ( lensPtr );
                geoPtr->setTypes     ( typePtr );

                if ( (meshIndexMask & 2) && texCoordPtr->size() > 0 )
                {
                    geoPtr->setTexCoords ( texCoordPtr );
                    texIndexPtr = GeoUInt32Property::create();
                    if(!isSingleIndex)
                        geoPtr->setIndex(texIndexPtr, Geometry::TexCoordsIndex);
                }
                else
                {
                    geoPtr->setTexCoords ( NULL );
                }

                if ( (meshIndexMask & 4) && normalPtr->size() > 0 )
                {
                    geoPtr->setNormals   ( normalPtr );
                    normalIndexPtr = GeoUInt32Property::create();
                    if(!isSingleIndex)
                        geoPtr->setIndex(normalIndexPtr, Geometry::NormalsIndex);
                }
                else
                {
                    geoPtr->setNormals   ( NULL );
                }

                if (meshI->mtlPtr == NULL)
                {
                    meshI->mtlPtr = SimpleTexturedMaterial::create();
                    meshI->mtlPtr->setDiffuse( Color3f( .8f, .8f, .8f ) );
                    meshI->mtlPtr->setSpecular( Color3f( 1.f, 1.f, 1.f ) );
                    meshI->mtlPtr->setShininess( 20.f );
开发者ID:jondo2010,项目名称:OpenSG,代码行数:67,代码来源:OSGOBJSceneFileType.cpp

示例2: initGeometries

void VTKPolyDataMapper::initGeometries(void)
{
    NodeUnrecPtr pRoot = Node::create();
    
    pRoot->setCore(Group::create());

    setRoot(pRoot);

    for(UInt32 i = 0; i < 4; ++i)
    {
        GeometryUnrecPtr           pGeo      = Geometry::create();
    
        ChunkMaterialUnrecPtr      pMat      = ChunkMaterial::create();
        MaterialChunkUnrecPtr      pMatChunk = MaterialChunk::create();
        
        GeoPnt3fPropertyUnrecPtr   pPoints   = GeoPnt3fProperty  ::create();
        GeoUInt32PropertyUnrecPtr  pLengths  = GeoUInt32Property ::create();
        GeoUInt8PropertyUnrecPtr   pTypes    = GeoUInt8Property  ::create();
        GeoColor4fPropertyUnrecPtr pColors   = GeoColor4fProperty::create();
        GeoVec3fPropertyUnrecPtr   pNormals  = GeoVec3fProperty  ::create();

        if(i < 2)
        {
            pMatChunk->setLit(false);
        }
        
        pMatChunk->setDiffuse  (OSG::Color4f(1.0, 1.0, 1.0, 1.0));
        pMatChunk->setSpecular (OSG::Color4f(0.0, 0.0, 0.0, 1.0));
        pMatChunk->setShininess(10.0f);
        
        pMat->addChunk(pMatChunk);

        TwoSidedLightingChunkUnrecPtr pTSLChunk = 
            TwoSidedLightingChunk::create();
            
        pMat->addChunk(pTSLChunk);

        pGeo->setDlistCache(false   );
        
        pGeo->setMaterial  (pMat    );
        pGeo->setPositions (pPoints );
        pGeo->setLengths   (pLengths);
        pGeo->setTypes     (pTypes  );
        pGeo->setColors    (pColors );

        if(i > 1)
        {
            pGeo->setNormals(pNormals);
        }

        OSG::NodeUnrecPtr pGeoRoot = OSG::Node::create();
        
        pGeoRoot->setCore    (pGeo);
        pGeoRoot->setTravMask(0   );

        pRoot->addChild(pGeoRoot);

        this->pushToGeometries    (pGeo     );
        this->pushToMaterials     (pMat     );
        this->pushToMaterialChunks(pMatChunk);
        this->pushToPositions     (pPoints  );
        this->pushToLength        (pLengths );
        this->pushToTypes         (pTypes   );
        this->pushToColors        (pColors  );
        this->pushToNormals       (pNormals );
        this->pushToGeoRoots      (pGeoRoot );
    }
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:68,代码来源:OSGVTKPolyDataMapper.cpp

示例3: main


//.........这里部分代码省略.........

    //Left Foot
    norms->push_back(Vec3f( 0.0,1.0,0.0));
    norms->push_back(Vec3f( 0.0,1.0,0.0));
    norms->push_back(Vec3f( 0.0,1.0,0.0));
    norms->push_back(Vec3f( 0.0,1.0,0.0));

    //Right Hip
    norms->push_back(Vec3f( 0.0,0.0,1.0));
    norms->push_back(Vec3f( 0.0,0.0,1.0));
    norms->push_back(Vec3f( 0.0,0.0,1.0));
    norms->push_back(Vec3f( 0.0,0.0,1.0));

    //Right Femur
    norms->push_back(Vec3f( 0.0,0.0,1.0));
    norms->push_back(Vec3f( 0.0,0.0,1.0));
    norms->push_back(Vec3f( 0.0,0.0,1.0));
    norms->push_back(Vec3f( 0.0,0.0,1.0));

    //Right Tibia
    norms->push_back(Vec3f( 0.0,0.0,1.0));
    norms->push_back(Vec3f( 0.0,0.0,1.0));
    norms->push_back(Vec3f( 0.0,0.0,1.0));
    norms->push_back(Vec3f( 0.0,0.0,1.0));

    //Right Foot
    norms->push_back(Vec3f( 0.0,1.0,0.0));
    norms->push_back(Vec3f( 0.0,1.0,0.0));
    norms->push_back(Vec3f( 0.0,1.0,0.0));
    norms->push_back(Vec3f( 0.0,1.0,0.0));

    //Tell the geometry (geo) to use the points and normals we just defined
    geo->setTypes    (type);
    geo->setLengths  (lens);
    geo->setPositions(pnts);
    geo->setNormals(norms);

    // assign a material to the geometry to make it visible. The details
    // of materials are defined later.
    geo->setMaterial(getDefaultMaterial());   

    //Create unbound geometry node (for displaying mesh in its bind pose)
    UnboundGeometry = Node::create();
    UnboundGeometry->setCore(geo);
    UnboundGeometry->setTravMask(0);  //By default, we won't show the mesh's bind pose




    //SkeletonDrawer
    SkeletonDrawableUnrecPtr ExampleSkeletonDrawable = SkeletonDrawable::create();
    ExampleSkeletonDrawable->setSkeleton(ExampleSkeleton);
    ExampleSkeletonDrawable->setMaterial(ExampleMaterial);
    ExampleSkeletonDrawable->setDrawBindPose(false);  //By default, we don't draw the skeleton's bind pose
    ExampleSkeletonDrawable->setBindPoseColor(Color4f(0.0, 1.0, 0.0, 1.0));  //When drawn, the skeleton's bind pose renders green
    ExampleSkeletonDrawable->setDrawPose(true);  //By default, we do draw the skeleton's current pose
    ExampleSkeletonDrawable->setPoseColor(Color4f(0.0, 0.0, 1.0, 1.0));  //The skeleton's current pose renders blue

    //Skeleton Node
    SkeletonNode = Node::create();
    SkeletonNode->setCore(ExampleSkeletonDrawable);




    // Skeleton Blended Geometry
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:67,代码来源:13MeshBlending.cpp

示例4: setName

Node *
ColladaGeometry::createInstance(ColladaInstInfo *colInstInfo)
{
    typedef ColladaInstanceGeometry::MaterialMap        MaterialMap;
    typedef ColladaInstanceGeometry::MaterialMapConstIt MaterialMapConstIt;

    domGeometryRef geometry = getDOMElementAs<domGeometry>();
    NodeUnrecPtr   groupN   = makeCoredNode<Group>();

    OSG_COLLADA_LOG(("ColladaGeometry::createInstance id [%s]\n",
                     geometry->getId()));

    if(getGlobal()->getOptions()->getCreateNameAttachments() == true &&
       geometry->getName()                                   != NULL   )
    {
        setName(groupN, geometry->getName());
    }

    ColladaInstanceGeometryRefPtr  colInstGeo =
        dynamic_cast<ColladaInstanceGeometry *>(colInstInfo->getColInst());
    const MaterialMap             &matMap     =
        colInstGeo->getMaterialMap();

    // iterate over all parts of geometry
    GeoStoreIt gsIt   = _geoStore.begin();
    GeoStoreIt gsEnd  = _geoStore.end  ();

    for(; gsIt != gsEnd; ++gsIt)
    {
        OSG_ASSERT(gsIt->_propStore.size() == gsIt->_indexStore.size());

        // find the material associated with the geometry's material symbol
        MaterialMapConstIt mmIt       = matMap.find(gsIt->_matSymbol);
        std::string        matTarget;

        if(mmIt != matMap.end())
        {
            matTarget = mmIt->second->getTarget();
        }

        // check if the geometry was already used with that material

        GeometryUnrecPtr   geo      = NULL;
        InstanceMapConstIt instIt   = gsIt->_instMap.find(matTarget);

        if(instIt != gsIt->_instMap.end())
        {
            // reuse geometry

            geo = dynamic_pointer_cast<Geometry>(
                getInstStore()[instIt->second]);

            getGlobal()->getStatCollector()->getElem(
                ColladaGlobal::statNGeometryUsed)->inc();
        }
        else
        {
            // create new geometry

            geo = Geometry::create();

            getGlobal()->getStatCollector()->getElem(
                ColladaGlobal::statNGeometryCreated)->inc();

            geo->setLengths(gsIt->_lengths);
            geo->setTypes  (gsIt->_types  );

            handleBindMaterial(*gsIt, geo, colInstGeo);

            // record the instantiation of the geometry with the
            // material for reuse
            gsIt->_instMap.insert(
                InstanceMap::value_type(matTarget, getInstStore().size()));

            editInstStore().push_back(geo);
        }

        NodeUnrecPtr geoN = makeNodeFor(geo);

        groupN->addChild(geoN);
    }

    // store the generated group node
    editInstStore().push_back(groupN);

    return groupN;
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:87,代码来源:OSGColladaGeometry.cpp

示例5: read

NodeTransitPtr RAWSceneFileType::read(      std::istream &is, 
                                      const Char8        *,
                                            Resolver        ) const
{
    NodeTransitPtr              root;
    GeometryUnrecPtr            geo;
    GeoPnt3fPropertyUnrecPtr    points;
    GeoVec3fPropertyUnrecPtr    normals;
    GeoIntegralPropertyUnrecPtr index;
    GeoIntegralPropertyUnrecPtr lens;
    GeoIntegralPropertyUnrecPtr type;

    Vec3f vec[3];

    UInt32 i = 0, n, triCount = 0;

    Real32 x,y,z;

    if(is)
    {
        root = Node    ::create();
        geo  = Geometry::create();

        root->setCore( geo );

        points = GeoPnt3fProperty::create();

        geo->setPositions(points);

        normals = GeoVec3fProperty::create();

        geo->setNormals(normals);

        triCount = i = 0;


        while(1) 
        {
            is >> x >> y >> z;

            if(is.eof())
            {
                break;
            }
            else 
            {
                points->editFieldPtr()->push_back(Pnt3f(x, y, z));

                vec[i].setValues(x,y,z);

				std::cerr << x << " " << y << " " << z << std::endl;

                if(i == 2) 
                {
                    vec[0] -= vec[1];
                    vec[1] -= vec[2];
                    vec[0].crossThis(vec[1]);
                    vec[0].normalize();

                    normals->editFieldPtr()->push_back(vec[0]);
                    normals->editFieldPtr()->push_back(vec[0]);
                    normals->editFieldPtr()->push_back(vec[0]);

                    i = 0;
                    triCount++;
                }
                else
                {
                    i++;
                }
            }
        }

        if(triCount != 0)
        {
            index = GeoUInt32Property::create();

            geo->setIndex(index, Geometry::PositionsIndex);
            geo->setIndex(index, Geometry::NormalsIndex  );

            n = triCount * 3;

            for(i = 0; i < n; i++)
                index->push_back(i);



            lens = GeoUInt32Property::create();

            geo->setLengths(lens);

            lens->push_back(n);

            type = GeoUInt8Property::create();

            geo->setTypes(type);

            type->push_back(GL_TRIANGLES);
        }

//.........这里部分代码省略.........
开发者ID:jondo2010,项目名称:OpenSG,代码行数:101,代码来源:OSGRAWSceneFileType.cpp


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