Mercurial > hg > old > magoroku_racing.bad
comparison field.cc @ 126:030394675d8e
succes compile
author | e085768 |
---|---|
date | Thu, 30 Jun 2011 21:48:38 +0900 |
parents | 6ef3b0efdeaf |
children | d9e3137e70a0 |
comparison
equal
deleted
inserted
replaced
125:c62fec1dd2f8 | 126:030394675d8e |
---|---|
8 #include "field.h" | 8 #include "field.h" |
9 #include "car.h" | 9 #include "car.h" |
10 #include "quotanion.h" | 10 #include "quotanion.h" |
11 #include <stdbool.h> | 11 #include <stdbool.h> |
12 | 12 |
13 #include "Application.h" | |
14 | |
13 #define BUFSIZE 256 | 15 #define BUFSIZE 256 |
14 | 16 |
15 /* --- main.c --- */ | 17 /* --- main.c --- */ |
16 extern FILE *main_fp; | 18 extern FILE *main_fp; |
17 | 19 |
19 static int field_num = 1; | 21 static int field_num = 1; |
20 | 22 |
21 static FieldPtr field_list; | 23 static FieldPtr field_list; |
22 static FieldPtr field_actual; | 24 static FieldPtr field_actual; |
23 | 25 |
26 extern Viewer *droot; | |
27 | |
24 // 適当に自作:miya | 28 // 適当に自作:miya |
25 PolygonInfo* xml_read_file(char *colImg) | 29 PolygonInfo* xml_read_file(char *colImg) |
26 { | 30 { |
27 PolygonInfo* test; | 31 PolygonInfo* test; |
28 printf("xml_read_file"); | 32 printf("xml_read_file"); |
34 static FieldPtr | 38 static FieldPtr |
35 field_create(char *fieldImg, char *colImg )// OBJECT *tex) | 39 field_create(char *fieldImg, char *colImg )// OBJECT *tex) |
36 { | 40 { |
37 FieldPtr self; | 41 FieldPtr self; |
38 OBJECT *obj; | 42 OBJECT *obj; |
39 PolygonInfo *xml; | |
40 void *free_addr; | 43 void *free_addr; |
41 | 44 |
42 //FVECTOR location = {0, 0, 0, 1}; | 45 // 初期化 |
43 //FVECTOR direction = {0, 0, 0, 1}; | 46 droot->createFromXMLfile(fieldImg); |
44 | 47 obj = droot->createSceneGraph("hoge"); |
45 obj = ps2util_obj_Create_fromXML(fieldImg); | 48 |
46 | 49 droot->createFromXMLfile(colImg); |
47 // 上の関数で終わらせといてる...ハズ | 50 OBJECT *col_obj = droot->createSceneGraph("hoge"); |
48 // memcpy(obj->xyz, location, sizeof(FVECTOR)); | |
49 // memcpy(obj->angle, direction, sizeof(FVECTOR)); | |
50 | |
51 ps2util_obj_Renew_transMatrix(obj); | |
52 ps2util_obj_Set_effect(obj, DEFAULT_SET); | |
53 //ps2util_obj_Set_texture(obj, tex); | |
54 | |
55 // mallocしないとダメかな? | |
56 // xml = (PolygonInfo *)malloc(sizeof(PolygonInfo)); | |
57 | |
58 xml = xml_read_file(colImg); //ここでコースの走れる場所(当たり判定) | |
59 | |
60 | 51 |
61 if (malloc_align16(&free_addr, &self, sizeof(Field)) == -1) { | 52 if (malloc_align16(&free_addr, &self, sizeof(Field)) == -1) { |
62 fprintf(stderr, "field.c: malloc_align16 error\n"); | 53 fprintf(stderr, "field.c: malloc_align16 error\n"); |
63 fflush(stderr); | 54 fflush(stderr); |
64 exit(EXIT_FAILURE); | 55 exit(EXIT_FAILURE); |
71 #ifdef DEBUG | 62 #ifdef DEBUG |
72 fprintf(main_fp, "malloc fieldNode addr = %x(free), %x(obj)\n", (int)free_addr, (int)self); | 63 fprintf(main_fp, "malloc fieldNode addr = %x(free), %x(obj)\n", (int)free_addr, (int)self); |
73 #endif | 64 #endif |
74 | 65 |
75 // ちょっと今だけコメント --- | 66 // ちょっと今だけコメント --- |
76 // col_init(&self->colface, xml); | 67 col_init(&self->colface, col_obj); |
77 | 68 |
78 #ifdef DEBUG | 69 #ifdef DEBUG |
79 fprintf(main_fp, " facenum = %d\n", self->colface.facenum); | 70 fprintf(main_fp, " facenum = %d\n", self->colface.facenum); |
80 fprintf(main_fp, " facenum = %x(free), ", (int)self->colface.free_addr); | 71 fprintf(main_fp, " facenum = %x(free), ", (int)self->colface.free_addr); |
81 fprintf(main_fp, "facenum = %x(obj)\n", (int)self->colface.colface); | 72 fprintf(main_fp, "facenum = %x(obj)\n", (int)self->colface.colface); |
82 #endif | 73 #endif |
83 | |
84 // xml_free(xml); | |
85 xml_free(*xml); | |
86 | |
87 printf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); | |
88 | 74 |
89 return self; | 75 return self; |
90 } | 76 } |
91 | 77 |
92 | 78 |
185 } | 171 } |
186 | 172 |
187 static void | 173 static void |
188 field_draw(FieldPtr p) | 174 field_draw(FieldPtr p) |
189 { | 175 { |
190 //ps2_vu0_unit_matrix((FMATRIX)(p->object->matrix)); | 176 ps2_vu0_unit_matrix((FMATRIX)(p->object->matrix)); |
191 | 177 |
192 /* | 178 /* |
193 p->object->matrix[3][0] = p->location[0]; | 179 p->object->matrix[3][0] = p->location[0]; |
194 p->object->matrix[3][1] = p->location[1]; | 180 p->object->matrix[3][1] = p->location[1]; |
195 p->object->matrix[3][2] = p->location[2]; | 181 p->object->matrix[3][2] = p->location[2]; |
196 p->object->matrix[3][3] = p->location[3]; | 182 p->object->matrix[3][3] = p->location[3]; |
197 */ | 183 */ |
198 | 184 |
199 // 上の5この処理、このやり方でも同じか確かめたい | 185 // 上の5この処理、このやり方でも同じか確かめたい |
200 for( int i = 0; i < 4; i ++ ) | 186 for( int i = 0; i < 4; i ++ ) |
201 p->object->matrix[12+i] = p->location[0]; | 187 p->object->matrix[11+i] = p->location[0]; |
202 | 188 |
203 // 今ちょっとコメント | 189 // 今ちょっとコメント |
204 //ps2util_obj_Draw(p->object); | 190 //ps2util_obj_Draw(p->object); |
205 } | 191 } |
206 | 192 |
208 void field_update(CarPtr car) | 194 void field_update(CarPtr car) |
209 { | 195 { |
210 FieldPtr p; | 196 FieldPtr p; |
211 | 197 |
212 p = field_actual; | 198 p = field_actual; |
199 | |
213 // current | 200 // current |
214 p->location[0] = -car->location[0]; | 201 p->location[0] = -car->location[0]; |
215 p->location[1] = -car->location[1]; | 202 p->location[1] = -car->location[1]; |
216 p->location[2] = -car->location[2]; | 203 p->location[2] = -car->location[2]; |
217 p->location[3] = 1; | 204 p->location[3] = 1; |