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


C++ ofMesh::clearNormals方法代码示例

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


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

示例1: setNormals

//Universal function which sets normals for the triangle mesh
void ofxOcean::setNormals( ofMesh &mesh ){
    //The number of the vertices
    int nV = mesh.getNumVertices();
    //The number of the triangles
    int nT = mesh.getNumIndices() / 3;
    vector<ofPoint> norm( nV ); //Array for the normals
    //Scan all the triangles. For each triangle add its
    //normal to norm's vectors of triangle's vertices
    for (int t=0; t<nT; t++) {
        //Get indices of the triangle t
        int i1 = mesh.getIndex( 3 * t );
        int i2 = mesh.getIndex( 3 * t + 1 );
        int i3 = mesh.getIndex( 3 * t + 2 );
        //Get vertices of the triangle
        const ofPoint &v1 = mesh.getVertex( i1 );
        const ofPoint &v2 = mesh.getVertex( i2 );
        const ofPoint &v3 = mesh.getVertex( i3 );
        //Compute the triangle's normal
        ofPoint dir = ( (v2 - v1).getCrossed( v3 - v1 ) ).getNormalized();
        //Accumulate it to norm array for i1, i2, i3
        norm[ i1 ] += dir;
        norm[ i2 ] += dir;
        norm[ i3 ] += dir;
    }
    //Normalize the normal's length
    for (int i=0; i<nV; i++) {
        norm[i].normalize();
    }
    //Set the normals to mesh
    mesh.clearNormals();
    mesh.addNormals( norm );
}
开发者ID:xfischer,项目名称:ofxOcean,代码行数:33,代码来源:ofxOcean.cpp

示例2: setNormals

void PyramidBrush::setNormals(ofMesh& mesh) {
    
    int nV = mesh.getNumVertices();
    int nT = mesh.getNumIndices() / 3;
    
    vector<ofPoint> norm(nV);
    for(int t=0; t < nT; t++) {
        int i1 = mesh.getIndex(3*t);
        int i2 = mesh.getIndex(3*t + 1);
        int i3 = mesh.getIndex(3*t + 2);
        
        const ofPoint &v1 = mesh.getVertex(i1);
        const ofPoint &v2 = mesh.getVertex(i2);
        const ofPoint &v3 = mesh.getVertex(i3);
        
        ofPoint dir = ( (v2 - v1).crossed(v3 - v1)).normalized();
        
        norm[i1] += dir;
        norm[i2] += dir;
        norm[i3] += dir;
    }
    for(int i = 0; i < nV; i++) {
        norm[i].normalize();
    }
    
    mesh.clearNormals();
    mesh.addNormals(norm);
}
开发者ID:GordeyChernyy,项目名称:DrawingTool,代码行数:28,代码来源:PyramidBrush.cpp

示例3: setNormals

//--------------------------------------------------------------
//Universal function which sets normals for the triangle mesh
void setNormals( ofMesh &mesh ){
    
    int nV = mesh.getNumVertices();//640
    int nT = mesh.getNumIndices() / 3;//213
    
    vector<ofPoint> norm( nV );
    
    for (int t=0; t<nT; t++) {
        
        int i1 = mesh.getIndex( 3 * t );
        int i2 = mesh.getIndex( 3 * t + 1 );
        int i3 = mesh.getIndex( 641 );
        
        const ofPoint &v1 = mesh.getVertex( i1 );
        const ofPoint &v2 = mesh.getVertex( i2 );
        const ofPoint &v3 = mesh.getVertex( i3 );
        
        //Compute the triangle's normal
        ofPoint dir = ( (v2 - v1).crossed( v3 - v1 ) ).normalized();
        
        norm[ i1 ] += dir;
        norm[ i2 ] += dir;
        norm[ i3 ] += dir;
    }
    
    //Normalize the normal's length
    for (int i=0; i<nV; i++) {
        norm[i].normalize();
    }
    
    //Set the normals to mesh
    mesh.clearNormals();
    mesh.addNormals( norm );
}
开发者ID:superpeachman,项目名称:BotB20160116,代码行数:36,代码来源:Human.cpp

示例4: buildNormalsFaces

void buildNormalsFaces(ofMesh& mesh) {
    mesh.clearNormals();
    for(int i = 0; i < mesh.getNumVertices(); i += 3) {
        int i0 = i + 0, i1 = i + 1, i2 = i + 2;
        ofVec3f normal = getNormal(mesh.getVertices()[i0], mesh.getVertices()[i1], mesh.getVertices()[i2]);
        for(int j = 0; j < 3; j++) {
            mesh.addNormal(normal);
        }
    }
}
开发者ID:Giladx,项目名称:ofxFaceShift,代码行数:10,代码来源:ofxFaceShift.cpp


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