Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

McBugzz

Can't render a NURBS surface

This topic is 5346 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

The following func doesn''t draw a NURBS surface, and I can''t unserstand why. // Draws a rippling NURBS surface. void DrawSurface() { // Misc vars float size = 10; // Size of a square surface static float angle = 0; // Rotation angle // Nurbs vars GLUnurbsObj* rippleSurf; // NURBS object float nurbs[10][10][3]; // Control points float knots[20]; // Control point influence // Set up a single NURBS object and it''s properties rippleSurf = gluNewNurbsRenderer(); gluNurbsProperty( rippleSurf, GLU_SAMPLING_TOLERANCE, 50.0 ); gluNurbsProperty( rippleSurf, GLU_DISPLAY_MODE, GLU_FILL ); // Rotate the surface around the Y axis and inc the angle for the next round glRotatef( angle, 0, 1, 0 ); angle += 0.1f; // Center the surface around ( 0, 0, 0 ) glTranslatef( -size/2.0f, 0, -size/2.0f ); // The "water" texture loaded from a bmp file glBindTexture( GL_TEXTURE_2D, texture[6] ); // Calculate the sine-rippled surface (the control points) for( int u = 0; u < size; u++ ) for( int v = 0; v < size; v++ ) { nurbs[u][v][0] = (float)u; nurbs[u][v][1] = (float)( sin( size * u ) + cos( size * v ) ) / size; nurbs[u][v][2] = (float)v; } // Set up the knots (weights) for( int i = 0; i < size * 2; i++ ) knots = 1.0f; // Draw the NURBS surface glColor3f( 1, 1, 1 ); gluBeginSurface( rippleSurf ); gluNurbsSurface( rippleSurf, 20, knots, 20, knots, 10, 10, &nurbs[0][0][0], 10, 10, GL_MAP2_VERTEX_3 ); gluEndSurface( rippleSurf ); glColor3f( 1.0, 1.0, 0.0 ); glPointSize( 5.0 ); glBegin( GL_POINTS ); for( int i = 0; i < size; i++ ) for( int j = 0; j < size; j++ ) glVertex3fv( &nurbs[i][j][0] ); glEnd(); glPointSize(1.0); // Old-style flat Quad //glBegin( GL_QUADS ); // glTexCoord2i( 0, 0 ); // glVertex3f( 0, 0, 0 ); // glTexCoord2i( 0, 1 ); // glVertex3f( 0, 0, size ); // glTexCoord2i( 1, 1 ); // glVertex3f( size, 0, size ); // glTexCoord2i( 1, 0 ); // glVertex3f( size, 0, 0 ); //glEnd(); }

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!