void helix::drawCenteredForDOF( ofShader & dofShader, bool bDrawInner, bool bDrawOuter ){ GLint sideLocation = dofShader.getAttributeLocation("side"); GLint nextLocation = dofShader.getAttributeLocation("next"); ofPoint midPt; int count = 0; for (int i = 0; i < helix0.size(); i++){ midPt += helix0[i]; count++; } for (int i = 0; i < helix1.size(); i++){ midPt += helix1[i]; count++; } for (int i = 0; i < lines.size(); i++){ midPt += lines[i].a; midPt += lines[i].b; count += 2; } midPt /= (float)count; ofPushMatrix(); ofTranslate(-midPt.x, -midPt.y, -midPt.z); if (bDrawOuter){ glBegin(GL_TRIANGLE_STRIP); for (int i = 0; i < helix0.size()-1; i++){ ofPoint cur = helix0[i]; ofPoint next = helix0[i+1]; ofPoint temp0 = cur; ofPoint temp1 = next; temp0.normalize(); temp1.normalize(); ofPoint normal = temp0.cross(temp1).normalize(); dofShader.setAttribute1f(sideLocation, -.5); dofShader.setAttribute3f(nextLocation, next.x, next.y, next.z); //glNormal3f(normal.x, normal.y, normal.y); glVertex3f(cur.x, cur.y, cur.z); dofShader.setAttribute1f(sideLocation, +.5); dofShader.setAttribute3f(nextLocation, next.x, next.y, next.z); //glNormal3f(normal.x, normal.y, normal.y); glVertex3f(cur.x, cur.y, cur.z); } glEnd(); glBegin(GL_TRIANGLE_STRIP); for (int i = 0; i < helix1.size()-1; i++){ ofPoint cur = helix1[i]; ofPoint next = helix1[i+1]; ofPoint temp0 = cur; ofPoint temp1 = next; temp0.normalize(); temp1.normalize(); ofPoint normal = temp0.cross(temp1).normalize(); dofShader.setAttribute1f(sideLocation, -.5); dofShader.setAttribute3f(nextLocation, next.x, next.y, next.z); //glNormal3f(normal.x, normal.y, normal.y); glVertex3f(cur.x, cur.y, cur.z); dofShader.setAttribute1f(sideLocation, +.5); dofShader.setAttribute3f(nextLocation, next.x, next.y, next.z); //glNormal3f(normal.x, normal.y, normal.y); glVertex3f(cur.x, cur.y, cur.z); } glEnd(); } if (bDrawInner) for (int i = 0; i < lines.size(); i++){ int divisions = 20; glBegin(GL_TRIANGLE_STRIP); for (int j = 0; j < 20; j++){ ofPoint cur = lines[i].a + ((lines[i].b - lines[i].a)/(float)19) * j; ofPoint next = lines[i].a + ((lines[i].b - lines[i].a)/(float)19) * (j+1); dofShader.setAttribute1f(sideLocation, -.5); dofShader.setAttribute3f(nextLocation, next.x, next.y, next.z); glVertex3f(cur.x, cur.y, cur.z); glTexCoord2d( ofRandom(0,50), ofRandom(0,50)); dofShader.setAttribute1f(sideLocation, +.5); dofShader.setAttribute3f(nextLocation, next.x, next.y, next.z); glVertex3f(cur.x, cur.y, cur.z); glTexCoord2d(ofRandom(0,50), ofRandom(0,50)); } glEnd(); } ofPopMatrix(); }