本文整理汇总了C++中ofMesh::getNormal方法的典型用法代码示例。如果您正苦于以下问题:C++ ofMesh::getNormal方法的具体用法?C++ ofMesh::getNormal怎么用?C++ ofMesh::getNormal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofMesh
的用法示例。
在下文中一共展示了ofMesh::getNormal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawNormals
void ofApp::drawNormals(const ofMesh& mesh){
for(int i = 0; i < mesh.getVertices().size(); i++){
ofVec3f n = mesh.getNormal(i);
ofVec3f v = mesh.getVertex(i);
ofPushStyle();
ofSetColor(0, 255, 0);
ofLine(v.x, v.y, v.z, v.x + (n.x*4), v.y + (n.y*4), v.z + (n.z*4) );
ofPopStyle();
}
}
示例2:
ofMesh SurfaceCoons::surfaceTesselation5(const ofMesh &mesh){
// pour chaque poly, ajouter sommet central
ofMesh meshret;
meshret.setMode(OF_PRIMITIVE_LINES);
vector<ofVec3f> vectorPts;
vector<ofVec3f> vectorNormalPts;
vector<ofVec3f> vectorSommetsArrets;
vector<ofVec3f> vectorNormalSommetsArrets;
int N = mesh.getVertices().size()/8;
for(int i = 0; i < N; i++){
vectorPts.push_back(mesh.getVertex(8*i));
vectorNormalPts.push_back(mesh.getNormal(8*i));
vectorPts.push_back(mesh.getVertex(8*i+2));
vectorNormalPts.push_back(mesh.getNormal(8*i+2));
vectorPts.push_back(mesh.getVertex(8*i+4));
vectorNormalPts.push_back(mesh.getNormal(8*i+4));
vectorPts.push_back(mesh.getVertex(8*i+6));
vectorNormalPts.push_back(mesh.getNormal(8*i+6));
ofVec3f sommetCentral = vectorPts[0]/4 + vectorPts[1]/4 + vectorPts[2]/4 + vectorPts[3]/4;
ofVec3f normalCentral = vectorNormalPts[0]/4 + vectorNormalPts[1]/4 + vectorNormalPts[2]/4 + vectorNormalPts[3]/4;
// pour chaque arret, ajouter sommet
// trouver triangle adjacent (fct)
vectorSommetsArrets.push_back(vectorPts[0]/2 + vectorPts[1]/2);
vectorNormalSommetsArrets.push_back(vectorNormalPts[0]/2 + vectorNormalPts[1]/2);
vectorSommetsArrets.push_back(vectorPts[1]/2 + vectorPts[2]/2);
vectorNormalSommetsArrets.push_back(vectorNormalPts[1]/2 + vectorNormalPts[2]/2);
vectorSommetsArrets.push_back(vectorPts[2]/2 + vectorPts[3]/2);
vectorNormalSommetsArrets.push_back(vectorNormalPts[2]/2 + vectorNormalPts[3]/2);
vectorSommetsArrets.push_back(vectorPts[3]/2 + vectorPts[0]/2);
vectorNormalSommetsArrets.push_back(vectorNormalPts[3]/2 + vectorNormalPts[0]/2);
// pour chaque arret, ajouter arret
// central-arret
for(int j = 0; j < 4; j++){
meshret.addVertex(sommetCentral);
meshret.addColor(ofFloatColor(1, 1, 0));
meshret.addNormal(normalCentral);
meshret.addVertex(vectorSommetsArrets[j]);
meshret.addColor(ofFloatColor(1, 1, 0));
meshret.addNormal(vectorNormalSommetsArrets[j]);
meshret.addVertex(vectorSommetsArrets[j]);
meshret.addColor(ofFloatColor(1, 1, 0));
meshret.addNormal(vectorNormalSommetsArrets[j]);
int l = j + 1;
if(j == 3){
l = 0;
}
meshret.addVertex(vectorPts[l]);
meshret.addColor(ofFloatColor(1, 1, 0));
meshret.addNormal(vectorNormalPts[l]);
meshret.addVertex(vectorPts[l]);
meshret.addColor(ofFloatColor(1, 1, 0));
meshret.addNormal(vectorNormalPts[l]);
int k = j + 1;
if(j == 3){
k = 0;
}
meshret.addVertex(vectorSommetsArrets[k]);
meshret.addColor(ofFloatColor(1, 1, 0));
meshret.addNormal(vectorNormalSommetsArrets[k]);
meshret.addVertex(vectorSommetsArrets[k]);
meshret.addColor(ofFloatColor(1, 1, 0));
meshret.addNormal(vectorNormalSommetsArrets[k]);
meshret.addVertex(sommetCentral);
meshret.addColor(ofFloatColor(1, 1, 0));
meshret.addNormal(normalCentral);
}
vectorPts.clear();
vectorSommetsArrets.clear();
vectorNormalPts.clear();
vectorNormalSommetsArrets.clear();
}
return meshret;
}