Vec2d* drawFlower(float radius, Vec2d center,int petals,float petalSize){
Vec2d cp; //circle points as vector
int points = 400;
Vec2d pointA[900];
float pointRatio = points/petals;
glColor3f( 0,0,1 );
glBegin( GL_LINE_LOOP );
for (int i = 0; i< points; i++){//number of points (x) x/number gives number of arcs how many points are in one arc of 360
float x =i; // watch the is
float angle = ((2*PI)/points)*x; //2*pi is 360 divided into degree segments based on points multiplied by what point your on
float addOn = petalSize * helpers::d_sin(((x/pointRatio)*360) );// to make a sine wave map to radius
cp.x= cos(angle) * (radius+addOn); //gets the length of x in unit circle and muiltiplies by radius the size out
cp.y= sin(angle) * (radius+addOn); //gets the length of y and muiltiplies by radius
cp = cp+center; //sets the offset center point
//cp.x += 300; //adds in the of set
//cp.y += 300; //adds in the of set
// glColor3f( (mouseX/windowW),(mouseY/windowH),0.0f);
// printf( "%f \n", i );
//cp.x= cp.x+ addOn; //gets the length of x in unit circle and muiltiplies by radius the size out
// cp.y= cp.y+ addOn;
pointA[i] = cp;
glVertex2f(cp.x,cp.y);
}
glEnd();
return pointA;
}
void drawWireframeExtrusion( Vec2d* _points, int _numPoints, float _height, int _steps){
float numOfShape = _height/_steps;// gives num of steps in range puts a shape
int apart = 2;// spacing
// for each spot
for(int h = 0; h < numOfShape; h++){
float step = (h*numOfShape)*apart;
glColor3f( 0,1,1 );
//draw shape
glBegin( GL_LINE_LOOP );
for(int i = 0; i < _numPoints; i++){
glVertex3f( _points[i].x,step , _points[i].y );
}
glEnd();
//draw in wire
int lineSpacing = 4;
for ( int j = lineSpacing; j<_numPoints; j += lineSpacing){
// glColor3f( 1,0,1 );
glBegin( GL_LINE_LOOP );
glVertex3f( _points[j].x, step ,_points[j].y );
glVertex3f( _points[j].x, 0 ,_points[j].y ); // y is z in Vec2d object should make a Vec3d
glEnd();
}
}
}
////////////////////////////****//////////////////////////////////////////////////////
void displayFunc ( void ) //arg void returns void
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); //clears buffers(what buffers?) by setting bit mask or.
//printf(" %f", mouseX);
Vec2d center(0,0);
glLoadIdentity();
glTranslatef(0.0f, mouseX-500, -200);
//circle();
//drawFlower(100, center,8 , 20.0);
Vec2d* va = drawFlower(100, center,8 , 20.0);
drawWireframeExtrusion(va , 400, 300, 20);
//drawWireframeCylinder();
glutPostRedisplay(); //tags the current window to be redisplayed or shown through the
//next iteration loop.
glutSwapBuffers(); //calls for the display of a the current buffer for the curretn window
// i assume to cut down on jerky motion
}