1 / 8

Curves and Surfaces in OpenGL

Curves and Surfaces in OpenGL. Manually Generating Line Coordinates. We can define almost any curve using a formula such as Q (U) = A0 + A1*U + A2*U 2 + A3*U 3 where: Q is the calculation for x, y, or z coordinate. U varies over the range of the curve segment

salim
Download Presentation

Curves and Surfaces in OpenGL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Curves and Surfaces in OpenGL

  2. Manually Generating Line Coordinates We can define almost any curve using a formula such as Q (U) = A0 + A1*U + A2*U2 + A3*U3 where: Q is the calculation for x, y, or z coordinate. U varies over the range of the curve segment see spreadsheet 1 at course web site

  3. Point 1,1 Point 1,2 etc 1st point 2nd point Nth point Lines v. Curves So, U varies from 1 to N and V varies from 1 to M And, for each point N,M we need to create an X,Y,Z So, U varies from 1 to N

  4. Manually Generating Curved Surface Coordinates Parametric surfaces can be defined using both a U and a V. So, Q(U,V) = A00 + A10U + A01V + A11UV + A20U2 + . . . The problem is keeping up with all these coefficients. We need a separate A00 A10 etc for X and Y and Z. see really bad spreadsheet on course web site

  5. Automated Curved Lines in OpenGL • We can define a curve using just a few control points. • For example • {-4.0, -4.0, 0.0} • {-2.0, 4.0, 0.0} • { 2.0, -4.0, 0.0} • { 4.0, 4.0, 0.0} • see bezcurve.c for source code

  6. Function Details glmap1f ( target, float Ustart, float Uend, int stride, int order, float *points) target GL_MAP1_VERTEX_3, GL_MAP1_VERTEX_4 GL_MAP1_NORMAL, GL_COLOR_4, etc Ustart, Uend almost always 0 and 1 stride distance between points in data (3->3D, 4->4D) order order + 1 , so 4 = cubic curve points array of control points

  7. Shortcuts • If this was too much code glBegin(GL_LINE_STRIP); for (i =3D 0; i <=3D 30; i++) glEvalCoord1f((GLfloat) i/30.0); glEnd(); • Try this equivalent glMapGrid1f (30, 0.0, 1.0); glEvalMesh1 (GL_LINE, 30);

  8. Automated Curved Surfaces in OpenGL glMap2f ( target, uStart, uEnd, uStride, uOrder, vStart, vEnd, vStride, vOrder, points) glEvalCoord2f ( u, v ) glMapGrid2f ( uNumber, uStart, uEnd, vNumber, vStart, vEnd) glEvalMesh2 (drawing_mode, i1, i2, j1, j2) drawing mode GL_LINE creates a mesh GL_POINT GL_FILL creates a filled surface i and j range of curve along x and y

More Related