comparison Renderer/Test/send_linda.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 0eed1fa290c1
children 4dc02d3e98bb
comparison
equal deleted inserted replaced
670:9eefc1b24c87 671:f42b303044f7
44 psx_free(data); 44 psx_free(data);
45 } 45 }
46 } 46 }
47 47
48 void 48 void
49 root_move(SceneGraphPtr node, int w, int h) 49 root_move(SceneGraphPtr node, void *sgroot_, int w, int h)
50 { 50 {
51 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
51 Pad *pad = sgroot->getController(); 52 Pad *pad = sgroot->getController();
52 int flag = 0; 53 int flag = 0;
53 if (pad->right.isHold() || pad->left.isHold()) { 54 if (pad->right.isHold() || pad->left.isHold()) {
54 if (pad->right.isHold()) { 55 if (pad->right.isHold()) {
55 node->xyz[0] += 5.0f; 56 node->xyz[0] += 5.0f;
77 send_position(node); 78 send_position(node);
78 } 79 }
79 } 80 }
80 81
81 void 82 void
82 root_collision(SceneGraphPtr node, int w, int h, SceneGraphPtr tree) 83 root_collision(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree)
83 { 84 {
84 } 85 }
85 86
86 void 87 void
87 move(SceneGraphPtr node, int w, int h) 88 move(SceneGraphPtr node, void *sgroot_, int w, int h)
88 { 89 {
89 } 90 }
90 91
91 void 92 void
92 collision(SceneGraphPtr node, int w, int h, SceneGraphPtr tree) 93 collision(SceneGraphPtr node, void *sgroot_, int w, int h, SceneGraphPtr tree)
93 { 94 {
94 } 95 }
95 96
96 void * 97 void *
97 file_map(const char *filename, int *size) { 98 file_map(const char *filename, int *size) {
153 int size; 154 int size;
154 int tspace; 155 int tspace;
155 int serial; 156 int serial;
156 int xml_id; 157 int xml_id;
157 158
158 SceneGraphPtr sgp;
159 SceneGraphPtr root;
160 159
161 // ここら辺長ったるいから、関数で分けるべきか... 160 // ここら辺長ったるいから、関数で分けるべきか...
162 161
163 // root オブジェクト作成 162 // root オブジェクト作成
164 root = sgroot->createSceneGraph(); 163 SceneGraphPtr root = sgr->createSceneGraph();
165 // root_moveはコントローラーの入力で動き、座標をLinda Serverにout 164 // root_moveはコントローラーの入力で動き、座標をLinda Serverにout
166 root->set_move_collision(root_move, root_collision); 165 root->set_move_collision(root_move, root_collision);
167 166
168 // XMLをメモリにmapして、オブジェクト生成 167 // XMLをメモリにmapして、オブジェクト生成
169 addr = file_map(xml, &size); 168 addr = file_map(xml, &size);
170 sgp = sgroot->createSceneGraph(); 169 SceneGraphPtr sgp = sgr->createSceneGraph();
171 sgroot->createFromXMLmemory(sgroot->tmanager, sgp, (char *)addr, size); 170 sgr->createFromXMLmemory(sgp, (char *)addr, size);
172 sgp->set_move_collision(move, collision); 171 sgp->set_move_collision(move, collision);
173 172
174 // rootに接続 173 // rootに接続
175 root->addChild(sgp); 174 root->addChild(sgp);
176 175
177 // Linda Serverに接続 176 // Linda Serverに接続
178 tspace = open_linda_java(linda, PORT_NUM); 177 tspace = open_linda_java(linda, PORT_NUM);
179 // rootにLindaのfdを持たせる 178 // rootにLindaのfdを持たせる
180 root->propertyptr = sgroot->tmanager->allocate(sizeof(int)); 179 root->propertyptr = (void*)malloc(sizeof(int));
181 root->property_size = sizeof(int); 180 int *p = (int*)root->propertyptr;
182 *(int *)root->propertyptr = tspace; 181 root->property_size = sizeof(int);
183 182 *p = tspace;
184 // このclientのserial_idを取得 183
185 serial = get_serial_id(tspace); 184 // このclientのserial_idを取得
186 root->id = serial; 185 serial = get_serial_id(tspace);
186 root->id = serial;
187 187
188 // ここから先の処理は、裏で何か動かせないかを考える 188 // ここから先の処理は、裏で何か動かせないかを考える
189 // とりあえず、関数に分けようか 189 // とりあえず、関数に分けようか
190 190
191 // serial_idを十倍したところにXMLを送信 191 // serial_idを十倍したところにXMLを送信
207 psx_out(tspace, pos_id, (unsigned char *)pos_data, SEND_DATA_SIZE); 207 psx_out(tspace, pos_id, (unsigned char *)pos_data, SEND_DATA_SIZE);
208 208
209 // 初期化のin() 209 // 初期化のin()
210 // send_position()でinの終了を確認する分岐が最初にあるため 210 // send_position()でinの終了を確認する分岐が最初にあるため
211 root->seq = psx_in(tspace, pos_id); 211 root->seq = psx_in(tspace, pos_id);
212 sgroot->setSceneData(root); 212 sgr->setSceneData(root);
213 213
214 return sgr; 214 return sgr;
215 }
216
217 MainLoopPtr
218 send_linda::init_only_sg(SgChange *sgchange, int w, int h)
219 {
220 return sgchange;
215 } 221 }
216 222
217 extern Application * 223 extern Application *
218 application() { 224 application() {
219 return new send_linda(); 225 return new send_linda();