本文整理汇总了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 );
}
示例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);
}
示例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 );
}
示例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);
}
}
}