1 / 11

Computer Graphic And Vision

Computer Graphic And Vision. Computer Science Department 2014-2015. Curves and Surfaces. Curves and Surfaces in OpenGL. OpenGL supports Bézier curves and surfaces though mechanisms called Evaluators . These are used to compute values for the Bernstein polynomials of any order.

Download Presentation

Computer Graphic And Vision

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. Computer Graphic And Vision Computer Science Department 2014-2015 Curves and Surfaces

  2. Curves and Surfaces in OpenGL • OpenGL supports Bézier curves and surfaces though mechanisms called Evaluators. • These are used to compute values for the Bernstein polynomials of any order. • The OpenGL evaluator functions allow you to use a polynomial mapping to produce Vertices, Normals, Texture Coordinates, and Colors.

  3. OpenGL Bezier-Spline Curve Function • To specify parameters and activate Bezier-curve: publicvoid glMap1{fd}(Glenum target , TYPE u1, TYPE u2, GLint stride, GLint order, const TYPE *points); • glEnable(Glenum target); • glDisable(Glenum target); target : GL_MAP1_VERTEX_3 target-type of objects to be evaluated using Bezier polynomials: GL_MAP1_VERTEX_3 u1,u2- u_min, u_max -Range of parameter values [0 – 1] stride - is the number of single- or doubleprecision values (as appropriate) in each block of storage. Thus, it’s an offset value between the beginning ofone control point and the beginning of the next. order- The orderis the degree plus 1, and it should agree with the number of control points. *points – Control Points float[] ctrlpoints = {…} double[] ctrlpoints = {…}

  4. Evaluator - Curve • „To calculate the coordinate position along the curve path: • void glEvalCoord1{fd}(TYPE u); • void glEvalCoord1{fd}v(const TYPE *u); • A Bézier curve is a vector-valued function of one variable • C(u) = [X(u) Y(u) Z(u)] • where u varies in some domain [0, 1]

  5. Bezier Curve Example BezierCurve.java

  6. Defining Evenly Spaced Coordinate Values in One Dimension • the following commands can be used to produce a set of uniformly spaced parameter values: • glMapGrid1{fd}(n, u1, u2); • glEvalMesh(mode, n1, n2); n: Equal subdivisions from u1 to u2 n1 and n2: an integer range corresponding tou1 and u2 mode: either GL_POINT, GL_LINE • Example: in the previous example we can replace the block containing the for loop with: • glColor3f(1.0, 1.0, 1.0); • glMapGrid1f(100, 0.0, 1.0); • glEvalMesh1(GL_LINE, 0, 100); GridBezierCurve.java

  7. OpenGL Bezier-Spline Surface Function • To specify parameters and activate Surface: publicvoid glMap2f{fd}(Glenum target , TYPE u1, TYPE u2, GLintustride, GLintuorder, TYPE v1, TYPE v2, GLintvstride, GLintvorder, const TYPE *points); • glEnable(Glenum target); • glDisable(Glenum target); target : GL_MAP2_VERTEX_3

  8. Evaluator - Surface • To calculate the coordinate position along the curve path: • void glEvalCoord2{fd}(TYPE u , TYPE v); • void glEvalCoord2{fd}v(const TYPE *values); • A Bézier surface patch is a vectorvalued function of two variables • S(u,v) = [X(u,v) Y(u,v) Z(u,v)] • where u and v can both vary in some domain [0, 1]

  9. Bezier Surface Example BezierSurface.java

  10. Defining Evenly Spaced Coordinate Values in Two Dimensions • Instead of using the glEvalCoord2() command, we can generate evenly spaced parameter values over the surface with • glMapGrid2{fd}(nu, u1, u2, nv, v1, v2); • glEvalMesh2(mode, nu1, nu2, nv1, nv2); nu: equaly spaced intervals between u1 and u2 nv: equaly spaced intervals between v1 and v2 nu1 and nu2: the corresponding integer for u nv1 and nv2: the corresponding integer for v mode: GL_POINT, GL_LINE, or GL_FILL • Example: in the previous example we can replace the block containing the two for loops with: • glMapGrid2{fd}(8, 0.0, 1.0, 8, 0.0, 1.0); • glEvalMesh2(GL_LINE, 0, 8, 0, 8) GridBezierSurface.java

  11. Thank You …

More Related