Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
55 | pj | 1 | /* $Id: nurbs.h,v 1.1 2003-02-28 11:42:07 pj Exp $ */ |
2 | |||
3 | /* |
||
4 | * Mesa 3-D graphics library |
||
5 | * Version: 3.3 |
||
6 | * Copyright (C) 1995-2000 Brian Paul |
||
7 | * |
||
8 | * This library is free software; you can redistribute it and/or |
||
9 | * modify it under the terms of the GNU Library General Public |
||
10 | * License as published by the Free Software Foundation; either |
||
11 | * version 2 of the License, or (at your option) any later version. |
||
12 | * |
||
13 | * This library is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
16 | * Library General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU Library General Public |
||
19 | * License along with this library; if not, write to the Free |
||
20 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||
21 | */ |
||
22 | |||
23 | |||
24 | /* |
||
25 | * NURBS implementation written by Bogdan Sikorski (bogdan@cira.it) |
||
26 | * See README2 for more info. |
||
27 | */ |
||
28 | |||
29 | |||
30 | #ifndef NURBS_H |
||
31 | #define NURBS_H |
||
32 | |||
33 | |||
34 | #define EPSILON 1e-06 /* epsilon for double precision compares */ |
||
35 | |||
36 | typedef enum |
||
37 | { |
||
38 | GLU_NURBS_CURVE, GLU_NURBS_SURFACE, GLU_NURBS_TRIM, GLU_NURBS_NO_TRIM, |
||
39 | GLU_NURBS_TRIM_DONE, GLU_NURBS_NONE |
||
40 | } |
||
41 | GLU_nurbs_enum; |
||
42 | |||
43 | typedef enum |
||
44 | { |
||
45 | GLU_TRIM_NURBS, GLU_TRIM_PWL |
||
46 | } |
||
47 | GLU_trim_enum; |
||
48 | |||
49 | typedef struct |
||
50 | { |
||
51 | GLint sknot_count; |
||
52 | GLfloat *sknot; |
||
53 | GLint tknot_count; |
||
54 | GLfloat *tknot; |
||
55 | GLint s_stride; |
||
56 | GLint t_stride; |
||
57 | GLfloat *ctrlarray; |
||
58 | GLint sorder; |
||
59 | GLint torder; |
||
60 | GLint dim; |
||
61 | GLenum type; |
||
62 | } |
||
63 | surface_attribs; |
||
64 | |||
65 | typedef struct |
||
66 | { |
||
67 | surface_attribs geom; |
||
68 | surface_attribs color; |
||
69 | surface_attribs texture; |
||
70 | surface_attribs normal; |
||
71 | } |
||
72 | nurbs_surface; |
||
73 | |||
74 | typedef struct |
||
75 | { |
||
76 | GLint knot_count; |
||
77 | GLfloat *knot; |
||
78 | GLint stride; |
||
79 | GLfloat *ctrlarray; |
||
80 | GLint order; |
||
81 | GLint dim; |
||
82 | GLenum type; |
||
83 | } |
||
84 | curve_attribs; |
||
85 | |||
86 | typedef struct |
||
87 | { |
||
88 | GLint pt_count; |
||
89 | GLfloat *ctrlarray; |
||
90 | GLint stride; |
||
91 | GLint dim; |
||
92 | GLenum type; |
||
93 | } |
||
94 | pwl_curve_attribs; |
||
95 | |||
96 | typedef struct |
||
97 | { |
||
98 | curve_attribs geom; |
||
99 | curve_attribs color; |
||
100 | curve_attribs texture; |
||
101 | curve_attribs normal; |
||
102 | } |
||
103 | nurbs_curve; |
||
104 | |||
105 | typedef struct trim_list_str |
||
106 | { |
||
107 | GLU_trim_enum trim_type; |
||
108 | union |
||
109 | { |
||
110 | pwl_curve_attribs pwl_curve; |
||
111 | curve_attribs nurbs_curve; |
||
112 | } |
||
113 | curve; |
||
114 | struct trim_list_str *next; |
||
115 | } |
||
116 | trim_list; |
||
117 | |||
118 | typedef struct seg_trim_str |
||
119 | { |
||
120 | GLfloat *points; |
||
121 | GLint pt_cnt, seg_array_len; |
||
122 | struct seg_trim_str *next; |
||
123 | } |
||
124 | trim_segments; |
||
125 | |||
126 | typedef struct nurbs_trim_str |
||
127 | { |
||
128 | trim_list *trim_loop; |
||
129 | trim_segments *segments; |
||
130 | struct nurbs_trim_str *next; |
||
131 | } |
||
132 | nurbs_trim; |
||
133 | |||
134 | typedef struct |
||
135 | { |
||
136 | GLfloat model[16], proj[16], viewport[4]; |
||
137 | } |
||
138 | culling_and_sampling_str; |
||
139 | |||
140 | struct GLUnurbs |
||
141 | { |
||
142 | GLboolean culling; |
||
143 | GLenum error; |
||
144 | void (GLCALLBACK * error_callback) (GLenum err); |
||
145 | GLenum display_mode; |
||
146 | GLU_nurbs_enum nurbs_type; |
||
147 | GLboolean auto_load_matrix; |
||
148 | culling_and_sampling_str sampling_matrices; |
||
149 | GLenum sampling_method; |
||
150 | GLfloat sampling_tolerance; |
||
151 | GLfloat parametric_tolerance; |
||
152 | GLint u_step, v_step; |
||
153 | nurbs_surface surface; |
||
154 | nurbs_curve curve; |
||
155 | nurbs_trim *trim; |
||
156 | }; |
||
157 | |||
158 | typedef struct |
||
159 | { |
||
160 | GLfloat *knot; |
||
161 | GLint nknots; |
||
162 | GLfloat *unified_knot; |
||
163 | GLint unified_nknots; |
||
164 | GLint order; |
||
165 | GLint t_min, t_max; |
||
166 | GLint delta_nknots; |
||
167 | GLboolean open_at_begin, open_at_end; |
||
168 | GLfloat *new_knot; |
||
169 | GLfloat *alpha; |
||
170 | } |
||
171 | knot_str_type; |
||
172 | |||
173 | typedef struct |
||
174 | { |
||
175 | GLfloat *geom_ctrl; |
||
176 | GLint geom_s_stride, geom_t_stride; |
||
177 | GLfloat **geom_offsets; |
||
178 | GLint geom_s_pt_cnt, geom_t_pt_cnt; |
||
179 | GLfloat *color_ctrl; |
||
180 | GLint color_s_stride, color_t_stride; |
||
181 | GLfloat **color_offsets; |
||
182 | GLint color_s_pt_cnt, color_t_pt_cnt; |
||
183 | GLfloat *normal_ctrl; |
||
184 | GLint normal_s_stride, normal_t_stride; |
||
185 | GLfloat **normal_offsets; |
||
186 | GLint normal_s_pt_cnt, normal_t_pt_cnt; |
||
187 | GLfloat *texture_ctrl; |
||
188 | GLint texture_s_stride, texture_t_stride; |
||
189 | GLfloat **texture_offsets; |
||
190 | GLint texture_s_pt_cnt, texture_t_pt_cnt; |
||
191 | GLint s_bezier_cnt, t_bezier_cnt; |
||
192 | } |
||
193 | new_ctrl_type; |
||
194 | |||
195 | extern void call_user_error(GLUnurbsObj * nobj, GLenum error); |
||
196 | |||
197 | extern GLenum test_knot(GLint nknots, GLfloat * knot, GLint order); |
||
198 | |||
199 | extern GLenum explode_knot(knot_str_type * the_knot); |
||
200 | |||
201 | extern GLenum calc_alphas(knot_str_type * the_knot); |
||
202 | |||
203 | extern GLenum calc_new_ctrl_pts(GLfloat * ctrl, GLint stride, |
||
204 | knot_str_type * the_knot, GLint dim, |
||
205 | GLfloat ** new_ctrl, GLint * ncontrol); |
||
206 | |||
207 | extern GLenum glu_do_sampling_crv(GLUnurbsObj * nobj, GLfloat * new_ctrl, |
||
208 | GLint n_ctrl, GLint order, GLint dim, |
||
209 | GLint ** factors); |
||
210 | |||
211 | extern GLenum glu_do_sampling_3D(GLUnurbsObj * nobj, new_ctrl_type * new_ctrl, |
||
212 | int **sfactors, GLint ** tfactors); |
||
213 | |||
214 | extern GLenum glu_do_sampling_uv(GLUnurbsObj * nobj, new_ctrl_type * new_ctrl, |
||
215 | int **sfactors, GLint ** tfactors); |
||
216 | |||
217 | extern GLenum glu_do_sampling_param_3D(GLUnurbsObj * nobj, |
||
218 | new_ctrl_type * new_ctrl, |
||
219 | int **sfactors, GLint ** tfactors); |
||
220 | |||
221 | extern GLboolean fine_culling_test_2D(GLUnurbsObj * nobj, GLfloat * ctrl, |
||
222 | GLint n_ctrl, GLint stride, GLint dim); |
||
223 | |||
224 | extern GLboolean fine_culling_test_3D(GLUnurbsObj * nobj, GLfloat * ctrl, |
||
225 | GLint s_n_ctrl, GLint t_n_ctrl, |
||
226 | GLint s_stride, GLint t_stride, |
||
227 | GLint dim); |
||
228 | |||
229 | extern void do_nurbs_curve(GLUnurbsObj * nobj); |
||
230 | |||
231 | extern void do_nurbs_surface(GLUnurbsObj * nobj); |
||
232 | |||
233 | extern GLenum patch_trimming(GLUnurbsObj * nobj, new_ctrl_type * new_ctrl, |
||
234 | GLint * sfactors, GLint * tfactors); |
||
235 | |||
236 | extern void collect_unified_knot(knot_str_type * dest, knot_str_type * src, |
||
237 | GLfloat maximal_min_knot, |
||
238 | GLfloat minimal_max_knot); |
||
239 | |||
240 | extern GLenum select_knot_working_range(GLUnurbsObj * nobj, |
||
241 | knot_str_type * geom_knot, |
||
242 | knot_str_type * color_knot, |
||
243 | knot_str_type * normal_knot, |
||
244 | knot_str_type * texture_knot); |
||
245 | |||
246 | extern void free_unified_knots(knot_str_type * geom_knot, |
||
247 | knot_str_type * color_knot, |
||
248 | knot_str_type * normal_knot, |
||
249 | knot_str_type * texture_knot); |
||
250 | |||
251 | |||
252 | |||
253 | #endif |