11218
|
1 #include"glm.h"
|
|
2 #include <GL/gl.h>
|
|
3 #include <GL/glu.h>
|
|
4 #include "face.h"
|
|
5
|
|
6 #define ASCII_DIGITS 48
|
|
7
|
|
8 void init_lists(GLint** lists, GLMmodel*** models, int num_lists, char* name, float my_scale){
|
|
9 int i;
|
|
10 char c;
|
|
11 GLint* temp_lists;
|
|
12 GLMmodel** temp_models;
|
|
13 char* temp = (char*)malloc(sizeof(char) * (strlen(name) + strlen(".obj" + 3)));
|
|
14 GLMmodel* model;
|
|
15 float dum;
|
|
16 temp_lists = (GLint*)malloc(sizeof(GLint) * num_lists);
|
|
17 temp_models = (GLMmodel**)malloc(sizeof(GLMmodel*) * num_lists);
|
|
18
|
|
19 for(i=0;i<num_lists;i++) {
|
|
20 strcpy(temp, name);
|
|
21 if(i<10){
|
|
22 c = (char)(ASCII_DIGITS+i);
|
|
23 strncat(temp, &c, 1);
|
|
24 }
|
|
25 else{
|
|
26 c = (char)(i/10+ASCII_DIGITS);
|
|
27 strncat(temp, &c, 1);
|
|
28 c = (char)(i%10 + ASCII_DIGITS);
|
|
29 strncat(temp, &c, 1);
|
|
30 }
|
|
31 strcat(temp, ".obj");
|
|
32 temp_models[i]=glmReadOBJ(temp);
|
|
33 glmScale(temp_models[i], my_scale);
|
|
34 dum =glmUnitize(temp_models[i]); // this actually just centers
|
|
35 //printf("%s factor %f", temp, dum);
|
|
36 temp_lists[i]=glmList(temp_models[i], GLM_SMOOTH);
|
|
37 }
|
|
38
|
|
39 *lists = temp_lists;
|
|
40 *models = temp_models;
|
|
41 free(temp);
|
|
42 }
|
|
43
|
|
44 int compute_lid(BOOL open, int curr_lid, int max){
|
|
45 if(open) {
|
|
46 if(curr_lid < max){
|
|
47 curr_lid++;
|
|
48 }
|
|
49 else
|
|
50 curr_lid=max;
|
|
51 }
|
|
52 else {
|
|
53 if(curr_lid >=2){
|
|
54 curr_lid-=2;
|
|
55 }
|
|
56 else if(curr_lid==1){
|
|
57 curr_lid--;
|
|
58 }
|
|
59 curr_lid=0;
|
|
60 }
|
|
61 return curr_lid;
|
|
62 }
|
|
63
|
|
64 void apply_output_mode(FACE f, GLfloat* angle, GLfloat* yangle, BOOL* left_open, BOOL* right_open, GLfloat* open, DIRECTION* dir)
|
|
65 {
|
|
66 struct doggy_struct* dog = (struct doggy_struct*)f->char_struct;
|
|
67 if(f->my_mode==NORMAL){
|
|
68 f->curr_z_angle=0;
|
|
69 return;
|
|
70 }
|
|
71 if(f->my_mode==CRAZY1){
|
|
72 f->curr_z_angle = f->curr_z_angle+ANGLE_INC;
|
|
73 *angle = f->curr_z_angle;
|
|
74 }
|
|
75 }
|