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


C++ Geometry::addVertex方法代码示例

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


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

示例1: setup

void SGQuad::setup(float w, float h) {
    float hw = 0.5f * w;
    float hh = 0.5f * h;
    vec3f n = vec3f(0,0,1);

    Geometry g;
    g.init();
    g.addVertex(vec3f(-hw, -hh, 0.0f));
    g.addVertex(vec3f(hw, -hh, 0.0f));
    g.addVertex(vec3f(hw, hh, 0.0f));
    g.addVertex(vec3f(-hw, hh, 0.0f));
    g.addNormal(n);
    g.addNormal(n);
    g.addNormal(n);
    g.addNormal(n);


    g.addTexCoord(vec2f(0, 0));
    g.addTexCoord(vec2f(1, 0));
    g.addTexCoord(vec2f(1, 1));
    g.addTexCoord(vec2f(0, 1));
    g.addTriangle(vec3u32(0, 1, 2));
    g.addTriangle(vec3u32(2, 3, 0));
    SGMesh::setup(g);

    if(TheShaderManager::Instance().has("textured")) {
        m_spEffect = SmartPtrSGEffect(new TexturedEffect(TheShaderManager::Instance().get("textured")));
    }
}
开发者ID:GraphicsEmpire,项目名称:tetcutter,代码行数:29,代码来源:sgquad.cpp

示例2: createGeom

    void Path::createGeom(Geometry& geom) {
        // clear geom from previous data
        geom.clear();

        // add vertices to the geom
        for (sf::Vector2f& p: points) {
            geom.addVertex(p);
        }

        // triangulate polygon (only with no holes)
        std::vector<sf::Vector2f> triangles;

        Triangulate::Process(points, triangles);

        for (int i = 0; i != triangles.size(); i += 3) {
            geom.addFace(triangles[i], triangles[i + 1], triangles[i + 2]);
        }
    }
开发者ID:frapa,项目名称:sistragatiwe,代码行数:18,代码来源:svg.cpp

示例3: loadObj

bool loadObj( std::vector<Geometry> &geomList, const std::string &filename, float scale, int flags)
{
    std::ifstream file;
    file.open(filename.c_str(), std::ios::in);

    std::cout<<"loading "<<filename<<std::endl;

    if(file.fail())
    {
        std::cout<<"loadObj failed, could not read "<<std::endl;
        return 1;
    }

    VertexBank vb;

    Geometry g;
    std::string line,param;

    std::vector<vec3> tempVertex;
    std::vector<vec3> tempNormal;
    std::vector<vec2> tempTexCoord;

    tempVertex.reserve(10000);
    tempNormal.reserve(10000);
    tempTexCoord.reserve(10000);
    
    std::vector<std::vector<int> > vertexUsed;
    std::vector<int> texCoordUsed;
    int tempSG = 0;

    std::vector<size_t> vertexRemap;
    std::vector<size_t> normalRemap;
    std::vector<size_t> texCoordRemap;

    std::vector<int> resetVector;
    resetVector.resize(1,-1);

    std::string tempName;

    while( !file.eof() && file.good() )
    {
        std::getline(file,line);

        #ifdef DEBUG
        std::cout<<line<<"\n";
        #endif
        Tokenizer token(line);

        param = token.getToken();
        if(param == "v")
        {
            vec3 vertex;

            vertex.x = scale*toFloat(token.getToken());
            vertex.y = scale*toFloat(token.getToken());
            vertex.z = scale*toFloat(token.getToken());

            //tempVertex.push_back(vertex);
            //vertexUsed.push_back(resetVector);
            vertexRemap.push_back( insertUnique(tempVertex, vertex) );
        }
        else if(param == "f")
        {
            ivec4 vdata(-1), tdata(-1), ndata(-1), fdata(-1);

            for(int i=0; i<(int)token.size()-1; ++i)
            {
                param = token.getToken();
                getIndices(param, vdata[i], tdata[i], ndata[i],
                    hasVertex,
                    hasTexCoord && !(flags & LOADOBJ_IGNORE_TEXCOORDS),
                    hasNormal && !(flags & LOADOBJ_IGNORE_NORMALS) );

                int remappedV = (vdata[i] > -1) ? vdata[i] : -1;
                int remappedN = (ndata[i] > -1) ? ndata[i] : -1;
                int remappedT = (tdata[i] > -1) ? tdata[i] : -1;

                int index;
                //printf("Checking vertex uniqueness \n");
                if(vb.isUnique(remappedV, remappedN, remappedT, index))
                {
                    index = g.getVertexSize();

                    Geometry::sVertex tv;

                    assert( remappedV < (int)tempVertex.size() );
                    tv.position = tempVertex[ remappedV ];

                    if(remappedT > -1)
                    {
                        assert( remappedT < (int)tempTexCoord.size() );
                        tv.texCoord = tempTexCoord[ remappedT ];
                    }
                    if(remappedN > -1)
                    {
                        assert( remappedN < (int)tempNormal.size() );
                        tv.normal = tempNormal[ remappedN ];
                    }

                    g.addVertex(tv);
//.........这里部分代码省略.........
开发者ID:scanberg,项目名称:fake-SSS,代码行数:101,代码来源:ObjLoader.cpp


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