home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / gfx / x11 / Mesa_Amiwin.lha / Mesa-Amiwin / src-glu / nurbs.h < prev    next >
C/C++ Source or Header  |  1995-11-17  |  5KB  |  222 lines

  1. /* nurbs.h */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  1.2
  6.  * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
  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. $Id: nurbs.h,v 1.3 1995/11/03 14:13:19 brianp Exp $
  26.  
  27. $Log: nurbs.h,v $
  28.  * Revision 1.3  1995/11/03  14:13:19  brianp
  29.  * Bogdan's November 3, 1995 updates
  30.  *
  31.  * Revision 1.2  1995/07/28  21:36:49  brianp
  32.  * changed all GLUenum to GLenum
  33.  *
  34.  * Revision 1.1  1995/07/28  17:38:30  brianp
  35.  * Initial revision
  36.  *
  37.  */
  38.  
  39.  
  40. /*
  41.  * NURBS implementation written by Bogdan Sikorski (bogdan@cira.it)
  42.  * See README2 for more info.
  43.  */
  44.  
  45.  
  46. #include "gluP.h"
  47.  
  48. #define EPSILON 1e-06 /* epsilon for double precision compares */
  49.  
  50. typedef enum
  51. {
  52.     GLU_NURBS_CURVE, GLU_NURBS_SURFACE, GLU_NURBS_TRIM, GLU_NURBS_NO_TRIM,
  53.     GLU_NURBS_TRIM_DONE, GLU_NURBS_NONE
  54. } GLU_nurbs_enum;
  55.  
  56. typedef enum
  57. {
  58.     GLU_TRIM_NURBS, GLU_TRIM_PWL
  59. } GLU_trim_enum;
  60.  
  61. typedef struct
  62. {
  63.     GLint    sknot_count;
  64.     GLfloat    *sknot;
  65.     GLint    tknot_count;
  66.     GLfloat    *tknot;
  67.     GLint    s_stride;
  68.     GLint    t_stride;
  69.     GLfloat    *ctrlarray;
  70.     GLint    sorder;
  71.     GLint    torder;
  72.     GLint    dim;
  73.     GLenum    type;
  74. } surface_attribs;
  75.  
  76. typedef struct
  77. {
  78.     surface_attribs    geom;
  79.     surface_attribs    color;
  80.     surface_attribs    texture;
  81.     surface_attribs    normal;
  82. } nurbs_surface;
  83.  
  84. typedef struct
  85. {
  86.     GLint            knot_count;
  87.     GLfloat            *knot;
  88.     GLint            stride;
  89.     GLfloat            *ctrlarray;
  90.     GLint            order;
  91.     GLint            dim;
  92.     GLenum            type;
  93. } curve_attribs;
  94.  
  95. typedef struct
  96. {
  97.     GLint            pt_count;
  98.     GLfloat            *ctrlarray;
  99.     GLint            stride;
  100.     GLint            dim;
  101.     GLenum            type;
  102. } pwl_curve_attribs;
  103.  
  104. typedef struct
  105. {
  106.     curve_attribs    geom;
  107.     curve_attribs    color;
  108.     curve_attribs    texture;
  109.     curve_attribs    normal;
  110. } nurbs_curve;
  111.  
  112. typedef struct trim_list_str
  113. {
  114.     GLU_trim_enum            trim_type;
  115.     union
  116.     {
  117.         pwl_curve_attribs    pwl_curve;
  118.         curve_attribs        nurbs_curve;
  119.     }                        curve;
  120.     struct trim_list_str    *next;
  121. } trim_list;
  122.  
  123. typedef struct seg_trim_str
  124. {
  125.     GLfloat             *points;
  126.     GLint                pt_cnt,seg_array_len;
  127.     struct seg_trim_str    *next;
  128. } trim_segments;
  129.  
  130. typedef struct nurbs_trim_str
  131. {
  132.     trim_list                *trim_loop;
  133.     trim_segments            *segments;
  134.     struct nurbs_trim_str    *next;
  135. } nurbs_trim;
  136.  
  137. typedef struct
  138. {
  139.     GLfloat model[16],proj[16],viewport[4];
  140. } culling_and_sampling_str;
  141.  
  142. struct GLUnurbsObj {
  143.     GLboolean        culling;
  144.     GLenum            error;
  145.     void            (*error_callback)( GLenum err );
  146.     GLenum            display_mode;
  147.     GLU_nurbs_enum    nurbs_type;
  148.     GLboolean        auto_load_matrix;
  149.     culling_and_sampling_str
  150.                     sampling_matrices;
  151.     GLfloat            sampling_tolerance;
  152.     nurbs_surface    surface;
  153.     nurbs_curve        curve;
  154.     nurbs_trim        *trim;
  155. };
  156.  
  157. typedef struct
  158. {
  159.     GLfloat        *knot;
  160.     GLint        nknots;
  161.     GLfloat        *unified_knot;
  162.     GLint        unified_nknots;
  163.     GLint        order;
  164.     GLint        t_min,t_max;
  165.     GLint        delta_nknots;
  166.     GLboolean    open_at_begin,open_at_end;
  167.     GLfloat        *new_knot;
  168.     GLfloat        *alpha;
  169. } knot_str_type;
  170.  
  171. typedef struct
  172. {
  173.     GLfloat    *geom_ctrl;
  174.     GLint    geom_s_stride,geom_t_stride;
  175.     GLfloat    **geom_offsets;
  176.     GLint    geom_s_pt_cnt,geom_t_pt_cnt;
  177.     GLfloat    *color_ctrl;
  178.     GLint    color_s_stride,color_t_stride;
  179.     GLfloat    **color_offsets;
  180.     GLint    color_s_pt_cnt,color_t_pt_cnt;
  181.     GLfloat *normal_ctrl;
  182.     GLint    normal_s_stride,normal_t_stride;
  183.     GLfloat    **normal_offsets;
  184.     GLint    normal_s_pt_cnt,normal_t_pt_cnt;
  185.     GLfloat    *texture_ctrl;
  186.     GLint    texture_s_stride,texture_t_stride;
  187.     GLfloat    **texture_offsets;
  188.     GLint    texture_s_pt_cnt,texture_t_pt_cnt;
  189.     GLint    s_bezier_cnt,t_bezier_cnt;
  190. } new_ctrl_type;
  191.  
  192. void call_user_error( GLUnurbsObj *nobj, GLenum error );
  193.  
  194. GLenum test_knot(GLint nknots, GLfloat *knot, GLint order);
  195.  
  196. GLenum explode_knot(knot_str_type *the_knot);
  197.  
  198. GLenum calc_alphas(knot_str_type *the_knot);
  199.  
  200. GLenum calc_new_ctrl_pts(GLfloat *ctrl,GLint stride,knot_str_type *the_knot,
  201.     GLint dim,GLfloat **new_ctrl,GLint *ncontrol);
  202.  
  203. GLenum glu_do_sampling_2D(GLUnurbsObj *nobj, GLfloat *new_ctrl,GLint n_ctrl,
  204.     GLint order,GLint dim,GLint **factors);
  205.  
  206. GLenum glu_do_sampling_3D(GLUnurbsObj *nobj, GLfloat *ctrl, GLint scnt,
  207.     GLint tcnt, GLint **sfactors, GLint **tfactors);
  208.  
  209. GLboolean fine_culling_test_2D(GLUnurbsObj *nobj, GLfloat *ctrl, GLint n_ctrl,
  210.     GLint stride, GLint dim);
  211.  
  212. GLboolean fine_culling_test_3D(GLUnurbsObj *nobj, GLfloat *ctrl,
  213.     GLint s_n_ctrl, GLint t_n_ctrl, GLint s_stride, GLint t_stride, GLint dim);
  214.  
  215. void do_nurbs_curve( GLUnurbsObj *nobj);
  216.  
  217. void do_nurbs_surface( GLUnurbsObj *nobj);
  218.  
  219. GLenum patch_trimming(GLUnurbsObj *nobj,new_ctrl_type *new_ctrl,
  220.     GLint *sfactors, GLint *tfactors);
  221.  
  222.