Sign in to follow this  

Problem in glnurbscurve for drawing circle

This topic is 4109 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi , I have a hexagon gving me six control points.I need to draw a circle using glNurbsCurve. Following is a snippet of my code :
void drawNurbsCurve(float** ObjectCtrPts , int iTotalCtrlPts) 
{
    //GLUnurbsObj *pNurb = NULL;
	int i = 0 ;
    //int iKnotCount =  ORDER + iTotalCtrlPts  ; 
	int iKnotCount = 13;
	int  kStride = 2;
	
GLfloat Knots[13] = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0} ;
	

	{
    glNewList(3, GL_COMPILE);
// Begin the NURB definition
	    glColor3f(0.2,0.8,0.5);	
	    gluBeginCurve(pNurb);
//Enable the following	
glEnable(GL_MAP1_VERTEX_3);
// Send the Non Uniform Rational BSpline
gluNurbsCurve(pNurb, 13, Knots, kStride, &ObjectCtrPts[0][0] , 4, GL_MAP1_VERTEX_3);
 gluEndCurve(pNurb);		
     
		glBegin(GL_POINTS);
		  glColor3f(1.0,1.0,1.0);
		  glVertex3f(0.0f, 0.0f , 0.0f);
	 	glEnd();
		
	glEndList();
	}

I am passing Object control points as follows: ObjCtrPts[][] = { 1.0 , 0.0 ; 0.5, sqrt(3)/4 ; -0.5, sqrt(3)/4; - 1.0 , 0.0 ; -0.5, -sqrt(3)/4}; 0.5, -sqrt(3)/4 } And I am using function call as : gluNurbsCurve(pNurb, 13, Knots, kStride, &ObjectCtrPts[0][0] , 4, GL_MAP1_VERTEX_3); Where my order is 4 , num of knots is 13 ( since control points are 9, for drawing a circle) and knotcount is 13. I am using GL_MAP1_VERTEX_3 RESULT : Getting two perpendicular lines meeting at coordinate (0.0f , 0.0f) i.e at origin. When i use GL_MAP_VERTEX_4 I get a straigh line starting from Control point number 1 and goes out of screen(viewport). I want to get a circle.Where am I going wrong.I searched the RED Book and other sites on google but could not get any help.Hope I will be fortunate this time.

Share this post


Link to post
Share on other sites

This topic is 4109 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this