Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created July 14, 2011 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roxlu/1083300 to your computer and use it in GitHub Desktop.
Save roxlu/1083300 to your computer and use it in GitHub Desktop.
vector<ofVec3f> bottom;
vector<ofVec3f> top;
for(float i = 0; i < 10; ++i) {
float a = (i/10) * TWO_PI;
float x = cos(a) * 5;
float z = sin(a) * 5;
ofVec3f vec(x,0,z);
mesh.addVertex(vec);
verts.push_back(vec);
}
for(float i = 0; i < 10; ++i) {
float a = (i/10) * TWO_PI;
float x = cos(a) * 5;
float z = sin(a) * 5;
ofVec3f vec(x,5,z);
mesh.addVertex(vec);
verts.push_back(vec);
}
// create triangles.
for(int j = 0; j < 1; ++j) {
for(int i = 0; i < 10; ++i) {
if( i < 9) {
mesh.addIndex(DX(i,j));
mesh.addIndex(DX(i+1,j));
mesh.addIndex(DX(i+1,j+1));
// triangle a
inds.push_back(DX(i,j));
inds.push_back(DX(i+1,j));
inds.push_back(DX(i+1,j+1));
// triangle b
inds.push_back(DX(i,j));
inds.push_back(DX(i,j+1));
inds.push_back(DX(i+1,j+1));
}
else {
inds.push_back(DX(i,j));
inds.push_back(DX(0,j));
inds.push_back(DX(0,j+1));
inds.push_back(DX(i,j));
inds.push_back(DX(i,j+1));
inds.push_back(DX(0,j+1));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment