home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / System / Mesa-3.1 / src-glu / nurbs.h < prev    next >
C/C++ Source or Header  |  1999-08-18  |  6KB  |  253 lines

  1. /* $Id: nurbs.h,v 1.1.1.1 1999/08/19 00:55:42 jtg Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  3.1
  6.  * Copyright (C) 1995-1999  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.  * $Log: nurbs.h,v $
  26.  * Revision 1.1.1.1  1999/08/19 00:55:42  jtg
  27.  * Imported sources
  28.  *
  29.  * Revision 1.5  1999/02/27 13:55:31  brianp
  30.  * fixed BeOS-related GLU typedef problems
  31.  *
  32.  * Revision 1.4  1999/01/03 03:23:15  brianp
  33.  * now using GLAPIENTRY and GLCALLBACK keywords (Ted Jump)
  34.  *
  35.  * Revision 1.3  1997/05/27 03:18:23  brianp
  36.  * minor clean-up
  37.  *
  38.  * Revision 1.2  1997/05/27 03:00:16  brianp
  39.  * incorporated Bogdan's new NURBS code
  40.  *
  41.  * Revision 1.1  1996/09/27 01:19:39  brianp
  42.  * Initial revision
  43.  *
  44.  */
  45.  
  46.  
  47. /*
  48.  * NURBS implementation written by Bogdan Sikorski (bogdan@cira.it)
  49.  * See README2 for more info.
  50.  */
  51.  
  52.  
  53. #ifndef NURBS_H
  54. #define NURBS_H
  55.  
  56.  
  57. #define EPSILON 1e-06 /* epsilon for double precision compares */
  58.  
  59. typedef enum
  60. {
  61.     GLU_NURBS_CURVE, GLU_NURBS_SURFACE, GLU_NURBS_TRIM, GLU_NURBS_NO_TRIM,
  62.     GLU_NURBS_TRIM_DONE, GLU_NURBS_NONE
  63. } GLU_nurbs_enum;
  64.  
  65. typedef enum
  66. {
  67.     GLU_TRIM_NURBS, GLU_TRIM_PWL
  68. } GLU_trim_enum;
  69.  
  70. typedef struct
  71. {
  72.     GLint    sknot_count;
  73.     GLfloat    *sknot;
  74.     GLint    tknot_count;
  75.     GLfloat    *tknot;
  76.     GLint    s_stride;
  77.     GLint    t_stride;
  78.     GLfloat    *ctrlarray;
  79.     GLint    sorder;
  80.     GLint    torder;
  81.     GLint    dim;
  82.     GLenum    type;
  83. } surface_attribs;
  84.  
  85. typedef struct
  86. {
  87.     surface_attribs    geom;
  88.     surface_attribs    color;
  89.     surface_attribs    texture;
  90.     surface_attribs    normal;
  91. } nurbs_surface;
  92.  
  93. typedef struct
  94. {
  95.     GLint            knot_count;
  96.     GLfloat            *knot;
  97.     GLint            stride;
  98.     GLfloat            *ctrlarray;
  99.     GLint            order;
  100.     GLint            dim;
  101.     GLenum            type;
  102. } curve_attribs;
  103.  
  104. typedef struct
  105. {
  106.     GLint            pt_count;
  107.     GLfloat            *ctrlarray;
  108.     GLint            stride;
  109.     GLint            dim;
  110.     GLenum            type;
  111. } pwl_curve_attribs;
  112.  
  113. typedef struct
  114. {
  115.     curve_attribs    geom;
  116.     curve_attribs    color;
  117.     curve_attribs    texture;
  118.     curve_attribs    normal;
  119. } nurbs_curve;
  120.  
  121. typedef struct trim_list_str
  122. {
  123.     GLU_trim_enum            trim_type;
  124.     union
  125.     {
  126.         pwl_curve_attribs    pwl_curve;
  127.         curve_attribs        nurbs_curve;
  128.     }                        curve;
  129.     struct trim_list_str    *next;
  130. } trim_list;
  131.  
  132. typedef struct seg_trim_str
  133. {
  134.     GLfloat             *points;
  135.     GLint                pt_cnt,seg_array_len;
  136.     struct seg_trim_str    *next;
  137. } trim_segments;
  138.  
  139. typedef struct nurbs_trim_str
  140. {
  141.     trim_list                *trim_loop;
  142.     trim_segments            *segments;
  143.     struct nurbs_trim_str    *next;
  144. } nurbs_trim;
  145.  
  146. typedef struct
  147. {
  148.     GLfloat model[16],proj[16],viewport[4];
  149. } culling_and_sampling_str;
  150.  
  151. struct GLUnurbs {
  152.     GLboolean        culling;
  153.     GLenum            error;
  154.     void            (GLCALLBACK *error_callback)( GLenum err );
  155.     GLenum            display_mode;
  156.     GLU_nurbs_enum    nurbs_type;
  157.     GLboolean        auto_load_matrix;
  158.     culling_and_sampling_str
  159.                     sampling_matrices;
  160.     GLenum            sampling_method;
  161.     GLfloat            sampling_tolerance;
  162.     GLfloat            parametric_tolerance;
  163.     GLint            u_step, v_step;
  164.     nurbs_surface    surface;
  165.     nurbs_curve        curve;
  166.     nurbs_trim        *trim;
  167. };
  168.  
  169. typedef struct
  170. {
  171.     GLfloat        *knot;
  172.     GLint        nknots;
  173.     GLfloat        *unified_knot;
  174.     GLint        unified_nknots;
  175.     GLint        order;
  176.     GLint        t_min,t_max;
  177.     GLint        delta_nknots;
  178.     GLboolean    open_at_begin,open_at_end;
  179.     GLfloat        *new_knot;
  180.     GLfloat        *alpha;
  181. } knot_str_type;
  182.  
  183. typedef struct
  184. {
  185.     GLfloat    *geom_ctrl;
  186.     GLint    geom_s_stride,geom_t_stride;
  187.     GLfloat    **geom_offsets;
  188.     GLint    geom_s_pt_cnt,geom_t_pt_cnt;
  189.     GLfloat    *color_ctrl;
  190.     GLint    color_s_stride,color_t_stride;
  191.     GLfloat    **color_offsets;
  192.     GLint    color_s_pt_cnt,color_t_pt_cnt;
  193.     GLfloat *normal_ctrl;
  194.     GLint    normal_s_stride,normal_t_stride;
  195.     GLfloat    **normal_offsets;
  196.     GLint    normal_s_pt_cnt,normal_t_pt_cnt;
  197.     GLfloat    *texture_ctrl;
  198.     GLint    texture_s_stride,texture_t_stride;
  199.     GLfloat    **texture_offsets;
  200.     GLint    texture_s_pt_cnt,texture_t_pt_cnt;
  201.     GLint    s_bezier_cnt,t_bezier_cnt;
  202. } new_ctrl_type;
  203.  
  204. extern void call_user_error( GLUnurbsObj *nobj, GLenum error );
  205.  
  206. extern GLenum test_knot(GLint nknots, GLfloat *knot, GLint order);
  207.  
  208. extern GLenum explode_knot(knot_str_type *the_knot);
  209.  
  210. extern GLenum calc_alphas(knot_str_type *the_knot);
  211.  
  212. extern GLenum calc_new_ctrl_pts(GLfloat *ctrl,GLint stride,knot_str_type *the_knot,
  213.     GLint dim,GLfloat **new_ctrl,GLint *ncontrol);
  214.  
  215. extern GLenum glu_do_sampling_crv(GLUnurbsObj *nobj, GLfloat *new_ctrl,GLint n_ctrl,
  216.     GLint order,GLint dim,GLint **factors);
  217.  
  218. extern GLenum glu_do_sampling_3D(GLUnurbsObj *nobj, new_ctrl_type *new_ctrl,
  219.     int **sfactors, GLint **tfactors);
  220.  
  221. extern GLenum glu_do_sampling_uv(GLUnurbsObj *nobj, new_ctrl_type *new_ctrl,
  222.     int **sfactors, GLint **tfactors);
  223.  
  224. extern GLenum glu_do_sampling_param_3D(GLUnurbsObj *nobj, new_ctrl_type *new_ctrl,
  225.     int **sfactors, GLint **tfactors);
  226.  
  227. extern GLboolean fine_culling_test_2D(GLUnurbsObj *nobj, GLfloat *ctrl, GLint n_ctrl,
  228.     GLint stride, GLint dim);
  229.  
  230. extern GLboolean fine_culling_test_3D(GLUnurbsObj *nobj, GLfloat *ctrl,
  231.     GLint s_n_ctrl, GLint t_n_ctrl, GLint s_stride, GLint t_stride, GLint dim);
  232.  
  233. extern void do_nurbs_curve( GLUnurbsObj *nobj);
  234.  
  235. extern void do_nurbs_surface( GLUnurbsObj *nobj);
  236.  
  237. extern GLenum patch_trimming(GLUnurbsObj *nobj,new_ctrl_type *new_ctrl,
  238.     GLint *sfactors, GLint *tfactors);
  239.  
  240. extern void collect_unified_knot(knot_str_type *dest, knot_str_type *src,
  241.     GLfloat maximal_min_knot, GLfloat minimal_max_knot);
  242.  
  243. extern GLenum select_knot_working_range(GLUnurbsObj *nobj,knot_str_type *geom_knot,
  244.     knot_str_type *color_knot, knot_str_type *normal_knot,
  245.     knot_str_type *texture_knot);
  246.  
  247. extern void free_unified_knots(knot_str_type *geom_knot, knot_str_type *color_knot,
  248.     knot_str_type *normal_knot, knot_str_type *texture_knot);
  249.  
  250.  
  251.  
  252. #endif
  253.