Mercurial > hg > Members > kono > Cerium
comparison Renderer/Test/dynamic_create.cc @ 671:f42b303044f7
fix several Renderer/Test with (void*)sgroot.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 05 Dec 2009 17:26:58 +0900 |
parents | d0b8860c17f8 |
children | 4dc02d3e98bb |
comparison
equal
deleted
inserted
replaced
670:9eefc1b24c87 | 671:f42b303044f7 |
---|---|
35 typedef struct { | 35 typedef struct { |
36 int tid; | 36 int tid; |
37 int sid; | 37 int sid; |
38 int read_id; | 38 int read_id; |
39 SceneGraphPtr node; | 39 SceneGraphPtr node; |
40 SceneGraphRoot *sgroot; | |
40 TaskManager *manager; | 41 TaskManager *manager; |
41 client_t *clist; | 42 client_t *clist; |
42 } callback_arg; | 43 } callback_arg; |
43 | 44 |
44 | 45 |
103 } | 104 } |
104 } | 105 } |
105 | 106 |
106 | 107 |
107 static void | 108 static void |
108 earth_move(SceneGraphPtr node, int screen_w, int screen_h) | 109 earth_move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
109 { | 110 { |
110 // psx_sync_n(); in viewer::MainLoop | 111 // psx_sync_n(); in viewer::MainLoop |
111 } | 112 } |
112 | 113 |
113 SceneGraphPtr | 114 SceneGraphPtr |
114 create_sg(TaskManager *manager, SceneGraphPtr parent, unsigned char *data, | 115 create_sg(TaskManager *manager, SceneGraphRoot *sgroot, SceneGraphPtr parent, unsigned char *data, |
115 int len, int serial_id) | 116 int len, int serial_id) |
116 { | 117 { |
117 SceneGraphPtr child = sgroot->createSceneGraph(); | 118 SceneGraphPtr child = sgroot->createSceneGraph(); |
118 parent->addChild(child); | 119 parent->addChild(child); |
119 // 読み込んだオブジェクトは、すべて、child の child になる。 | 120 // 読み込んだオブジェクトは、すべて、child の child になる。 |
120 sgroot->createFromXMLmemory(sgroot->tmanager, child, (char *)data, len); | 121 sgroot->createFromXMLmemory(sgroot->tmanager, child, (char *)data, len); |
121 child->set_move_collision(moon_move, moon_collision); | 122 child->set_move_collision(moon_move, moon_collision); |
122 child->id = serial_id; | 123 child->id = serial_id; |
123 child->seq = psx_wait_rd(sgroot->tid, serial_id * 10 + 1); | 124 child->seq = psx_wait_rd(sgroot->tid, serial_id * 10 + 1); |
124 | 125 |
125 return child; | 126 return child; |
126 } | 127 } |
127 | 128 |
128 | 129 |
132 callback_arg *carg = (callback_arg *)arg; | 133 callback_arg *carg = (callback_arg *)arg; |
133 unsigned char *xml_data = xml_tuple + LINDA_HEADER_SIZE; | 134 unsigned char *xml_data = xml_tuple + LINDA_HEADER_SIZE; |
134 SceneGraphPtr sgp; | 135 SceneGraphPtr sgp; |
135 // ここで create | 136 // ここで create |
136 // fwrite(xml_data, 1, 10, stdout); | 137 // fwrite(xml_data, 1, 10, stdout); |
137 sgp = create_sg(carg->manager, carg->node, xml_data, xml_len, carg->sid); | 138 sgp = create_sg(carg->manager, carg->sgroot, carg->node, xml_data, xml_len, carg->sid); |
138 printf("%s size %d loaded\n", sgp->children->name, xml_len); | 139 printf("%s size %d loaded\n", sgp->children->name, xml_len); |
139 client_list_update(carg->manager, carg->clist, carg->sid, sgp); | 140 client_list_update(carg->manager, carg->clist, carg->sid, sgp); |
140 free(arg); | 141 free(arg); |
141 free(xml_tuple); | 142 free(xml_tuple); |
142 } | 143 } |
164 psx_callback_in(carg->tid, xml_id, callback_get_xml, (void *)copy_arg); | 165 psx_callback_in(carg->tid, xml_id, callback_get_xml, (void *)copy_arg); |
165 | 166 |
166 /* dataは'\0'で終わっている事を期待 (writerで保証する) */ | 167 /* dataは'\0'で終わっている事を期待 (writerで保証する) */ |
167 //printf("get data[%d]: `%s'\n", len, data); | 168 //printf("get data[%d]: `%s'\n", len, data); |
168 free(taple); | 169 free(taple); |
169 | 170 |
171 // arg は使い回すらしい。 | |
172 | |
170 psx_callback_in(carg->tid, carg->read_id, callbacker, arg); | 173 psx_callback_in(carg->tid, carg->read_id, callbacker, arg); |
171 } | 174 } |
172 | 175 |
173 static char const *linda = "localhost"; | 176 static char const *linda = "localhost"; |
174 | 177 |
175 void | 178 static void |
176 linda_init(TaskManager *manager, client_t *clist, SceneGraphPtr node) | 179 linda_init(TaskManager *manager, SceneGraphRoot *sgroot, client_t *clist, SceneGraphPtr node) |
177 { | 180 { |
178 init_linda(); | 181 init_linda(); |
179 callback_arg *carg = (callback_arg *)manager->allocate(sizeof(callback_arg)); | 182 callback_arg *carg = (callback_arg *)manager->allocate(sizeof(callback_arg)); |
180 | 183 |
181 carg->tid = open_linda_java(linda, PORT); | 184 carg->tid = open_linda_java(linda, PORT); |
182 sgroot->tid = carg->tid; | 185 carg->sgroot = sgroot; |
186 carg->sgroot->tid = carg->tid; | |
183 carg->read_id = SERIAL_REGIST_TUPLE_NO; | 187 carg->read_id = SERIAL_REGIST_TUPLE_NO; |
184 carg->node = node; | 188 carg->node = node; |
185 carg->manager = manager; | 189 carg->manager = manager; |
186 carg->clist = clist; | 190 carg->clist = clist; |
187 psx_callback_in(carg->tid, carg->read_id, callbacker, carg); | 191 psx_callback_in(carg->tid, carg->read_id, callbacker, carg); |
199 SceneGraphPtr parent; | 203 SceneGraphPtr parent; |
200 parent = sgroot->createSceneGraph(); | 204 parent = sgroot->createSceneGraph(); |
201 parent->set_move_collision(earth_move, earth_collision); | 205 parent->set_move_collision(earth_move, earth_collision); |
202 // parent->xyz[0] += 300; | 206 // parent->xyz[0] += 300; |
203 // parent->xyz[1] += 300; | 207 // parent->xyz[1] += 300; |
204 linda_init(sgroot->manager, clist, parent); | 208 linda_init(sgroot->manager, sgroot->sgroot, clist, parent); |
205 | 209 |
206 // SceneGraphRoot に、使用する SceneGraph を設定する | 210 // SceneGraphRoot に、使用する SceneGraph を設定する |
207 // このとき、ユーザーが記述した SceneGraph の root を渡す。 | 211 // このとき、ユーザーが記述した SceneGraph の root を渡す。 |
208 sgroot->setSceneData(parent); | 212 sgroot->setSceneData(parent); |
209 return sgroot; | 213 return sgroot; |