本文整理汇总了C++中ofMesh::clearColors方法的典型用法代码示例。如果您正苦于以下问题:C++ ofMesh::clearColors方法的具体用法?C++ ofMesh::clearColors怎么用?C++ ofMesh::clearColors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofMesh
的用法示例。
在下文中一共展示了ofMesh::clearColors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ofxNDCircularGradient
void ofxNDCircularGradient(float radius, const ofColor & start, const ofColor & end)
{
int n = 32; // circular gradient resolution
static ofMesh _nd_cg_mesh;
_nd_cg_mesh.clear();
_nd_cg_mesh.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
ofVec2f center(0,0);
_nd_cg_mesh.addVertex(center);
float angleBisector = TWO_PI / (n * 2);
float smallRadius = radius;
float bigRadius = smallRadius / cos(angleBisector);
for(int i = 0; i <= n; i++) {
float theta = i * TWO_PI / n;
_nd_cg_mesh.addVertex(center + ofVec2f(sin(theta), cos(theta)) * bigRadius);
}
_nd_cg_mesh.clearColors();
_nd_cg_mesh.addColor(start);
for(int i = 0; i <= n; i++) {
_nd_cg_mesh.addColor(end);
}
_nd_cg_mesh.draw();
}
示例2: faceColorToTexture
void faceColorToTexture(ofMesh& mesh, ofImage& image)
{
vector<ofFloatColor> &color = mesh.getColors();
int num_face = color.size() / 3;
int tex_size = ofNextPow2(ceil(sqrt(num_face)));
bool arb = ofGetUsingArbTex();
ofDisableArbTex();
image.allocate(tex_size, tex_size, OF_IMAGE_COLOR);
if (arb) ofEnableArbTex();
mesh.clearTexCoords();
image.getPixelsRef().set(0);
float texel_size = (1. / image.getWidth()) * 0.5;
for (int i = 0; i < num_face; i++)
{
int u = (i % tex_size);
int v = (i / tex_size);
ofColor c = color[i * 3];
image.setColor(u, v, c);
float uu = (float)u / image.getWidth() + texel_size;
float vv = (float)v / image.getHeight() + texel_size;
mesh.addTexCoord(ofVec2f(uu, vv));
mesh.addTexCoord(ofVec2f(uu, vv));
mesh.addTexCoord(ofVec2f(uu, vv));
}
image.update();
mesh.clearColors();
}