2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
33 #ifndef _BEZIERPATCHMESH_H
34 #define _BEZIERPATCHMESH_H
36 #include "bezierPatch.h"
38 typedef struct bezierPatchMesh
{
39 bezierPatch
*bpatch
; /*vertex*/
40 bezierPatch
*bpatch_normal
;
41 bezierPatch
*bpatch_texcoord
; /*s,t,r,q*/
42 bezierPatch
*bpatch_color
; /*RGBA*/
44 float *UVarray
; /*all UV components of all vertices of all strips*/
45 int *length_array
; /*[i] is the number of vertices in the ith strip*/
46 GLenum
*type_array
; /*[i] is the type of the ith primitive*/
48 /*to support dynamic insertion*/
51 int size_length_array
;
52 int index_length_array
;
54 int counter
; /*track the current strip size*/
55 GLenum type
; /*track the current type: 0: GL_TRIANGLES, 1: GL_TRIANGLE_STRIP*/
57 /*we eventually want to evaluate from (u,v) to (x,y,z) and draw them*/
58 float *vertex_array
; /*each vertex contains three components*/
59 float *normal_array
; /*each normal contains three components*/
61 float *texcoord_array
;
63 /*in case we need a linked list*/
64 struct bezierPatchMesh
*next
;
73 bezierPatchMesh
*bezierPatchMeshMake(int maptype
, float umin
, float umax
, int ustride
, int uorder
, float vmin
, float vmax
, int vstride
, int vorder
, float *ctlpoints
, int size_UVarray
, int size_length_array
);
75 /*initilize patches to be null*/
76 bezierPatchMesh
*bezierPatchMeshMake2(int size_UVarray
, int size_length_array
);
78 void bezierPatchMeshPutPatch(bezierPatchMesh
*bpm
, int maptype
, float umin
, float umax
, int ustride
, int uorder
, float vmin
, float vmax
, int vstride
, int vorder
, float *ctlpoints
);
80 void bezierPatchMeshDelete(bezierPatchMesh
*bpm
);
82 void bezierPatchMeshBeginStrip(bezierPatchMesh
*bpm
, GLenum type
);
84 void bezierPatchMeshEndStrip(bezierPatchMesh
*bpm
);
86 void bezierPatchMeshInsertUV(bezierPatchMesh
*bpm
, float u
, float v
);
88 void bezierPatchMeshPrint(bezierPatchMesh
*bpm
);
90 bezierPatchMesh
* bezierPatchMeshListInsert(bezierPatchMesh
* list
, bezierPatchMesh
* bpm
);
92 void bezierPatchMeshListPrint(bezierPatchMesh
* list
);
94 int bezierPatchMeshListTotalStrips(bezierPatchMesh
* list
);
96 int bezierPatchMeshListTotalVert(bezierPatchMesh
* list
);
97 int bezierPatchMeshNumTriangles(bezierPatchMesh
* bpm
);
98 int bezierPatchMeshListNumTriangles(bezierPatchMesh
* list
);
100 void bezierPatchMeshDelDeg(bezierPatchMesh
* bpm
);
103 void bezierPatchMeshEval(bezierPatchMesh
* bpm
);
105 void bezierPatchMeshDraw(bezierPatchMesh
* bpm
);
107 void bezierPatchMeshListDraw(bezierPatchMesh
* list
);
108 void bezierPatchMeshListEval(bezierPatchMesh
* list
);
109 void bezierPatchMeshListCollect(bezierPatchMesh
* list
, float **vertex_array
, float **normal_array
, int **length_array
, GLenum
**type_array
, int *num_strips
);
111 void bezierPatchMeshListDelDeg(bezierPatchMesh
* list
);
112 void bezierPatchMeshListDelete(bezierPatchMesh
*list
);
113 bezierPatchMesh
* bezierPatchMeshListReverse(bezierPatchMesh
* list
);
114 void drawStrips(float *vertex_array
, float *normal_array
, int *length_array
, GLenum
*type_array
, int num_strips
);