/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Development/libraries/opengl/nurb.txt

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Evaluators
 
2
==========
 
3
 The basic idea is following. Using 'glMap*' functions a Bezier curves, NURBS,
 
4
and etc. are defined. Then, if it is neccessary to draw this curve, glEvalCord*
 
5
functions should be called to produced desired number of vertices on this
 
6
curve. As much vertices are generated beter the curve is displayed.
 
7
 
 
8
(desired number of times) 
 
9
 
 
10
This defines evaluator functions
 
11
 
 
12
 glMap1{fd}(target, u1, u2, stride, order, ctrlpoints)
 
13
    target      - target
 
14
        GL_MAP1_VERTEX3         x,y,z vertices 
 
15
        GL_MAP1_VERTEX4         x,y,z,w vertices
 
16
        GL_MAP1_COLOR4          r,g,b,a colors
 
17
        GL_MAP1_NORMAL          normal coordinates
 
18
        GL_MAP1_TEXTURE_COORD_1 s - texture coordinate
 
19
        GL_MAP1_TEXTURE_COORD_2 s,t - texture coords.
 
20
        GL_MAP1_TEXTURE_COORD_3 s,t,r - texture coords.
 
21
        GL_MAP1_TEXTURE_COORD_4 s,t,r,q - texture coords.
 
22
        - It is possible to sequentialy define several targets, so when
 
23
        the glEvalCoords are called, both coords. and color (for example)
 
24
        of vertices are set.
 
25
        - Coresponding targets should be enabled using glEnable call
 
26
 
 
27
    u1,u2       - Is lowest and highest values which would be passed to the
 
28
                glEvalCord function. The lowest value is coresponding to a
 
29
                start point of spline and the highest to the end point.
 
30
    stride      - The number of floating-point values to advance in the data 
 
31
                between one control point and the next
 
32
    order       - order of spline (degree + 1, normally equal to number of
 
33
                control points?)
 
34
    ctrlpoints  - coordinates of control points
 
35
 
 
36
  glEnable(<target>);           - enabling target
 
37
 
 
38
  glEvalCoord1{fd}{v}(value);
 
39
    Generates vertex on the spline created with 'glMap1f' functio. 
 
40
    value - addresses poisition in the spline (should be between "from" and
 
41
    "to" values defined in the g1Map1f call)
 
42
    
 
43
 glMapGrid1(n, from, to)
 
44
    Used to define a grid of 'n' uniformly distributed between 'from' and 'to'
 
45
    points.
 
46
 glEvalMesh1(<mode>, p1, p2)
 
47
    Applies part of currently defined GRID to all enabled evaluators
 
48
    p1, p2: number of points defining part of grids 0 <= p1 < p2 <= n
 
49
    mode: defines type of primitives to be drawn
 
50
        GL_POINT        draw points
 
51
        GL_LINE         conect lines along the curve
 
52
 
 
53
 
 
54
 Defining 2D Evaluators
 
55
 ----------------------
 
56
 targets: GL_MAP2_VERTEX_3, GL_MAP2_VERTEX_4, ...
 
57
 
 
58
 glMap2{fd}(target, 
 
59
    u1, u2, ustride, uorder, 
 
60
    v1, v2, vstride, vorder, 
 
61
    points);
 
62
        
 
63
 glEvalCoord2{fd}{v}(u,v)
 
64
    
 
65
 glEnable(GL_AUTO_NORMAL)       - enables auto-generation of normals
 
66
 
 
67
 glMapGrid2{fd}(nu, u1, u2, nv, v1, v2)
 
68
 glEvalMesh2(mode, p1, p2, q2, q2);
 
69
    modes: GL_FILL (quad-mesh polygons), GL_POINT, GL_LINE
 
70
    
 
71
NURBS (Non-Uniform Rational B-Spline) 
 
72
=====================================
 
73
    Implemented by OpenGL utility library on top of the evaluators
 
74
    
 
75
    
 
76
 GLUnurbsObj gluNewNurbsRenderer()              - creating NURBS object
 
77
 gluNurbsProperty(GLUnurbsObj, prop, value)     - setting property
 
78
    GLU_SAMPLING_TOLERANCE = limit      - limits maximal polygon size
 
79
        NURBS are rendered as primitives using some Grid. This property
 
80
        defines maximal size of grid's cell.
 
81
    GLU_DISPLAY_MODE = <mode>
 
82
        GLU_FILL                - renders as polygons
 
83
        GLU_OUTLINE_POLYGON     - renders as outlines of polygons
 
84
        GLU_OUTLINE_PATCH       - enders the outlines of patches and 
 
85
                                trimming curves
 
86
    GLU_CULLING = <enabled>     - speed up performance by not performing 
 
87
                                tessellation if the NURBS object falls 
 
88
                                completely outside the viewing volume
 
89
    GLU_AUTO_LOAD_MATRIX        - determines whether transformation matrices
 
90
                                are downloaded from the OpenGL server (GL_TRUE)
 
91
                                or whether the application must supply these 
 
92
                                matrices with gluLoadSamplingMatrices()
 
93
 
 
94
 
 
95
 Drawing 2D Surfaces:
 
96
 gluBeginSurface(GLUnurbsObj);
 
97
 void gluNurbsSurface (GLUnurbsObj,     - Configuring NURBS
 
98
    GLint uknot_count, GLfloat *uknot,  - KNOT Vector 
 
99
    GLint vknot_count, GLfloat *vknot,  - KNOT Vector
 
100
    GLint u_stride, GLint v_stride,     - number of floating-point values 
 
101
                                        between control points in each 
 
102
                                        parametric direction
 
103
    GLfloat *ctlarray,                  - control points, the number of control
 
104
                                        points along each parameter as the 
 
105
                                        number of knots minus the order
 
106
    GLint uorder, GLint vorder,         - order of NURBS
 
107
    GLenum type);                       - ne of the two-dimensional evaluator 
 
108
                                        types: GL_MAP2_VERTEX_3, ...
 
109
 gluEndSurface(GLUnurbsObj);
 
110
 
 
111
 Drawing 1D Curves:
 
112
    gluBeginCurve(GLUnurbsObj)
 
113
    gluNurbsCurve (GLUnurbsObj, uknot_count, uknot, u_stride, ctlarray, uorder, type);
 
114
    gluEndCurve(GLUnurbsObj)
 
115
 
 
116
 Trimming:
 
117
    - You need to consider the orientation of trimming curves - that is, 
 
118
    whether they're counterclockwise or clockwise - to make sure you include 
 
119
    the desired part of the surface. If you imagine walking along a curve, 
 
120
    everything to the left is included and everything to the right is trimmed 
 
121
    away.
 
122
 
 
123
    gluBegin(Curve|Surface)
 
124
      gluNurbs(Curve|Surface)
 
125
        .......................
 
126
      gluBeginTrim()
 
127
        
 
128
        gluPwlCurve(GLUnurbsObj, GLint count, GFloat *array, GLint stride, GLEnum type )                
 
129
            - piecewise linear trimming curve: There are 'count' points on the 
 
130
            curve, and they're given by 'array'. 
 
131
            stride: number of floating-point values to the next vertex
 
132
            type: GLU_MAP1_TRIM_2 or GLU_MAP1_TRIM_3
 
133
 
 
134
        gluNurbsCurve(GLUnurbsObj, uknot_count, uknot, u_stride, ctlarray, uorder, type)
 
135
            - NURBS trimming curve
 
136
 
 
137
      gluEndTrim()
 
138
    gluEnd(Curve|Surface)