本文整理汇总了C++中ofMesh::addVertex方法的典型用法代码示例。如果您正苦于以下问题:C++ ofMesh::addVertex方法的具体用法?C++ ofMesh::addVertex怎么用?C++ ofMesh::addVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofMesh
的用法示例。
在下文中一共展示了ofMesh::addVertex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createMesh
void ofxPolyline::createMesh(ofMesh &mesh, int begin, int end) {
if (end - begin == 1) {
// If only two points, just make a line.
mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
pair<ofVec2f, ofVec2f> joint = jointBegin((*this)[begin], (*this)[end], width);
mesh.addVertex(joint.first);
mesh.addVertex(joint.second);
joint = jointEnd((*this)[begin], (*this)[end], width);
mesh.addVertex(joint.first);
mesh.addVertex(joint.second);
return;
} else if (end - begin == 0) {
// Return no mesh
return;
}
// More than two points
if (strokeLinejoin == OFXSVG_STROKE_LINEJOIN_MITER) {
createMeshMiterJoint(mesh, begin, end);
} else if (strokeLinejoin == OFXSVG_STROKE_LINEJOIN_BEVEL) {
createMeshBevelJoint(mesh, begin, end);
} else if (strokeLinejoin == OFXSVG_STROKE_LINEJOIN_ROUND) {
createMeshRoundJoint(mesh, begin, end);
}
}
示例3: addFace
void addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c) {
ofVec3f normal = ((b - a).cross(c - a)).normalize();
mesh.addNormal(normal);
mesh.addVertex(a);
mesh.addNormal(normal);
mesh.addVertex(b);
mesh.addNormal(normal);
mesh.addVertex(c);
}
示例4: addFace
//Some helper functions
//--------------------------------------------------------------
void Page::addFace(ofMesh& mesh, ofPoint a, ofPoint b, ofPoint c) {
ofVec3f normal = ((b - a).cross(c - a)).normalize();
mesh.addNormal(normal);
mesh.addVertex(a);
mesh.addNormal(normal);
mesh.addVertex(b);
mesh.addNormal(normal);
mesh.addVertex(c);
}
示例5: update
void update() {
ofVec2f cur(mouseX, mouseY);
historyMesh.addVertex(cur);
vector<ofVec2f*> neighbors = data.getNeighborsRatio(cur, .1);
neighborsMesh.clear();
for(int i = 0; i < neighbors.size(); i++) {
neighborsMesh.addVertex(*neighbors[i]);
}
float minimumDistance = getMinimumDistance(cur, neighbors);
if(neighbors.size() == 0 || minimumDistance > 16) {
data.add(cur, cur);
dataMesh.addVertex(cur);
}
}
示例6: addBranch
void CloudsVisualSystemLSystem::addBranch(ofMesh &_mesh, int _index, float _relativeTime, float _speed){
int totalPoints = lsysLines[_index].size();
int drawPoints = 0;
for (int k = 0 ; k < totalPoints-1; k++){
float thisTime = _speed*(float)k;
float nextTime = _speed*((float)k+1.0f);
if ( k == totalPoints-1){
nextTime = thisTime;
}
if (_relativeTime > thisTime && _relativeTime < nextTime ){
float part = _relativeTime - thisTime;
float whole = nextTime - thisTime;
float pct = part / whole;
ofPoint A = lsysLines[ _index ][k];
ofPoint B = lsysLines[ _index ][k+1];
// figure out where we are between a and b
//
ofPoint pos = (1.0-pct)*A + (pct)*B;
dots.push_back(pos);
_mesh.addVertex(lsysLines[ _index ][k]);
_mesh.addVertex(pos);
} else if ( _relativeTime > thisTime ){
ofPoint pos = lsysLines[ _index ][k];
_mesh.addVertex(pos);
_mesh.addVertex(lsysLines[_index][k+1]);
// check if pass over a node
//
int index = isNode(pos);
if (index != -1){
if ( lsysNodes[index].startTime == -1.0 ){
lsysNodes[index].startTime = time +lsysGrowingBorn*_speed;
}
}
} else {
break;
}
}
}
示例7: update
void update()
{
mesh.clear();
float t = ofGetElapsedTimef() * 0.3;
float noise_scale = 0.05;
float size = 300;
float shape_size = 200;
int num = 100;
for (int i = 0; i < num; i++)
{
ofVec3f base(ofSignedNoise(10, 0, 0, i * noise_scale + t),
ofSignedNoise(0, 10, 0, i * noise_scale + t),
ofSignedNoise(0, 0, 10, i * noise_scale + t));
ofVec3f v0(ofSignedNoise(1, 0, 0, i * noise_scale + t),
ofSignedNoise(0, 1, 0, i * noise_scale + t),
ofSignedNoise(0, 0, 1, i * noise_scale + t));
ofVec3f v1(ofSignedNoise(2, 0, 0, i * noise_scale + t),
ofSignedNoise(0, 2, 0, i * noise_scale + t),
ofSignedNoise(0, 0, 2, i * noise_scale + t));
ofVec3f v2(ofSignedNoise(3, 0, 0, i * noise_scale + t),
ofSignedNoise(0, 3, 0, i * noise_scale + t),
ofSignedNoise(0, 0, 3, i * noise_scale + t));
float hue = ofMap(i, 0, num, 0, 1);
ofFloatColor c = ofFloatColor::fromHsb(hue, 1, 1);
float s = fabs(sin(i * 0.1 + t)) + 0.1;
mesh.addColor(c);
mesh.addColor(c);
mesh.addColor(c);
mesh.addVertex(base * size + v0 * shape_size * s);
mesh.addVertex(base * size + v1 * shape_size * s);
mesh.addVertex(base * size + v2 * shape_size * s);
}
IndexColor::convertColorToTexCoord(mesh);
// export to abc
abc_out.addPolyMesh("/mesh", mesh);
}
示例8: addCircle
//http://www.packtpub.com/sites/default/files/9781849518048_Chapter_07.pdf
//knotExample
void ofApp::addCircle( ofVec3f nextPoint, ofMesh &mesh ){
float time = ofGetElapsedTimef(); //Time
//Parameters – twisting and rotating angles and color
ofFloatColor color( ofNoise( time * 0.05 ),
ofNoise( time * 0.1 ),
ofNoise( time * 0.15 ));
color.setSaturation( 1.0 ); //Make the color maximally
//Add vertices
for (int i=0; i<circleN; i++) {
float angle = float(i) / circleN * TWO_PI+(PI*0.25);
float x = Rad * cos( angle );
float y = Rad * sin( angle );
ofPoint p = nextPoint+ofVec3f(x ,y , 0);
mesh.addVertex( p );
mesh.addColor( color );
}
//Add the triangles
int base = mesh.getNumVertices() - 2 * circleN;
if ( base >= 0 ) { //Check if it is not the first step
//and we really need to add the triangles
for (int i=0; i<circleN; i++) {
int a = base + i;
int b = base + (i + 1) % circleN;
int c = circleN + a;
int d = circleN + b;
mesh.addTriangle(a,b,d);
mesh.addTriangle(a, d, c);
}
//Update the normals
setNormals( mesh );
}
}
示例9: meshFromFbo
void CloudsVisualSystemNbody::meshFromFbo(ofFbo& fbo, ofMesh& mesh){
mesh.addTexCoord(ofVec2f(0,0));
mesh.addVertex(ofVec3f(0,0,0));
mesh.addTexCoord(ofVec2f(fbo.getWidth(),0));
mesh.addVertex(ofVec3f(fbo.getWidth(),0,0));
mesh.addTexCoord(ofVec2f(0,fbo.getHeight()));
mesh.addVertex(ofVec3f(0,fbo.getHeight(),0));
mesh.addTexCoord(ofVec2f(fbo.getWidth(),fbo.getHeight()));
mesh.addVertex(ofVec3f(fbo.getWidth(),fbo.getHeight(),0));
mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
}
示例10: texturedRect
void texturedRect(float width, float height) {
if(texturedRectMesh.getNumVertices() == 0) {
texturedRectMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
texturedRectMesh.addTexCoord(ofVec2f(0, 0));
texturedRectMesh.addVertex(ofVec2f(0, 0));
texturedRectMesh.addTexCoord(ofVec2f(0, 1));
texturedRectMesh.addVertex(ofVec2f(0, 1));
texturedRectMesh.addTexCoord(ofVec2f(1, 0));
texturedRectMesh.addVertex(ofVec2f(1, 0));
texturedRectMesh.addTexCoord(ofVec2f(1, 1));
texturedRectMesh.addVertex(ofVec2f(1, 1));
}
ofPushMatrix();
ofScale(width, height);
texturedRectMesh.drawFaces();
ofPopMatrix();
}
示例11: draw
//--------------------------------------------------------------
void testApp::draw(){
fbo.begin();
ofSetTextureWrap(GL_REPEAT,GL_REPEAT);
fbfbo.draw(0,2);
//cam.draw(0,0);
fbfbo.getTextureReference().bind();
trik2.draw();
fbfbo.getTextureReference().unbind();
ofSetColor(255,255,255);
if(tritimer>tritimerlimit){
float xpt, ypt,xtoff,ytoff;
//draw gradient splashes
ofMesh trik;
for(int b = 0;b<5;b++){
xtoff = ofRandomf()*0.5;
ytoff = ofRandomf()*0.5;
for(int i=0;i<3;i++){
xpt = ofRandomuf()*2+xtoff;
ypt = ofRandomuf()*2+ytoff;
trik.addVertex(ofVec3f(xpt*w,ypt*h,0));
trik.addColor(ofFloatColor(float(ofRandomuf()>0.5)*0.6+0.4,float(ofRandomuf()>0.5)*0.5+0.5,float(ofRandomuf()>0.5)*0.7+0.3));
}
}
trik.draw();
tritimer = 0;
tritimerlimit= ofRandom(20,200);
}
if(tritimer2>45){
//re-generate the feedback triangles
float xpt, ypt,xoff,yoff,xtoff,ytoff;
trik2.clear();
//ofEnableNormalizedTexCoords();
for(int b = 0;b<5;b++){
xoff = ofRandomf()*0.1;
yoff = ofRandomf()*0.1;
xtoff = ofRandomf()*0.5;
ytoff = ofRandomf()*0.5;
for(int i=0;i<3;i++){
xpt = ofRandomuf()+xtoff;
ypt = ofRandomuf()+ytoff;
trik2.addVertex(ofVec3f((xpt+xoff)*w,(ypt+yoff)*h,0));
trik2.addTexCoord(ofVec2f(xpt*w,ypt*h));
trik2.addColor(ofFloatColor(1,1,1));
}
}
tritimer2=0;
tritimer2limit= ofRandom(20,200);
//ofDisableNormalizedTexCoords();
}
fbo.end();
fbfbo.begin();
fbo.draw(0,0);
fbfbo.end();
fbo.draw(0,0);
}
示例12: addToMesh
void Particle::addToMesh(ofMesh & mesh, unsigned long long systemTime) {
float pct;
switch(state) {
case INACTIVE:
break;
case BORN:
mesh.addColor(ofColor(baseColor));
mesh.addVertex(location);
break;
case FALLING:
pct = 1 - ofMap(systemTime - bornTime, BORN_TIMEOUT_MS, FALL_TIMEOUT_MS, 0,1,true);
curColor = baseColor * pct;
mesh.addColor(curColor);
mesh.addVertex(location);
break;
default:
break;
}
}
示例13: update
void update() {
int n = mesh.getNumVertices();
int start = ofMap(mouseX, 0, ofGetWidth(), 0, n, true);
controlPoints.clear();
controlPoints.setMode(OF_PRIMITIVE_POINTS);
for(int i = start; i < n; i++) {
unsigned int index = rankedCorners[i];
controlPoints.addVertex(mesh.getVertex(index));
}
}
示例14: addFace
//--------------------------------------------------------------
void addFace(ofMesh& mesh,
ofVec3f a, ofFloatColor aC,
ofVec3f b, ofFloatColor bC,
ofVec3f c, ofFloatColor cC) {
ofVec3f normal = ((b - a).cross(c - a)).normalize() * -1.0;
mesh.addNormal(normal);
mesh.addColor(aC);
mesh.addVertex(a);
mesh.addNormal(normal);
mesh.addColor(bC);
mesh.addVertex(b);
mesh.addNormal(normal);
mesh.addColor(cC);
mesh.addVertex(c);
}
示例15: load
OFX_OBJLOADER_BEGIN_NAMESPACE
void load(string path, ofMesh& mesh, bool generateNormals, bool flipFace)
{
path = ofToDataPath(path);
mesh.clear();
GLMmodel* m;
m = glmReadOBJ((char*)path.c_str());
if (generateNormals)
{
glmFacetNormals(m);
glmVertexNormals(m, 90);
}
if (flipFace)
{
glmReverseWinding(m);
}
for (int j = 0; j < m->numtriangles; j++)
{
const GLMtriangle &tri = m->triangles[j];
for (int k = 0; k < 3; k++)
{
GLfloat *v = m->vertices + (tri.vindices[k] * 3);
mesh.addVertex(ofVec3f(v[0], v[1], v[2]));
if (m->colors)
{
GLfloat *c = m->colors + (tri.vindices[k] * 3);
mesh.addColor(ofFloatColor(c[0], c[1], c[2]));
}
if (m->normals && ofInRange(tri.nindices[k], 0, m->numnormals))
{
GLfloat *n = m->normals + (tri.nindices[k] * 3);
mesh.addNormal(ofVec3f(n[0], n[1], n[2]));
}
if (m->texcoords && ofInRange(tri.tindices[k], 0, m->numtexcoords))
{
GLfloat *c = m->texcoords + (tri.tindices[k] * 2);
mesh.addTexCoord(ofVec2f(c[0], c[1]));
}
}
}
glmDelete(m);
}