Lines Matching defs:bpm

183 void bezierPatchMeshPutPatch(bezierPatchMesh *bpm, int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints)
187 bpm->bpatch = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
190 bpm->bpatch = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4,ustride, vstride, ctlpoints );
193 bpm->bpatch_normal = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
196 bpm->bpatch_color = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 1, ustride, vstride, ctlpoints);
199 bpm->bpatch_color = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4, ustride, vstride, ctlpoints);
202 bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 1, ustride, vstride, ctlpoints);
205 bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 2, ustride, vstride, ctlpoints);
208 bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 3, ustride, vstride, ctlpoints);
211 bpm->bpatch_texcoord = bezierPatchMake2(umin, vmin, umax, vmax, uorder, vorder, 4, ustride, vstride, ctlpoints);
223 void bezierPatchMeshDelete(bezierPatchMesh *bpm)
225 if(bpm->bpatch != NULL)
226 bezierPatchDelete(bpm->bpatch);
227 if(bpm->bpatch_normal != NULL)
228 bezierPatchDelete(bpm->bpatch_normal);
229 if(bpm->bpatch_color != NULL)
230 bezierPatchDelete(bpm->bpatch_color);
231 if(bpm->bpatch_texcoord != NULL)
232 bezierPatchDelete(bpm->bpatch_texcoord);
234 free(bpm->UVarray);
235 free(bpm->length_array);
236 free(bpm->vertex_array);
237 free(bpm->normal_array);
238 free(bpm->type_array);
239 free(bpm);
245 void bezierPatchMeshBeginStrip(bezierPatchMesh *bpm, GLenum type)
247 bpm->counter = 0;
248 bpm->type = type;
252 void bezierPatchMeshEndStrip(bezierPatchMesh *bpm)
257 if(bpm->counter == 0) return;
260 if(bpm->index_length_array >= bpm->size_length_array)
262 int *temp = (int*) malloc(sizeof(int) * (bpm->size_length_array*2 + 1));
264 GLenum *temp_type = (GLenum*) malloc(sizeof(GLenum) * (bpm->size_length_array*2 + 1));
267 bpm->size_length_array = bpm->size_length_array*2 + 1;
270 for(i=0; i<bpm->index_length_array; i++)
272 temp[i] = bpm->length_array[i];
273 temp_type[i] = bpm->type_array[i];
277 free(bpm->length_array);
278 free(bpm->type_array);
281 bpm->length_array = temp;
282 bpm->type_array = temp_type;
284 bpm->type_array[bpm->index_length_array] = bpm->type;
285 bpm->length_array[bpm->index_length_array++] = bpm->counter;
290 void bezierPatchMeshInsertUV(bezierPatchMesh *bpm, float u, float v)
294 if(bpm->index_UVarray+1 >= bpm->size_UVarray)
296 float *temp = (float*) malloc(sizeof(float) * (bpm->size_UVarray * 2 + 2));
300 bpm->size_UVarray = bpm->size_UVarray*2 + 2;
303 for(i=0; i<bpm->index_UVarray; i++)
305 temp[i] = bpm->UVarray[i];
309 free(bpm->UVarray);
312 bpm->UVarray = temp;
315 bpm->UVarray[bpm->index_UVarray] = u;
316 bpm->index_UVarray++;
317 bpm->UVarray[bpm->index_UVarray] = v;
318 bpm->index_UVarray++;
321 bpm->counter++;
326 void bezierPatchMeshPrint(bezierPatchMesh *bpm)
330 bezierPatchPrint(bpm->bpatch);
331 printf("index_length_array= %i\n", bpm->index_length_array);
332 printf("size_length_array =%i\n", bpm->size_length_array);
333 printf("index_UVarray =%i\n", bpm->index_UVarray);
334 printf("size_UVarray =%i\n", bpm->size_UVarray);
336 for(i=0; i<bpm->index_UVarray; i++)
337 printf("%f ", bpm->UVarray[i]);
340 for(i=0; i<bpm->index_length_array; i++)
341 printf("%i ", bpm->length_array[i]);
347 bezierPatchMesh* bezierPatchMeshListInsert(bezierPatchMesh* list, bezierPatchMesh* bpm)
349 bpm->next=list;
350 return bpm;
396 int bezierPatchMeshNumTriangles(bezierPatchMesh* bpm)
400 for(i=0; i<bpm->index_length_array; i++)
402 switch(bpm->type_array[i])
405 sum += bpm->length_array[i]/3;
408 if(bpm->length_array[i] > 2)
409 sum += bpm->length_array[i]-2;
412 if(bpm->length_array[i] > 2)
413 sum += bpm->length_array[i]-2;
416 if(bpm->length_array[i]>2)
417 sum += (bpm->length_array[i]-2);
427 void bezierPatchMeshDelDeg(bezierPatchMesh* bpm)
429 if(bpm == NULL) return;
437 new_length_array = (int*)malloc(sizeof(int) * bpm->index_length_array);
439 new_type_array = (GLenum*)malloc(sizeof(GLenum) * bpm->index_length_array);
441 new_UVarray = (float*) malloc(sizeof(float) * bpm->index_UVarray);
447 for(i=0; i<bpm->index_length_array; i++){
450 if( (bpm->length_array[i] != 3) || (!isDegenerate(bpm->UVarray+k, bpm->UVarray+k+2, bpm->UVarray+k+4)))
452 for(j=0; j<2* bpm->length_array[i]; j++)
453 new_UVarray[index_new_UVarray++] = bpm->UVarray[k++];
455 new_length_array[index_new_length_array] = bpm->length_array[i];
456 new_type_array[index_new_length_array] = bpm->type_array[i];
464 free(bpm->UVarray);
465 free(bpm->length_array);
466 free(bpm->type_array);
467 bpm->UVarray=new_UVarray;
468 bpm->length_array=new_length_array;
469 bpm->type_array=new_type_array;
470 bpm->index_UVarray = index_new_UVarray;
471 bpm->index_length_array = index_new_length_array;
479 void bezierPatchMeshEval(bezierPatchMesh* bpm)
483 float u0 = bpm->bpatch->umin;
484 float u1 = bpm->bpatch->umax;
485 int uorder = bpm->bpatch->uorder;
486 float v0 = bpm->bpatch->vmin;
487 float v1 = bpm->bpatch->vmax;
488 int vorder = bpm->bpatch->vorder;
489 int dimension = bpm->bpatch->dimension;
492 float *ctlpoints = bpm->bpatch->ctlpoints;
494 bpm->vertex_array = (float*) malloc(sizeof(float)* (bpm->index_UVarray/2) * 3);
495 assert(bpm->vertex_array);
496 bpm->normal_array = (float*) malloc(sizeof(float)* (bpm->index_UVarray/2) * 3);
497 assert(bpm->normal_array);
501 for(i=0; i<bpm->index_length_array; i++)
503 for(j=0; j<bpm->length_array[i]; j++)
505 u = bpm->UVarray[k];
506 v = bpm->UVarray[k+1];
507 bezierSurfEval(u0,u1,uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u,v, bpm->vertex_array+l);
508 bezierSurfEvalNormal(u0,u1,uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u,v, bpm->normal_array+l);
524 void bezierPatchMeshDraw(bezierPatchMesh* bpm)
529 for(i=0; i<bpm->index_length_array; i++)
531 glBegin(bpm->type_array[i]);
532 for(j=0; j<bpm->length_array[i]; j++)
534 glNormal3fv(bpm->normal_array+k);
535 glVertex3fv(bpm->vertex_array+k);