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
37 #include "bezierPatch.h"
39 typedef struct bezierPatchMesh
{
40 bezierPatch
*bpatch
; /*vertex*/
41 bezierPatch
*bpatch_normal
;
42 bezierPatch
*bpatch_texcoord
; /*s,t,r,q*/
43 bezierPatch
*bpatch_color
; /*RGBA*/
45 float *UVarray
; /*all UV components of all vertices of all strips*/
46 int *length_array
; /*[i] is the number of vertices in the ith strip*/
47 GLenum
*type_array
; /*[i] is the type of the ith primitive*/
49 /*to support dynamic insertion*/
52 int size_length_array
;
53 int index_length_array
;
55 int counter
; /*track the current strip size*/
56 GLenum type
; /*track the current type: 0: GL_TRIANGLES, 1: GL_TRIANGLE_STRIP*/
58 /*we eventually want to evaluate from (u,v) to (x,y,z) and draw them*/
59 float *vertex_array
; /*each vertex contains three components*/
60 float *normal_array
; /*each normal contains three components*/
62 float *texcoord_array
;
64 /*in case we need a linked list*/
65 struct bezierPatchMesh
*next
;
74 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
);
76 /*initilize patches to be null*/
77 bezierPatchMesh
*bezierPatchMeshMake2(int size_UVarray
, int size_length_array
);
79 void bezierPatchMeshPutPatch(bezierPatchMesh
*bpm
, int maptype
, float umin
, float umax
, int ustride
, int uorder
, float vmin
, float vmax
, int vstride
, int vorder
, float *ctlpoints
);
81 void bezierPatchMeshDelete(bezierPatchMesh
*bpm
);
83 void bezierPatchMeshBeginStrip(bezierPatchMesh
*bpm
, GLenum type
);
85 void bezierPatchMeshEndStrip(bezierPatchMesh
*bpm
);
87 void bezierPatchMeshInsertUV(bezierPatchMesh
*bpm
, float u
, float v
);
89 void bezierPatchMeshPrint(bezierPatchMesh
*bpm
);
91 bezierPatchMesh
* bezierPatchMeshListInsert(bezierPatchMesh
* list
, bezierPatchMesh
* bpm
);
93 void bezierPatchMeshListPrint(bezierPatchMesh
* list
);
95 int bezierPatchMeshListTotalStrips(bezierPatchMesh
* list
);
97 int bezierPatchMeshListTotalVert(bezierPatchMesh
* list
);
98 int bezierPatchMeshNumTriangles(bezierPatchMesh
* bpm
);
99 int bezierPatchMeshListNumTriangles(bezierPatchMesh
* list
);
101 void bezierPatchMeshDelDeg(bezierPatchMesh
* bpm
);
104 void bezierPatchMeshEval(bezierPatchMesh
* bpm
);
106 void bezierPatchMeshDraw(bezierPatchMesh
* bpm
);
108 void bezierPatchMeshListDraw(bezierPatchMesh
* list
);
109 void bezierPatchMeshListEval(bezierPatchMesh
* list
);
110 void bezierPatchMeshListCollect(bezierPatchMesh
* list
, float **vertex_array
, float **normal_array
, int **length_array
, GLenum
**type_array
, int *num_strips
);
112 void bezierPatchMeshListDelDeg(bezierPatchMesh
* list
);
113 void bezierPatchMeshListDelete(bezierPatchMesh
*list
);
114 bezierPatchMesh
* bezierPatchMeshListReverse(bezierPatchMesh
* list
);
115 void drawStrips(float *vertex_array
, float *normal_array
, int *length_array
, GLenum
*type_array
, int num_strips
);