本文整理汇总了C++中ofPath::curveTo方法的典型用法代码示例。如果您正苦于以下问题:C++ ofPath::curveTo方法的具体用法?C++ ofPath::curveTo怎么用?C++ ofPath::curveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofPath
的用法示例。
在下文中一共展示了ofPath::curveTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
//--------------------------------------------------------------
void testApp::update(){
/* get the spectral data */
float * val = ofSoundGetSpectrum(nBandsToGet);
for (int i = 0; i < nBandsToGet; i++){
// let the smoothed calue sink to zero:
fftSmoothed[i] *= 0.96f;
// take the max, either the smoothed or the incoming:
if (fftSmoothed[i] < val[i])
fftSmoothed[i] = val[i];
if (fftSmoothed[i] > fftmax) {
fftmax = fftSmoothed[i];
}
}
/* update our bark map'd frequency bins */
memset(bins, 0x00, sizeof(bins));
for (int i = 0; i < SPECTRAL_BANDS; i++) {
int idx = barkmap[i];
bins[idx] += fftSmoothed[i] * 20;
}
/* put the eq vals into a path to turn them into a curve */
int line_len = fbo_res;
float ppseg = line_len /(float)(BARK_MAX+1);
eq_path.clear();
eq_path.curveTo(0, -bins[0]);
for (int i = 0; i < BARK_MAX; i++) {
// bins[i] = max(5.0f, bins[i]); //set a lower bound on the bin val
eq_path.curveTo(i * ppseg, -bins[i]);
}
// eq_path.curveTo(BARK_MAX * ppseg, -bins[0]);
// eq_path.curveTo(BARK_MAX * ppseg, -bins[0]);
//smooth this out a little at the end so the eq texture wraps, 25 = BARK_MAX
eq_path.curveTo(25 * ppseg, -(bins[0] + bins[24] + bins[23] + bins[22])/4.0f);
eq_path.curveTo(26 * ppseg, -bins[0]);
eq_path.curveTo(26 * ppseg, -bins[0]);
ofMesh eq_m = eq_path.getTessellation();
//load up the eq curve into a texture
eq_tex.loadData((float *)eq_m.getVerticesPointer(), fbo_res, 1, GL_RGB);
//update where on the axis we will apply the latest eq data
axis_loc--;
if (axis_loc < 0)
axis_loc = fbo_res;
//use fbo to work out displacement coeffcients
posbuf.dst->begin();
ofClear(0);
pos_shader.begin();
pos_shader.setUniformTexture("u_prevDisp", posbuf.src->getTextureReference(), 0);
pos_shader.setUniformTexture("u_newDisp", eq_tex, 1); //pass the new displacement data
pos_shader.setUniform1f("u_axisloc", axis_loc);
pos_shader.setUniform1f("u_decayRate", posdecayrate);
ofSetColor(255, 255, 255, 255);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex3f(0, 0, 0);
glTexCoord2f(fbo_res, 0); glVertex3f(fbo_res, 0, 0);
glTexCoord2f(fbo_res, fbo_res); glVertex3f(fbo_res, fbo_res, 0);
glTexCoord2f(0, fbo_res); glVertex3f(0, fbo_res, 0);
glEnd();
pos_shader.end();
posbuf.dst->end();
posbuf.swap();
}